-
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.
Error on types named "undefined" (#57575)
- Loading branch information
1 parent
3fca8c8
commit e24d886
Showing
13 changed files
with
360 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
typeNamedUndefined1.ts(3,17): error TS2457: Type alias name cannot be 'undefined'. | ||
typeNamedUndefined1.ts(13,13): error TS2457: Type alias name cannot be 'undefined'. | ||
|
||
|
||
==== typeNamedUndefined1.ts (2 errors) ==== | ||
export namespace ns { | ||
const s = Symbol(); | ||
export type undefined = typeof s; | ||
~~~~~~~~~ | ||
!!! error TS2457: Type alias name cannot be 'undefined'. | ||
export function x(p: undefined): undefined { // global undefined | ||
return p; | ||
} | ||
} | ||
|
||
export function x(p: ns.undefined) { // undefined from the namespace | ||
return p; | ||
} | ||
|
||
export type undefined = ""; | ||
~~~~~~~~~ | ||
!!! error TS2457: Type alias name cannot be 'undefined'. | ||
|
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,30 @@ | ||
//// [tests/cases/compiler/typeNamedUndefined1.ts] //// | ||
|
||
//// [typeNamedUndefined1.ts] | ||
export namespace ns { | ||
const s = Symbol(); | ||
export type undefined = typeof s; | ||
export function x(p: undefined): undefined { // global undefined | ||
return p; | ||
} | ||
} | ||
|
||
export function x(p: ns.undefined) { // undefined from the namespace | ||
return p; | ||
} | ||
|
||
export type undefined = ""; | ||
|
||
|
||
//// [typeNamedUndefined1.js] | ||
export var ns; | ||
(function (ns) { | ||
const s = Symbol(); | ||
function x(p) { | ||
return p; | ||
} | ||
ns.x = x; | ||
})(ns || (ns = {})); | ||
export function x(p) { | ||
return p; | ||
} |
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,36 @@ | ||
//// [tests/cases/compiler/typeNamedUndefined1.ts] //// | ||
|
||
=== typeNamedUndefined1.ts === | ||
export namespace ns { | ||
>ns : Symbol(ns, Decl(typeNamedUndefined1.ts, 0, 0)) | ||
|
||
const s = Symbol(); | ||
>s : Symbol(s, Decl(typeNamedUndefined1.ts, 1, 9)) | ||
>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) | ||
|
||
export type undefined = typeof s; | ||
>undefined : Symbol(undefined, Decl(typeNamedUndefined1.ts, 1, 23)) | ||
>s : Symbol(s, Decl(typeNamedUndefined1.ts, 1, 9)) | ||
|
||
export function x(p: undefined): undefined { // global undefined | ||
>x : Symbol(x, Decl(typeNamedUndefined1.ts, 2, 37)) | ||
>p : Symbol(p, Decl(typeNamedUndefined1.ts, 3, 22)) | ||
|
||
return p; | ||
>p : Symbol(p, Decl(typeNamedUndefined1.ts, 3, 22)) | ||
} | ||
} | ||
|
||
export function x(p: ns.undefined) { // undefined from the namespace | ||
>x : Symbol(x, Decl(typeNamedUndefined1.ts, 6, 1)) | ||
>p : Symbol(p, Decl(typeNamedUndefined1.ts, 8, 18)) | ||
>ns : Symbol(ns, Decl(typeNamedUndefined1.ts, 0, 0)) | ||
>undefined : Symbol(ns.undefined, Decl(typeNamedUndefined1.ts, 1, 23)) | ||
|
||
return p; | ||
>p : Symbol(p, Decl(typeNamedUndefined1.ts, 8, 18)) | ||
} | ||
|
||
export type undefined = ""; | ||
>undefined : Symbol(undefined, Decl(typeNamedUndefined1.ts, 10, 1)) | ||
|
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,36 @@ | ||
//// [tests/cases/compiler/typeNamedUndefined1.ts] //// | ||
|
||
=== typeNamedUndefined1.ts === | ||
export namespace ns { | ||
>ns : typeof ns | ||
|
||
const s = Symbol(); | ||
>s : unique symbol | ||
>Symbol() : unique symbol | ||
>Symbol : SymbolConstructor | ||
|
||
export type undefined = typeof s; | ||
>undefined : unique symbol | ||
>s : unique symbol | ||
|
||
export function x(p: undefined): undefined { // global undefined | ||
>x : (p: undefined) => undefined | ||
>p : undefined | ||
|
||
return p; | ||
>p : undefined | ||
} | ||
} | ||
|
||
export function x(p: ns.undefined) { // undefined from the namespace | ||
>x : (p: ns.undefined) => symbol | ||
>p : unique symbol | ||
>ns : any | ||
|
||
return p; | ||
>p : unique symbol | ||
} | ||
|
||
export type undefined = ""; | ||
>undefined : "" | ||
|
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,28 @@ | ||
typeNamedUndefined2.ts(4,21): error TS2457: Type alias name cannot be 'undefined'. | ||
typeNamedUndefined2.ts(17,17): error TS2457: Type alias name cannot be 'undefined'. | ||
|
||
|
||
==== typeNamedUndefined2.ts (2 errors) ==== | ||
export namespace ns { | ||
export namespace undefined { | ||
export const s = Symbol(); | ||
export type undefined = typeof s; | ||
~~~~~~~~~ | ||
!!! error TS2457: Type alias name cannot be 'undefined'. | ||
}; | ||
export function x(p: undefined): undefined { | ||
return p; | ||
} | ||
} | ||
|
||
export function x(p: ns.undefined.undefined) { | ||
return p; | ||
} | ||
|
||
export namespace undefined { | ||
export const s = Symbol(); | ||
export type undefined = typeof s; | ||
~~~~~~~~~ | ||
!!! error TS2457: Type alias name cannot be 'undefined'. | ||
}; | ||
|
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,44 @@ | ||
//// [tests/cases/compiler/typeNamedUndefined2.ts] //// | ||
|
||
//// [typeNamedUndefined2.ts] | ||
export namespace ns { | ||
export namespace undefined { | ||
export const s = Symbol(); | ||
export type undefined = typeof s; | ||
}; | ||
export function x(p: undefined): undefined { | ||
return p; | ||
} | ||
} | ||
|
||
export function x(p: ns.undefined.undefined) { | ||
return p; | ||
} | ||
|
||
export namespace undefined { | ||
export const s = Symbol(); | ||
export type undefined = typeof s; | ||
}; | ||
|
||
|
||
//// [typeNamedUndefined2.js] | ||
export var ns; | ||
(function (ns) { | ||
let undefined; | ||
(function (undefined) { | ||
undefined.s = Symbol(); | ||
})(undefined = ns.undefined || (ns.undefined = {})); | ||
; | ||
function x(p) { | ||
return p; | ||
} | ||
ns.x = x; | ||
})(ns || (ns = {})); | ||
export function x(p) { | ||
return p; | ||
} | ||
export var undefined; | ||
(function (undefined) { | ||
undefined.s = Symbol(); | ||
})(undefined || (undefined = {})); | ||
; |
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,51 @@ | ||
//// [tests/cases/compiler/typeNamedUndefined2.ts] //// | ||
|
||
=== typeNamedUndefined2.ts === | ||
export namespace ns { | ||
>ns : Symbol(ns, Decl(typeNamedUndefined2.ts, 0, 0)) | ||
|
||
export namespace undefined { | ||
>undefined : Symbol(undefined, Decl(typeNamedUndefined2.ts, 0, 21)) | ||
|
||
export const s = Symbol(); | ||
>s : Symbol(s, Decl(typeNamedUndefined2.ts, 2, 20)) | ||
>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) | ||
|
||
export type undefined = typeof s; | ||
>undefined : Symbol(undefined, Decl(typeNamedUndefined2.ts, 2, 34)) | ||
>s : Symbol(s, Decl(typeNamedUndefined2.ts, 2, 20)) | ||
|
||
}; | ||
export function x(p: undefined): undefined { | ||
>x : Symbol(x, Decl(typeNamedUndefined2.ts, 4, 6)) | ||
>p : Symbol(p, Decl(typeNamedUndefined2.ts, 5, 22)) | ||
|
||
return p; | ||
>p : Symbol(p, Decl(typeNamedUndefined2.ts, 5, 22)) | ||
} | ||
} | ||
|
||
export function x(p: ns.undefined.undefined) { | ||
>x : Symbol(x, Decl(typeNamedUndefined2.ts, 8, 1)) | ||
>p : Symbol(p, Decl(typeNamedUndefined2.ts, 10, 18)) | ||
>ns : Symbol(ns, Decl(typeNamedUndefined2.ts, 0, 0)) | ||
>undefined : Symbol(ns.undefined, Decl(typeNamedUndefined2.ts, 0, 21)) | ||
>undefined : Symbol(ns.undefined.undefined, Decl(typeNamedUndefined2.ts, 2, 34)) | ||
|
||
return p; | ||
>p : Symbol(p, Decl(typeNamedUndefined2.ts, 10, 18)) | ||
} | ||
|
||
export namespace undefined { | ||
>undefined : Symbol(undefined, Decl(typeNamedUndefined2.ts, 12, 1)) | ||
|
||
export const s = Symbol(); | ||
>s : Symbol(s, Decl(typeNamedUndefined2.ts, 15, 16)) | ||
>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) | ||
|
||
export type undefined = typeof s; | ||
>undefined : Symbol(undefined, Decl(typeNamedUndefined2.ts, 15, 30)) | ||
>s : Symbol(s, Decl(typeNamedUndefined2.ts, 15, 16)) | ||
|
||
}; | ||
|
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,52 @@ | ||
//// [tests/cases/compiler/typeNamedUndefined2.ts] //// | ||
|
||
=== typeNamedUndefined2.ts === | ||
export namespace ns { | ||
>ns : typeof ns | ||
|
||
export namespace undefined { | ||
>undefined : typeof undefined | ||
|
||
export const s = Symbol(); | ||
>s : unique symbol | ||
>Symbol() : unique symbol | ||
>Symbol : SymbolConstructor | ||
|
||
export type undefined = typeof s; | ||
>undefined : unique symbol | ||
>s : unique symbol | ||
|
||
}; | ||
export function x(p: undefined): undefined { | ||
>x : (p: undefined) => undefined | ||
>p : undefined | ||
|
||
return p; | ||
>p : undefined | ||
} | ||
} | ||
|
||
export function x(p: ns.undefined.undefined) { | ||
>x : (p: ns.undefined.undefined) => symbol | ||
>p : unique symbol | ||
>ns : any | ||
>undefined : any | ||
|
||
return p; | ||
>p : unique symbol | ||
} | ||
|
||
export namespace undefined { | ||
>undefined : typeof undefined | ||
|
||
export const s = Symbol(); | ||
>s : unique symbol | ||
>Symbol() : unique symbol | ||
>Symbol : SymbolConstructor | ||
|
||
export type undefined = typeof s; | ||
>undefined : unique symbol | ||
>s : unique symbol | ||
|
||
}; | ||
|
4 changes: 2 additions & 2 deletions
4
tests/baselines/reference/undefinedTypeAssignment1.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
Oops, something went wrong.