-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Parse reserved identifiers as dotted names of ambient modules #55282
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
sandersn
merged 4 commits into
microsoft:main
from
Andarist:fix/parse-reserved-identifiers-in-declared-dotted-names
Aug 28, 2023
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
099106e
Parse reserved identifiers as dotted names of ambient modules
Andarist 6f13fe2
Merge remote-tracking branch 'origin/main' into fix/parse-reserved-id…
Andarist 312f9ab
Merge remote-tracking branch 'origin/main' into fix/parse-reserved-id…
Andarist 0277da6
add an extra test case
Andarist File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...baselines/reference/ambientModuleDeclarationWithReservedIdentifierInDottedPath.errors.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
ambientModuleDeclarationWithReservedIdentifierInDottedPath.ts(11,1): error TS2304: Cannot find name 'declare'. | ||
ambientModuleDeclarationWithReservedIdentifierInDottedPath.ts(11,9): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. | ||
ambientModuleDeclarationWithReservedIdentifierInDottedPath.ts(11,16): error TS2819: Namespace name cannot be 'debugger'. | ||
ambientModuleDeclarationWithReservedIdentifierInDottedPath.ts(11,25): error TS1005: ';' expected. | ||
|
||
|
||
==== ambientModuleDeclarationWithReservedIdentifierInDottedPath.ts (4 errors) ==== | ||
// https://github.com/microsoft/TypeScript/issues/7840 | ||
|
||
declare module chrome.debugger { | ||
declare var tabId: number; | ||
} | ||
|
||
export const tabId = chrome.debugger.tabId; | ||
|
||
declare module test.class {} | ||
|
||
declare module debugger {} // still an error | ||
~~~~~~~ | ||
!!! error TS2304: Cannot find name 'declare'. | ||
~~~~~~ | ||
!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. | ||
~~~~~~~~ | ||
!!! error TS2819: Namespace name cannot be 'debugger'. | ||
~ | ||
!!! error TS1005: ';' expected. | ||
|
30 changes: 30 additions & 0 deletions
30
tests/baselines/reference/ambientModuleDeclarationWithReservedIdentifierInDottedPath.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//// [tests/cases/conformance/ambient/ambientModuleDeclarationWithReservedIdentifierInDottedPath.ts] //// | ||
|
||
//// [ambientModuleDeclarationWithReservedIdentifierInDottedPath.ts] | ||
// https://github.com/microsoft/TypeScript/issues/7840 | ||
|
||
declare module chrome.debugger { | ||
declare var tabId: number; | ||
} | ||
|
||
export const tabId = chrome.debugger.tabId; | ||
|
||
declare module test.class {} | ||
|
||
declare module debugger {} // still an error | ||
|
||
|
||
//// [ambientModuleDeclarationWithReservedIdentifierInDottedPath.js] | ||
"use strict"; | ||
// https://github.com/microsoft/TypeScript/issues/7840 | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.tabId = void 0; | ||
exports.tabId = chrome.debugger.tabId; | ||
declare; | ||
module; | ||
debugger; | ||
{ } // still an error | ||
|
||
|
||
//// [ambientModuleDeclarationWithReservedIdentifierInDottedPath.d.ts] | ||
export declare const tabId: number; |
27 changes: 27 additions & 0 deletions
27
tests/baselines/reference/ambientModuleDeclarationWithReservedIdentifierInDottedPath.symbols
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//// [tests/cases/conformance/ambient/ambientModuleDeclarationWithReservedIdentifierInDottedPath.ts] //// | ||
|
||
=== ambientModuleDeclarationWithReservedIdentifierInDottedPath.ts === | ||
// https://github.com/microsoft/TypeScript/issues/7840 | ||
|
||
declare module chrome.debugger { | ||
>chrome : Symbol(chrome, Decl(ambientModuleDeclarationWithReservedIdentifierInDottedPath.ts, 0, 0)) | ||
>debugger : Symbol(debugger, Decl(ambientModuleDeclarationWithReservedIdentifierInDottedPath.ts, 2, 22)) | ||
|
||
declare var tabId: number; | ||
>tabId : Symbol(tabId, Decl(ambientModuleDeclarationWithReservedIdentifierInDottedPath.ts, 3, 15)) | ||
} | ||
|
||
export const tabId = chrome.debugger.tabId; | ||
>tabId : Symbol(tabId, Decl(ambientModuleDeclarationWithReservedIdentifierInDottedPath.ts, 6, 12)) | ||
>chrome.debugger.tabId : Symbol(chrome.debugger.tabId, Decl(ambientModuleDeclarationWithReservedIdentifierInDottedPath.ts, 3, 15)) | ||
>chrome.debugger : Symbol(chrome.debugger, Decl(ambientModuleDeclarationWithReservedIdentifierInDottedPath.ts, 2, 22)) | ||
>chrome : Symbol(chrome, Decl(ambientModuleDeclarationWithReservedIdentifierInDottedPath.ts, 0, 0)) | ||
>debugger : Symbol(chrome.debugger, Decl(ambientModuleDeclarationWithReservedIdentifierInDottedPath.ts, 2, 22)) | ||
>tabId : Symbol(chrome.debugger.tabId, Decl(ambientModuleDeclarationWithReservedIdentifierInDottedPath.ts, 3, 15)) | ||
|
||
declare module test.class {} | ||
>test : Symbol(test, Decl(ambientModuleDeclarationWithReservedIdentifierInDottedPath.ts, 6, 43)) | ||
>class : Symbol(class, Decl(ambientModuleDeclarationWithReservedIdentifierInDottedPath.ts, 8, 20)) | ||
|
||
declare module debugger {} // still an error | ||
|
27 changes: 27 additions & 0 deletions
27
tests/baselines/reference/ambientModuleDeclarationWithReservedIdentifierInDottedPath.types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//// [tests/cases/conformance/ambient/ambientModuleDeclarationWithReservedIdentifierInDottedPath.ts] //// | ||
|
||
=== ambientModuleDeclarationWithReservedIdentifierInDottedPath.ts === | ||
// https://github.com/microsoft/TypeScript/issues/7840 | ||
|
||
declare module chrome.debugger { | ||
>chrome : typeof chrome | ||
>debugger : typeof debugger | ||
|
||
declare var tabId: number; | ||
>tabId : number | ||
} | ||
|
||
export const tabId = chrome.debugger.tabId; | ||
>tabId : number | ||
>chrome.debugger.tabId : number | ||
>chrome.debugger : typeof chrome.debugger | ||
>chrome : typeof chrome | ||
>debugger : typeof chrome.debugger | ||
>tabId : number | ||
|
||
declare module test.class {} | ||
|
||
declare module debugger {} // still an error | ||
>declare : any | ||
>module : any | ||
|
25 changes: 25 additions & 0 deletions
25
...aselines/reference/ambientModuleDeclarationWithReservedIdentifierInDottedPath2.errors.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
ambientModuleDeclarationWithReservedIdentifierInDottedPath2.ts(9,1): error TS2304: Cannot find name 'declare'. | ||
ambientModuleDeclarationWithReservedIdentifierInDottedPath2.ts(9,9): error TS2304: Cannot find name 'namespace'. | ||
ambientModuleDeclarationWithReservedIdentifierInDottedPath2.ts(9,19): error TS2819: Namespace name cannot be 'debugger'. | ||
ambientModuleDeclarationWithReservedIdentifierInDottedPath2.ts(9,28): error TS1005: ';' expected. | ||
|
||
|
||
==== ambientModuleDeclarationWithReservedIdentifierInDottedPath2.ts (4 errors) ==== | ||
declare namespace chrome.debugger { | ||
declare var tabId: number; | ||
} | ||
|
||
export const tabId = chrome.debugger.tabId; | ||
|
||
declare namespace test.class {} | ||
|
||
declare namespace debugger {} // still an error | ||
~~~~~~~ | ||
!!! error TS2304: Cannot find name 'declare'. | ||
~~~~~~~~~ | ||
!!! error TS2304: Cannot find name 'namespace'. | ||
~~~~~~~~ | ||
!!! error TS2819: Namespace name cannot be 'debugger'. | ||
~ | ||
!!! error TS1005: ';' expected. | ||
|
27 changes: 27 additions & 0 deletions
27
tests/baselines/reference/ambientModuleDeclarationWithReservedIdentifierInDottedPath2.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//// [tests/cases/conformance/ambient/ambientModuleDeclarationWithReservedIdentifierInDottedPath2.ts] //// | ||
|
||
//// [ambientModuleDeclarationWithReservedIdentifierInDottedPath2.ts] | ||
declare namespace chrome.debugger { | ||
declare var tabId: number; | ||
} | ||
|
||
export const tabId = chrome.debugger.tabId; | ||
|
||
declare namespace test.class {} | ||
|
||
declare namespace debugger {} // still an error | ||
|
||
|
||
//// [ambientModuleDeclarationWithReservedIdentifierInDottedPath2.js] | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.tabId = void 0; | ||
exports.tabId = chrome.debugger.tabId; | ||
declare; | ||
namespace; | ||
debugger; | ||
{ } // still an error | ||
|
||
|
||
//// [ambientModuleDeclarationWithReservedIdentifierInDottedPath2.d.ts] | ||
export declare const tabId: number; |
25 changes: 25 additions & 0 deletions
25
...s/baselines/reference/ambientModuleDeclarationWithReservedIdentifierInDottedPath2.symbols
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//// [tests/cases/conformance/ambient/ambientModuleDeclarationWithReservedIdentifierInDottedPath2.ts] //// | ||
|
||
=== ambientModuleDeclarationWithReservedIdentifierInDottedPath2.ts === | ||
declare namespace chrome.debugger { | ||
>chrome : Symbol(chrome, Decl(ambientModuleDeclarationWithReservedIdentifierInDottedPath2.ts, 0, 0)) | ||
>debugger : Symbol(debugger, Decl(ambientModuleDeclarationWithReservedIdentifierInDottedPath2.ts, 0, 25)) | ||
|
||
declare var tabId: number; | ||
>tabId : Symbol(tabId, Decl(ambientModuleDeclarationWithReservedIdentifierInDottedPath2.ts, 1, 15)) | ||
} | ||
|
||
export const tabId = chrome.debugger.tabId; | ||
>tabId : Symbol(tabId, Decl(ambientModuleDeclarationWithReservedIdentifierInDottedPath2.ts, 4, 12)) | ||
>chrome.debugger.tabId : Symbol(chrome.debugger.tabId, Decl(ambientModuleDeclarationWithReservedIdentifierInDottedPath2.ts, 1, 15)) | ||
>chrome.debugger : Symbol(chrome.debugger, Decl(ambientModuleDeclarationWithReservedIdentifierInDottedPath2.ts, 0, 25)) | ||
>chrome : Symbol(chrome, Decl(ambientModuleDeclarationWithReservedIdentifierInDottedPath2.ts, 0, 0)) | ||
>debugger : Symbol(chrome.debugger, Decl(ambientModuleDeclarationWithReservedIdentifierInDottedPath2.ts, 0, 25)) | ||
>tabId : Symbol(chrome.debugger.tabId, Decl(ambientModuleDeclarationWithReservedIdentifierInDottedPath2.ts, 1, 15)) | ||
|
||
declare namespace test.class {} | ||
>test : Symbol(test, Decl(ambientModuleDeclarationWithReservedIdentifierInDottedPath2.ts, 4, 43)) | ||
>class : Symbol(class, Decl(ambientModuleDeclarationWithReservedIdentifierInDottedPath2.ts, 6, 23)) | ||
|
||
declare namespace debugger {} // still an error | ||
|
25 changes: 25 additions & 0 deletions
25
tests/baselines/reference/ambientModuleDeclarationWithReservedIdentifierInDottedPath2.types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//// [tests/cases/conformance/ambient/ambientModuleDeclarationWithReservedIdentifierInDottedPath2.ts] //// | ||
|
||
=== ambientModuleDeclarationWithReservedIdentifierInDottedPath2.ts === | ||
declare namespace chrome.debugger { | ||
>chrome : typeof chrome | ||
>debugger : typeof debugger | ||
|
||
declare var tabId: number; | ||
>tabId : number | ||
} | ||
|
||
export const tabId = chrome.debugger.tabId; | ||
>tabId : number | ||
>chrome.debugger.tabId : number | ||
>chrome.debugger : typeof chrome.debugger | ||
>chrome : typeof chrome | ||
>debugger : typeof chrome.debugger | ||
>tabId : number | ||
|
||
declare namespace test.class {} | ||
|
||
declare namespace debugger {} // still an error | ||
>declare : any | ||
>namespace : any | ||
|
13 changes: 13 additions & 0 deletions
13
...s/cases/conformance/ambient/ambientModuleDeclarationWithReservedIdentifierInDottedPath.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// @declaration: true | ||
|
||
// https://github.com/microsoft/TypeScript/issues/7840 | ||
|
||
declare module chrome.debugger { | ||
declare var tabId: number; | ||
} | ||
|
||
export const tabId = chrome.debugger.tabId; | ||
|
||
declare module test.class {} | ||
|
||
declare module debugger {} // still an error |
11 changes: 11 additions & 0 deletions
11
.../cases/conformance/ambient/ambientModuleDeclarationWithReservedIdentifierInDottedPath2.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// @declaration: true | ||
|
||
declare namespace chrome.debugger { | ||
declare var tabId: number; | ||
} | ||
|
||
export const tabId = chrome.debugger.tabId; | ||
|
||
declare namespace test.class {} | ||
|
||
declare namespace debugger {} // still an error |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we haven't (yet) deprecated the
module
keyword, but please usedeclare namespace
for new testsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While the syntax is supported - shouldn't I add extra tests with
declare namespace
instead of changing this one?