mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
265 lines
7.7 KiB
Plaintext
265 lines
7.7 KiB
Plaintext
//// [tests/cases/compiler/controlFlowNoImplicitAny.ts] ////
|
|
|
|
=== controlFlowNoImplicitAny.ts ===
|
|
declare let cond: boolean;
|
|
>cond : Symbol(cond, Decl(controlFlowNoImplicitAny.ts, 0, 11))
|
|
|
|
// CFA for 'let' with no type annotation and initializer
|
|
function f1() {
|
|
>f1 : Symbol(f1, Decl(controlFlowNoImplicitAny.ts, 0, 26))
|
|
|
|
let x;
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 4, 7))
|
|
|
|
if (cond) {
|
|
>cond : Symbol(cond, Decl(controlFlowNoImplicitAny.ts, 0, 11))
|
|
|
|
x = 1;
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 4, 7))
|
|
}
|
|
if (cond) {
|
|
>cond : Symbol(cond, Decl(controlFlowNoImplicitAny.ts, 0, 11))
|
|
|
|
x = "hello";
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 4, 7))
|
|
}
|
|
const y = x; // string | number | undefined
|
|
>y : Symbol(y, Decl(controlFlowNoImplicitAny.ts, 11, 9))
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 4, 7))
|
|
}
|
|
|
|
// CFA for 'let' with no type annotation and 'undefined' initializer
|
|
function f2() {
|
|
>f2 : Symbol(f2, Decl(controlFlowNoImplicitAny.ts, 12, 1))
|
|
|
|
let x = undefined;
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 16, 7))
|
|
>undefined : Symbol(undefined)
|
|
|
|
if (cond) {
|
|
>cond : Symbol(cond, Decl(controlFlowNoImplicitAny.ts, 0, 11))
|
|
|
|
x = 1;
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 16, 7))
|
|
}
|
|
if (cond) {
|
|
>cond : Symbol(cond, Decl(controlFlowNoImplicitAny.ts, 0, 11))
|
|
|
|
x = "hello";
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 16, 7))
|
|
}
|
|
const y = x; // string | number | undefined
|
|
>y : Symbol(y, Decl(controlFlowNoImplicitAny.ts, 23, 9))
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 16, 7))
|
|
}
|
|
|
|
// CFA for 'let' with no type annotation and 'null' initializer
|
|
function f3() {
|
|
>f3 : Symbol(f3, Decl(controlFlowNoImplicitAny.ts, 24, 1))
|
|
|
|
let x = null;
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 28, 7))
|
|
|
|
if (cond) {
|
|
>cond : Symbol(cond, Decl(controlFlowNoImplicitAny.ts, 0, 11))
|
|
|
|
x = 1;
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 28, 7))
|
|
}
|
|
if (cond) {
|
|
>cond : Symbol(cond, Decl(controlFlowNoImplicitAny.ts, 0, 11))
|
|
|
|
x = "hello";
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 28, 7))
|
|
}
|
|
const y = x; // string | number | null
|
|
>y : Symbol(y, Decl(controlFlowNoImplicitAny.ts, 35, 9))
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 28, 7))
|
|
}
|
|
|
|
// No CFA for 'let' with with type annotation
|
|
function f4() {
|
|
>f4 : Symbol(f4, Decl(controlFlowNoImplicitAny.ts, 36, 1))
|
|
|
|
let x: any;
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 40, 7))
|
|
|
|
if (cond) {
|
|
>cond : Symbol(cond, Decl(controlFlowNoImplicitAny.ts, 0, 11))
|
|
|
|
x = 1;
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 40, 7))
|
|
}
|
|
if (cond) {
|
|
>cond : Symbol(cond, Decl(controlFlowNoImplicitAny.ts, 0, 11))
|
|
|
|
x = "hello";
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 40, 7))
|
|
}
|
|
const y = x; // any
|
|
>y : Symbol(y, Decl(controlFlowNoImplicitAny.ts, 47, 9))
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 40, 7))
|
|
}
|
|
|
|
// CFA for 'var' with no type annotation and initializer
|
|
function f5() {
|
|
>f5 : Symbol(f5, Decl(controlFlowNoImplicitAny.ts, 48, 1))
|
|
|
|
var x;
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 52, 7))
|
|
|
|
if (cond) {
|
|
>cond : Symbol(cond, Decl(controlFlowNoImplicitAny.ts, 0, 11))
|
|
|
|
x = 1;
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 52, 7))
|
|
}
|
|
if (cond) {
|
|
>cond : Symbol(cond, Decl(controlFlowNoImplicitAny.ts, 0, 11))
|
|
|
|
x = "hello";
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 52, 7))
|
|
}
|
|
const y = x; // string | number | undefined
|
|
>y : Symbol(y, Decl(controlFlowNoImplicitAny.ts, 59, 9))
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 52, 7))
|
|
}
|
|
|
|
// CFA for 'var' with no type annotation and 'undefined' initializer
|
|
function f6() {
|
|
>f6 : Symbol(f6, Decl(controlFlowNoImplicitAny.ts, 60, 1))
|
|
|
|
var x = undefined;
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 64, 7))
|
|
>undefined : Symbol(undefined)
|
|
|
|
if (cond) {
|
|
>cond : Symbol(cond, Decl(controlFlowNoImplicitAny.ts, 0, 11))
|
|
|
|
x = 1;
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 64, 7))
|
|
}
|
|
if (cond) {
|
|
>cond : Symbol(cond, Decl(controlFlowNoImplicitAny.ts, 0, 11))
|
|
|
|
x = "hello";
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 64, 7))
|
|
}
|
|
const y = x; // string | number | undefined
|
|
>y : Symbol(y, Decl(controlFlowNoImplicitAny.ts, 71, 9))
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 64, 7))
|
|
}
|
|
|
|
// CFA for 'var' with no type annotation and 'null' initializer
|
|
function f7() {
|
|
>f7 : Symbol(f7, Decl(controlFlowNoImplicitAny.ts, 72, 1))
|
|
|
|
var x = null;
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 76, 7))
|
|
|
|
if (cond) {
|
|
>cond : Symbol(cond, Decl(controlFlowNoImplicitAny.ts, 0, 11))
|
|
|
|
x = 1;
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 76, 7))
|
|
}
|
|
if (cond) {
|
|
>cond : Symbol(cond, Decl(controlFlowNoImplicitAny.ts, 0, 11))
|
|
|
|
x = "hello";
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 76, 7))
|
|
}
|
|
const y = x; // string | number | null
|
|
>y : Symbol(y, Decl(controlFlowNoImplicitAny.ts, 83, 9))
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 76, 7))
|
|
}
|
|
|
|
// No CFA for 'var' with with type annotation
|
|
function f8() {
|
|
>f8 : Symbol(f8, Decl(controlFlowNoImplicitAny.ts, 84, 1))
|
|
|
|
var x: any;
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 88, 7))
|
|
|
|
if (cond) {
|
|
>cond : Symbol(cond, Decl(controlFlowNoImplicitAny.ts, 0, 11))
|
|
|
|
x = 1;
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 88, 7))
|
|
}
|
|
if (cond) {
|
|
>cond : Symbol(cond, Decl(controlFlowNoImplicitAny.ts, 0, 11))
|
|
|
|
x = "hello";
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 88, 7))
|
|
}
|
|
const y = x; // any
|
|
>y : Symbol(y, Decl(controlFlowNoImplicitAny.ts, 95, 9))
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 88, 7))
|
|
}
|
|
|
|
// No CFA for captured outer variables
|
|
function f9() {
|
|
>f9 : Symbol(f9, Decl(controlFlowNoImplicitAny.ts, 96, 1))
|
|
|
|
let x;
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 100, 7))
|
|
|
|
if (cond) {
|
|
>cond : Symbol(cond, Decl(controlFlowNoImplicitAny.ts, 0, 11))
|
|
|
|
x = 1;
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 100, 7))
|
|
}
|
|
if (cond) {
|
|
>cond : Symbol(cond, Decl(controlFlowNoImplicitAny.ts, 0, 11))
|
|
|
|
x = "hello";
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 100, 7))
|
|
}
|
|
const y = x; // string | number | undefined
|
|
>y : Symbol(y, Decl(controlFlowNoImplicitAny.ts, 107, 9))
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 100, 7))
|
|
|
|
function f() {
|
|
>f : Symbol(f, Decl(controlFlowNoImplicitAny.ts, 107, 16))
|
|
|
|
const z = x; // any
|
|
>z : Symbol(z, Decl(controlFlowNoImplicitAny.ts, 109, 13))
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 100, 7))
|
|
}
|
|
}
|
|
|
|
// No CFA for captured outer variables
|
|
function f10() {
|
|
>f10 : Symbol(f10, Decl(controlFlowNoImplicitAny.ts, 111, 1))
|
|
|
|
let x;
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 115, 7))
|
|
|
|
if (cond) {
|
|
>cond : Symbol(cond, Decl(controlFlowNoImplicitAny.ts, 0, 11))
|
|
|
|
x = 1;
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 115, 7))
|
|
}
|
|
if (cond) {
|
|
>cond : Symbol(cond, Decl(controlFlowNoImplicitAny.ts, 0, 11))
|
|
|
|
x = "hello";
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 115, 7))
|
|
}
|
|
const y = x; // string | number | undefined
|
|
>y : Symbol(y, Decl(controlFlowNoImplicitAny.ts, 122, 9))
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 115, 7))
|
|
|
|
const f = () => {
|
|
>f : Symbol(f, Decl(controlFlowNoImplicitAny.ts, 123, 9))
|
|
|
|
const z = x; // any
|
|
>z : Symbol(z, Decl(controlFlowNoImplicitAny.ts, 124, 13))
|
|
>x : Symbol(x, Decl(controlFlowNoImplicitAny.ts, 115, 7))
|
|
|
|
};
|
|
}
|