Make sure autoArrayType is unique, even if no lib is available (#20344)
* Make sure autoArrayType is unique, even if no lib is available * fix typo
This commit is contained in:
parent
1045d95a44
commit
59e5bbc393
|
@ -25170,7 +25170,12 @@ namespace ts {
|
|||
globalBooleanType = getGlobalType("Boolean" as __String, /*arity*/ 0, /*reportErrors*/ true);
|
||||
globalRegExpType = getGlobalType("RegExp" as __String, /*arity*/ 0, /*reportErrors*/ true);
|
||||
anyArrayType = createArrayType(anyType);
|
||||
|
||||
autoArrayType = createArrayType(autoType);
|
||||
if (autoArrayType === emptyObjectType) {
|
||||
// autoArrayType is used as a marker, so even if global Array type is not defined, it needs to be a unique type
|
||||
autoArrayType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
|
||||
}
|
||||
|
||||
globalReadonlyArrayType = <GenericType>getGlobalTypeOrUndefined("ReadonlyArray" as __String, /*arity*/ 1);
|
||||
anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType;
|
||||
|
|
25
tests/baselines/reference/noCrashOnNoLib.errors.txt
Normal file
25
tests/baselines/reference/noCrashOnNoLib.errors.txt
Normal file
|
@ -0,0 +1,25 @@
|
|||
error TS2318: Cannot find global type 'Array'.
|
||||
error TS2318: Cannot find global type 'Boolean'.
|
||||
error TS2318: Cannot find global type 'Function'.
|
||||
error TS2318: Cannot find global type 'IArguments'.
|
||||
error TS2318: Cannot find global type 'Number'.
|
||||
error TS2318: Cannot find global type 'Object'.
|
||||
error TS2318: Cannot find global type 'RegExp'.
|
||||
error TS2318: Cannot find global type 'String'.
|
||||
|
||||
|
||||
!!! error TS2318: Cannot find global type 'Array'.
|
||||
!!! error TS2318: Cannot find global type 'Boolean'.
|
||||
!!! error TS2318: Cannot find global type 'Function'.
|
||||
!!! error TS2318: Cannot find global type 'IArguments'.
|
||||
!!! error TS2318: Cannot find global type 'Number'.
|
||||
!!! error TS2318: Cannot find global type 'Object'.
|
||||
!!! error TS2318: Cannot find global type 'RegExp'.
|
||||
!!! error TS2318: Cannot find global type 'String'.
|
||||
==== tests/cases/compiler/noCrashOnNoLib.ts (0 errors) ====
|
||||
export function f() {
|
||||
let e: {}[];
|
||||
while (true) {
|
||||
e = [...(e || [])];
|
||||
}
|
||||
}
|
18
tests/baselines/reference/noCrashOnNoLib.js
Normal file
18
tests/baselines/reference/noCrashOnNoLib.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
//// [noCrashOnNoLib.ts]
|
||||
export function f() {
|
||||
let e: {}[];
|
||||
while (true) {
|
||||
e = [...(e || [])];
|
||||
}
|
||||
}
|
||||
|
||||
//// [noCrashOnNoLib.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
function f() {
|
||||
var e;
|
||||
while (true) {
|
||||
e = (e || []).slice();
|
||||
}
|
||||
}
|
||||
exports.f = f;
|
13
tests/baselines/reference/noCrashOnNoLib.symbols
Normal file
13
tests/baselines/reference/noCrashOnNoLib.symbols
Normal file
|
@ -0,0 +1,13 @@
|
|||
=== tests/cases/compiler/noCrashOnNoLib.ts ===
|
||||
export function f() {
|
||||
>f : Symbol(f, Decl(noCrashOnNoLib.ts, 0, 0))
|
||||
|
||||
let e: {}[];
|
||||
>e : Symbol(e, Decl(noCrashOnNoLib.ts, 1, 7))
|
||||
|
||||
while (true) {
|
||||
e = [...(e || [])];
|
||||
>e : Symbol(e, Decl(noCrashOnNoLib.ts, 1, 7))
|
||||
>e : Symbol(e, Decl(noCrashOnNoLib.ts, 1, 7))
|
||||
}
|
||||
}
|
21
tests/baselines/reference/noCrashOnNoLib.types
Normal file
21
tests/baselines/reference/noCrashOnNoLib.types
Normal file
|
@ -0,0 +1,21 @@
|
|||
=== tests/cases/compiler/noCrashOnNoLib.ts ===
|
||||
export function f() {
|
||||
>f : () => void
|
||||
|
||||
let e: {}[];
|
||||
>e : {}
|
||||
|
||||
while (true) {
|
||||
>true : true
|
||||
|
||||
e = [...(e || [])];
|
||||
>e = [...(e || [])] : {}
|
||||
>e : {}
|
||||
>[...(e || [])] : {}
|
||||
>...(e || []) : any
|
||||
>(e || []) : {}
|
||||
>e || [] : {}
|
||||
>e : {}
|
||||
>[] : {}
|
||||
}
|
||||
}
|
8
tests/cases/compiler/noCrashOnNoLib.ts
Normal file
8
tests/cases/compiler/noCrashOnNoLib.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
// @noLib: true
|
||||
|
||||
export function f() {
|
||||
let e: {}[];
|
||||
while (true) {
|
||||
e = [...(e || [])];
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue