mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-24 11:43:18 -05:00
Accept new baselines
This commit is contained in:
85
tests/baselines/reference/controlFlowArrayErrors.errors.txt
Normal file
85
tests/baselines/reference/controlFlowArrayErrors.errors.txt
Normal file
@@ -0,0 +1,85 @@
|
||||
tests/cases/compiler/controlFlowArrayErrors.ts(6,9): error TS7005: Variable 'y' implicitly has an 'any[]' type.
|
||||
tests/cases/compiler/controlFlowArrayErrors.ts(14,9): error TS7005: Variable 'y' implicitly has an 'any[]' type.
|
||||
tests/cases/compiler/controlFlowArrayErrors.ts(20,9): error TS7034: Variable 'x' implicitly has type 'any[]' in some locations where its type cannot be determined.
|
||||
tests/cases/compiler/controlFlowArrayErrors.ts(23,9): error TS7005: Variable 'x' implicitly has an 'any[]' type.
|
||||
tests/cases/compiler/controlFlowArrayErrors.ts(30,12): error TS2345: Argument of type 'true' is not assignable to parameter of type 'string | number'.
|
||||
tests/cases/compiler/controlFlowArrayErrors.ts(35,12): error TS2345: Argument of type 'true' is not assignable to parameter of type 'string | number'.
|
||||
tests/cases/compiler/controlFlowArrayErrors.ts(49,5): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((...items: (string | number)[]) => number) | ((...items: boolean[]) => number)' has no compatible call signatures.
|
||||
tests/cases/compiler/controlFlowArrayErrors.ts(57,12): error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/controlFlowArrayErrors.ts (8 errors) ====
|
||||
|
||||
declare function cond(): boolean;
|
||||
|
||||
function f1() {
|
||||
let x = [];
|
||||
let y = x; // Implicit any[] error
|
||||
~
|
||||
!!! error TS7005: Variable 'y' implicitly has an 'any[]' type.
|
||||
x.push(5);
|
||||
let z = x;
|
||||
}
|
||||
|
||||
function f2() {
|
||||
let x;
|
||||
x = [];
|
||||
let y = x; // Implicit any[] error
|
||||
~
|
||||
!!! error TS7005: Variable 'y' implicitly has an 'any[]' type.
|
||||
x.push(5);
|
||||
let z = x;
|
||||
}
|
||||
|
||||
function f3() {
|
||||
let x = []; // Implicit any[] error in some locations
|
||||
~
|
||||
!!! error TS7034: Variable 'x' implicitly has type 'any[]' in some locations where its type cannot be determined.
|
||||
x.push(5);
|
||||
function g() {
|
||||
x; // Implicit any[] error
|
||||
~
|
||||
!!! error TS7005: Variable 'x' implicitly has an 'any[]' type.
|
||||
}
|
||||
}
|
||||
|
||||
function f4() {
|
||||
let x;
|
||||
x = [5, "hello"]; // Non-evolving array
|
||||
x.push(true); // Error
|
||||
~~~~
|
||||
!!! error TS2345: Argument of type 'true' is not assignable to parameter of type 'string | number'.
|
||||
}
|
||||
|
||||
function f5() {
|
||||
let x = [5, "hello"]; // Non-evolving array
|
||||
x.push(true); // Error
|
||||
~~~~
|
||||
!!! error TS2345: Argument of type 'true' is not assignable to parameter of type 'string | number'.
|
||||
}
|
||||
|
||||
function f6() {
|
||||
let x;
|
||||
if (cond()) {
|
||||
x = [];
|
||||
x.push(5);
|
||||
x.push("hello");
|
||||
}
|
||||
else {
|
||||
x = [true]; // Non-evolving array
|
||||
}
|
||||
x; // boolean[] | (string | number)[]
|
||||
x.push(99); // Error
|
||||
~~~~~~~~~~
|
||||
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((...items: (string | number)[]) => number) | ((...items: boolean[]) => number)' has no compatible call signatures.
|
||||
}
|
||||
|
||||
function f7() {
|
||||
let x = []; // x has evolving array value
|
||||
x.push(5);
|
||||
let y = x; // y has non-evolving array value
|
||||
x.push("hello"); // Ok
|
||||
y.push("hello"); // Error
|
||||
~~~~~~~
|
||||
!!! error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'.
|
||||
}
|
||||
110
tests/baselines/reference/controlFlowArrayErrors.js
Normal file
110
tests/baselines/reference/controlFlowArrayErrors.js
Normal file
@@ -0,0 +1,110 @@
|
||||
//// [controlFlowArrayErrors.ts]
|
||||
|
||||
declare function cond(): boolean;
|
||||
|
||||
function f1() {
|
||||
let x = [];
|
||||
let y = x; // Implicit any[] error
|
||||
x.push(5);
|
||||
let z = x;
|
||||
}
|
||||
|
||||
function f2() {
|
||||
let x;
|
||||
x = [];
|
||||
let y = x; // Implicit any[] error
|
||||
x.push(5);
|
||||
let z = x;
|
||||
}
|
||||
|
||||
function f3() {
|
||||
let x = []; // Implicit any[] error in some locations
|
||||
x.push(5);
|
||||
function g() {
|
||||
x; // Implicit any[] error
|
||||
}
|
||||
}
|
||||
|
||||
function f4() {
|
||||
let x;
|
||||
x = [5, "hello"]; // Non-evolving array
|
||||
x.push(true); // Error
|
||||
}
|
||||
|
||||
function f5() {
|
||||
let x = [5, "hello"]; // Non-evolving array
|
||||
x.push(true); // Error
|
||||
}
|
||||
|
||||
function f6() {
|
||||
let x;
|
||||
if (cond()) {
|
||||
x = [];
|
||||
x.push(5);
|
||||
x.push("hello");
|
||||
}
|
||||
else {
|
||||
x = [true]; // Non-evolving array
|
||||
}
|
||||
x; // boolean[] | (string | number)[]
|
||||
x.push(99); // Error
|
||||
}
|
||||
|
||||
function f7() {
|
||||
let x = []; // x has evolving array value
|
||||
x.push(5);
|
||||
let y = x; // y has non-evolving array value
|
||||
x.push("hello"); // Ok
|
||||
y.push("hello"); // Error
|
||||
}
|
||||
|
||||
//// [controlFlowArrayErrors.js]
|
||||
function f1() {
|
||||
var x = [];
|
||||
var y = x; // Implicit any[] error
|
||||
x.push(5);
|
||||
var z = x;
|
||||
}
|
||||
function f2() {
|
||||
var x;
|
||||
x = [];
|
||||
var y = x; // Implicit any[] error
|
||||
x.push(5);
|
||||
var z = x;
|
||||
}
|
||||
function f3() {
|
||||
var x = []; // Implicit any[] error in some locations
|
||||
x.push(5);
|
||||
function g() {
|
||||
x; // Implicit any[] error
|
||||
}
|
||||
}
|
||||
function f4() {
|
||||
var x;
|
||||
x = [5, "hello"]; // Non-evolving array
|
||||
x.push(true); // Error
|
||||
}
|
||||
function f5() {
|
||||
var x = [5, "hello"]; // Non-evolving array
|
||||
x.push(true); // Error
|
||||
}
|
||||
function f6() {
|
||||
var x;
|
||||
if (cond()) {
|
||||
x = [];
|
||||
x.push(5);
|
||||
x.push("hello");
|
||||
}
|
||||
else {
|
||||
x = [true]; // Non-evolving array
|
||||
}
|
||||
x; // boolean[] | (string | number)[]
|
||||
x.push(99); // Error
|
||||
}
|
||||
function f7() {
|
||||
var x = []; // x has evolving array value
|
||||
x.push(5);
|
||||
var y = x; // y has non-evolving array value
|
||||
x.push("hello"); // Ok
|
||||
y.push("hello"); // Error
|
||||
}
|
||||
267
tests/baselines/reference/controlFlowArrays.js
Normal file
267
tests/baselines/reference/controlFlowArrays.js
Normal file
@@ -0,0 +1,267 @@
|
||||
//// [controlFlowArrays.ts]
|
||||
|
||||
declare function cond(): boolean;
|
||||
|
||||
function f1() {
|
||||
let x = [];
|
||||
x[0] = 5;
|
||||
x[1] = "hello";
|
||||
x[2] = true;
|
||||
return x; // (string | number | boolean)[]
|
||||
}
|
||||
|
||||
function f2() {
|
||||
let x = [];
|
||||
x.push(5);
|
||||
x.push("hello");
|
||||
x.push(true);
|
||||
return x; // (string | number | boolean)[]
|
||||
}
|
||||
|
||||
function f3() {
|
||||
let x;
|
||||
x = [];
|
||||
x.push(5, "hello");
|
||||
return x; // (string | number)[]
|
||||
}
|
||||
|
||||
function f4() {
|
||||
let x = [];
|
||||
if (cond()) {
|
||||
x.push(5);
|
||||
}
|
||||
else {
|
||||
x.push("hello");
|
||||
}
|
||||
return x; // (string | number)[]
|
||||
}
|
||||
|
||||
function f5() {
|
||||
let x;
|
||||
if (cond()) {
|
||||
x = [];
|
||||
x.push(5);
|
||||
}
|
||||
else {
|
||||
x = [];
|
||||
x.push("hello");
|
||||
}
|
||||
return x; // (string | number)[]
|
||||
}
|
||||
|
||||
function f6() {
|
||||
let x;
|
||||
if (cond()) {
|
||||
x = 5;
|
||||
}
|
||||
else {
|
||||
x = [];
|
||||
x.push("hello");
|
||||
}
|
||||
return x; // number | string[]
|
||||
}
|
||||
|
||||
function f7() {
|
||||
let x = null;
|
||||
if (cond()) {
|
||||
x = [];
|
||||
while (cond()) {
|
||||
x.push("hello");
|
||||
}
|
||||
}
|
||||
return x; // string[] | null
|
||||
}
|
||||
|
||||
function f8() {
|
||||
let x = [];
|
||||
x.push(5);
|
||||
if (cond()) return x; // number[]
|
||||
x.push("hello");
|
||||
if (cond()) return x; // (string | number)[]
|
||||
x.push(true);
|
||||
return x; // (string | number | boolean)[]
|
||||
}
|
||||
|
||||
function f9() {
|
||||
let x = [];
|
||||
if (cond()) {
|
||||
x.push(5);
|
||||
return x; // number[]
|
||||
}
|
||||
else {
|
||||
x.push("hello");
|
||||
return x; // string[]
|
||||
}
|
||||
}
|
||||
|
||||
function f10() {
|
||||
let x = [];
|
||||
if (cond()) {
|
||||
x.push(true);
|
||||
x; // boolean[]
|
||||
}
|
||||
else {
|
||||
x.push(5);
|
||||
x; // number[]
|
||||
while (cond()) {
|
||||
x.push("hello");
|
||||
}
|
||||
x; // (string | number)[]
|
||||
}
|
||||
x.push(99);
|
||||
return x; // (string | number | boolean)[]
|
||||
}
|
||||
|
||||
function f11() {
|
||||
let x = [];
|
||||
return x; // never[]
|
||||
}
|
||||
|
||||
function f12() {
|
||||
let x;
|
||||
x = [];
|
||||
return x; // never[]
|
||||
}
|
||||
|
||||
function f13() {
|
||||
var x = [];
|
||||
x.push(5);
|
||||
x.push("hello");
|
||||
x.push(true);
|
||||
return x; // (string | number | boolean)[]
|
||||
}
|
||||
|
||||
function f14() {
|
||||
const x = [];
|
||||
x.push(5);
|
||||
x.push("hello");
|
||||
x.push(true);
|
||||
return x; // (string | number | boolean)[]
|
||||
}
|
||||
|
||||
//// [controlFlowArrays.js]
|
||||
function f1() {
|
||||
var x = [];
|
||||
x[0] = 5;
|
||||
x[1] = "hello";
|
||||
x[2] = true;
|
||||
return x; // (string | number | boolean)[]
|
||||
}
|
||||
function f2() {
|
||||
var x = [];
|
||||
x.push(5);
|
||||
x.push("hello");
|
||||
x.push(true);
|
||||
return x; // (string | number | boolean)[]
|
||||
}
|
||||
function f3() {
|
||||
var x;
|
||||
x = [];
|
||||
x.push(5, "hello");
|
||||
return x; // (string | number)[]
|
||||
}
|
||||
function f4() {
|
||||
var x = [];
|
||||
if (cond()) {
|
||||
x.push(5);
|
||||
}
|
||||
else {
|
||||
x.push("hello");
|
||||
}
|
||||
return x; // (string | number)[]
|
||||
}
|
||||
function f5() {
|
||||
var x;
|
||||
if (cond()) {
|
||||
x = [];
|
||||
x.push(5);
|
||||
}
|
||||
else {
|
||||
x = [];
|
||||
x.push("hello");
|
||||
}
|
||||
return x; // (string | number)[]
|
||||
}
|
||||
function f6() {
|
||||
var x;
|
||||
if (cond()) {
|
||||
x = 5;
|
||||
}
|
||||
else {
|
||||
x = [];
|
||||
x.push("hello");
|
||||
}
|
||||
return x; // number | string[]
|
||||
}
|
||||
function f7() {
|
||||
var x = null;
|
||||
if (cond()) {
|
||||
x = [];
|
||||
while (cond()) {
|
||||
x.push("hello");
|
||||
}
|
||||
}
|
||||
return x; // string[] | null
|
||||
}
|
||||
function f8() {
|
||||
var x = [];
|
||||
x.push(5);
|
||||
if (cond())
|
||||
return x; // number[]
|
||||
x.push("hello");
|
||||
if (cond())
|
||||
return x; // (string | number)[]
|
||||
x.push(true);
|
||||
return x; // (string | number | boolean)[]
|
||||
}
|
||||
function f9() {
|
||||
var x = [];
|
||||
if (cond()) {
|
||||
x.push(5);
|
||||
return x; // number[]
|
||||
}
|
||||
else {
|
||||
x.push("hello");
|
||||
return x; // string[]
|
||||
}
|
||||
}
|
||||
function f10() {
|
||||
var x = [];
|
||||
if (cond()) {
|
||||
x.push(true);
|
||||
x; // boolean[]
|
||||
}
|
||||
else {
|
||||
x.push(5);
|
||||
x; // number[]
|
||||
while (cond()) {
|
||||
x.push("hello");
|
||||
}
|
||||
x; // (string | number)[]
|
||||
}
|
||||
x.push(99);
|
||||
return x; // (string | number | boolean)[]
|
||||
}
|
||||
function f11() {
|
||||
var x = [];
|
||||
return x; // never[]
|
||||
}
|
||||
function f12() {
|
||||
var x;
|
||||
x = [];
|
||||
return x; // never[]
|
||||
}
|
||||
function f13() {
|
||||
var x = [];
|
||||
x.push(5);
|
||||
x.push("hello");
|
||||
x.push(true);
|
||||
return x; // (string | number | boolean)[]
|
||||
}
|
||||
function f14() {
|
||||
var x = [];
|
||||
x.push(5);
|
||||
x.push("hello");
|
||||
x.push(true);
|
||||
return x; // (string | number | boolean)[]
|
||||
}
|
||||
350
tests/baselines/reference/controlFlowArrays.symbols
Normal file
350
tests/baselines/reference/controlFlowArrays.symbols
Normal file
@@ -0,0 +1,350 @@
|
||||
=== tests/cases/compiler/controlFlowArrays.ts ===
|
||||
|
||||
declare function cond(): boolean;
|
||||
>cond : Symbol(cond, Decl(controlFlowArrays.ts, 0, 0))
|
||||
|
||||
function f1() {
|
||||
>f1 : Symbol(f1, Decl(controlFlowArrays.ts, 1, 33))
|
||||
|
||||
let x = [];
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 4, 7))
|
||||
|
||||
x[0] = 5;
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 4, 7))
|
||||
|
||||
x[1] = "hello";
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 4, 7))
|
||||
|
||||
x[2] = true;
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 4, 7))
|
||||
|
||||
return x; // (string | number | boolean)[]
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 4, 7))
|
||||
}
|
||||
|
||||
function f2() {
|
||||
>f2 : Symbol(f2, Decl(controlFlowArrays.ts, 9, 1))
|
||||
|
||||
let x = [];
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 12, 7))
|
||||
|
||||
x.push(5);
|
||||
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 12, 7))
|
||||
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
|
||||
x.push("hello");
|
||||
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 12, 7))
|
||||
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
|
||||
x.push(true);
|
||||
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 12, 7))
|
||||
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
|
||||
return x; // (string | number | boolean)[]
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 12, 7))
|
||||
}
|
||||
|
||||
function f3() {
|
||||
>f3 : Symbol(f3, Decl(controlFlowArrays.ts, 17, 1))
|
||||
|
||||
let x;
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 20, 7))
|
||||
|
||||
x = [];
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 20, 7))
|
||||
|
||||
x.push(5, "hello");
|
||||
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 20, 7))
|
||||
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
|
||||
return x; // (string | number)[]
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 20, 7))
|
||||
}
|
||||
|
||||
function f4() {
|
||||
>f4 : Symbol(f4, Decl(controlFlowArrays.ts, 24, 1))
|
||||
|
||||
let x = [];
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 27, 7))
|
||||
|
||||
if (cond()) {
|
||||
>cond : Symbol(cond, Decl(controlFlowArrays.ts, 0, 0))
|
||||
|
||||
x.push(5);
|
||||
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 27, 7))
|
||||
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
}
|
||||
else {
|
||||
x.push("hello");
|
||||
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 27, 7))
|
||||
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
}
|
||||
return x; // (string | number)[]
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 27, 7))
|
||||
}
|
||||
|
||||
function f5() {
|
||||
>f5 : Symbol(f5, Decl(controlFlowArrays.ts, 35, 1))
|
||||
|
||||
let x;
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 38, 7))
|
||||
|
||||
if (cond()) {
|
||||
>cond : Symbol(cond, Decl(controlFlowArrays.ts, 0, 0))
|
||||
|
||||
x = [];
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 38, 7))
|
||||
|
||||
x.push(5);
|
||||
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 38, 7))
|
||||
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
}
|
||||
else {
|
||||
x = [];
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 38, 7))
|
||||
|
||||
x.push("hello");
|
||||
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 38, 7))
|
||||
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
}
|
||||
return x; // (string | number)[]
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 38, 7))
|
||||
}
|
||||
|
||||
function f6() {
|
||||
>f6 : Symbol(f6, Decl(controlFlowArrays.ts, 48, 1))
|
||||
|
||||
let x;
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 51, 7))
|
||||
|
||||
if (cond()) {
|
||||
>cond : Symbol(cond, Decl(controlFlowArrays.ts, 0, 0))
|
||||
|
||||
x = 5;
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 51, 7))
|
||||
}
|
||||
else {
|
||||
x = [];
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 51, 7))
|
||||
|
||||
x.push("hello");
|
||||
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 51, 7))
|
||||
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
}
|
||||
return x; // number | string[]
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 51, 7))
|
||||
}
|
||||
|
||||
function f7() {
|
||||
>f7 : Symbol(f7, Decl(controlFlowArrays.ts, 60, 1))
|
||||
|
||||
let x = null;
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 63, 7))
|
||||
|
||||
if (cond()) {
|
||||
>cond : Symbol(cond, Decl(controlFlowArrays.ts, 0, 0))
|
||||
|
||||
x = [];
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 63, 7))
|
||||
|
||||
while (cond()) {
|
||||
>cond : Symbol(cond, Decl(controlFlowArrays.ts, 0, 0))
|
||||
|
||||
x.push("hello");
|
||||
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 63, 7))
|
||||
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
}
|
||||
}
|
||||
return x; // string[] | null
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 63, 7))
|
||||
}
|
||||
|
||||
function f8() {
|
||||
>f8 : Symbol(f8, Decl(controlFlowArrays.ts, 71, 1))
|
||||
|
||||
let x = [];
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 74, 7))
|
||||
|
||||
x.push(5);
|
||||
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 74, 7))
|
||||
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
|
||||
if (cond()) return x; // number[]
|
||||
>cond : Symbol(cond, Decl(controlFlowArrays.ts, 0, 0))
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 74, 7))
|
||||
|
||||
x.push("hello");
|
||||
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 74, 7))
|
||||
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
|
||||
if (cond()) return x; // (string | number)[]
|
||||
>cond : Symbol(cond, Decl(controlFlowArrays.ts, 0, 0))
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 74, 7))
|
||||
|
||||
x.push(true);
|
||||
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 74, 7))
|
||||
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
|
||||
return x; // (string | number | boolean)[]
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 74, 7))
|
||||
}
|
||||
|
||||
function f9() {
|
||||
>f9 : Symbol(f9, Decl(controlFlowArrays.ts, 81, 1))
|
||||
|
||||
let x = [];
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 84, 7))
|
||||
|
||||
if (cond()) {
|
||||
>cond : Symbol(cond, Decl(controlFlowArrays.ts, 0, 0))
|
||||
|
||||
x.push(5);
|
||||
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 84, 7))
|
||||
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
|
||||
return x; // number[]
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 84, 7))
|
||||
}
|
||||
else {
|
||||
x.push("hello");
|
||||
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 84, 7))
|
||||
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
|
||||
return x; // string[]
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 84, 7))
|
||||
}
|
||||
}
|
||||
|
||||
function f10() {
|
||||
>f10 : Symbol(f10, Decl(controlFlowArrays.ts, 93, 1))
|
||||
|
||||
let x = [];
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 96, 7))
|
||||
|
||||
if (cond()) {
|
||||
>cond : Symbol(cond, Decl(controlFlowArrays.ts, 0, 0))
|
||||
|
||||
x.push(true);
|
||||
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 96, 7))
|
||||
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
|
||||
x; // boolean[]
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 96, 7))
|
||||
}
|
||||
else {
|
||||
x.push(5);
|
||||
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 96, 7))
|
||||
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
|
||||
x; // number[]
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 96, 7))
|
||||
|
||||
while (cond()) {
|
||||
>cond : Symbol(cond, Decl(controlFlowArrays.ts, 0, 0))
|
||||
|
||||
x.push("hello");
|
||||
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 96, 7))
|
||||
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
}
|
||||
x; // (string | number)[]
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 96, 7))
|
||||
}
|
||||
x.push(99);
|
||||
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 96, 7))
|
||||
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
|
||||
return x; // (string | number | boolean)[]
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 96, 7))
|
||||
}
|
||||
|
||||
function f11() {
|
||||
>f11 : Symbol(f11, Decl(controlFlowArrays.ts, 111, 1))
|
||||
|
||||
let x = [];
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 114, 7))
|
||||
|
||||
return x; // never[]
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 114, 7))
|
||||
}
|
||||
|
||||
function f12() {
|
||||
>f12 : Symbol(f12, Decl(controlFlowArrays.ts, 116, 1))
|
||||
|
||||
let x;
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 119, 7))
|
||||
|
||||
x = [];
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 119, 7))
|
||||
|
||||
return x; // never[]
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 119, 7))
|
||||
}
|
||||
|
||||
function f13() {
|
||||
>f13 : Symbol(f13, Decl(controlFlowArrays.ts, 122, 1))
|
||||
|
||||
var x = [];
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 125, 7))
|
||||
|
||||
x.push(5);
|
||||
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 125, 7))
|
||||
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
|
||||
x.push("hello");
|
||||
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 125, 7))
|
||||
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
|
||||
x.push(true);
|
||||
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 125, 7))
|
||||
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
|
||||
return x; // (string | number | boolean)[]
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 125, 7))
|
||||
}
|
||||
|
||||
function f14() {
|
||||
>f14 : Symbol(f14, Decl(controlFlowArrays.ts, 130, 1))
|
||||
|
||||
const x = [];
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 133, 9))
|
||||
|
||||
x.push(5);
|
||||
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 133, 9))
|
||||
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
|
||||
x.push("hello");
|
||||
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 133, 9))
|
||||
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
|
||||
x.push(true);
|
||||
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 133, 9))
|
||||
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
|
||||
return x; // (string | number | boolean)[]
|
||||
>x : Symbol(x, Decl(controlFlowArrays.ts, 133, 9))
|
||||
}
|
||||
447
tests/baselines/reference/controlFlowArrays.types
Normal file
447
tests/baselines/reference/controlFlowArrays.types
Normal file
@@ -0,0 +1,447 @@
|
||||
=== tests/cases/compiler/controlFlowArrays.ts ===
|
||||
|
||||
declare function cond(): boolean;
|
||||
>cond : () => boolean
|
||||
|
||||
function f1() {
|
||||
>f1 : () => (string | number | boolean)[]
|
||||
|
||||
let x = [];
|
||||
>x : any[]
|
||||
>[] : never[]
|
||||
|
||||
x[0] = 5;
|
||||
>x[0] = 5 : 5
|
||||
>x[0] : any
|
||||
>x : any[]
|
||||
>0 : 0
|
||||
>5 : 5
|
||||
|
||||
x[1] = "hello";
|
||||
>x[1] = "hello" : "hello"
|
||||
>x[1] : any
|
||||
>x : any[]
|
||||
>1 : 1
|
||||
>"hello" : "hello"
|
||||
|
||||
x[2] = true;
|
||||
>x[2] = true : true
|
||||
>x[2] : any
|
||||
>x : any[]
|
||||
>2 : 2
|
||||
>true : true
|
||||
|
||||
return x; // (string | number | boolean)[]
|
||||
>x : (string | number | boolean)[]
|
||||
}
|
||||
|
||||
function f2() {
|
||||
>f2 : () => (string | number | boolean)[]
|
||||
|
||||
let x = [];
|
||||
>x : any[]
|
||||
>[] : never[]
|
||||
|
||||
x.push(5);
|
||||
>x.push(5) : number
|
||||
>x.push : (...items: any[]) => number
|
||||
>x : any[]
|
||||
>push : (...items: any[]) => number
|
||||
>5 : 5
|
||||
|
||||
x.push("hello");
|
||||
>x.push("hello") : number
|
||||
>x.push : (...items: any[]) => number
|
||||
>x : any[]
|
||||
>push : (...items: any[]) => number
|
||||
>"hello" : "hello"
|
||||
|
||||
x.push(true);
|
||||
>x.push(true) : number
|
||||
>x.push : (...items: any[]) => number
|
||||
>x : any[]
|
||||
>push : (...items: any[]) => number
|
||||
>true : true
|
||||
|
||||
return x; // (string | number | boolean)[]
|
||||
>x : (string | number | boolean)[]
|
||||
}
|
||||
|
||||
function f3() {
|
||||
>f3 : () => (string | number)[]
|
||||
|
||||
let x;
|
||||
>x : any
|
||||
|
||||
x = [];
|
||||
>x = [] : never[]
|
||||
>x : any
|
||||
>[] : never[]
|
||||
|
||||
x.push(5, "hello");
|
||||
>x.push(5, "hello") : number
|
||||
>x.push : (...items: any[]) => number
|
||||
>x : any[]
|
||||
>push : (...items: any[]) => number
|
||||
>5 : 5
|
||||
>"hello" : "hello"
|
||||
|
||||
return x; // (string | number)[]
|
||||
>x : (string | number)[]
|
||||
}
|
||||
|
||||
function f4() {
|
||||
>f4 : () => (string | number)[]
|
||||
|
||||
let x = [];
|
||||
>x : any[]
|
||||
>[] : never[]
|
||||
|
||||
if (cond()) {
|
||||
>cond() : boolean
|
||||
>cond : () => boolean
|
||||
|
||||
x.push(5);
|
||||
>x.push(5) : number
|
||||
>x.push : (...items: any[]) => number
|
||||
>x : any[]
|
||||
>push : (...items: any[]) => number
|
||||
>5 : 5
|
||||
}
|
||||
else {
|
||||
x.push("hello");
|
||||
>x.push("hello") : number
|
||||
>x.push : (...items: any[]) => number
|
||||
>x : any[]
|
||||
>push : (...items: any[]) => number
|
||||
>"hello" : "hello"
|
||||
}
|
||||
return x; // (string | number)[]
|
||||
>x : (string | number)[]
|
||||
}
|
||||
|
||||
function f5() {
|
||||
>f5 : () => (string | number)[]
|
||||
|
||||
let x;
|
||||
>x : any
|
||||
|
||||
if (cond()) {
|
||||
>cond() : boolean
|
||||
>cond : () => boolean
|
||||
|
||||
x = [];
|
||||
>x = [] : never[]
|
||||
>x : any
|
||||
>[] : never[]
|
||||
|
||||
x.push(5);
|
||||
>x.push(5) : number
|
||||
>x.push : (...items: any[]) => number
|
||||
>x : any[]
|
||||
>push : (...items: any[]) => number
|
||||
>5 : 5
|
||||
}
|
||||
else {
|
||||
x = [];
|
||||
>x = [] : never[]
|
||||
>x : any
|
||||
>[] : never[]
|
||||
|
||||
x.push("hello");
|
||||
>x.push("hello") : number
|
||||
>x.push : (...items: any[]) => number
|
||||
>x : any[]
|
||||
>push : (...items: any[]) => number
|
||||
>"hello" : "hello"
|
||||
}
|
||||
return x; // (string | number)[]
|
||||
>x : (string | number)[]
|
||||
}
|
||||
|
||||
function f6() {
|
||||
>f6 : () => number | string[]
|
||||
|
||||
let x;
|
||||
>x : any
|
||||
|
||||
if (cond()) {
|
||||
>cond() : boolean
|
||||
>cond : () => boolean
|
||||
|
||||
x = 5;
|
||||
>x = 5 : 5
|
||||
>x : any
|
||||
>5 : 5
|
||||
}
|
||||
else {
|
||||
x = [];
|
||||
>x = [] : never[]
|
||||
>x : any
|
||||
>[] : never[]
|
||||
|
||||
x.push("hello");
|
||||
>x.push("hello") : number
|
||||
>x.push : (...items: any[]) => number
|
||||
>x : any[]
|
||||
>push : (...items: any[]) => number
|
||||
>"hello" : "hello"
|
||||
}
|
||||
return x; // number | string[]
|
||||
>x : number | string[]
|
||||
}
|
||||
|
||||
function f7() {
|
||||
>f7 : () => string[] | null
|
||||
|
||||
let x = null;
|
||||
>x : any
|
||||
>null : null
|
||||
|
||||
if (cond()) {
|
||||
>cond() : boolean
|
||||
>cond : () => boolean
|
||||
|
||||
x = [];
|
||||
>x = [] : never[]
|
||||
>x : any
|
||||
>[] : never[]
|
||||
|
||||
while (cond()) {
|
||||
>cond() : boolean
|
||||
>cond : () => boolean
|
||||
|
||||
x.push("hello");
|
||||
>x.push("hello") : number
|
||||
>x.push : (...items: any[]) => number
|
||||
>x : any[]
|
||||
>push : (...items: any[]) => number
|
||||
>"hello" : "hello"
|
||||
}
|
||||
}
|
||||
return x; // string[] | null
|
||||
>x : string[] | null
|
||||
}
|
||||
|
||||
function f8() {
|
||||
>f8 : () => (string | number | boolean)[]
|
||||
|
||||
let x = [];
|
||||
>x : any[]
|
||||
>[] : never[]
|
||||
|
||||
x.push(5);
|
||||
>x.push(5) : number
|
||||
>x.push : (...items: any[]) => number
|
||||
>x : any[]
|
||||
>push : (...items: any[]) => number
|
||||
>5 : 5
|
||||
|
||||
if (cond()) return x; // number[]
|
||||
>cond() : boolean
|
||||
>cond : () => boolean
|
||||
>x : number[]
|
||||
|
||||
x.push("hello");
|
||||
>x.push("hello") : number
|
||||
>x.push : (...items: any[]) => number
|
||||
>x : any[]
|
||||
>push : (...items: any[]) => number
|
||||
>"hello" : "hello"
|
||||
|
||||
if (cond()) return x; // (string | number)[]
|
||||
>cond() : boolean
|
||||
>cond : () => boolean
|
||||
>x : (string | number)[]
|
||||
|
||||
x.push(true);
|
||||
>x.push(true) : number
|
||||
>x.push : (...items: any[]) => number
|
||||
>x : any[]
|
||||
>push : (...items: any[]) => number
|
||||
>true : true
|
||||
|
||||
return x; // (string | number | boolean)[]
|
||||
>x : (string | number | boolean)[]
|
||||
}
|
||||
|
||||
function f9() {
|
||||
>f9 : () => string[] | number[]
|
||||
|
||||
let x = [];
|
||||
>x : any[]
|
||||
>[] : never[]
|
||||
|
||||
if (cond()) {
|
||||
>cond() : boolean
|
||||
>cond : () => boolean
|
||||
|
||||
x.push(5);
|
||||
>x.push(5) : number
|
||||
>x.push : (...items: any[]) => number
|
||||
>x : any[]
|
||||
>push : (...items: any[]) => number
|
||||
>5 : 5
|
||||
|
||||
return x; // number[]
|
||||
>x : number[]
|
||||
}
|
||||
else {
|
||||
x.push("hello");
|
||||
>x.push("hello") : number
|
||||
>x.push : (...items: any[]) => number
|
||||
>x : any[]
|
||||
>push : (...items: any[]) => number
|
||||
>"hello" : "hello"
|
||||
|
||||
return x; // string[]
|
||||
>x : string[]
|
||||
}
|
||||
}
|
||||
|
||||
function f10() {
|
||||
>f10 : () => (string | number | boolean)[]
|
||||
|
||||
let x = [];
|
||||
>x : any[]
|
||||
>[] : never[]
|
||||
|
||||
if (cond()) {
|
||||
>cond() : boolean
|
||||
>cond : () => boolean
|
||||
|
||||
x.push(true);
|
||||
>x.push(true) : number
|
||||
>x.push : (...items: any[]) => number
|
||||
>x : any[]
|
||||
>push : (...items: any[]) => number
|
||||
>true : true
|
||||
|
||||
x; // boolean[]
|
||||
>x : boolean[]
|
||||
}
|
||||
else {
|
||||
x.push(5);
|
||||
>x.push(5) : number
|
||||
>x.push : (...items: any[]) => number
|
||||
>x : any[]
|
||||
>push : (...items: any[]) => number
|
||||
>5 : 5
|
||||
|
||||
x; // number[]
|
||||
>x : number[]
|
||||
|
||||
while (cond()) {
|
||||
>cond() : boolean
|
||||
>cond : () => boolean
|
||||
|
||||
x.push("hello");
|
||||
>x.push("hello") : number
|
||||
>x.push : (...items: any[]) => number
|
||||
>x : any[]
|
||||
>push : (...items: any[]) => number
|
||||
>"hello" : "hello"
|
||||
}
|
||||
x; // (string | number)[]
|
||||
>x : (string | number)[]
|
||||
}
|
||||
x.push(99);
|
||||
>x.push(99) : number
|
||||
>x.push : (...items: any[]) => number
|
||||
>x : any[]
|
||||
>push : (...items: any[]) => number
|
||||
>99 : 99
|
||||
|
||||
return x; // (string | number | boolean)[]
|
||||
>x : (string | number | boolean)[]
|
||||
}
|
||||
|
||||
function f11() {
|
||||
>f11 : () => never[]
|
||||
|
||||
let x = [];
|
||||
>x : any[]
|
||||
>[] : never[]
|
||||
|
||||
return x; // never[]
|
||||
>x : never[]
|
||||
}
|
||||
|
||||
function f12() {
|
||||
>f12 : () => never[]
|
||||
|
||||
let x;
|
||||
>x : any
|
||||
|
||||
x = [];
|
||||
>x = [] : never[]
|
||||
>x : any
|
||||
>[] : never[]
|
||||
|
||||
return x; // never[]
|
||||
>x : never[]
|
||||
}
|
||||
|
||||
function f13() {
|
||||
>f13 : () => (string | number | boolean)[]
|
||||
|
||||
var x = [];
|
||||
>x : any[]
|
||||
>[] : never[]
|
||||
|
||||
x.push(5);
|
||||
>x.push(5) : number
|
||||
>x.push : (...items: any[]) => number
|
||||
>x : any[]
|
||||
>push : (...items: any[]) => number
|
||||
>5 : 5
|
||||
|
||||
x.push("hello");
|
||||
>x.push("hello") : number
|
||||
>x.push : (...items: any[]) => number
|
||||
>x : any[]
|
||||
>push : (...items: any[]) => number
|
||||
>"hello" : "hello"
|
||||
|
||||
x.push(true);
|
||||
>x.push(true) : number
|
||||
>x.push : (...items: any[]) => number
|
||||
>x : any[]
|
||||
>push : (...items: any[]) => number
|
||||
>true : true
|
||||
|
||||
return x; // (string | number | boolean)[]
|
||||
>x : (string | number | boolean)[]
|
||||
}
|
||||
|
||||
function f14() {
|
||||
>f14 : () => (string | number | boolean)[]
|
||||
|
||||
const x = [];
|
||||
>x : any[]
|
||||
>[] : never[]
|
||||
|
||||
x.push(5);
|
||||
>x.push(5) : number
|
||||
>x.push : (...items: any[]) => number
|
||||
>x : any[]
|
||||
>push : (...items: any[]) => number
|
||||
>5 : 5
|
||||
|
||||
x.push("hello");
|
||||
>x.push("hello") : number
|
||||
>x.push : (...items: any[]) => number
|
||||
>x : any[]
|
||||
>push : (...items: any[]) => number
|
||||
>"hello" : "hello"
|
||||
|
||||
x.push(true);
|
||||
>x.push(true) : number
|
||||
>x.push : (...items: any[]) => number
|
||||
>x : any[]
|
||||
>push : (...items: any[]) => number
|
||||
>true : true
|
||||
|
||||
return x; // (string | number | boolean)[]
|
||||
>x : (string | number | boolean)[]
|
||||
}
|
||||
Reference in New Issue
Block a user