Don't error when 'reserved' names appear in ambient contexts.

Fixes #8293
This commit is contained in:
Ryan Cavanaugh 2016-04-26 13:10:06 -07:00
parent fed42cc6bd
commit de4f2797c6
4 changed files with 18 additions and 11 deletions

View File

@ -1377,7 +1377,8 @@ namespace ts {
if (inStrictMode &&
node.originalKeywordKind >= SyntaxKind.FirstFutureReservedWord &&
node.originalKeywordKind <= SyntaxKind.LastFutureReservedWord &&
!isIdentifierName(node)) {
!isIdentifierName(node) &&
!isInAmbientContext(node)) {
// Report error only if there are no parse errors in file
if (!file.parseDiagnostics.length) {

View File

@ -1,10 +0,0 @@
tests/cases/compiler/ambientNameRestrictions.ts(2,14): error TS1214: Identifier expected. 'static' is a reserved word in strict mode. Modules are automatically in strict mode.
==== tests/cases/compiler/ambientNameRestrictions.ts (1 errors) ====
export declare namespace Foo {
export var static: any;
~~~~~~
!!! error TS1214: Identifier expected. 'static' is a reserved word in strict mode. Modules are automatically in strict mode.
}

View File

@ -0,0 +1,8 @@
=== tests/cases/compiler/ambientNameRestrictions.ts ===
export declare namespace Foo {
>Foo : Symbol(Foo, Decl(ambientNameRestrictions.ts, 0, 0))
export var static: any;
>static : Symbol(static, Decl(ambientNameRestrictions.ts, 1, 12))
}

View File

@ -0,0 +1,8 @@
=== tests/cases/compiler/ambientNameRestrictions.ts ===
export declare namespace Foo {
>Foo : typeof Foo
export var static: any;
>static : any
}