/arkcompiler/ets_runtime/test/typeinfer/automatedcases/ |
D | typeGuardsInConditionalExpression.ts | 28 function foo(x: number | string) { 29 AssertType(typeof x === "string" ? x.length // string : x++, "number"); 30 AssertType(typeof x === "string", "boolean"); 31 AssertType(typeof x, "union"); 32 AssertType(x, "union"); 34 return typeof x === "string" 36 ? x.length // string 37 AssertType(x.length, "number"); 39 : x++; // number 40 AssertType(x++, "number"); [all …]
|
D | parenthesizedContexualTyping3.ts | 26 function tempFun<T>(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; 27 function tempFun<T>(tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; 28 function tempFun<T>(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T { 29 AssertType(g(x), "T"); 31 AssertType(x, "T"); 32 return g(x); 35 let a = tempFun `${ x => x } ${ 10 }` 37 AssertType(tempFun `${ x => x } ${ 10 }`, "number"); 39 AssertType(`${ x => x } ${ 10 }`, "string"); 40 AssertType(x => x, "(number) => number"); [all …]
|
D | contextualTypeLogicalOr.ts | 23 let x = 123; 24 AssertType(x, "number"); 30 x && [1, 2, 3, 4] || 31 …x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x … 32 …x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x … 33 …x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x … 34 …x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x … 35 …x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x … 36 …x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x … 37 …ype(x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || … [all …]
|
D | nestedBlockScopedBindings5.ts | 22 for (let x in []) { 23 AssertType(x, "string"); 26 x = x + 1; 27 AssertType(x = x + 1, "string"); 28 AssertType(x, "string"); 29 AssertType(x + 1, "string"); 30 AssertType(x, "string"); 33 for (let x;;) { variable 34 AssertType(x, "any"); 36 x = x + 2; [all …]
|
D | nestedBlockScopedBindings6.ts | 22 for (let x of [1]) { 23 AssertType(x, "number"); 27 x = x + 1; 28 AssertType(x = x + 1, "number"); 29 AssertType(x, "number"); 30 AssertType(x + 1, "number"); 31 AssertType(x, "number"); 34 for (let x;;) { variable 35 AssertType(x, "any"); 37 x = x + 2; [all …]
|
D | capturedLetConstInLoop1_ES6.ts | 22 for (let x in {}) { 24 AssertType((function() { return x}), "() => string"); 25 AssertType(function() { return x}, "() => string"); 26 AssertType(x, "string"); 27 return x}); 29 (() => x); 30 AssertType((() => x), "() => string"); 31 AssertType(() => x, "() => string"); 32 AssertType(x, "string"); 35 for (let x of []) { variable [all …]
|
D | typeGuardsInRightOperandOfAndAndOperator.ts | 23 function foo(x: number | string) { 24 AssertType(typeof x === "string" && x.length === 10, "boolean"); 25 AssertType(typeof x === "string", "boolean"); 26 AssertType(typeof x, "union"); 27 AssertType(x, "union"); 29 AssertType(x.length === 10, "boolean"); 30 AssertType(x.length, "number"); 32 return typeof x === "string" && x.length === 10; // string 34 function foo2(x: number | string) { 36 AssertType(typeof x === "string" && ((x = 10) && x), "number"); [all …]
|
D | typeGuardsInRightOperandOfOrOrOperator.ts | 24 function foo(x: number | string) { 25 AssertType(typeof x !== "string" || x.length === 10, "boolean"); 26 AssertType(typeof x !== "string", "boolean"); 27 AssertType(typeof x, "union"); 28 AssertType(x, "union"); 30 AssertType(x.length === 10, "boolean"); 31 AssertType(x.length, "number"); 33 return typeof x !== "string" || x.length === 10; // string 35 function foo2(x: number | string) { 37 AssertType(typeof x !== "string" || ((x = 10) || x), "union"); [all …]
|
D | nestedBlockScopedBindings3.ts | 23 for (let x = 0; x < 1; ) { 24 AssertType(x, "number"); 26 AssertType(x < 1, "boolean"); 27 AssertType(x, "number"); 30 () => x; 31 AssertType(() => x, "() => number"); 32 AssertType(x, "number"); 36 for (let x;;) { 37 AssertType(x, "any"); 39 () => x; [all …]
|
D | capturedLetConstInLoop1.ts | 21 declare function use(x: any): any; 24 for (let x in {}) { 26 AssertType((function() { return x}), "() => string"); 27 AssertType(function() { return x}, "() => string"); 28 AssertType(x, "string"); 29 return x}); 31 (() => x); 32 AssertType((() => x), "() => string"); 33 AssertType(() => x, "() => string"); 34 AssertType(x, "string"); [all …]
|
D | nestedBlockScopedBindings4.ts | 22 for (let x; x < 1;) { 23 AssertType(x, "any"); 24 AssertType(x < 1, "boolean"); 25 AssertType(x, "any"); 28 x = x + 1; 29 AssertType(x = x + 1, "any"); 30 AssertType(x, "any"); 31 AssertType(x + 1, "any"); 32 AssertType(x, "any"); 35 for (let x;;) { [all …]
|
D | controlFlowWhileStatement.ts | 25 let x: string | number; 26 AssertType(x, "union"); 28 x = ""; 29 AssertType(x = "", "string"); 30 AssertType(x, "union"); 36 x; // string 37 AssertType(x, "string"); 41 let x: string | number; 42 AssertType(x, "union"); 44 x = ""; [all …]
|
D | typeGuardsInFunctionAndModuleBlock.ts | 23 function foo(x: number | string | boolean) { 24 AssertType(typeof x === "string" ? x : function f() { let b = x; // number… 25 AssertType(typeof x === "string", "boolean"); 26 AssertType(typeof x, "union"); 27 AssertType(x, "union"); 29 return typeof x === "string" 31 ? x 32 AssertType(x, "string"); 35 AssertType(function f() { let b = x; // number | boolean return typeof x === … 37 AssertType(function f() { let b = x; // number | boolean return typeof x === … [all …]
|
D | controlFlowArrays.ts | 24 let x = []; 25 AssertType(x, "any[]"); 28 x[0] = 5; 29 AssertType(x[0] = 5, "int"); 30 AssertType(x[0], "any"); 31 AssertType(x, "any[]"); 35 x[1] = "hello"; 36 AssertType(x[1] = "hello", "string"); 37 AssertType(x[1], "any"); 38 AssertType(x, "any[]"); [all …]
|
D | controlFlowForStatement.ts | 25 let x: string | number | boolean; 26 AssertType(x, "union"); 28 for (x = ""; cond; x = 5) { 29 AssertType(x = "", "string"); 30 AssertType(x, "union"); 33 AssertType(x = 5, "int"); 34 AssertType(x, "union"); 37 x; // string | number 38 AssertType(x, "union"); 42 let x: string | number | boolean; [all …]
|
D | typeGuardsAsAssertions.ts | 83 let x: string | number | boolean = 0; 84 AssertType(x, "union"); 87 x; // number 88 AssertType(x, "number"); 93 x; // number, then string | number 94 AssertType(x, "union"); 96 x = typeof x === "string" ? x.slice() : "abc"; 97 AssertType(x = typeof x === "string" ? x.slice() : "abc", "string"); 98 AssertType(x, "union"); 99 AssertType(typeof x === "string" ? x.slice() : "abc", "string"); [all …]
|
D | typeGuardRedundancy.ts | 21 let x: string|number; 22 AssertType(x, "union"); 24 let r1 = typeof x === "string" && typeof x === "string" ? x.substr : x.toFixed; 26 AssertType(typeof x === "string" && typeof x === "string" ? x.substr : x.toFixed, "union"); 27 AssertType(typeof x === "string" && typeof x === "string", "boolean"); 28 AssertType(typeof x === "string", "boolean"); 29 AssertType(typeof x, "union"); 30 AssertType(x, "union"); 32 AssertType(typeof x === "string", "boolean"); 33 AssertType(typeof x, "union"); [all …]
|
D | controlFlowDoWhileStatement.ts | 25 let x: string | number; 26 AssertType(x, "union"); 28 x = ""; 29 AssertType(x = "", "string"); 30 AssertType(x, "union"); 34 x; // string 35 AssertType(x, "string"); 41 let x: string | number; 42 AssertType(x, "union"); 44 x = ""; [all …]
|
D | asyncWithVarShadowing_es6.ts | 25 async function fn1(x) { 26 let x; 27 AssertType(x, "any"); 30 async function fn2(x) { 31 let x, z; 32 AssertType(x, "any"); 36 async function fn3(x) { 41 async function fn4(x) { 42 let x = y; 43 AssertType(x, "any"); [all …]
|
D | nestedBlockScopedBindings2.ts | 23 let x = 1; 24 AssertType(x, "number"); 27 () => x; 28 AssertType(() => x, "() => number"); 29 AssertType(x, "number"); 32 let x = 1; 33 AssertType(x, "number"); 40 let x; 41 AssertType(x, "any"); 44 let x = 1; [all …]
|
D | letDeclarations-access.ts | 21 let x = 0 22 AssertType(x, "number"); 27 x = 1; 28 AssertType(x = 1, "int"); 29 AssertType(x, "number"); 32 x += 2; 33 AssertType(x += 2, "number"); 34 AssertType(x, "number"); 37 x -= 3; 38 AssertType(x -= 3, "number"); [all …]
|
D | narrowingByTypeofInSwitch.ts | 21 function assertNever(x: never) { 22 AssertType(x, "never"); 23 return x; 26 function assertNumber(x: number) { 27 AssertType(x, "number"); 28 return x; 31 function assertBoolean(x: boolean) { 32 AssertType(x, "boolean"); 33 return x; 36 function assertString(x: string) { [all …]
|
D | capturedLetConstInLoop4.ts | 45 for (let x of []) { variable 46 let v0 = x; 48 AssertType(x, "any"); 51 AssertType((function() { return x + v0}), "() => any"); 52 AssertType(function() { return x + v0}, "() => any"); 53 AssertType(x + v0, "any"); 54 AssertType(x, "any"); 56 return x + v0}); 58 (() => x); 59 AssertType((() => x), "() => any"); [all …]
|
D | capturedLetConstInLoop4_ES6.ts | 45 for (let x of []) { variable 46 let v0 = x; 48 AssertType(x, "any"); 51 AssertType((function() { return x + v0}), "() => any"); 52 AssertType(function() { return x + v0}, "() => any"); 53 AssertType(x + v0, "any"); 54 AssertType(x, "any"); 56 return x + v0}); 58 (() => x); 59 AssertType((() => x), "() => any"); [all …]
|
D | downlevelLetConst17.ts | 26 let x; 27 AssertType(x, "any"); 29 for (let x = 10; ;) { 30 use(x); 31 AssertType(use(x), "any"); 33 AssertType(x, "number"); 35 use(x); 36 AssertType(use(x), "any"); 38 AssertType(x, "any"); 40 for (const x = 10; ;) { constant [all …]
|