Skip to content

Commit ed5dc55

Browse files
committed
Merge pull request #5390 from maybejulian/declareOnTypeAliasInDts
Allow type aliases to omit 'declare' keyword in '.d.ts' files
2 parents c3c66a4 + 1d6f5c6 commit ed5dc55

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15979,11 +15979,14 @@ namespace ts {
1597915979
// DeclarationElement:
1598015980
// ExportAssignment
1598115981
// export_opt InterfaceDeclaration
15982+
// export_opt TypeAliasDeclaration
1598215983
// export_opt ImportDeclaration
1598315984
// export_opt ExternalImportDeclaration
1598415985
// export_opt AmbientDeclaration
1598515986
//
15987+
// TODO: The spec needs to be amended to reflect this grammar.
1598615988
if (node.kind === SyntaxKind.InterfaceDeclaration ||
15989+
node.kind === SyntaxKind.TypeAliasDeclaration ||
1598715990
node.kind === SyntaxKind.ImportDeclaration ||
1598815991
node.kind === SyntaxKind.ImportEqualsDeclaration ||
1598915992
node.kind === SyntaxKind.ExportDeclaration ||
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
=== tests/cases/compiler/typeAliasDeclareKeyword01.d.ts ===
2+
type Foo = number;
3+
>Foo : Symbol(Foo, Decl(typeAliasDeclareKeyword01.d.ts, 0, 0))
4+
5+
declare type Bar = string;
6+
>Bar : Symbol(Bar, Decl(typeAliasDeclareKeyword01.d.ts, 0, 18))
7+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
=== tests/cases/compiler/typeAliasDeclareKeyword01.d.ts ===
2+
type Foo = number;
3+
>Foo : number
4+
5+
declare type Bar = string;
6+
>Bar : string
7+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
type Foo = number;
2+
declare type Bar = string;

0 commit comments

Comments
 (0)