Merge pull request #5390 from maybejulian/declareOnTypeAliasInDts

Allow type aliases to omit 'declare' keyword in '.d.ts' files
This commit is contained in:
Mohamed Hegazy 2015-10-25 23:26:18 -07:00
commit ed5dc5536d
4 changed files with 19 additions and 0 deletions

View File

@ -15979,11 +15979,14 @@ namespace ts {
// DeclarationElement:
// ExportAssignment
// export_opt InterfaceDeclaration
// export_opt TypeAliasDeclaration
// export_opt ImportDeclaration
// export_opt ExternalImportDeclaration
// export_opt AmbientDeclaration
//
// TODO: The spec needs to be amended to reflect this grammar.
if (node.kind === SyntaxKind.InterfaceDeclaration ||
node.kind === SyntaxKind.TypeAliasDeclaration ||
node.kind === SyntaxKind.ImportDeclaration ||
node.kind === SyntaxKind.ImportEqualsDeclaration ||
node.kind === SyntaxKind.ExportDeclaration ||

View File

@ -0,0 +1,7 @@
=== tests/cases/compiler/typeAliasDeclareKeyword01.d.ts ===
type Foo = number;
>Foo : Symbol(Foo, Decl(typeAliasDeclareKeyword01.d.ts, 0, 0))
declare type Bar = string;
>Bar : Symbol(Bar, Decl(typeAliasDeclareKeyword01.d.ts, 0, 18))

View File

@ -0,0 +1,7 @@
=== tests/cases/compiler/typeAliasDeclareKeyword01.d.ts ===
type Foo = number;
>Foo : number
declare type Bar = string;
>Bar : string

View File

@ -0,0 +1,2 @@
type Foo = number;
declare type Bar = string;