/arkcompiler/ets_runtime/test/typeinfer/automatedcases/ |
D | contextuallyTypingOrOperator.ts | 21 let v: { a: (_: string) => number } = { a: s => s.length } || { a: s => 1 }; 25 AssertType({ a: s => s.length } || { a: s => 1 }, "{ a: (string) => number; }"); 26 AssertType({ a: s => s.length }, "{ a: (string) => number; }"); 28 AssertType(s => s.length, "(string) => number"); 29 AssertType(s, "string"); 30 AssertType(s.length, "number"); 31 AssertType({ a: s => 1 }, "{ a: (string) => number; }"); 33 AssertType(s => 1, "(string) => number"); 34 AssertType(s, "string"); 37 let v2 = (s: string) => s.length || function (s) { s.length }; [all …]
|
D | typeGuardNarrowsIndexedAccessOfKnownProperty1.ts | 44 function area(s: Shape): number { 45 switch(s['dash-ok']) { 46 AssertType(s['dash-ok'], "union"); 47 AssertType(s, "Shape"); 52 AssertType(s['square-size'] * s['square-size'], "number"); 53 AssertType(s['square-size'], "number"); 54 AssertType(s, "Square"); 56 AssertType(s['square-size'], "number"); 57 AssertType(s, "Square"); 59 return s['square-size'] * s['square-size']; [all …]
|
D | contextuallyTypingOrOperator2.ts | 21 let v: { a: (_: string) => number } = { a: s => s.length } || { a: s => 1 }; 25 AssertType({ a: s => s.length } || { a: s => 1 }, "{ a: (string) => number; }"); 26 AssertType({ a: s => s.length }, "{ a: (string) => number; }"); 28 AssertType(s => s.length, "(string) => number"); 29 AssertType(s, "string"); 30 AssertType(s.length, "number"); 31 AssertType({ a: s => 1 }, "{ a: (string) => number; }"); 33 AssertType(s => 1, "(string) => number"); 34 AssertType(s, "string"); 37 let v2 = (s: string) => s.length || function (s) { s.aaa }; [all …]
|
D | symbolType11.ts | 21 let s = Symbol.for("logical"); 22 AssertType(s, "symbol"); 27 s && s; 28 AssertType(s && s, "symbol"); 29 AssertType(s, "symbol"); 30 AssertType(s, "symbol"); 32 s && []; 33 AssertType(s && [], "undefined[]"); 34 AssertType(s, "symbol"); 37 0 && s; [all …]
|
D | literalTypes3.ts | 21 function f1(s: string) { 22 if (s === "foo") { 23 AssertType(s === "foo", "boolean"); 24 AssertType(s, "string"); 27 s; // "foo" 28 AssertType(s, "string"); 30 if (s === "foo" || s === "bar") { 31 AssertType(s === "foo" || s === "bar", "boolean"); 32 AssertType(s === "foo", "boolean"); 33 AssertType(s, "string"); [all …]
|
D | mappedTypeContextualTypesApplied.ts | 21 type TakeString = (s: string) => any; 35 mapped1({foo: s => 42}); 36 AssertType(mapped1({foo: s => 42}), "void"); 38 AssertType({foo: s => 42}, "{ foo: (string) => number; }"); 40 AssertType(s => 42, "(string) => number"); 41 AssertType(s, "string"); 44 mapped2({foo: s => 42}); 45 AssertType(mapped2({foo: s => 42}), "void"); 47 AssertType({foo: s => 42}, "{ foo: (string) => number; }"); 49 AssertType(s => 42, "(string) => number"); [all …]
|
D | uniqueSymbols.ts | 361 declare const s: unique symbol; constant 362 AssertType(s, "unique symbol"); 364 declare namespace N { const s: unique symbol; } constant 365 declare const o: { [s]: "a", [N.s]: "b" }; 367 AssertType([s], "string"); 368 AssertType(s, "unique symbol"); 369 AssertType([N.s], "string"); 370 AssertType(N.s, "unique symbol"); 373 declare function g(x: typeof s): void; 374 declare function g(x: typeof N.s): void; [all …]
|
D | computedPropertyNames4_ES5.ts | 21 let s: string; 22 AssertType(s, "string"); 32 AssertType({ [s]: 0, [n]: n, [s + s]: 1, [s + n]: 2, [+s]: s, [""]: 0, [0]: 0,… 34 [s]: 0, 35 AssertType([s], "number"); 36 AssertType(s, "string"); 44 [s + s]: 1, 45 AssertType([s + s], "number"); 46 AssertType(s + s, "string"); 47 AssertType(s, "string"); [all …]
|
D | computedPropertyNames4_ES6.ts | 21 let s: string; 22 AssertType(s, "string"); 32 AssertType({ [s]: 0, [n]: n, [s + s]: 1, [s + n]: 2, [+s]: s, [""]: 0, [0]: 0,… 34 [s]: 0, 35 AssertType([s], "number"); 36 AssertType(s, "string"); 44 [s + s]: 1, 45 AssertType([s + s], "number"); 46 AssertType(s + s, "string"); 47 AssertType(s, "string"); [all …]
|
D | computedPropertyNames10_ES6.ts | 21 let s: string; 22 AssertType(s, "string"); 32 AssertType({ [s]() { }, [n]() { }, [s + s]() { }, [s + n]() { }, [+s]() { }, [""]… 34 [s]() { }, 35 AssertType([s], "() => void"); 36 AssertType(s, "string"); 42 [s + s]() { }, 43 AssertType([s + s], "() => void"); 44 AssertType(s + s, "string"); 45 AssertType(s, "string"); [all …]
|
D | computedPropertyNames10_ES5.ts | 21 let s: string; 22 AssertType(s, "string"); 32 AssertType({ [s]() { }, [n]() { }, [s + s]() { }, [s + n]() { }, [+s]() { }, [""]… 34 [s]() { }, 35 AssertType([s], "() => void"); 36 AssertType(s, "string"); 42 [s + s]() { }, 43 AssertType([s + s], "() => void"); 44 AssertType(s + s, "string"); 45 AssertType(s, "string"); [all …]
|
D | privateNameInLhsReceiverExpression.ts | 24 obj[(new class { #x = 1; readonly s = "prop"; }).s].#y = 1; 25 AssertType(obj[(new class { #x = 1; readonly s = "prop"; }).s].#y = 1, "int"); 26 AssertType(obj[(new class { #x = 1; readonly s = "prop"; }).s].#y, "number"); 27 AssertType(obj[(new class { #x = 1; readonly s = "prop"; }).s], "Test"); 29 AssertType((new class { #x = 1; readonly s = "prop"; }).s, "string"); 30 AssertType((new class { #x = 1; readonly s = "prop"; }), "(Anonymous class)"); 31 AssertType(new class { #x = 1; readonly s = "prop"; }, "(Anonymous class)"); 32 AssertType(class { #x = 1; readonly s = "prop"; }, "typeof (Anonymous class)"); 35 AssertType(s, "string"); 39 obj[(new class { #x = 1; readonly s = "prop"; }).s].#y += 1; [all …]
|
D | uniqueSymbolsDeclarations.ts | 354 declare const s: unique symbol; constant 355 AssertType(s, "unique symbol"); 357 declare namespace N { const s: unique symbol; } constant 358 declare const o: { [s]: "a", [N.s]: "b" }; 360 AssertType([s], "string"); 361 AssertType(s, "unique symbol"); 362 AssertType([N.s], "string"); 363 AssertType(N.s, "unique symbol"); 366 declare function g(x: typeof s): void; 367 declare function g(x: typeof N.s): void; [all …]
|
D | uniqueSymbolsDeclarationsErrors.ts | 21 declare const s: unique symbol; 22 AssertType(s, "unique symbol"); 30 AssertType({ method1(p: typeof s): typeof s { return p; }, method2(p: I["readonlyTy… 32 method1(p: typeof s): typeof s { 35 AssertType(s, "unique symbol"); 36 AssertType(s, "unique symbol"); 53 AssertType(class { method1(p: typeof s): typeof s { return p; } method2(p: I["reado… 55 method1(p: typeof s): typeof s { 58 AssertType(s, "unique symbol"); 59 AssertType(s, "unique symbol"); [all …]
|
D | computedPropertyNames11_ES6.ts | 21 let s: string; 22 AssertType(s, "string"); 32 AssertType({ get [s]() { return 0; }, set [n](v) { }, get [s + s]() { return 0; }, set … 34 get [s]() { 35 AssertType([s], "number"); 36 AssertType(s, "string"); 45 get [s + s]() { 46 AssertType([s + s], "number"); 47 AssertType(s + s, "string"); 48 AssertType(s, "string"); [all …]
|
D | computedPropertyNames11_ES5.ts | 21 let s: string; 22 AssertType(s, "string"); 32 AssertType({ get [s]() { return 0; }, set [n](v) { }, get [s + s]() { return 0; }, set … 34 get [s]() { 35 AssertType([s], "number"); 36 AssertType(s, "string"); 45 get [s + s]() { 46 AssertType([s + s], "number"); 47 AssertType(s + s, "string"); 48 AssertType(s, "string"); [all …]
|
D | bestChoiceType.ts | 23 (''.match(/ /) || []).map(s => s.toLowerCase()); 24 AssertType((''.match(/ /) || []).map(s => s.toLowerCase()), "any[]"); 26 AssertType(s => s.toLowerCase(), "(any) => any"); 27 AssertType(s, "any"); 28 AssertType(s.toLowerCase(), "any"); 29 AssertType(s.toLowerCase, "any"); 47 let z = y.map(s => s.toLowerCase()); 49 AssertType(y.map(s => s.toLowerCase()), "any[]"); 51 AssertType(s => s.toLowerCase(), "(any) => any"); 52 AssertType(s, "any"); [all …]
|
D | targetTypingOnFunctions.ts | 21 let fu: (s: string) => string = function (s) { 23 AssertType(s, "string"); 24 AssertType(function (s) { return s.toLowerCase() }, "(string) => string"); 25 AssertType(s, "string"); 26 AssertType(s.toLowerCase(), "string"); 27 AssertType(s.toLowerCase, "() => string"); 28 return s.toLowerCase() }; 30 let zu = fu = function (s) { 32 AssertType(fu = function (s) { return s.toLowerCase() }, "(string) => string"); 34 AssertType(function (s) { return s.toLowerCase() }, "(string) => string"); [all …]
|
D | stringLiteralTypeAssertion01.ts | 24 let s: S; 25 AssertType(s, "S"); 35 s = <S>t; 36 AssertType(s = <S>t, "S"); 37 AssertType(s, "S"); 41 s = t as S; 42 AssertType(s = t as S, "S"); 43 AssertType(s, "S"); 47 s = <S>str; 48 AssertType(s = <S>str, "S"); [all …]
|
D | inferFromGenericFunctionReturnTypes2.ts | 31 let f1: Mapper<string, number> = s => s.length; 33 AssertType(s => s.length, "(string) => number"); 34 AssertType(s, "string"); 35 AssertType(s.length, "number"); 37 let f2: Mapper<string, number> = wrap(s => s.length); 39 AssertType(wrap(s => s.length), "Mapper<string, number>"); 41 AssertType(s => s.length, "(string) => number"); 42 AssertType(s, "string"); 43 AssertType(s.length, "number"); 45 let f3: Mapper<string, number[]> = arrayize(wrap(s => s.length)); [all …]
|
D | symbolProperty1.ts | 21 let s: symbol; 22 AssertType(s, "symbol"); 26 AssertType({ [s]: 0, [s]() { }, get [s]() { return 0; }}, "{ [symbol]: union; }"… 28 [s]: 0, 29 AssertType([s], "number"); 30 AssertType(s, "symbol"); 33 [s]() { }, 34 AssertType([s], "() => void"); 35 AssertType(s, "symbol"); 37 get [s]() { [all …]
|
D | symbolProperty2.ts | 21 let s = Symbol(); 22 AssertType(s, "symbol"); 28 AssertType({ [s]: 0, [s]() { }, get [s]() { return 0; }}, "{ [symbol]: union; }"… 30 [s]: 0, 31 AssertType([s], "number"); 32 AssertType(s, "symbol"); 35 [s]() { }, 36 AssertType([s], "() => void"); 37 AssertType(s, "symbol"); 39 get [s]() { [all …]
|
D | moduleWithStatementsOfEveryKind.ts | 22 class A { s: string } 23 class AA<T> { s: T } 32 class A { s: string } 36 function F(s: string): number { 41 let fn = (s: string) => { 42 AssertType('hello ' + s, "string"); 44 AssertType(s, "string"); 45 return 'hello ' + s; 47 let ol = { s: 'hello', id: 2, isvalid: true }; 55 export class A { s: string } property in A [all …]
|
D | subtypingWithOptionalProperties.ts | 25 let b: { s?: number } = a; 27 AssertType(s, "number"); 34 let r = f({ s: new Object() }); // ok 36 AssertType(f({ s: new Object() }), "{ s?: number; }"); 38 AssertType({ s: new Object() }, "{ s: Object; }"); 39 AssertType(s, "Object"); 43 r.s && r.s.toFixed(); // would blow up at runtime 44 AssertType(r.s && r.s.toFixed(), "string"); 45 AssertType(r.s, "number"); 46 AssertType(r.s.toFixed(), "string"); [all …]
|
D | partiallyDiscriminantedUnions.ts | 64 function isShape(s : Shapes): s is Shape { 65 AssertType(!Array.isArray(s), "boolean"); 66 AssertType(Array.isArray(s), "boolean"); 68 AssertType(s, "Shapes"); 69 return !Array.isArray(s); 72 function fail(s: Shapes) { 73 if (isShape(s)) { 74 AssertType(isShape(s), "boolean"); 76 AssertType(s, "Shapes"); 78 if (s.kind === "circle") { [all …]
|