diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 201913a50b..145cdb5dc7 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -9,8 +9,8 @@ module ts { export function getModuleInstanceState(node: Node): ModuleInstanceState { // A module is uninstantiated if it contains only - // 1. interface declarations - if (node.kind === SyntaxKind.InterfaceDeclaration) { + // 1. interface declarations, type alias declarations + if (node.kind === SyntaxKind.InterfaceDeclaration || node.kind === SyntaxKind.TypeAliasDeclaration) { return ModuleInstanceState.NonInstantiated; } // 2. const enum declarations don't make module instantiated diff --git a/tests/baselines/reference/typeAliasDoesntMakeModuleInstantiated.js b/tests/baselines/reference/typeAliasDoesntMakeModuleInstantiated.js new file mode 100644 index 0000000000..861e20cb0d --- /dev/null +++ b/tests/baselines/reference/typeAliasDoesntMakeModuleInstantiated.js @@ -0,0 +1,13 @@ +//// [typeAliasDoesntMakeModuleInstantiated.ts] +declare module m { + // type alias declaration here shouldnt make the module declaration instantiated + type Selector = string| string[] |Function; + + export interface IStatic { + (selector: any /* Selector */): IInstance; + } + export interface IInstance { } +} +declare var m: m.IStatic; // Should be ok to have var 'm' as module is non instantiated + +//// [typeAliasDoesntMakeModuleInstantiated.js] diff --git a/tests/baselines/reference/typeAliasDoesntMakeModuleInstantiated.types b/tests/baselines/reference/typeAliasDoesntMakeModuleInstantiated.types new file mode 100644 index 0000000000..18f4561241 --- /dev/null +++ b/tests/baselines/reference/typeAliasDoesntMakeModuleInstantiated.types @@ -0,0 +1,24 @@ +=== tests/cases/compiler/typeAliasDoesntMakeModuleInstantiated.ts === +declare module m { +>m : IStatic + + // type alias declaration here shouldnt make the module declaration instantiated + type Selector = string| string[] |Function; +>Selector : string | Function | string[] +>Function : Function + + export interface IStatic { +>IStatic : IStatic + + (selector: any /* Selector */): IInstance; +>selector : any +>IInstance : IInstance + } + export interface IInstance { } +>IInstance : IInstance +} +declare var m: m.IStatic; // Should be ok to have var 'm' as module is non instantiated +>m : m.IStatic +>m : unknown +>IStatic : m.IStatic + diff --git a/tests/cases/compiler/typeAliasDoesntMakeModuleInstantiated.ts b/tests/cases/compiler/typeAliasDoesntMakeModuleInstantiated.ts new file mode 100644 index 0000000000..89faf9e451 --- /dev/null +++ b/tests/cases/compiler/typeAliasDoesntMakeModuleInstantiated.ts @@ -0,0 +1,10 @@ +declare module m { + // type alias declaration here shouldnt make the module declaration instantiated + type Selector = string| string[] |Function; + + export interface IStatic { + (selector: any /* Selector */): IInstance; + } + export interface IInstance { } +} +declare var m: m.IStatic; // Should be ok to have var 'm' as module is non instantiated \ No newline at end of file