TypeScript/tests/cases/conformance/controlFlow/controlFlowDestructuringDeclaration.ts
Anders Hejlsberg e45bac8139 Adding test
2016-04-09 17:56:03 -07:00

60 lines
1.2 KiB
TypeScript

// @strictNullChecks: true
function f1() {
let x: string | number = 1;
x;
let y: string | undefined = "";
y;
}
function f2() {
let [x]: [string | number] = [1];
x;
let [y]: [string | undefined] = [""];
y;
let [z = ""]: [string | undefined] = [undefined];
z;
}
function f3() {
let [x]: (string | number)[] = [1];
x;
let [y]: (string | undefined)[] = [""];
y;
let [z = ""]: (string | undefined)[] = [undefined];
z;
}
function f4() {
let { x }: { x: string | number } = { x: 1 };
x;
let { y }: { y: string | undefined } = { y: "" };
y;
let { z = "" }: { z: string | undefined } = { z: undefined };
z;
}
function f5() {
let { x }: { x?: string | number } = { x: 1 };
x;
let { y }: { y?: string | undefined } = { y: "" };
y;
let { z = "" }: { z?: string | undefined } = { z: undefined };
z;
}
function f6() {
let { x }: { x?: string | number } = {};
x;
let { y }: { y?: string | undefined } = {};
y;
let { z = "" }: { z?: string | undefined } = {};
z;
}
function f7() {
let o: { [x: string]: number } = { x: 1 };
let { x }: { [x: string]: string | number } = o;
x;
}