Skip to content

Commit de4f279

Browse files
committed
Don't error when 'reserved' names appear in ambient contexts.
Fixes microsoft#8293
1 parent fed42cc commit de4f279

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
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) {

tests/baselines/reference/ambientNameRestrictions.errors.txt

Lines changed: 0 additions & 10 deletions
This file was deleted.
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+

0 commit comments

Comments
 (0)