-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix "Cannot find name 'global'. Did you mean 'global'?" (#42262)
* Add tests for "Cannot find name 'global'. Did you mean 'global'?" * Fix "Cannot find name 'global'. Did you mean 'global'?" * Add an additional test case for spelling suggestions of "global". * Name the boolean for suggestions being global scope augmentations.
- Loading branch information
Showing
21 changed files
with
184 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
10 changes: 10 additions & 0 deletions
10
tests/baselines/reference/spellingSuggestionGlobal1.errors.txt
This file contains 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,10 @@ | ||
tests/cases/compiler/spellingSuggestionGlobal1.ts(3,1): error TS2304: Cannot find name 'global'. | ||
|
||
|
||
==== tests/cases/compiler/spellingSuggestionGlobal1.ts (1 errors) ==== | ||
export {} | ||
declare global { const x: any } | ||
global.x // should not suggest `global` (GH#42209) | ||
~~~~~~ | ||
!!! error TS2304: Cannot find name 'global'. | ||
|
This file contains 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,10 @@ | ||
//// [spellingSuggestionGlobal1.ts] | ||
export {} | ||
declare global { const x: any } | ||
global.x // should not suggest `global` (GH#42209) | ||
|
||
|
||
//// [spellingSuggestionGlobal1.js] | ||
"use strict"; | ||
exports.__esModule = true; | ||
global.x; // should not suggest `global` (GH#42209) |
This file contains 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,8 @@ | ||
=== tests/cases/compiler/spellingSuggestionGlobal1.ts === | ||
export {} | ||
declare global { const x: any } | ||
>global : Symbol(global, Decl(spellingSuggestionGlobal1.ts, 0, 9)) | ||
>x : Symbol(x, Decl(spellingSuggestionGlobal1.ts, 1, 22)) | ||
|
||
global.x // should not suggest `global` (GH#42209) | ||
|
This file contains 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 @@ | ||
=== tests/cases/compiler/spellingSuggestionGlobal1.ts === | ||
export {} | ||
declare global { const x: any } | ||
>global : typeof global | ||
>x : any | ||
|
||
global.x // should not suggest `global` (GH#42209) | ||
>global.x : any | ||
>global : any | ||
>x : any | ||
|
12 changes: 12 additions & 0 deletions
12
tests/baselines/reference/spellingSuggestionGlobal2.errors.txt
This file contains 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,12 @@ | ||
tests/cases/compiler/spellingSuggestionGlobal2.ts(4,1): error TS2552: Cannot find name 'global'. Did you mean 'globals'? | ||
|
||
|
||
==== tests/cases/compiler/spellingSuggestionGlobal2.ts (1 errors) ==== | ||
export {} | ||
declare global { const x: any } | ||
const globals = { x: true } | ||
global.x // should suggest `globals` (GH#42209) | ||
~~~~~~ | ||
!!! error TS2552: Cannot find name 'global'. Did you mean 'globals'? | ||
!!! related TS2728 tests/cases/compiler/spellingSuggestionGlobal2.ts:3:7: 'globals' is declared here. | ||
|
This file contains 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,12 @@ | ||
//// [spellingSuggestionGlobal2.ts] | ||
export {} | ||
declare global { const x: any } | ||
const globals = { x: true } | ||
global.x // should suggest `globals` (GH#42209) | ||
|
||
|
||
//// [spellingSuggestionGlobal2.js] | ||
"use strict"; | ||
exports.__esModule = true; | ||
var globals = { x: true }; | ||
global.x; // should suggest `globals` (GH#42209) |
12 changes: 12 additions & 0 deletions
12
tests/baselines/reference/spellingSuggestionGlobal2.symbols
This file contains 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,12 @@ | ||
=== tests/cases/compiler/spellingSuggestionGlobal2.ts === | ||
export {} | ||
declare global { const x: any } | ||
>global : Symbol(global, Decl(spellingSuggestionGlobal2.ts, 0, 9)) | ||
>x : Symbol(x, Decl(spellingSuggestionGlobal2.ts, 1, 22)) | ||
|
||
const globals = { x: true } | ||
>globals : Symbol(globals, Decl(spellingSuggestionGlobal2.ts, 2, 5)) | ||
>x : Symbol(x, Decl(spellingSuggestionGlobal2.ts, 2, 17)) | ||
|
||
global.x // should suggest `globals` (GH#42209) | ||
|
This file contains 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,17 @@ | ||
=== tests/cases/compiler/spellingSuggestionGlobal2.ts === | ||
export {} | ||
declare global { const x: any } | ||
>global : typeof global | ||
>x : any | ||
|
||
const globals = { x: true } | ||
>globals : { x: boolean; } | ||
>{ x: true } : { x: boolean; } | ||
>x : boolean | ||
>true : true | ||
|
||
global.x // should suggest `globals` (GH#42209) | ||
>global.x : any | ||
>global : any | ||
>x : any | ||
|
10 changes: 10 additions & 0 deletions
10
tests/baselines/reference/spellingSuggestionGlobal3.errors.txt
This file contains 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,10 @@ | ||
tests/cases/compiler/spellingSuggestionGlobal3.ts(2,1): error TS2552: Cannot find name 'globals'. Did you mean 'global'? | ||
|
||
|
||
==== tests/cases/compiler/spellingSuggestionGlobal3.ts (1 errors) ==== | ||
const global = { x: true } | ||
globals.x // should suggest `global` (GH#42209) | ||
~~~~~~~ | ||
!!! error TS2552: Cannot find name 'globals'. Did you mean 'global'? | ||
!!! related TS2728 tests/cases/compiler/spellingSuggestionGlobal3.ts:1:7: 'global' is declared here. | ||
|
This file contains 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,8 @@ | ||
//// [spellingSuggestionGlobal3.ts] | ||
const global = { x: true } | ||
globals.x // should suggest `global` (GH#42209) | ||
|
||
|
||
//// [spellingSuggestionGlobal3.js] | ||
var global = { x: true }; | ||
globals.x; // should suggest `global` (GH#42209) |
This file contains 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,7 @@ | ||
=== tests/cases/compiler/spellingSuggestionGlobal3.ts === | ||
const global = { x: true } | ||
>global : Symbol(global, Decl(spellingSuggestionGlobal3.ts, 0, 5)) | ||
>x : Symbol(x, Decl(spellingSuggestionGlobal3.ts, 0, 16)) | ||
|
||
globals.x // should suggest `global` (GH#42209) | ||
|
This file contains 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,12 @@ | ||
=== tests/cases/compiler/spellingSuggestionGlobal3.ts === | ||
const global = { x: true } | ||
>global : { x: boolean; } | ||
>{ x: true } : { x: boolean; } | ||
>x : boolean | ||
>true : true | ||
|
||
globals.x // should suggest `global` (GH#42209) | ||
>globals.x : any | ||
>globals : any | ||
>x : any | ||
|
10 changes: 10 additions & 0 deletions
10
tests/baselines/reference/spellingSuggestionGlobal4.errors.txt
This file contains 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,10 @@ | ||
tests/cases/compiler/spellingSuggestionGlobal4.ts(3,1): error TS2304: Cannot find name 'global'. | ||
|
||
|
||
==== tests/cases/compiler/spellingSuggestionGlobal4.ts (1 errors) ==== | ||
export {} | ||
declare global { var x: any } | ||
global.x // should not suggest `global` (GH#42209) | ||
~~~~~~ | ||
!!! error TS2304: Cannot find name 'global'. | ||
|
This file contains 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,10 @@ | ||
//// [spellingSuggestionGlobal4.ts] | ||
export {} | ||
declare global { var x: any } | ||
global.x // should not suggest `global` (GH#42209) | ||
|
||
|
||
//// [spellingSuggestionGlobal4.js] | ||
"use strict"; | ||
exports.__esModule = true; | ||
global.x; // should not suggest `global` (GH#42209) |
This file contains 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,8 @@ | ||
=== tests/cases/compiler/spellingSuggestionGlobal4.ts === | ||
export {} | ||
declare global { var x: any } | ||
>global : Symbol(global, Decl(spellingSuggestionGlobal4.ts, 0, 9)) | ||
>x : Symbol(x, Decl(spellingSuggestionGlobal4.ts, 1, 20)) | ||
|
||
global.x // should not suggest `global` (GH#42209) | ||
|
This file contains 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 @@ | ||
=== tests/cases/compiler/spellingSuggestionGlobal4.ts === | ||
export {} | ||
declare global { var x: any } | ||
>global : typeof global | ||
>x : any | ||
|
||
global.x // should not suggest `global` (GH#42209) | ||
>global.x : any | ||
>global : any | ||
>x : any | ||
|
This file contains 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,3 @@ | ||
export {} | ||
declare global { const x: any } | ||
global.x // should not suggest `global` (GH#42209) |
This file contains 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,4 @@ | ||
export {} | ||
declare global { const x: any } | ||
const globals = { x: true } | ||
global.x // should suggest `globals` (GH#42209) |
This file contains 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,2 @@ | ||
const global = { x: true } | ||
globals.x // should suggest `global` (GH#42209) |
This file contains 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,3 @@ | ||
export {} | ||
declare global { var x: any } | ||
global.x // should not suggest `global` (GH#42209) |