Skip to content

Cannot reference TSC v1.8 compilation #6382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
SetTrend opened this issue Jan 6, 2016 · 5 comments
Closed

Cannot reference TSC v1.8 compilation #6382

SetTrend opened this issue Jan 6, 2016 · 5 comments
Labels
Question An issue which isn't directly actionable in code

Comments

@SetTrend
Copy link

SetTrend commented Jan 6, 2016

I'm not sure but it looks like an error to me:

I don't seem to be able to reference a TypeScript file transpiled with TSC v1.8.

I have set up a repository with a sample project and a description of the errors I get when I try to reference the transpiled JavaScript type definition file:

referenceerror

importerror

@vladima
Copy link
Contributor

vladima commented Jan 6, 2016

all.d.ts is not an external module but just a .d.ts file that contains declarations for three ambient modules.

declare module "_Base" {
    export default class _Base {
        protected element: HTMLElement;
        private _var;
        constructor(element: HTMLElement);
    }
}
declare module "Derived" {
    import _Base from "_Base";
    export default class Derived extends _Base {
        constructor(element: HTMLElement);
    }
}
declare module "Manager" {
    import _Base from "_Base";
    export default class Manager {
        private _provider;
        constructor(provider: _Base);
    }
}

as a consequence:

  • it cannot be imported as is since the file itself is not a module
  • it can be referenced to bring these 3 modules into scope.
// main.ts

/// <reference path="../../output/headers/all.d.ts" />
import Derived from "Derived";
import Manager from "Manager";

const d: Derived = new Derived(null);
const m: Manager = new Manager(d);

@vladima vladima closed this as completed Jan 6, 2016
@SetTrend
Copy link
Author

SetTrend commented Jan 7, 2016

Thanks for enlightening me! 🍰

Yet, I'm surprised about the syntax. I've not seen this before:

import Derived from "Derived";
import Manager from "Manager";

Would you mind pointing me to where this is documented? I want to understand how this works.

@mhegazy
Copy link
Contributor

mhegazy commented Jan 7, 2016

@mhegazy mhegazy added the Question An issue which isn't directly actionable in code label Jan 7, 2016
@SetTrend
Copy link
Author

SetTrend commented Jan 9, 2016

The suggested solution doesn't appear to work. It creates false define() statements in the JavaScript file:

importerror

IMHO, import { module1.Identifier2, module2.Identifier1 module3.Identifier1 } from "./moduleFile" should be the only valid syntax here. It'll load the module file and import all the required modules and identifiers from there.

@mhegazy
Copy link
Contributor

mhegazy commented Jan 11, 2016

The suggested solution doesn't appear to work. It creates false define() statements in the JavaScript file:

what does "false define()" mean? can you provide the expected output?

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

3 participants