diff --git a/tests/baselines/reference/controlFlowIteration.js b/tests/baselines/reference/controlFlowIteration.js new file mode 100644 index 00000000000..7b319ba8098 --- /dev/null +++ b/tests/baselines/reference/controlFlowIteration.js @@ -0,0 +1,40 @@ +//// [controlFlowIteration.ts] + +let cond: boolean; + +function ff() { + let x: string | undefined; + while (true) { + if (cond) { + x = ""; + } + else { + if (x) { + x.length; + } + if (x) { + x.length; + } + } + } +} + + +//// [controlFlowIteration.js] +var cond; +function ff() { + var x; + while (true) { + if (cond) { + x = ""; + } + else { + if (x) { + x.length; + } + if (x) { + x.length; + } + } + } +} diff --git a/tests/baselines/reference/controlFlowIteration.symbols b/tests/baselines/reference/controlFlowIteration.symbols new file mode 100644 index 00000000000..84c1c57b69b --- /dev/null +++ b/tests/baselines/reference/controlFlowIteration.symbols @@ -0,0 +1,39 @@ +=== tests/cases/conformance/controlFlow/controlFlowIteration.ts === + +let cond: boolean; +>cond : Symbol(cond, Decl(controlFlowIteration.ts, 1, 3)) + +function ff() { +>ff : Symbol(ff, Decl(controlFlowIteration.ts, 1, 18)) + + let x: string | undefined; +>x : Symbol(x, Decl(controlFlowIteration.ts, 4, 7)) + + while (true) { + if (cond) { +>cond : Symbol(cond, Decl(controlFlowIteration.ts, 1, 3)) + + x = ""; +>x : Symbol(x, Decl(controlFlowIteration.ts, 4, 7)) + } + else { + if (x) { +>x : Symbol(x, Decl(controlFlowIteration.ts, 4, 7)) + + x.length; +>x.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowIteration.ts, 4, 7)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) + } + if (x) { +>x : Symbol(x, Decl(controlFlowIteration.ts, 4, 7)) + + x.length; +>x.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowIteration.ts, 4, 7)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) + } + } + } +} + diff --git a/tests/baselines/reference/controlFlowIteration.types b/tests/baselines/reference/controlFlowIteration.types new file mode 100644 index 00000000000..52be501d68e --- /dev/null +++ b/tests/baselines/reference/controlFlowIteration.types @@ -0,0 +1,43 @@ +=== tests/cases/conformance/controlFlow/controlFlowIteration.ts === + +let cond: boolean; +>cond : boolean + +function ff() { +>ff : () => void + + let x: string | undefined; +>x : string | undefined + + while (true) { +>true : boolean + + if (cond) { +>cond : boolean + + x = ""; +>x = "" : string +>x : string | undefined +>"" : string + } + else { + if (x) { +>x : string | undefined + + x.length; +>x.length : number +>x : string +>length : number + } + if (x) { +>x : string | undefined + + x.length; +>x.length : number +>x : string +>length : number + } + } + } +} + diff --git a/tests/cases/conformance/controlFlow/controlFlowIteration.ts b/tests/cases/conformance/controlFlow/controlFlowIteration.ts new file mode 100644 index 00000000000..56172b1bbdf --- /dev/null +++ b/tests/cases/conformance/controlFlow/controlFlowIteration.ts @@ -0,0 +1,20 @@ +// @strictNullChecks: true + +let cond: boolean; + +function ff() { + let x: string | undefined; + while (true) { + if (cond) { + x = ""; + } + else { + if (x) { + x.length; + } + if (x) { + x.length; + } + } + } +}