Type alias declaration is type only declaration and doesnt make module instantiated

Handles #1724
This commit is contained in:
Sheetal Nandi 2015-01-21 11:18:42 -08:00
parent 8f3609048d
commit 4d1182401c
4 changed files with 49 additions and 2 deletions

View file

@ -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

View file

@ -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]

View file

@ -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

View file

@ -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