mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-12 04:17:34 -06:00
Merge pull request #1760 from Microsoft/typeAliasDoesntMakeModuleInstantiated
Type alias declaration is type only declaration and doesnt make module instantiated
This commit is contained in:
commit
e13d6fab55
@ -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
|
||||
|
||||
@ -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]
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
Loading…
x
Reference in New Issue
Block a user