From fc2dca23448c66f6f31aafc46b2e2b7136c2bee5 Mon Sep 17 00:00:00 2001 From: Julian Williams Date: Thu, 22 Oct 2015 18:18:57 -0400 Subject: [PATCH 1/5] Added test. --- tests/cases/compiler/typeAliasDeclareKeyword01.d.ts | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 tests/cases/compiler/typeAliasDeclareKeyword01.d.ts diff --git a/tests/cases/compiler/typeAliasDeclareKeyword01.d.ts b/tests/cases/compiler/typeAliasDeclareKeyword01.d.ts new file mode 100644 index 00000000000..cf2a5061937 --- /dev/null +++ b/tests/cases/compiler/typeAliasDeclareKeyword01.d.ts @@ -0,0 +1,2 @@ +type Foo = number; +declare type Bar = string; \ No newline at end of file From c30ac53c66e164ac1260ddf8a1f54ade497733c5 Mon Sep 17 00:00:00 2001 From: Julian Williams Date: Thu, 22 Oct 2015 20:44:50 -0400 Subject: [PATCH 2/5] Accepted baselines. --- .../reference/typeAliasDeclareKeyword01.d.errors.txt | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 tests/baselines/reference/typeAliasDeclareKeyword01.d.errors.txt diff --git a/tests/baselines/reference/typeAliasDeclareKeyword01.d.errors.txt b/tests/baselines/reference/typeAliasDeclareKeyword01.d.errors.txt new file mode 100644 index 00000000000..000ef77c3f4 --- /dev/null +++ b/tests/baselines/reference/typeAliasDeclareKeyword01.d.errors.txt @@ -0,0 +1,8 @@ +tests/cases/compiler/typeAliasDeclareKeyword01.d.ts(1,1): error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. + + +==== tests/cases/compiler/typeAliasDeclareKeyword01.d.ts (1 errors) ==== + type Foo = number; + ~~~~ +!!! error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. + declare type Bar = string; \ No newline at end of file From a0939d962be86c9c6e3c0a7df0440824d2c8d8f0 Mon Sep 17 00:00:00 2001 From: Julian Williams Date: Fri, 23 Oct 2015 22:43:11 -0400 Subject: [PATCH 3/5] Added TypeAliasDeclaration to exceptions for required top level declare modifier --- src/compiler/checker.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 663825f1e84..c7317908273 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -15917,6 +15917,7 @@ namespace ts { // export_opt AmbientDeclaration // if (node.kind === SyntaxKind.InterfaceDeclaration || + node.kind === SyntaxKind.TypeAliasDeclaration || node.kind === SyntaxKind.ImportDeclaration || node.kind === SyntaxKind.ImportEqualsDeclaration || node.kind === SyntaxKind.ExportDeclaration || From 5613ba860f773bce9ed40d2172caf4a615369724 Mon Sep 17 00:00:00 2001 From: Julian Williams Date: Sat, 24 Oct 2015 13:43:11 -0400 Subject: [PATCH 4/5] accepted baselines --- .../reference/typeAliasDeclareKeyword01.d.errors.txt | 8 -------- .../reference/typeAliasDeclareKeyword01.d.symbols | 7 +++++++ .../baselines/reference/typeAliasDeclareKeyword01.d.types | 7 +++++++ 3 files changed, 14 insertions(+), 8 deletions(-) delete mode 100644 tests/baselines/reference/typeAliasDeclareKeyword01.d.errors.txt create mode 100644 tests/baselines/reference/typeAliasDeclareKeyword01.d.symbols create mode 100644 tests/baselines/reference/typeAliasDeclareKeyword01.d.types diff --git a/tests/baselines/reference/typeAliasDeclareKeyword01.d.errors.txt b/tests/baselines/reference/typeAliasDeclareKeyword01.d.errors.txt deleted file mode 100644 index 000ef77c3f4..00000000000 --- a/tests/baselines/reference/typeAliasDeclareKeyword01.d.errors.txt +++ /dev/null @@ -1,8 +0,0 @@ -tests/cases/compiler/typeAliasDeclareKeyword01.d.ts(1,1): error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. - - -==== tests/cases/compiler/typeAliasDeclareKeyword01.d.ts (1 errors) ==== - type Foo = number; - ~~~~ -!!! error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. - declare type Bar = string; \ No newline at end of file diff --git a/tests/baselines/reference/typeAliasDeclareKeyword01.d.symbols b/tests/baselines/reference/typeAliasDeclareKeyword01.d.symbols new file mode 100644 index 00000000000..86c1ae8f40c --- /dev/null +++ b/tests/baselines/reference/typeAliasDeclareKeyword01.d.symbols @@ -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)) + diff --git a/tests/baselines/reference/typeAliasDeclareKeyword01.d.types b/tests/baselines/reference/typeAliasDeclareKeyword01.d.types new file mode 100644 index 00000000000..588fdd9012c --- /dev/null +++ b/tests/baselines/reference/typeAliasDeclareKeyword01.d.types @@ -0,0 +1,7 @@ +=== tests/cases/compiler/typeAliasDeclareKeyword01.d.ts === +type Foo = number; +>Foo : number + +declare type Bar = string; +>Bar : string + From 1d6f5c6781509715430eac337067273e5cae90c0 Mon Sep 17 00:00:00 2001 From: Julian Williams Date: Sat, 24 Oct 2015 22:21:34 -0400 Subject: [PATCH 5/5] Added grammar change to the comments. --- src/compiler/checker.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c7317908273..9766926c3d0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -15912,10 +15912,12 @@ 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 ||