Skip to content

Commit e00f573

Browse files
committed
Merge pull request #8312 from RyanCavanaugh/fix8293
Don't error when 'reserved' names appear in ambient contexts
2 parents da01975 + de4f279 commit e00f573

File tree

5 files changed

+29
-1
lines changed

5 files changed

+29
-1
lines changed

src/compiler/binder.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1377,7 +1377,8 @@ namespace ts {
13771377
if (inStrictMode &&
13781378
node.originalKeywordKind >= SyntaxKind.FirstFutureReservedWord &&
13791379
node.originalKeywordKind <= SyntaxKind.LastFutureReservedWord &&
1380-
!isIdentifierName(node)) {
1380+
!isIdentifierName(node) &&
1381+
!isInAmbientContext(node)) {
13811382

13821383
// Report error only if there are no parse errors in file
13831384
if (!file.parseDiagnostics.length) {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//// [ambientNameRestrictions.ts]
2+
export declare namespace Foo {
3+
export var static: any;
4+
}
5+
6+
7+
//// [ambientNameRestrictions.js]
8+
"use strict";
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
=== tests/cases/compiler/ambientNameRestrictions.ts ===
2+
export declare namespace Foo {
3+
>Foo : Symbol(Foo, Decl(ambientNameRestrictions.ts, 0, 0))
4+
5+
export var static: any;
6+
>static : Symbol(static, Decl(ambientNameRestrictions.ts, 1, 12))
7+
}
8+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
=== tests/cases/compiler/ambientNameRestrictions.ts ===
2+
export declare namespace Foo {
3+
>Foo : typeof Foo
4+
5+
export var static: any;
6+
>static : any
7+
}
8+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export declare namespace Foo {
2+
export var static: any;
3+
}

0 commit comments

Comments
 (0)