mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Adding test
This commit is contained in:
@@ -0,0 +1,113 @@
|
||||
//// [controlFlowDestructuringDeclaration.ts]
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
//// [controlFlowDestructuringDeclaration.js]
|
||||
function f1() {
|
||||
var x = 1;
|
||||
x;
|
||||
var y = "";
|
||||
y;
|
||||
}
|
||||
function f2() {
|
||||
var x = [1][0];
|
||||
x;
|
||||
var y = [""][0];
|
||||
y;
|
||||
var _a = [undefined][0], z = _a === void 0 ? "" : _a;
|
||||
z;
|
||||
}
|
||||
function f3() {
|
||||
var x = [1][0];
|
||||
x;
|
||||
var y = [""][0];
|
||||
y;
|
||||
var _a = [undefined][0], z = _a === void 0 ? "" : _a;
|
||||
z;
|
||||
}
|
||||
function f4() {
|
||||
var x = { x: 1 }.x;
|
||||
x;
|
||||
var y = { y: "" }.y;
|
||||
y;
|
||||
var _a = { z: undefined }.z, z = _a === void 0 ? "" : _a;
|
||||
z;
|
||||
}
|
||||
function f5() {
|
||||
var x = { x: 1 }.x;
|
||||
x;
|
||||
var y = { y: "" }.y;
|
||||
y;
|
||||
var _a = { z: undefined }.z, z = _a === void 0 ? "" : _a;
|
||||
z;
|
||||
}
|
||||
function f6() {
|
||||
var x = {}.x;
|
||||
x;
|
||||
var y = {}.y;
|
||||
y;
|
||||
var _a = {}.z, z = _a === void 0 ? "" : _a;
|
||||
z;
|
||||
}
|
||||
function f7() {
|
||||
var o = { x: 1 };
|
||||
var x = o.x;
|
||||
x;
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
=== tests/cases/conformance/controlFlow/controlFlowDestructuringDeclaration.ts ===
|
||||
|
||||
function f1() {
|
||||
>f1 : Symbol(f1, Decl(controlFlowDestructuringDeclaration.ts, 0, 0))
|
||||
|
||||
let x: string | number = 1;
|
||||
>x : Symbol(x, Decl(controlFlowDestructuringDeclaration.ts, 2, 7))
|
||||
|
||||
x;
|
||||
>x : Symbol(x, Decl(controlFlowDestructuringDeclaration.ts, 2, 7))
|
||||
|
||||
let y: string | undefined = "";
|
||||
>y : Symbol(y, Decl(controlFlowDestructuringDeclaration.ts, 4, 7))
|
||||
|
||||
y;
|
||||
>y : Symbol(y, Decl(controlFlowDestructuringDeclaration.ts, 4, 7))
|
||||
}
|
||||
|
||||
function f2() {
|
||||
>f2 : Symbol(f2, Decl(controlFlowDestructuringDeclaration.ts, 6, 1))
|
||||
|
||||
let [x]: [string | number] = [1];
|
||||
>x : Symbol(x, Decl(controlFlowDestructuringDeclaration.ts, 9, 9))
|
||||
|
||||
x;
|
||||
>x : Symbol(x, Decl(controlFlowDestructuringDeclaration.ts, 9, 9))
|
||||
|
||||
let [y]: [string | undefined] = [""];
|
||||
>y : Symbol(y, Decl(controlFlowDestructuringDeclaration.ts, 11, 9))
|
||||
|
||||
y;
|
||||
>y : Symbol(y, Decl(controlFlowDestructuringDeclaration.ts, 11, 9))
|
||||
|
||||
let [z = ""]: [string | undefined] = [undefined];
|
||||
>z : Symbol(z, Decl(controlFlowDestructuringDeclaration.ts, 13, 9))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
z;
|
||||
>z : Symbol(z, Decl(controlFlowDestructuringDeclaration.ts, 13, 9))
|
||||
}
|
||||
|
||||
function f3() {
|
||||
>f3 : Symbol(f3, Decl(controlFlowDestructuringDeclaration.ts, 15, 1))
|
||||
|
||||
let [x]: (string | number)[] = [1];
|
||||
>x : Symbol(x, Decl(controlFlowDestructuringDeclaration.ts, 18, 9))
|
||||
|
||||
x;
|
||||
>x : Symbol(x, Decl(controlFlowDestructuringDeclaration.ts, 18, 9))
|
||||
|
||||
let [y]: (string | undefined)[] = [""];
|
||||
>y : Symbol(y, Decl(controlFlowDestructuringDeclaration.ts, 20, 9))
|
||||
|
||||
y;
|
||||
>y : Symbol(y, Decl(controlFlowDestructuringDeclaration.ts, 20, 9))
|
||||
|
||||
let [z = ""]: (string | undefined)[] = [undefined];
|
||||
>z : Symbol(z, Decl(controlFlowDestructuringDeclaration.ts, 22, 9))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
z;
|
||||
>z : Symbol(z, Decl(controlFlowDestructuringDeclaration.ts, 22, 9))
|
||||
}
|
||||
|
||||
function f4() {
|
||||
>f4 : Symbol(f4, Decl(controlFlowDestructuringDeclaration.ts, 24, 1))
|
||||
|
||||
let { x }: { x: string | number } = { x: 1 };
|
||||
>x : Symbol(x, Decl(controlFlowDestructuringDeclaration.ts, 27, 9))
|
||||
>x : Symbol(x, Decl(controlFlowDestructuringDeclaration.ts, 27, 16))
|
||||
>x : Symbol(x, Decl(controlFlowDestructuringDeclaration.ts, 27, 41))
|
||||
|
||||
x;
|
||||
>x : Symbol(x, Decl(controlFlowDestructuringDeclaration.ts, 27, 9))
|
||||
|
||||
let { y }: { y: string | undefined } = { y: "" };
|
||||
>y : Symbol(y, Decl(controlFlowDestructuringDeclaration.ts, 29, 9))
|
||||
>y : Symbol(y, Decl(controlFlowDestructuringDeclaration.ts, 29, 16))
|
||||
>y : Symbol(y, Decl(controlFlowDestructuringDeclaration.ts, 29, 44))
|
||||
|
||||
y;
|
||||
>y : Symbol(y, Decl(controlFlowDestructuringDeclaration.ts, 29, 9))
|
||||
|
||||
let { z = "" }: { z: string | undefined } = { z: undefined };
|
||||
>z : Symbol(z, Decl(controlFlowDestructuringDeclaration.ts, 31, 9))
|
||||
>z : Symbol(z, Decl(controlFlowDestructuringDeclaration.ts, 31, 21))
|
||||
>z : Symbol(z, Decl(controlFlowDestructuringDeclaration.ts, 31, 49))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
z;
|
||||
>z : Symbol(z, Decl(controlFlowDestructuringDeclaration.ts, 31, 9))
|
||||
}
|
||||
|
||||
function f5() {
|
||||
>f5 : Symbol(f5, Decl(controlFlowDestructuringDeclaration.ts, 33, 1))
|
||||
|
||||
let { x }: { x?: string | number } = { x: 1 };
|
||||
>x : Symbol(x, Decl(controlFlowDestructuringDeclaration.ts, 36, 9))
|
||||
>x : Symbol(x, Decl(controlFlowDestructuringDeclaration.ts, 36, 16))
|
||||
>x : Symbol(x, Decl(controlFlowDestructuringDeclaration.ts, 36, 42))
|
||||
|
||||
x;
|
||||
>x : Symbol(x, Decl(controlFlowDestructuringDeclaration.ts, 36, 9))
|
||||
|
||||
let { y }: { y?: string | undefined } = { y: "" };
|
||||
>y : Symbol(y, Decl(controlFlowDestructuringDeclaration.ts, 38, 9))
|
||||
>y : Symbol(y, Decl(controlFlowDestructuringDeclaration.ts, 38, 16))
|
||||
>y : Symbol(y, Decl(controlFlowDestructuringDeclaration.ts, 38, 45))
|
||||
|
||||
y;
|
||||
>y : Symbol(y, Decl(controlFlowDestructuringDeclaration.ts, 38, 9))
|
||||
|
||||
let { z = "" }: { z?: string | undefined } = { z: undefined };
|
||||
>z : Symbol(z, Decl(controlFlowDestructuringDeclaration.ts, 40, 9))
|
||||
>z : Symbol(z, Decl(controlFlowDestructuringDeclaration.ts, 40, 21))
|
||||
>z : Symbol(z, Decl(controlFlowDestructuringDeclaration.ts, 40, 50))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
z;
|
||||
>z : Symbol(z, Decl(controlFlowDestructuringDeclaration.ts, 40, 9))
|
||||
}
|
||||
|
||||
function f6() {
|
||||
>f6 : Symbol(f6, Decl(controlFlowDestructuringDeclaration.ts, 42, 1))
|
||||
|
||||
let { x }: { x?: string | number } = {};
|
||||
>x : Symbol(x, Decl(controlFlowDestructuringDeclaration.ts, 45, 9))
|
||||
>x : Symbol(x, Decl(controlFlowDestructuringDeclaration.ts, 45, 16))
|
||||
|
||||
x;
|
||||
>x : Symbol(x, Decl(controlFlowDestructuringDeclaration.ts, 45, 9))
|
||||
|
||||
let { y }: { y?: string | undefined } = {};
|
||||
>y : Symbol(y, Decl(controlFlowDestructuringDeclaration.ts, 47, 9))
|
||||
>y : Symbol(y, Decl(controlFlowDestructuringDeclaration.ts, 47, 16))
|
||||
|
||||
y;
|
||||
>y : Symbol(y, Decl(controlFlowDestructuringDeclaration.ts, 47, 9))
|
||||
|
||||
let { z = "" }: { z?: string | undefined } = {};
|
||||
>z : Symbol(z, Decl(controlFlowDestructuringDeclaration.ts, 49, 9))
|
||||
>z : Symbol(z, Decl(controlFlowDestructuringDeclaration.ts, 49, 21))
|
||||
|
||||
z;
|
||||
>z : Symbol(z, Decl(controlFlowDestructuringDeclaration.ts, 49, 9))
|
||||
}
|
||||
|
||||
function f7() {
|
||||
>f7 : Symbol(f7, Decl(controlFlowDestructuringDeclaration.ts, 51, 1))
|
||||
|
||||
let o: { [x: string]: number } = { x: 1 };
|
||||
>o : Symbol(o, Decl(controlFlowDestructuringDeclaration.ts, 54, 7))
|
||||
>x : Symbol(x, Decl(controlFlowDestructuringDeclaration.ts, 54, 14))
|
||||
>x : Symbol(x, Decl(controlFlowDestructuringDeclaration.ts, 54, 38))
|
||||
|
||||
let { x }: { [x: string]: string | number } = o;
|
||||
>x : Symbol(x, Decl(controlFlowDestructuringDeclaration.ts, 55, 9))
|
||||
>x : Symbol(x, Decl(controlFlowDestructuringDeclaration.ts, 55, 18))
|
||||
>o : Symbol(o, Decl(controlFlowDestructuringDeclaration.ts, 54, 7))
|
||||
|
||||
x;
|
||||
>x : Symbol(x, Decl(controlFlowDestructuringDeclaration.ts, 55, 9))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,196 @@
|
||||
=== tests/cases/conformance/controlFlow/controlFlowDestructuringDeclaration.ts ===
|
||||
|
||||
function f1() {
|
||||
>f1 : () => void
|
||||
|
||||
let x: string | number = 1;
|
||||
>x : string | number
|
||||
>1 : number
|
||||
|
||||
x;
|
||||
>x : number
|
||||
|
||||
let y: string | undefined = "";
|
||||
>y : string | undefined
|
||||
>"" : string
|
||||
|
||||
y;
|
||||
>y : string
|
||||
}
|
||||
|
||||
function f2() {
|
||||
>f2 : () => void
|
||||
|
||||
let [x]: [string | number] = [1];
|
||||
>x : string | number
|
||||
>[1] : [number]
|
||||
>1 : number
|
||||
|
||||
x;
|
||||
>x : number
|
||||
|
||||
let [y]: [string | undefined] = [""];
|
||||
>y : string | undefined
|
||||
>[""] : [string]
|
||||
>"" : string
|
||||
|
||||
y;
|
||||
>y : string
|
||||
|
||||
let [z = ""]: [string | undefined] = [undefined];
|
||||
>z : string
|
||||
>"" : string
|
||||
>[undefined] : [undefined]
|
||||
>undefined : undefined
|
||||
|
||||
z;
|
||||
>z : string
|
||||
}
|
||||
|
||||
function f3() {
|
||||
>f3 : () => void
|
||||
|
||||
let [x]: (string | number)[] = [1];
|
||||
>x : string | number
|
||||
>[1] : number[]
|
||||
>1 : number
|
||||
|
||||
x;
|
||||
>x : number
|
||||
|
||||
let [y]: (string | undefined)[] = [""];
|
||||
>y : string | undefined
|
||||
>[""] : string[]
|
||||
>"" : string
|
||||
|
||||
y;
|
||||
>y : string
|
||||
|
||||
let [z = ""]: (string | undefined)[] = [undefined];
|
||||
>z : string
|
||||
>"" : string
|
||||
>[undefined] : undefined[]
|
||||
>undefined : undefined
|
||||
|
||||
z;
|
||||
>z : string
|
||||
}
|
||||
|
||||
function f4() {
|
||||
>f4 : () => void
|
||||
|
||||
let { x }: { x: string | number } = { x: 1 };
|
||||
>x : string | number
|
||||
>x : string | number
|
||||
>{ x: 1 } : { x: number; }
|
||||
>x : number
|
||||
>1 : number
|
||||
|
||||
x;
|
||||
>x : number
|
||||
|
||||
let { y }: { y: string | undefined } = { y: "" };
|
||||
>y : string | undefined
|
||||
>y : string | undefined
|
||||
>{ y: "" } : { y: string; }
|
||||
>y : string
|
||||
>"" : string
|
||||
|
||||
y;
|
||||
>y : string
|
||||
|
||||
let { z = "" }: { z: string | undefined } = { z: undefined };
|
||||
>z : string
|
||||
>"" : string
|
||||
>z : string | undefined
|
||||
>{ z: undefined } : { z: undefined; }
|
||||
>z : undefined
|
||||
>undefined : undefined
|
||||
|
||||
z;
|
||||
>z : string
|
||||
}
|
||||
|
||||
function f5() {
|
||||
>f5 : () => void
|
||||
|
||||
let { x }: { x?: string | number } = { x: 1 };
|
||||
>x : string | number | undefined
|
||||
>x : string | number | undefined
|
||||
>{ x: 1 } : { x: number; }
|
||||
>x : number
|
||||
>1 : number
|
||||
|
||||
x;
|
||||
>x : number
|
||||
|
||||
let { y }: { y?: string | undefined } = { y: "" };
|
||||
>y : string | undefined
|
||||
>y : string | undefined
|
||||
>{ y: "" } : { y: string; }
|
||||
>y : string
|
||||
>"" : string
|
||||
|
||||
y;
|
||||
>y : string
|
||||
|
||||
let { z = "" }: { z?: string | undefined } = { z: undefined };
|
||||
>z : string
|
||||
>"" : string
|
||||
>z : string | undefined
|
||||
>{ z: undefined } : { z: undefined; }
|
||||
>z : undefined
|
||||
>undefined : undefined
|
||||
|
||||
z;
|
||||
>z : string
|
||||
}
|
||||
|
||||
function f6() {
|
||||
>f6 : () => void
|
||||
|
||||
let { x }: { x?: string | number } = {};
|
||||
>x : string | number | undefined
|
||||
>x : string | number | undefined
|
||||
>{} : {}
|
||||
|
||||
x;
|
||||
>x : string | number | undefined
|
||||
|
||||
let { y }: { y?: string | undefined } = {};
|
||||
>y : string | undefined
|
||||
>y : string | undefined
|
||||
>{} : {}
|
||||
|
||||
y;
|
||||
>y : string | undefined
|
||||
|
||||
let { z = "" }: { z?: string | undefined } = {};
|
||||
>z : string
|
||||
>"" : string
|
||||
>z : string | undefined
|
||||
>{} : {}
|
||||
|
||||
z;
|
||||
>z : string
|
||||
}
|
||||
|
||||
function f7() {
|
||||
>f7 : () => void
|
||||
|
||||
let o: { [x: string]: number } = { x: 1 };
|
||||
>o : { [x: string]: number; }
|
||||
>x : string
|
||||
>{ x: 1 } : { x: number; }
|
||||
>x : number
|
||||
>1 : number
|
||||
|
||||
let { x }: { [x: string]: string | number } = o;
|
||||
>x : string | number
|
||||
>x : string
|
||||
>o : { [x: string]: number; }
|
||||
|
||||
x;
|
||||
>x : number
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
// @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;
|
||||
}
|
||||
Reference in New Issue
Block a user