forked from microsoft/TypeScript
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes microsoft#33860 by making it an error. This is an improvement, but sounds like it would be better to make it work later.
- Loading branch information
1 parent
d8840f8
commit eb0208c
Showing
8 changed files
with
55 additions
and
5 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
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
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/extendGlobalThis2.ts(1,11): error TS2397: Declaration name conflicts with built-in global identifier 'globalThis'. | ||
|
||
|
||
==== tests/cases/compiler/extendGlobalThis2.ts (1 errors) ==== | ||
namespace globalThis { | ||
~~~~~~~~~~ | ||
!!! error TS2397: Declaration name conflicts with built-in global identifier 'globalThis'. | ||
export function foo() { console.log("x"); } | ||
} | ||
|
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 @@ | ||
//// [extendGlobalThis2.ts] | ||
namespace globalThis { | ||
export function foo() { console.log("x"); } | ||
} | ||
|
||
|
||
//// [extendGlobalThis2.js] | ||
var globalThis; | ||
(function (globalThis) { | ||
function foo() { console.log("x"); } | ||
globalThis.foo = foo; | ||
})(globalThis || (globalThis = {})); |
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/extendGlobalThis2.ts === | ||
namespace globalThis { | ||
>globalThis : Symbol(globalThis, Decl(extendGlobalThis2.ts, 0, 0)) | ||
|
||
export function foo() { console.log("x"); } | ||
>foo : Symbol(foo, Decl(extendGlobalThis2.ts, 0, 22)) | ||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) | ||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
} | ||
|
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,13 @@ | ||
=== tests/cases/compiler/extendGlobalThis2.ts === | ||
namespace globalThis { | ||
>globalThis : typeof globalThis | ||
|
||
export function foo() { console.log("x"); } | ||
>foo : () => void | ||
>console.log("x") : void | ||
>console.log : (message?: any, ...optionalParams: any[]) => void | ||
>console : Console | ||
>log : (message?: any, ...optionalParams: any[]) => void | ||
>"x" : "x" | ||
} | ||
|
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
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 @@ | ||
namespace globalThis { | ||
export function foo() { console.log("x"); } | ||
} |