_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance3.ts_0_4286
// checking subtype relations for function types as it relates to contextual signature instantiation // error cases module Errors { class Base { foo: string; } class Derived extends Base { bar: string; } class Derived2 extends Derived { baz: string; } class OtherDerived extends Base { bing: string; } ...
{ "end_byte": 4286, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance3.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignatures2.ts_0_253
// some complex cases of assignment compat of generic signatures. No contextual signature instantiation interface A { <T>(x: T, ...y: T[][]): void } interface B { <S>(x: S, ...y: S[]): void } var a: A; var b: B; // Both errors a = b; b = a;
{ "end_byte": 253, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignatures2.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance2.ts_0_3100
// checking subtype relations for function types as it relates to contextual signature instantiation class Base { foo: string; } class Derived extends Base { bar: string; } class Derived2 extends Derived { baz: string; } class OtherDerived extends Base { bing: string; } interface A { // T // M's a: (x: number...
{ "end_byte": 3100, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance2.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts_0_1516
// members N and M of types S and T have the same name, same accessibility, same optionality, and N is assignable M module TargetIsPublic { // targets class Base { public foo: string; } interface I { foo: string; } var a: { foo: string; } var b: Base; var i: I; //...
{ "end_byte": 1516, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance6.ts_0_1258
// checking subtype relations for function types as it relates to contextual signature instantiation // same as subtypingWithCallSignatures4 but using class type parameters instead of generic signatures // all are errors class Base { foo: string; } class Derived extends Base { bar: string; } class Derived2 extends Der...
{ "end_byte": 1258, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance6.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts_0_4168
// call signatures in derived types must have the same or fewer optional parameters as the target for assignment module ClassTypeParam { class Base<T> { a: () => T; a2: (x?: T) => T; a3: (x: T) => T; a4: (x: T, y?: T) => T; a5: (x?: T, y?: T) => T; init = () => { ...
{ "end_byte": 4168, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts_0_2486
// call signatures in derived types must have the same or fewer optional parameters as the target for assignment interface Base { a: (...args: number[]) => number; a2: (x: number, ...z: number[]) => number; a3: (x: number, y?: string, ...z: number[]) => number; a4: (x?: number, y?: string, ...z: numbe...
{ "end_byte": 2486, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance6.ts_0_1329
// checking subtype relations for function types as it relates to contextual signature instantiation // same as subtypingWithConstructSignatures4 but using class type parameters instead of generic signatures // all are errors class Base { foo: string; } class Derived extends Base { bar: string; } class Derived2 extend...
{ "end_byte": 1329, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance6.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts_0_1000
// enums assignable to number, any, Object, errors unless otherwise noted enum E { A } enum F { B } var e = E.A; var f = F.B; e = f; f = e; e = 1; // ok f = 1; // ok var x: number = e; // ok x = f; // ok module Others { var a: any = e; // ok class C { foo: string; } var ac: C; interfa...
{ "end_byte": 1000, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance2.ts_0_3292
// checking subtype relations for function types as it relates to contextual signature instantiation class Base { foo: string; } class Derived extends Base { bar: string; } class Derived2 extends Derived { baz: string; } class OtherDerived extends Base { bing: string; } interface A { // T // M's a: new (x: nu...
{ "end_byte": 3292, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance2.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance.ts_0_1586
module CallSignature { interface Base { // T // M's (x: number): void; (x: number, y: number): void; } // S's interface I extends Base { // N's (x: number): number; // ok because base returns void (x: number, y: number): boolean; // ok because base return...
{ "end_byte": 1586, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/anyAssignableToEveryType2.ts_0_1485
// any is not a subtype of any other types, but is assignable, all the below should work interface I { [x: string]: any; foo: any; // ok, any identical to itself } interface I2 { [x: string]: number; foo: any; } interface I3 { [x: string]: string; foo: any; } interface I4 { [x: string...
{ "end_byte": 1485, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/anyAssignableToEveryType2.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignatures3.ts_0_296
// some complex cases of assignment compat of generic signatures that stress contextual signature instantiation interface I<T, S> { <U>(f: (x: T) => (y: S) => U): U } var g: <T>(x: T) => <S>(y: S) => I<T, S> var h: <T>(x: T) => <S>(y: S) => { <U>(f: (x: T) => (y: S) => U): U } g = h // ok
{ "end_byte": 296, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignatures3.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance3.ts_0_4356
// checking subtype relations for function types as it relates to contextual signature instantiation // error cases module Errors { class Base { foo: string; } class Derived extends Base { bar: string; } class Derived2 extends Derived { baz: string; } class OtherDerived extends Base { bing: string; } ...
{ "end_byte": 4356, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance3.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericContextualTypes1.ts_0_1678
// @strict: true // @declaration: true type Box<T> = { value: T }; declare function wrap<A, B>(f: (a: A) => B): (a: A) => B; declare function compose<A, B, C>(f: (a: A) => B, g: (b: B) => C): (a: A) => C; declare function list<T>(a: T): T[]; declare function unlist<T>(a: T[]): T; declare function box<V>(x: V): Bo...
{ "end_byte": 1678, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericContextualTypes1.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/indexSignatureTypeInference.ts_0_525
interface NumberMap<T> { [index: number]: T; } interface StringMap<T> { [index: string]: T; } declare function numberMapToArray<T>(object: NumberMap<T>): T[]; declare function stringMapToArray<T>(object: StringMap<T>): T[]; var numberMap: NumberMap<Function>; var stringMap: StringMap<Function>; var v1: Func...
{ "end_byte": 525, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/indexSignatureTypeInference.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/bivariantInferences.ts_0_309
// @strict: true // Repro from #27337 interface Array<T> { equalsShallow<T>(this: ReadonlyArray<T>, other: ReadonlyArray<T>): boolean; } declare const a: (string | number)[] | null[] | undefined[] | {}[]; declare const b: (string | number)[] | null[] | undefined[] | {}[]; let x = a.equalsShallow(b);
{ "end_byte": 309, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/bivariantInferences.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments.ts_0_1524
// When a function expression is inferentially typed (section 4.9.3) and a type assigned to a parameter in that expression references type parameters for which inferences are being made, // the corresponding inferred type arguments to become fixed and no further candidate inferences are made for them. function foo<T>...
{ "end_byte": 1524, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithNonSymmetricSubtypes.ts_0_911
// generic type argument inference where inference leads to two candidates that are both supertypes of all candidates // we choose the first candidate so the result is dependent on the order of the arguments provided function foo<T>(x: T, y: T) { var r: T; return r; } var a: { x: number; y?: number; }; var b:...
{ "end_byte": 911, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithNonSymmetricSubtypes.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgs2.ts_0_624
class Base { x: string; } class Derived extends Base { y: string; } class Derived2 extends Base { z: string; } // returns {}[] function f<T extends Base, U extends Base>(a: { x: T; y: U }) { return [a.x, a.y]; } var r = f({ x: new Derived(), y: new Derived2() }); // {}[] var r2 = f({ x: new Base(), y:...
{ "end_byte": 624, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgs2.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectLiteralArgs.ts_0_261
function foo<T>(x: { bar: T; baz: T }) { return x; } var r = foo({ bar: 1, baz: '' }); // error var r2 = foo({ bar: 1, baz: 1 }); // T = number var r3 = foo({ bar: foo, baz: foo }); // T = typeof foo var r4 = foo<Object>({ bar: 1, baz: '' }); // T = Object
{ "end_byte": 261, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectLiteralArgs.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithConstructorTypedArguments5.ts_0_771
// Generic call with parameter of object type with member of function type of n args passed object whose associated member is call signature with n+1 args function foo<T, U>(arg: { cb: new(t: T) => U }) { return new arg.cb(null); } var arg: { cb: new<T>(x: T) => string }; var r = foo(arg); // {} // more args not ...
{ "end_byte": 771, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithConstructorTypedArguments5.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithConstraintsTypeArgumentInference2.ts_0_318
// Generic call with parameters of T and U, U extends T, no parameter of type U function foo<T, U extends T>(t: T) { var u: U; return u; } var r = foo(1); // ok var r2 = foo(null); // {} var r3 = foo(new Object()); // {} var r4 = foo<Date, Date>(1); // error var r5 = foo<Date, Date>(new Date()); // no error
{ "end_byte": 318, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithConstraintsTypeArgumentInference2.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndIndexersErrors.ts_0_521
// Type inference infers from indexers in target type, error cases function foo<T>(x: T) { return x; } function other<T>(arg: T) { var b: { [x: string]: Object; [x: number]: T; // ok, T is a subtype of Object because its apparent type is {} }; var r2 = foo(b); // T } function other3<T...
{ "end_byte": 521, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndIndexersErrors.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithArrayLiteralArgs.ts_0_337
function foo<T>(t: T) { return t; } var r = foo([1, 2]); // number[] var r = foo<number[]>([1, 2]); // number[] var ra = foo<any[]>([1, 2]); // any[] var r2 = foo([]); // any[] var r3 = foo<number[]>([]); // number[] var r4 = foo([1, '']); // {}[] var r5 = foo<any[]>([1, '']); // any[] var r6 = foo<Object[]>([1, '...
{ "end_byte": 337, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithArrayLiteralArgs.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts_3_499
terface I<T, U> { tuple1: [T, U]; } var i1: I<string, number>; var i2: I<{}, {}>; // no error i1.tuple1 = ["foo", 5]; var e1 = i1.tuple1[0]; // string var e2 = i1.tuple1[1]; // number i1.tuple1 = ["foo", 5, false, true]; var e3 = i1.tuple1[2]; // {} i1.tuple1[3] = { a: "string" }; var e4 = i1.tuple1[3]; // {...
{ "end_byte": 499, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/noInferRedeclaration.ts_0_223
// @strict: true // @declaration: true // @target: esnext // @filename: a.ts export const f = <T>(x: T, y: NoInfer<T>) => x; // @filename: b.ts import { f } from "./a"; type NoInfer<T> = T & number; export const g = f;
{ "end_byte": 223, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/noInferRedeclaration.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments2.ts_0_931
// Generic functions used as arguments for function typed parameters are not used to make inferences from // Using construct signature arguments, no errors expected function foo<T>(x: new(a: T) => T) { return new x(null); } interface I { new <T>(x: T): T; } interface I2<T> { new (x: T): T; } var i: I; var...
{ "end_byte": 931, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments2.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints2.ts_0_724
// Generic call with constraints infering type parameter from object member properties // No errors expected class Base { x: string; } class Derived extends Base { y: string; } function f<T extends Base>(x: { foo: T; bar: T }) { var r: T; return r; } var r = f({ foo: new Base(), bar: new Derived() });...
{ "end_byte": 724, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints2.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/unionAndIntersectionInference1.ts_0_1967
// @target: es2015 // Repro from #2264 interface Y { 'i am a very certain type': Y } var y: Y = <Y>undefined; function destructure<a, r>( something: a | Y, haveValue: (value: a) => r, haveY: (value: Y) => r ): r { return something === y ? haveY(y) : haveValue(<a>something); } var value = Math.random(...
{ "end_byte": 1967, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/unionAndIntersectionInference1.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/keyofInferenceLowerPriorityThanReturn.ts_0_1145
// #22736 declare class Write { protected dummy: Write; } declare class Col<s, a> { protected dummy: [Col<s, a>, s, a]; } declare class Table<Req, Def> { protected dummy: [Table<Req, Def>, Req, Def]; } type MakeTable<T1 extends object, T2 extends object> = { [P in keyof T1]: Col<Write, T1[P]>; } & { ...
{ "end_byte": 1145, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/keyofInferenceLowerPriorityThanReturn.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/noInfer.ts_0_2710
// @strict: true // @declaration: true // NoInfer<T> is erased for primitives type T00 = NoInfer<string>; type T01 = NoInfer<string | number | boolean>; type T02 = NoInfer<undefined>; type T03 = NoInfer<"foo">; type T04 = NoInfer<`foo${string}`>; type T05 = NoInfer<`foo${string}` & `${string}bar`>; type T06 = NoInfer...
{ "end_byte": 2710, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/noInfer.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts_0_1792
// Generic functions used as arguments for function typed parameters are not used to make inferences from // Using function arguments, no errors expected module ImmediatelyFix { class C<T> { foo<T>(x: (a: T) => T) { return x(null); } } var c = new C<number>(); var r = c.foo...
{ "end_byte": 1792, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndNumericIndexer.ts_0_735
// Type inference infers from indexers in target type, no errors expected function foo<T>(x: T) { return x; } var a: { [x: number]: Date }; var r = foo(a); function other<T>(arg: T) { var b: { [x: number]: T }; var r2 = foo(b); // T } function other2<T extends Date>(arg: T) { var b: { [x: number]: T...
{ "end_byte": 735, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndNumericIndexer.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints.ts_0_508
// Generic call with constraints infering type parameter from object member properties // No errors expected class C { x: string; } class D { x: string; y: string; } class X<T> { x: T; } function foo<T extends { x: string }>(t: X<T>, t2: X<T>) { var x: T; return x; } var c1 = new X<C>(); va...
{ "end_byte": 508, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments3.ts_0_468
// No inference is made from function typed arguments which have multiple call signatures var a: { (x: boolean): boolean; (x: string): any; } function foo4<T, U>(cb: (x: T) => U) { var u: U; return u; } var r = foo4(a); // T is {} (candidates boolean and string), U is any (candidates any and boolean)...
{ "end_byte": 468, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments3.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints3.ts_0_841
// Generic call with constraints infering type parameter from object member properties class Base { x: string; } class Derived extends Base { y: string; } class Derived2 extends Base { z: string; } function f<T extends Base>(a: { x: T; y: T }) { var r: T; return r; } var r1 = f({ x: new Derived()...
{ "end_byte": 841, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints3.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOverloadedConstructorTypedArguments2.ts_0_1020
// Function typed arguments with multiple signatures must be passed an implementation that matches all of them // Inferences are made quadratic-pairwise to and from these overload sets module NonGenericParameter { var a: { new(x: boolean): boolean; new(x: string): string; } function foo4(c...
{ "end_byte": 1020, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOverloadedConstructorTypedArguments2.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericCallToOverloadedMethodWithOverloadedArguments.ts_1_2545
module m1 { interface Promise<T> { then<U>(cb: (x: T) => Promise<U>): Promise<U>; } declare function testFunction(n: number): Promise<number>; var numPromise: Promise<number>; var newPromise = numPromise.then(testFunction); } ////////////////////////////////////// module m2 { interfa...
{ "end_byte": 2545, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericCallToOverloadedMethodWithOverloadedArguments.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOverloadedFunctionTypedArguments.ts_0_1704
// Function typed arguments with multiple signatures must be passed an implementation that matches all of them // Inferences are made quadratic-pairwise to and from these overload sets module NonGenericParameter { var a: { (x: boolean): boolean; (x: string): string; } function foo4(cb: typ...
{ "end_byte": 1704, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOverloadedFunctionTypedArguments.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/unionAndIntersectionInference3.ts_0_2282
// @strict: true // @target: esnext // Repro from #30720 type Maybe<T> = T | undefined; declare function concatMaybe<T>(...args: (Maybe<T> | Maybe<T>[])[]): T[]; concatMaybe([1, 2, 3], 4); // Repros from #32247 const g: <U, R, S>(com: () => Iterator<S, U, R> | AsyncIterator<S, U, R>) => Promise<U> = async <U, R, S>...
{ "end_byte": 2282, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/unionAndIntersectionInference3.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndStringIndexer.ts_0_787
// Type inference infers from indexers in target type, no errors expected function foo<T>(x: T) { return x; } var a: { [x: string]: Date }; var r = foo(a); function other<T>(arg: T) { var b: { [x: string]: T }; var r2 = foo(b); // T } function other2<T extends Date>(arg: T) { var b: { [x: string]: T...
{ "end_byte": 787, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndStringIndexer.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericFunctionParameters.ts_0_457
// @strict: true // @declaration: true declare function f1<T>(cb: <S>(x: S) => T): T; declare function f2<T>(cb: <S extends number>(x: S) => T): T; declare function f3<T>(cb: <S extends Array<S>>(x: S) => T): T; let x1 = f1(x => x); // {} let x2 = f2(x => x); // number let x3 = f3(x => x); // Array<any> // Repro ...
{ "end_byte": 457, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericFunctionParameters.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments4.ts_0_514
// No inference is made from function typed arguments which have multiple call signatures class C { foo: string } class D { bar: string } var a: { new(x: boolean): C; new(x: string): D; } function foo4<T, U>(cb: new(x: T) => U) { var u: U; return u; } var r = foo4(a); // T is {} (candidates boolean a...
{ "end_byte": 514, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments4.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints4.ts_0_631
// Generic call with constraints infering type parameter from object member properties class C { x: string; } class D { x: string; y: string; } function foo<T, U extends T>(t: T, t2: U) { return (x: T) => t2; } var c: C; var d: D; var r = foo(c, d); var r2 = foo(d, c); // error because C does not ex...
{ "end_byte": 631, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints4.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments5.ts_0_700
// Generic call with parameter of object type with member of function type of n args passed object whose associated member is call signature with n+1 args function foo<T, U>(arg: { cb: (t: T) => U }) { return arg.cb(null); } var arg = { cb: <T>(x: T) => '' }; var r = foo(arg); // {} // more args not allowed var r...
{ "end_byte": 700, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments5.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints5.ts_0_504
// Generic call with constraints infering type parameter from object member properties class C { x: string; } class D { x: string; y: string; } function foo<T, U extends T>(t: T, t2: U) { return (x: T) => t2; } var c: C; var d: D; var r2 = foo(d, c); // the constraints are self-referencing, no downs...
{ "end_byte": 504, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints5.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOverloadedFunctionTypedArguments2.ts_0_961
// Function typed arguments with multiple signatures must be passed an implementation that matches all of them // Inferences are made quadratic-pairwise to and from these overload sets module NonGenericParameter { var a: { (x: boolean): boolean; (x: string): string; } function foo4(cb: typ...
{ "end_byte": 961, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOverloadedFunctionTypedArguments2.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithObjectTypeArgsAndConstraints.ts_0_1184
// Generic call with constraints infering type parameter from object member properties // No errors expected class C { x: string; } class D { x: string; y: string; } class X<T> { x: T; } module Class { class G<T extends { x: string }> { foo<T extends { x: string }>(t: X<T>, t2: X<T>) { ...
{ "end_byte": 1184, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithObjectTypeArgsAndConstraints.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndIndexers.ts_0_370
// Type inference infers from indexers in target type, no errors expected function foo<T>(x: T) { return x; } var a: { [x: string]: Object; [x: number]: Date; }; var r = foo(a); function other<T extends Date>(arg: T) { var b: { [x: string]: Object; [x: number]: T }; var r2 = f...
{ "end_byte": 370, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndIndexers.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/contextualSignatureInstantiation.ts_0_1461
// TypeScript Spec, section 4.12.2: // If e is an expression of a function type that contains exactly one generic call signature and no other members, // and T is a function type with exactly one non - generic call signature and no other members, then any inferences // made for type parameters referenced by the paramet...
{ "end_byte": 1461, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/contextualSignatureInstantiation.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/unionAndIntersectionInference2.ts_0_602
declare function f1<T>(x: T | string): T; var a1: string; var b1: string | string[]; var c1: string[] | string; var d1: string | { name: string }; var e1: number | string | boolean; f1(a1); // string f1(b1); // string[] f1(c1); // string[] f1(d1); // { name: string } f1(e1); // number | boolean declare function f2<T>...
{ "end_byte": 602, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/unionAndIntersectionInference2.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithConstraintsTypeArgumentInference.ts_0_2441
// Basic type inference with generic calls and constraints, no errors expected class Base { foo: string; } class Derived extends Base { bar: string; } class Derived2 extends Derived { baz: string; } var b: Base; var d1: Derived; var d2: Derived2; function foo<T extends Base>(t: T) { return t; } var r = foo(b); /...
{ "end_byte": 2441, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithConstraintsTypeArgumentInference.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/unionTypeInference.ts_0_1986
// @strict: true // @target: esnext declare const b: boolean; declare const s: string; declare const sn: string | number; declare function f1<T>(x: T, y: string | T): T; const a1 = f1(1, 2); // 1 | 2 const a2 = f1(1, "hello"); // 1 const a3 = f1(1, sn); // number const a4 = f1(undefined, "abc"); // undefined con...
{ "end_byte": 1986, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/unionTypeInference.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/discriminatedUnionInference.ts_0_493
// @strict: true // Repro from #28862 type Foo<A> = { type: "foo", (): A[] }; type Bar<A> = { type: "bar", (): A }; type FooBar<A> = Foo<A> | Bar<A>; type InferA<T> = T extends FooBar<infer A> ? A : never; type FooA = InferA<Foo<number>>; // number // Repro from #28862 type Item<T> = { kind: 'a', data: T } | { ...
{ "end_byte": 493, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/discriminatedUnionInference.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts_0_1145
// Generic functions used as arguments for function typed parameters are not used to make inferences from // Using function arguments, no errors expected function foo<T>(x: (a: T) => T) { return x(null); } var r = foo(<U>(x: U) => ''); // {} var r2 = foo<string>(<U>(x: U) => ''); // string var r3 = foo(x => '');...
{ "end_byte": 1145, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments3.ts_0_1479
// When a function expression is inferentially typed (section 4.9.3) and a type assigned to a parameter in that expression references type parameters for which inferences are being made, // the corresponding inferred type arguments to become fixed and no further candidate inferences are made for them. function foo<T>...
{ "end_byte": 1479, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments3.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferencesJsx.tsx_0_1625
// @strict: true // @jsx: react-jsx // @noEmit: true /// <reference path="/.lib/react16.d.ts" /> // repro from #52798 type A = { a: boolean; }; type B = { b: string; }; type C = { c: number; }; type Animations = { [key: string]: { value: number } & ( | ({ kind: "a"; func?(): Partial<A> } & A) | ({...
{ "end_byte": 1625, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferencesJsx.tsx" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgs.ts_0_265
class C { private x: string; } class D { private x: string; } class X<T> { x: T; } function foo<T>(t: X<T>, t2: X<T>) { var x: T; return x; } var c1 = new X<C>(); var d1 = new X<D>(); var r = foo(c1, d1); // error var r2 = foo(c1, c1); // ok
{ "end_byte": 265, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgs.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericContextualTypes3.ts_0_871
// @strict: true // @noEmit: true type LowInfer<T> = T & {}; type PartialAssigner<TContext, TKey extends keyof TContext> = ( context: TContext ) => TContext[TKey]; type PropertyAssigner<TContext> = { [K in keyof TContext]?: PartialAssigner<TContext, K> | TContext[K]; }; type Meta<TContext> = { action: (ctx: T...
{ "end_byte": 871, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericContextualTypes3.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOverloadedConstructorTypedArguments.ts_0_1510
// Function typed arguments with multiple signatures must be passed an implementation that matches all of them // Inferences are made quadratic-pairwise to and from these overload sets module NonGenericParameter { var a: { new(x: boolean): boolean; new(x: string): string; } function foo4(c...
{ "end_byte": 1510, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOverloadedConstructorTypedArguments.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericCallTypeArgumentInference.ts_0_1625
// Basic type inference with generic calls, no errors expected function foo<T>(t: T) { return t; } var r = foo(''); // string function foo2<T, U>(t: T, u: U) { return u; } function foo2b<T, U>(u: U) { var x: T; return x; } var r2 = foo2('', 1); // number var r3 = foo2b(1); // {} class C<T, U> { ...
{ "end_byte": 1625, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericCallTypeArgumentInference.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/keyofInferenceIntersectsResults.ts_0_288
interface X { a: string; b: string; } declare function foo<T = X>(x: keyof T, y: keyof T): T; declare function bar<T>(x: keyof T, y: keyof T): T; const a = foo<X>('a', 'b'); // compiles cleanly const b = foo('a', 'b'); // also clean const c = bar('a', 'b'); // still clean
{ "end_byte": 288, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/keyofInferenceIntersectsResults.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericContextualTypes2.ts_0_879
// @strict: true // @noEmit: true type LowInfer<T> = T & {}; type PartialAssigner<TContext, TKey extends keyof TContext> = ( context: TContext ) => TContext[TKey]; type PropertyAssigner<TContext> = { [K in keyof TContext]?: PartialAssigner<TContext, K> | TContext[K]; }; type Meta<TContext> = { action: (ctx: T...
{ "end_byte": 879, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericContextualTypes2.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferences.ts_0_5982
// @strict: true // @declaration: true // Repros from #47599 declare function callIt<T>(obj: { produce: (n: number) => T, consume: (x: T) => void }): void; callIt({ produce: () => 0, consume: n => n.toFixed() }); callIt({ produce: _a => 0, consume: n => n.toFixed(), }); callIt({ produce...
{ "end_byte": 5982, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferences.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferences.ts_5984_6478
const resOnion2 = onion2({ a: (arg) => [arg], nested: { b: (arg) => arg.join(","), c: (arg) => Number(arg), nested2: { d: (arg) => Boolean(arg), }, }, }); declare function distant<T>(args: { foo: { bar: { baz: { producer: (arg: string) => T; }; }; }; consum...
{ "end_byte": 6478, "start_byte": 5984, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferences.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts_0_2068
// When a function expression is inferentially typed (section 4.9.3) and a type assigned to a parameter in that expression references type parameters for which inferences are being made, // the corresponding inferred type arguments to become fixed and no further candidate inferences are made for them. module onlyT { ...
{ "end_byte": 2068, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtyping.ts_0_721
// subtype checks use the apparent type of the target type // S is a subtype of a type T, and T is a supertype of S, if one of the following is true, where S' denotes the apparent type (section 3.8.1) of S: class Base<U extends String> { x: U; } // is String (S) a subtype of U extends String (T)? Would only be tr...
{ "end_byte": 721, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtyping.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSupertype.ts_0_415
// subtype checks use the apparent type of the target type // S is a subtype of a type T, and T is a supertype of S, if one of the following is true, where S' denotes the apparent type (section 3.8.1) of S: class Base { x: string; } // is String (S) a subtype of U extends String (T)? Would only be true if we used...
{ "end_byte": 415, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSupertype.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/instanceOf/narrowingGenericTypeFromInstanceof01.ts_0_385
class A<T> { constructor(private a: string) { } } class B<T> { } function acceptA<T>(a: A<T>) { } function acceptB<T>(b: B<T>) { } function test<T>(x: A<T> | B<T>) { if (x instanceof B) { acceptA(x); } if (x instanceof A) { acceptA(x); } if (x instanceof B) { acceptB...
{ "end_byte": 385, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/instanceOf/narrowingGenericTypeFromInstanceof01.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/instanceOf/narrowingConstrainedTypeVariable.ts_0_564
// @strict: true // Repro from #20138 class C { } function f1<T extends C>(v: T | string): void { if (v instanceof C) { const x: T = v; } else { const s: string = v; } } class D { } function f2<T extends C, U extends D>(v: T | U) { if (v instanceof C) { const x: T = v; ...
{ "end_byte": 564, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/instanceOf/narrowingConstrainedTypeVariable.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer.ts_0_752
// Derived type indexer must be subtype of base type indexer interface Base { foo: string; } interface Derived extends Base { bar: string; } interface Derived2 extends Derived { baz: string; } class A { [x: string]: Base; } class B extends A { [x: string]: Derived; // ok } class B2 extends A { [x: strin...
{ "end_byte": 752, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersOptionality4.ts_0_514
// Base has required property, derived adds an optional property, no errors interface Base { foo: string; } interface Derived extends Base { bar: string; } interface T { Foo: Base; } interface S extends T { Foo2?: Derived // ok } interface T2 { 1: Base; } interface S2 extends T2 { 2?: Derived; // ...
{ "end_byte": 514, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersOptionality4.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers5.ts_0_1054
interface Base { foo: string; } interface Derived extends Base { bar: string; } // N and M have the same name, same accessibility, same optionality, and N is a subtype of M // foo properties are valid, bar properties cause errors in the derived class declarations module NotOptional { interface A { ...
{ "end_byte": 1054, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers5.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer3.ts_0_860
// Derived type indexer must be subtype of base type indexer interface Base { foo: string; } interface Derived extends Base { bar: string; } interface Derived2 extends Derived { baz: string; } class A { [x: string]: Derived; } class B extends A { [x: string]: Base; // error } class B2 extends A { [x: st...
{ "end_byte": 860, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer3.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersOptionality.ts_0_1600
// Derived member is not optional but base member is, should be ok interface Base { foo: string; } interface Derived extends Base { bar: string; } interface Derived2 extends Derived { baz: string; } // S is a subtype of a type T, and T is a supertype of S, if one of the following is true, where S' denotes the apparen...
{ "end_byte": 1600, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersOptionality.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts_0_1394
enum E { e1, e2 } interface I8 { [x: string]: number[]; } class A { foo: number; } class A2<T> { foo: T; } function f() { } module f { export var bar = 1; } class c { baz: string } module c { export var bar = 1; } // A type T is a subtype of a union type U if T is a subtype of any type in U. interface I1<T> { [x: ...
{ "end_byte": 1394, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers4.ts_0_400
// subtyping when property names do not match class Base { foo: string; } class Derived extends Base { bar: string; } class A { foo: Base; } class B extends A { fooo: Derived; // ok, inherits foo } class A2 { 1: Base; } class B2 extends A2 { 1.1: Derived; // ok, inherits 1 } class A3 { ...
{ "end_byte": 400, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers4.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer2.ts_0_896
// Derived type indexer must be subtype of base type indexer interface Base { foo: string; } interface Derived extends Base { bar: string; } interface Derived2 extends Derived { baz: string; } interface A { [x: string]: Derived; } interface B extends A { [x: string]: Base; // error } interface B2 extends A ...
{ "end_byte": 896, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer2.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts_0_6074
// call signatures in derived types must have the same or fewer optional parameters as the base type module ClassTypeParam { interface Base<T> { a: () => T; a2: (x?: T) => T; a3: (x: T) => T; a4: (x: T, y?: T) => T; a5: (x?: T, y?: T) => T; } interface I1<T> extends...
{ "end_byte": 6074, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts_0_3666
// checking whether other types are subtypes of type parameters with constraints class Foo<T> { foo: T; } function f<T extends Foo<U>, U extends Foo<T>, V extends Foo<V>>(t: T, u: U, v: V) { // ok var r1 = true ? t : u; var r1 = true ? u : t; // ok var r2 = true ? t : v; var r2 = true ? v : t;...
{ "end_byte": 3666, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer2.ts_0_896
// Derived type indexer must be subtype of base type indexer interface Base { foo: string; } interface Derived extends Base { bar: string; } interface Derived2 extends Derived { baz: string; } interface A { [x: number]: Derived; } interface B extends A { [x: number]: Base; // error } interface B2 extends A ...
{ "end_byte": 896, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer2.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts_0_1128
class Base { foo: string; } class Derived extends Base { bar: string; } class Derived2 extends Derived { baz: string; } // N and M have the same name, same accessibility, same optionality, and N is a subtype of M // foo properties are valid, bar properties cause errors in the derived class declarations class A { f...
{ "end_byte": 1128, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignatures3.ts_0_4928
// checking subtype relations for function types as it relates to contextual signature instantiation // error cases, so function calls will all result in 'any' module Errors { class Base { foo: string; } class Derived extends Base { bar: string; } class Derived2 extends Derived { baz: string; } class O...
{ "end_byte": 4928, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignatures3.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersAccessibility.ts_0_426
// Derived member is private, base member is not causes errors class Base { foo: string; } class Derived extends Base { bar: string; } class A { public foo: Base; } class B extends A { private foo: Derived; // error } class A2 { public 1: Base; } class B2 extends A2 { private 1: Derived; ...
{ "end_byte": 426, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersAccessibility.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignaturesWithSpecializedSignatures.ts_0_2008
// same as subtypingWithCallSignatures but with additional specialized signatures that should not affect the results module CallSignature { interface Base { // T // M's new (x: 'a'): void; new (x: string, y: number): void; } // S's interface I extends Base { // N's ...
{ "end_byte": 2008, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignaturesWithSpecializedSignatures.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignatures2.ts_0_5425
// checking subtype relations for function types as it relates to contextual signature instantiation class Base { foo: string; } class Derived extends Base { bar: string; } class Derived2 extends Derived { baz: string; } class OtherDerived extends Base { bing: string; } declare function foo1(a: new (x: number) => num...
{ "end_byte": 5425, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignatures2.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignatures2.ts_5426_6330
var r12arg2: new (x: Array<Base>, y: Array<Derived2>) => Array<Derived>; var r12 = foo12(r12arg1); // any var r12a = [r12arg1, r12arg2]; var r12b = [r12arg2, r12arg1]; var r13arg1: new <T extends Array<Derived>>(x: Array<Base>, y: T) => T; var r13arg2: new (x: Array<Base>, y: Array<Derived>) => Array<Derived>; var r13...
{ "end_byte": 6330, "start_byte": 5426, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignatures2.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts_0_1557
// checking whether other types are subtypes of type parameters with constraints class Foo { foo: number; } function f<T extends Foo, U extends Foo, V>(t: T, u: U, v: V) { // ok var r = true ? t : u; var r = true ? u : t; // ok var r2 = true ? t : v; var r2 = true ? v : t; // ok var r...
{ "end_byte": 1557, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithCallSignatures4.ts_0_3352
// checking subtype relations for function types as it relates to contextual signature instantiation class Base { foo: string; } class Derived extends Base { bar: string; } class Derived2 extends Derived { baz: string; } class OtherDerived extends Base { bing: string; } declare function foo1(a: <T>(x: T) => T[]); dec...
{ "end_byte": 3352, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithCallSignatures4.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignatures6.ts_0_1329
// checking subtype relations for function types as it relates to contextual signature instantiation // same as subtypingWithConstructSignatures4 but using class type parameters instead of generic signatures // all are errors class Base { foo: string; } class Derived extends Base { bar: string; } class Derived2 extend...
{ "end_byte": 1329, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignatures6.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer3.ts_0_860
// Derived type indexer must be subtype of base type indexer interface Base { foo: string; } interface Derived extends Base { bar: string; } interface Derived2 extends Derived { baz: string; } class A { [x: number]: Derived; } class B extends A { [x: number]: Base; // error } class B2 extends A { [x: nu...
{ "end_byte": 860, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer3.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithCallSignatures3.ts_0_4768
// checking subtype relations for function types as it relates to contextual signature instantiation // error cases, so function calls will all result in 'any' module Errors { class Base { foo: string; } class Derived extends Base { bar: string; } class Derived2 extends Derived { baz: string; } class O...
{ "end_byte": 4768, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithCallSignatures3.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts_0_1454
// enums are only subtypes of number, any and no other types enum E { A } interface I { [x: string]: any; foo: E; // ok } interface I2 { [x: string]: number; foo: E; // ok } // error cases interface I3 { [x: string]: string; foo: E; } interface I4 { [x: string]: boolean; foo: E; } ...
{ "end_byte": 1454, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts_0_2313
enum e { e1, e2 } // A union type U is a subtype of a type T if each type in U is a subtype of T interface I { [x: string]: any; foo: string | number; // ok foo2: e | number; // ok } interface I2 { [x: string]: number; // S is union type and each constituent type of S is a subtype of T ...
{ "end_byte": 2313, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersAccessibility2.ts_0_881
// Derived member is private, base member is not causes errors class Base { foo: string; } class Derived extends Base { bar: string; } module ExplicitPublic { class A { private foo: Base; } class B extends A { public foo: Derived; // error } class A2 { private 1:...
{ "end_byte": 881, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersAccessibility2.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer4.ts_0_540
// Derived type indexer must be subtype of base type indexer interface Base { foo: string; } interface Derived extends Base { bar: string; } interface Derived2 extends Derived { baz: string; } class A { [x: number]: Derived; } class B extends A { [x: number]: string; // error } module Generics { class A...
{ "end_byte": 540, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer4.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/nullIsSubtypeOfEverythingButUndefined.ts_0_1895
// null is a subtype of any other types except undefined var r0 = true ? null : null; var r0 = true ? null : null; var u: typeof undefined; var r0b = true ? u : null; var r0b = true ? null : u; var r1 = true ? 1 : null; var r1 = true ? null : 1; var r2 = true ? '' : null; var r2 = true ? null : ''; var r3 = true ?...
{ "end_byte": 1895, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/nullIsSubtypeOfEverythingButUndefined.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer.ts_0_763
// Derived type indexer must be subtype of base type indexer interface Base { foo: string; } interface Derived extends Base { bar: string; } interface Derived2 extends Derived { baz: string; } class A { [x: number]: Base; } class B extends A { [x: number]: Derived; // ok } class B2 extends A { [x: numbe...
{ "end_byte": 763, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer.ts" }
TypeScript/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithCallSignaturesWithRestParameters.ts_0_3344
// call signatures in derived types must have the same or fewer optional parameters as the base type interface Base { a: (...args: number[]) => number; a2: (x: number, ...z: number[]) => number; a3: (x: number, y?: string, ...z: number[]) => number; a4: (x?: number, y?: string, ...z: number[]) => numb...
{ "end_byte": 3344, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithCallSignaturesWithRestParameters.ts" }