Skip to content

Don't error when 'reserved' names appear in ambient contexts #8312

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/compiler/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 8 additions & 0 deletions tests/baselines/reference/ambientNameRestrictions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//// [ambientNameRestrictions.ts]
export declare namespace Foo {
export var static: any;
}


//// [ambientNameRestrictions.js]
"use strict";
8 changes: 8 additions & 0 deletions tests/baselines/reference/ambientNameRestrictions.symbols
Original file line number Diff line number Diff line change
@@ -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))
}

8 changes: 8 additions & 0 deletions tests/baselines/reference/ambientNameRestrictions.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
=== tests/cases/compiler/ambientNameRestrictions.ts ===
export declare namespace Foo {
>Foo : typeof Foo

export var static: any;
>static : any
}

3 changes: 3 additions & 0 deletions tests/cases/compiler/ambientNameRestrictions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export declare namespace Foo {
export var static: any;
}