file_path
stringlengths
3
280
file_language
stringclasses
66 values
content
stringlengths
1
1.04M
repo_name
stringlengths
5
92
repo_stars
int64
0
154k
repo_description
stringlengths
0
402
repo_primary_language
stringclasses
108 values
developer_username
stringlengths
1
25
developer_name
stringlengths
0
30
developer_company
stringlengths
0
82
crates/swc_ecma_parser/tests/tsc/subtypingWithConstructSignatures2.ts
TypeScript
// 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) => number[]): typeof a; declare function foo1(a: any): any; declare function foo2(a: new (x: number) => string[]): typeof a; declare function foo2(a: any): any; declare function foo3(a: new (x: number) => void): typeof a; declare function foo3(a: any): any; declare function foo4(a: new (x: string, y: number) => string): typeof a; declare function foo4(a: any): any; declare function foo5(a: new (x: new (arg: string) => number) => string): typeof a; declare function foo5(a: any): any; declare function foo6(a: new (x: new (arg: Base) => Derived) => Base): typeof a; declare function foo6(a: any): any; declare function foo7(a: new (x: new (arg: Base) => Derived) => new (r: Base) => Derived): typeof a; declare function foo7(a: any): any; declare function foo8(a: new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived): typeof a; declare function foo8(a: any): any; declare function foo9(a: new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived): typeof a; declare function foo9(a: any): any; declare function foo10(a: new (...x: Derived[]) => Derived): typeof a; declare function foo10(a: any): any; declare function foo11(a: new (x: { foo: string }, y: { foo: string; bar: string }) => Base): typeof a; declare function foo11(a: any): any; declare function foo12(a: new (x: Array<Base>, y: Array<Derived2>) => Array<Derived>): typeof a; declare function foo12(a: any): any; declare function foo13(a: new (x: Array<Base>, y: Array<Derived>) => Array<Derived>): typeof a; declare function foo13(a: any): any; declare function foo14(a: new (x: { a: string; b: number }) => Object): typeof a; declare function foo14(a: any): any; declare function foo15(a: { new (x: number): number[]; new (x: string): string[]; }): typeof a; declare function foo15(a: any): any; declare function foo16(a: { new <T extends Derived>(x: T): number[]; new <U extends Base>(x: U): number[]; }): typeof a; declare function foo16(a: any): any; declare function foo17(a: { new (x: (a: number) => number): number[]; new (x: (a: string) => string): string[]; }): typeof a; declare function foo17(a: any): any; declare function foo18(a: { new (x: { new (a: number): number; new (a: string): string; }): any[]; new (x: { new (a: boolean): boolean; new (a: Date): Date; }): any[]; }): typeof a; declare function foo18(a: any): any; var r1arg1: new <T>(x: T) => T[]; var r1arg2: new (x: number) => number[]; var r1 = foo1(r1arg1); // any, return types are not subtype of first overload var r1a = [r1arg2, r1arg1]; // generic signature, subtype in both directions var r1b = [r1arg1, r1arg2]; // generic signature, subtype in both directions var r2arg1: new <T>(x: T) => string[]; var r2arg2: new (x: number) => string[]; var r2 = foo2(r2arg1); var r2a = [r2arg1, r2arg2]; var r2b = [r2arg2, r2arg1]; var r3arg1: new <T>(x: T) => T; var r3arg2: new (x: number) => void; var r3 = foo3(r3arg1); var r3a = [r3arg1, r3arg2]; var r3b = [r3arg2, r3arg1]; var r4arg1: new <T, U>(x: T, y: U) => T; var r4arg2: new (x: string, y: number) => string; var r4 = foo4(r4arg1); // any var r4a = [r4arg1, r4arg2]; var r4b = [r4arg2, r4arg1]; var r5arg1: new <T, U>(x: new (arg: T) => U) => T; var r5arg2: new (x: new (arg: string) => number) => string; var r5 = foo5(r5arg1); // any var r5a = [r5arg1, r5arg2]; var r5b = [r5arg2, r5arg1]; var r6arg1: new <T extends Base, U extends Derived>(x: new (arg: T) => U) => T; var r6arg2: new (x: new (arg: Base) => Derived) => Base; var r6 = foo6(r6arg1); // any var r6a = [r6arg1, r6arg2]; var r6b = [r6arg2, r6arg1]; var r7arg1: new <T extends Base, U extends Derived>(x: new (arg: T) => U) => new (r: T) => U; var r7arg2: new (x: new (arg: Base) => Derived) => new (r: Base) => Derived; var r7 = foo7(r7arg1); // any var r7a = [r7arg1, r7arg2]; var r7b = [r7arg2, r7arg1]; var r8arg1: new <T extends Base, U extends Derived>(x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U; var r8arg2: new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived; var r8 = foo8(r8arg1); // any var r8a = [r8arg1, r8arg2]; var r8b = [r8arg2, r8arg1]; var r9arg1: new <T extends Base, U extends Derived>(x: new (arg: T) => U, y: (arg2: { foo: string; bing: number }) => U) => new (r: T) => U; var r9arg2: new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived; var r9 = foo9(r9arg1); // any var r9a = [r9arg1, r9arg2]; var r9b = [r9arg2, r9arg1]; var r10arg1: new <T extends Derived>(...x: T[]) => T; var r10arg2: new (...x: Derived[]) => Derived; var r10 = foo10(r10arg1); // any var r10a = [r10arg1, r10arg2]; var r10b = [r10arg2, r10arg1]; var r11arg1: new <T extends Base>(x: T, y: T) => T; var r11arg2: new (x: { foo: string }, y: { foo: string; bar: string }) => Base; var r11 = foo11(r11arg1); // any var r11a = [r11arg1, r11arg2]; var r11b = [r11arg2, r11arg1]; var r12arg1: new <T extends Array<Base>>(x: Array<Base>, y: T) => Array<Derived>; 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 = foo13(r13arg1); // any var r13a = [r13arg1, r13arg2]; var r13b = [r13arg2, r13arg1]; var r14arg1: new <T>(x: { a: T; b: T }) => T; var r14arg2: new (x: { a: string; b: number }) => Object; var r14 = foo14(r14arg1); // any var r14a = [r14arg1, r14arg2]; var r14b = [r14arg2, r14arg1]; var r15arg1: new <T>(x: T) => T[]; var r15 = foo15(r15arg1); // any var r16arg1: new <T extends Base>(x: T) => number[]; var r16 = foo16(r16arg1); var r17arg1: new <T>(x: (a: T) => T) => T[]; var r17 = foo17(r17arg1); // any var r18arg1: new <T>(x: (a: T) => T) => T[]; var r18 = foo18(r18arg1);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithConstructSignatures3.ts
TypeScript
// 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 OtherDerived extends Base { bing: string; } declare function foo2(a2: new (x: number) => string[]): typeof a2; declare function foo2(a2: any): any; declare function foo7(a2: new (x: new (arg: Base) => Derived) => new (r: Base) => Derived2): typeof a2; declare function foo7(a2: any): any; declare function foo8(a2: new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived): typeof a2; declare function foo8(a2: any): any; declare function foo10(a2: new (...x: Base[]) => Base): typeof a2; declare function foo10(a2: any): any; declare function foo11(a2: new (x: { foo: string }, y: { foo: string; bar: string }) => Base): typeof a2; declare function foo11(a2: any): any; declare function foo12(a2: new (x: Array<Base>, y: Array<Derived2>) => Array<Derived>): typeof a2; declare function foo12(a2: any): any; declare function foo15(a2: new (x: { a: string; b: number }) => number): typeof a2; declare function foo15(a2: any): any; declare function foo16(a2: { // type of parameter is overload set which means we can't do inference based on this type new (x: { new (a: number): number; new (a?: number): number; }): number[]; new (x: { new (a: boolean): boolean; new (a?: boolean): boolean; }): boolean[]; }): typeof a2; declare function foo16(a2: any): any; declare function foo17(a2: { new (x: { new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }): any[]; new (x: { new <T extends Derived2>(a: T): T; new <T extends Base>(a: T): T; }): any[]; }): typeof a2; declare function foo17(a2: any): any; var r1arg1: new <T, U>(x: T) => U[]; var r1arg2: new (x: number) => string[]; var r1 = foo2(r1arg1); // any var r1a = [r1arg2, r1arg1]; var r1b = [r1arg1, r1arg2]; var r2arg1: new <T extends Base, U extends Derived, V extends Derived2>(x: new (arg: T) => U) => new (r: T) => V; var r2arg2: new (x: new (arg: Base) => Derived) => new (r: Base) => Derived2; var r2 = foo7(r2arg1); // any var r2a = [r2arg2, r2arg1]; var r2b = [r2arg1, r2arg2]; var r3arg1: new <T extends Base, U extends Derived>(x: new (arg: T) => U, y: (arg2: { foo: number; }) => U) => new (r: T) => U; var r3arg2: new (x: (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived; var r3 = foo8(r3arg1); // any var r3a = [r3arg2, r3arg1]; var r3b = [r3arg1, r3arg2]; var r4arg1: new <T extends Derived>(...x: T[]) => T; var r4arg2: new (...x: Base[]) => Base; var r4 = foo10(r4arg1); // any var r4a = [r4arg2, r4arg1]; var r4b = [r4arg1, r4arg2]; var r5arg1: new <T extends Derived>(x: T, y: T) => T; var r5arg2: new (x: { foo: string }, y: { foo: string; bar: string }) => Base; var r5 = foo11(r5arg1); // any var r5a = [r5arg2, r5arg1]; var r5b = [r5arg1, r5arg2]; var r6arg1: new (x: Array<Base>, y: Array<Derived2>) => Array<Derived>; var r6arg2: new <T extends Array<Derived2>>(x: Array<Base>, y: Array<Base>) => T; var r6 = foo12(r6arg1); // new (x: Array<Base>, y: Array<Derived2>) => Array<Derived> var r6a = [r6arg2, r6arg1]; var r6b = [r6arg1, r6arg2]; var r7arg1: new <T>(x: { a: T; b: T }) => T; var r7arg2: new (x: { a: string; b: number }) => number; var r7 = foo15(r7arg1); // (x: { a: string; b: number }) => number): number; var r7a = [r7arg2, r7arg1]; var r7b = [r7arg1, r7arg2]; var r7arg3: new <T extends Base>(x: { a: T; b: T }) => number; var r7c = foo15(r7arg3); // any var r7d = [r7arg2, r7arg3]; var r7e = [r7arg3, r7arg2]; var r8arg: new <T>(x: new (a: T) => T) => T[]; var r8 = foo16(r8arg); // any var r9arg: new <T>(x: new (a: T) => T) => any[]; var r9 = foo17(r9arg); // // (x: { <T extends Derived >(a: T): T; <T extends Base >(a: T): T; }): any[]; (x: { <T extends Derived2>(a: T): T; <T extends Base>(a: T): T; }): any[]; } module WithGenericSignaturesInBaseType { declare function foo2(a2: new <T>(x: T) => T[]): typeof a2; declare function foo2(a2: any): any; var r2arg2: new <T>(x: T) => string[]; var r2 = foo2(r2arg2); // <T>(x:T) => T[] since we can infer from generic signatures now declare function foo3(a2: new <T>(x: T) => string[]): typeof a2; declare function foo3(a2: any): any; var r3arg2: new <T>(x: T) => T[]; var r3 = foo3(r3arg2); // any }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithConstructSignatures4.ts
TypeScript
// 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 <T>(x: T) => T[]); declare function foo1(a: any): any; declare function foo2(a2: new <T>(x: T) => string[]); declare function foo2(a: any): any; declare function foo3(a3: new <T>(x: T) => void); declare function foo3(a: any): any; declare function foo4(a4: new <T, U>(x: T, y: U) => string); declare function foo4(a: any): any; declare function foo5(a5: new <T, U>(x: new (arg: T) => U) => T); declare function foo5(a: any): any; declare function foo6(a6: new <T extends Base>(x: new (arg: T) => Derived) => T); declare function foo6(a: any): any; declare function foo11(a11: new <T>(x: { foo: T }, y: { foo: T; bar: T }) => Base); declare function foo11(a: any): any; declare function foo15(a15: new <T>(x: { a: T; b: T }) => T[]); declare function foo15(a: any): any; declare function foo16(a16: new <T extends Base>(x: { a: T; b: T }) => T[]); declare function foo16(a: any): any; declare function foo17(a17: { new <T extends Derived>(x: new (a: T) => T): T[]; new <T extends Base>(x: new (a: T) => T): T[]; }); declare function foo17(a: any): any; declare function foo18(a18: { new (x: { new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }): any[]; new (x: { new <T extends Derived2>(a: T): T; new <T extends Base>(a: T): T; }): any[]; }); declare function foo18(a: any): any; var r1arg: new <T>(x: T) => T[]; var r1arg2: new <T>(x: T) => T[]; var r1 = foo1(r1arg); var r1a = [r1arg, r1arg2]; var r1b = [r1arg2, r1arg]; var r2arg: new <T>(x: T) => string[]; var r2arg2: new <T>(x: T) => string[]; var r2 = foo2(r2arg); var r2a = [r2arg, r2arg2]; var r2b = [r2arg2, r2arg]; var r3arg: new <T>(x: T) => T; var r3arg2: new <T>(x: T) => void; var r3 = foo3(r3arg); var r3a = [r3arg, r3arg2]; var r3b = [r3arg2, r3arg]; var r4arg: new <T, U>(x: T, y: U) => string; var r4arg2: new <T, U>(x: T, y: U) => string; var r4 = foo4(r4arg); var r4a = [r4arg, r4arg2]; var r4b = [r4arg2, r4arg]; var r5arg: new <T, U>(x: new (arg: T) => U) => T; var r5arg2: new <T, U>(x: new (arg: T) => U) => T; var r5 = foo5(r5arg); var r5a = [r5arg, r5arg2]; var r5b = [r5arg2, r5arg]; var r6arg: new <T extends Base, U extends Derived>(x: new (arg: T) => U) => T; var r6arg2: new <T extends Base>(x: new (arg: T) => Derived) => T; var r6 = foo6(r6arg); var r6a = [r6arg, r6arg2]; var r6b = [r6arg2, r6arg]; var r11arg: new <T, U>(x: { foo: T }, y: { foo: U; bar: U }) => Base; var r11arg2: new <T>(x: { foo: T }, y: { foo: T; bar: T }) => Base; var r11 = foo11(r11arg); var r11a = [r11arg, r11arg2]; var r11b = [r11arg2, r11arg]; var r15arg: new <U, V>(x: { a: U; b: V; }) => U[]; var r15arg2: new <T>(x: { a: T; b: T }) => T[]; var r15 = foo15(r15arg); var r15a = [r15arg, r15arg2]; var r15b = [r15arg2, r15arg]; var r16arg: new <T extends Base>(x: { a: T; b: T }) => T[]; var r16arg2: new <T extends Base>(x: { a: T; b: T }) => T[]; var r16 = foo16(r16arg); var r16a = [r16arg, r16arg2]; var r16b = [r16arg2, r16arg]; var r17arg: new <T>(x: new (a: T) => T) => T[]; var r17 = foo17(r17arg); var r18arg: new (x: new <T>(a: T) => T) => any[]; var r18 = foo18(r18arg);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithConstructSignatures5.ts
TypeScript
// checking subtype relations for function types as it relates to contextual signature instantiation // same as subtypingWithConstructSignatures2 just with an extra level of indirection in the inheritance chain 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: number) => number[]; a2: new (x: number) => string[]; a3: new (x: number) => void; a4: new (x: string, y: number) => string; a5: new (x: (arg: string) => number) => string; a6: new (x: (arg: Base) => Derived) => Base; a7: new (x: (arg: Base) => Derived) => (r: Base) => Derived; a8: new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived; a9: new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived; a10: new (...x: Derived[]) => Derived; a11: new (x: { foo: string }, y: { foo: string; bar: string }) => Base; a12: new (x: Array<Base>, y: Array<Derived2>) => Array<Derived>; a13: new (x: Array<Base>, y: Array<Derived>) => Array<Derived>; a14: new (x: { a: string; b: number }) => Object; } interface B extends A { a: new <T>(x: T) => T[]; } // S's interface I extends B { // N's a: new <T>(x: T) => T[]; // ok, instantiation of N is a subtype of M, T is number a2: new <T>(x: T) => string[]; // ok a3: new <T>(x: T) => T; // ok since Base returns void a4: new <T, U>(x: T, y: U) => T; // ok, instantiation of N is a subtype of M, T is string, U is number a5: new <T, U>(x: (arg: T) => U) => T; // ok, U is in a parameter position so inferences can be made a6: new <T extends Base, U extends Derived>(x: (arg: T) => U) => T; // ok, same as a5 but with object type hierarchy a7: new <T extends Base, U extends Derived>(x: (arg: T) => U) => (r: T) => U; // ok a8: new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U; // ok a9: new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: string; bing: number }) => U) => (r: T) => U; // ok, same as a8 with compatible object literal a10: new <T extends Derived>(...x: T[]) => T; // ok a11: new <T extends Base>(x: T, y: T) => T; // ok a12: new <T extends Array<Base>>(x: Array<Base>, y: T) => Array<Derived>; // ok, less specific parameter type a13: new <T extends Array<Derived>>(x: Array<Base>, y: T) => T; // ok, T = Array<Derived>, satisfies constraint, contextual signature instantiation succeeds a14: new <T, U>(x: { a: T; b: U }) => T; // ok }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithConstructSignatures6.ts
TypeScript
// 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 extends Derived { baz: string; } class OtherDerived extends Base { bing: string; } interface A { // T // M's a: new <T>(x: T) => T[]; a2: new <T>(x: T) => string[]; a3: new <T>(x: T) => void; a4: new <T, U>(x: T, y: U) => string; a5: new <T, U>(x: (arg: T) => U) => T; a6: new <T extends Base>(x: (arg: T) => Derived) => T; a11: new <T>(x: { foo: T }, y: { foo: T; bar: T }) => Base; a15: new <T>(x: { a: T; b: T }) => T[]; a16: new <T extends Base>(x: { a: T; b: T }) => T[]; } // S's interface I<T> extends A { a: new (x: T) => T[]; } interface I2<T> extends A { a2: new (x: T) => string[]; } interface I3<T> extends A { a3: new (x: T) => T; } interface I4<T> extends A { a4: new <U>(x: T, y: U) => string; } interface I5<T> extends A { a5: new <U>(x: (arg: T) => U) => T; } interface I7<T> extends A { a11: new <U>(x: { foo: T }, y: { foo: U; bar: U }) => Base; } interface I9<T> extends A { a16: new (x: { a: T; b: T }) => T[]; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithConstructSignaturesWithOptionalParameters.ts
TypeScript
// call signatures in derived types must have the same or fewer optional parameters as the base type interface Base { a: new () => number; a2: new (x?: number) => number; a3: new (x: number) => number; a4: new (x: number, y?: number) => number; a5: new (x?: number, y?: number) => number; } interface I1 extends Base { a: new () => number; // ok, same number of required params } interface I2 extends Base { a: new (x?: number) => number; // ok, same number of required params } interface I3 extends Base { a: new (x: number) => number; // error, too many required params } interface I4 extends Base { a2: new () => number; // ok, same number of required params } interface I5 extends Base { a2: new (x?: number) => number; // ok, same number of required params } interface I6 extends Base { a2: new (x: number) => number; // ok, same number of params } interface I7 extends Base { a3: new () => number; // ok, fewer required params } interface I8 extends Base { a3: new (x?: number) => number; // ok, fewer required params } interface I9 extends Base { a3: new (x: number) => number; // ok, same number of required params } interface I10 extends Base { a3: new (x: number, y: number) => number; // error, too many required params } interface I11 extends Base { a4: new () => number; // ok, fewer required params } interface I12 extends Base { a4: new (x?: number, y?: number) => number; // ok, fewer required params } interface I13 extends Base { a4: new (x: number) => number; // ok, same number of required params } interface I14 extends Base { a4: new (x: number, y: number) => number; // ok, same number of params } interface I15 extends Base { a5: new () => number; // ok, fewer required params } interface I16 extends Base { a5: new (x?: number, y?: number) => number; // ok, fewer required params } interface I17 extends Base { a5: new (x: number) => number; // ok, all present params match } interface I18 extends Base { a5: new (x: number, y: number) => number; // ok, same number of params }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithConstructSignaturesWithSpecializedSignatures.ts
TypeScript
// 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 new (x: 'a'): number; // ok because base returns void new (x: string, y: number): number; // ok because base returns void new <T>(x: T): string; // ok because base returns void } interface Base2 { // T // M's new (x: 'a'): number; new (x: string): number; } // S's interface I2 extends Base2 { // N's new (x: 'a'): string; new (x: string): string; // error because base returns non-void; } // S's interface I3 extends Base2 { // N's new <T>(x: T): string; // ok, adds a new call signature } } module MemberWithCallSignature { interface Base { // T // M's a: { new (x: 'a'): void; new (x: string): void; } a2: { new (x: 'a', y: number): void; new (x: string, y: number): void; } a3: new <T>(x: T) => void; } // S's interface I extends Base { // N's a: new (x: string) => number; // ok because base returns void a2: new (x: string, y: number) => boolean; // ok because base returns void a3: new <T>(x: T) => string; // ok because base returns void } interface Base2 { // T // M's a: { new (x: 'a'): number; new (x: string): number; } a2: new <T>(x: T) => T; } // S's interface I2 extends Base2 { // N's a: new (x: string) => string; // error because base returns non-void; } // S's interface I3 extends Base2 { // N's a2: new <T>(x: T) => string; // error because base returns non-void; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithGenericCallSignaturesWithOptionalParameters.ts
TypeScript
// 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 Base<T> { a: () => T; // ok, same T of required params } interface I2<T> extends Base<T> { a: (x?: T) => T; // ok, same T of required params } interface I3<T> extends Base<T> { a: (x: T) => T; // error, too many required params } interface I4<T> extends Base<T> { a2: () => T; // ok, same T of required params } interface I5<T> extends Base<T> { a2: (x?: T) => T; // ok, same T of required params } interface I6<T> extends Base<T> { a2: (x: T) => T; // ok, same number of params } interface I7<T> extends Base<T> { a3: () => T; // ok, fewer required params } interface I8<T> extends Base<T> { a3: (x?: T) => T; // ok, fewer required params } interface I9<T> extends Base<T> { a3: (x: T) => T; // ok, same T of required params } interface I10<T> extends Base<T> { a3: (x: T, y: T) => T; // error, too many required params } interface I11<T> extends Base<T> { a4: () => T; // ok, fewer required params } interface I12<T> extends Base<T> { a4: (x?: T, y?: T) => T; // ok, fewer required params } interface I13<T> extends Base<T> { a4: (x: T) => T; // ok, same T of required params } interface I14<T> extends Base<T> { a4: (x: T, y: T) => T; // ok, same number of params } interface I15<T> extends Base<T> { a5: () => T; // ok, fewer required params } interface I16<T> extends Base<T> { a5: (x?: T, y?: T) => T; // ok, fewer required params } interface I17<T> extends Base<T> { a5: (x: T) => T; // ok, all present params match } interface I18<T> extends Base<T> { a5: (x: T, y: T) => T; // ok, same number of params } } module GenericSignaturesInvalid { // all of these are errors interface Base2 { a: <T>() => T; a2: <T>(x?: T) => T; a3: <T>(x: T) => T; a4: <T>(x: T, y?: T) => T; a5: <T>(x?: T, y?: T) => T; } interface I1<T> extends Base2 { a: () => T; } interface I2<T> extends Base2 { a: (x?: T) => T; } interface I3<T> extends Base2 { a: (x: T) => T; } interface I4<T> extends Base2 { a2: () => T; } interface I5<T> extends Base2 { a2: (x?: T) => T } interface I6<T> extends Base2 { a2: (x: T) => T; } interface I7<T> extends Base2 { a3: () => T; } interface I8<T> extends Base2 { a3: (x?: T) => T; } interface I9<T> extends Base2 { a3: (x: T) => T; } interface I10<T> extends Base2 { a3: (x: T, y: T) => T; } interface I11<T> extends Base2 { a4: () => T; } interface I12<T> extends Base2 { a4: (x?: T, y?: T) => T; } interface I13<T> extends Base2 { a4: (x: T) => T; } interface I14<T> extends Base2 { a4: (x: T, y: T) => T; } interface I15<T> extends Base2 { a5: () => T; } interface I16<T> extends Base2 { a5: (x?: T, y?: T) => T; } interface I17<T> extends Base2 { a5: (x: T) => T; } interface I18<T> extends Base2 { a5: (x: T, y: T) => T; } } module GenericSignaturesValid { interface Base2 { a: <T>() => T; a2: <T>(x?: T) => T; a3: <T>(x: T) => T; a4: <T>(x: T, y?: T) => T; a5: <T>(x?: T, y?: T) => T; } // BUG 833350 interface I1 extends Base2 { a: <T>() => T; // ok, same number of required params } interface I2 extends Base2 { a: <T>(x?: T) => T; // error, not identical and contextual signature instatiation can't make inference from T to T } interface I3 extends Base2 { a: <T>(x: T) => T; // error, not identical and contextual signature instatiation can't make inference from T to T } interface I4 extends Base2 { a2: <T>() => T; // error, not identical and contextual signature instatiation can't make inference from T to T } interface I5 extends Base2 { a2: <T>(x?: T) => T; // ok, identical } interface I6 extends Base2 { a2: <T>(x: T) => T; // ok, same number of params } interface I7 extends Base2 { a3: <T>() => T; // error, no inferences for T so {} not assignable to {} in return type } interface I8 extends Base2 { a3: <T>(x?: T) => T; // ok, fewer required params } interface I9 extends Base2 { a3: <T>(x: T) => T; // ok, identical, same number of required params } interface I10 extends Base2 { a3: <T>(x: T, y: T) => T; // error, too many required params } interface I11 extends Base2 { a4: <T>() => T; // error, not identical and contextual signature instatiation can't make inference from T to T } interface I12 extends Base2 { a4: <T>(x?: T, y?: T) => T; // ok, fewer required params } interface I13 extends Base2 { a4: <T>(x: T) => T; // ok, same T of required params } interface I14 extends Base2 { a4: <T>(x: T, y: T) => T; // error, too many required params } interface I15 extends Base2 { a5: <T>() => T; // error, not identical and contextual signature instatiation can't make inference from T to T } interface I16 extends Base2 { a5: <T>(x?: T, y?: T) => T; // ok, fewer required params } interface I17 extends Base2 { a5: <T>(x: T) => T; // ok, all present params match } interface I18 extends Base2 { a5: <T>(x: T, y: T) => T; // ok, same number of params } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts
TypeScript
// call signatures in derived types must have the same or fewer optional parameters as the base type module ClassTypeParam { interface Base<T> { a: new () => T; a2: new (x?: T) => T; a3: new (x: T) => T; a4: new (x: T, y?: T) => T; a5: new (x?: T, y?: T) => T; } interface I1<T> extends Base<T> { a: new () => T; // ok, same T of required params } interface I2<T> extends Base<T> { a: new (x?: T) => T; // ok, same T of required params } interface I3<T> extends Base<T> { a: new (x: T) => T; // error, too many required params } interface I4<T> extends Base<T> { a2: new () => T; // ok, same T of required params } interface I5<T> extends Base<T> { a2: new (x?: T) => T; // ok, same T of required params } interface I6<T> extends Base<T> { a2: new (x: T) => T; // ok, same number of params } interface I7<T> extends Base<T> { a3: new () => T; // ok, fewer required params } interface I8<T> extends Base<T> { a3: new (x?: T) => T; // ok, fewer required params } interface I9<T> extends Base<T> { a3: new (x: T) => T; // ok, same T of required params } interface I10<T> extends Base<T> { a3: new (x: T, y: T) => T; // error, too many required params } interface I11<T> extends Base<T> { a4: new () => T; // ok, fewer required params } interface I12<T> extends Base<T> { a4: new (x?: T, y?: T) => T; // ok, fewer required params } interface I13<T> extends Base<T> { a4: new (x: T) => T; // ok, same T of required params } interface I14<T> extends Base<T> { a4: new (x: T, y: T) => T; // ok, same number of params } interface I15<T> extends Base<T> { a5: new () => T; // ok, fewer required params } interface I16<T> extends Base<T> { a5: new (x?: T, y?: T) => T; // ok, fewer required params } interface I17<T> extends Base<T> { a5: new (x: T) => T; // ok, all present params match } interface I18<T> extends Base<T> { a5: new (x: T, y: T) => T; // ok, same number of params } } module GenericSignaturesInvalid { // all of these are errors interface Base2 { a: new <T>() => T; a2: new <T>(x?: T) => T; a3: new <T>(x: T) => T; a4: new <T>(x: T, y?: T) => T; a5: new <T>(x?: T, y?: T) => T; } interface I1<T> extends Base2 { a: new () => T; } interface I2<T> extends Base2 { a: new (x?: T) => T; } interface I3<T> extends Base2 { a: new (x: T) => T; } interface I4<T> extends Base2 { a2: new () => T; } interface I5<T> extends Base2 { a2: new (x?: T) => T } interface I6<T> extends Base2 { a2: new (x: T) => T; } interface I7<T> extends Base2 { a3: new () => T; } interface I8<T> extends Base2 { a3: new (x?: T) => T; } interface I9<T> extends Base2 { a3: new (x: T) => T; } interface I10<T> extends Base2 { a3: new (x: T, y: T) => T; } interface I11<T> extends Base2 { a4: new () => T; } interface I12<T> extends Base2 { a4: new (x?: T, y?: T) => T; } interface I13<T> extends Base2 { a4: new (x: T) => T; } interface I14<T> extends Base2 { a4: new (x: T, y: T) => T; } interface I15<T> extends Base2 { a5: new () => T; } interface I16<T> extends Base2 { a5: new (x?: T, y?: T) => T; } interface I17<T> extends Base2 { a5: new (x: T) => T; } interface I18<T> extends Base2 { a5: new (x: T, y: T) => T; } } module GenericSignaturesValid { interface Base2 { a: new <T>() => T; a2: new <T>(x?: T) => T; a3: new <T>(x: T) => T; a4: new <T>(x: T, y?: T) => T; a5: new <T>(x?: T, y?: T) => T; } // BUG 833350 interface I1 extends Base2 { a: new <T>() => T; // ok, same number of required params } interface I2 extends Base2 { a: new <T>(x?: T) => T; // error, not identical and contextual signature instatiation can't make inference from T to T } interface I3 extends Base2 { a: new <T>(x: T) => T; // error, not identical and contextual signature instatiation can't make inference from T to T } interface I4 extends Base2 { a2: new <T>() => T; // error, not identical and contextual signature instatiation can't make inference from T to T } interface I5 extends Base2 { a2: new <T>(x?: T) => T; // ok, identical } interface I6 extends Base2 { a2: new <T>(x: T) => T; // ok, same number of params } interface I7 extends Base2 { a3: new <T>() => T; // ok, fewer required params } interface I8 extends Base2 { a3: new <T>(x?: T) => T; // error, no inferences for T so {} not assignable to {} in return type } interface I9 extends Base2 { a3: new <T>(x: T) => T; // ok, identical, same number of required params } interface I10 extends Base2 { a3: new <T>(x: T, y: T) => T; // error, too many required params } interface I11 extends Base2 { a4: new <T>() => T; // error, not identical and contextual signature instatiation can't make inference from T to T } interface I12 extends Base2 { a4: new <T>(x?: T, y?: T) => T; // ok, fewer required params } interface I13 extends Base2 { a4: new <T>(x: T) => T; // ok, same T of required params } interface I14 extends Base2 { a4: new <T>(x: T, y: T) => T; // ok, same number of params } interface I15 extends Base2 { a5: new <T>() => T; // error, not identical and contextual signature instatiation can't make inference from T to T } interface I16 extends Base2 { a5: new <T>(x?: T, y?: T) => T; // ok, fewer required params } interface I17 extends Base2 { a5: new <T>(x: T) => T; // ok, all present params match } interface I18 extends Base2 { a5: new <T>(x: T, y: T) => T; // ok, same number of params } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithNumericIndexer.ts
TypeScript
// 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: number]: Derived2; // ok } module Generics { class A<T extends Base> { [x: number]: T; } class B extends A<Base> { [x: number]: Derived; // ok } class B2 extends A<Base> { [x: number]: Derived2; // ok } class B3<T extends Base> extends A<T> { [x: number]: Derived; // error, BUG? } class B4<T extends Base> extends A<T> { [x: number]: Derived2; // error, BUG? } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithNumericIndexer2.ts
TypeScript
// 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 { [x: number]: Derived2; // ok } module Generics { interface A<T extends Derived> { [x: number]: T; } interface B extends A<Base> { [x: number]: Derived; // error } interface B2 extends A<Derived> { [x: number]: Derived2; // ok } interface B3<T extends Derived> extends A<T> { [x: number]: Base; // error } interface B4<T extends Derived> extends A<T> { [x: number]: Derived; // error } interface B5<T extends Derived2> extends A<T> { [x: number]: Derived2; // error } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithNumericIndexer3.ts
TypeScript
// 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: number]: Derived2; // ok } module Generics { class A<T extends Derived> { [x: number]: T; } class B extends A<Base> { [x: number]: Derived; // error } class B2 extends A<Derived> { [x: number]: Derived2; // ok } class B3<T extends Derived> extends A<T> { [x: number]: Base; // error } class B4<T extends Derived> extends A<T> { [x: number]: Derived; // error } class B5<T extends Derived2> extends A<T> { [x: number]: Derived2; // error } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithNumericIndexer4.ts
TypeScript
// 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<T extends Derived> { [x: number]: T; } class B extends A<Base> { [x: number]: string; // error } class B3<T extends Derived> extends A<T> { [x: number]: string; // error } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithNumericIndexer5.ts
TypeScript
// 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; } class B implements A { [x: string]: Base; // error } class B2 implements A { [x: string]: Derived2; // ok } module Generics { interface A<T extends Base> { [x: number]: T; } class B implements A<Base> { [x: string]: Derived; // ok } class B2 implements A<Derived> { [x: string]: Derived2; // ok } class B3<T extends Derived> implements A<T> { [x: string]: Base; // error } class B4<T extends Derived> implements A<T> { [x: string]: Derived; // error } class B5<T extends Derived2> implements A<T> { [x: string]: Derived2; // error } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithObjectMembers.ts
TypeScript
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 { foo: Base; bar: Base; } class B extends A { foo: Derived; // ok bar: string; // error } class A2 { 1: Base; 2.0: Base; } class B2 extends A2 { 1: Derived; // ok 2: string; // error } class A3 { '1': Base; '2.0': Base; } class B3 extends A3 { '1': Derived; // ok '2.0': string; // error } module TwoLevels { class A { foo: Base; bar: Base; } class B extends A { foo: Derived2; // ok bar: string; // error } class A2 { 1: Base; 2.0: Base; } class B2 extends A2 { 1: Derived2; // ok 2: string; // error } class A3 { '1': Base; '2.0': Base; } class B3 extends A3 { '1': Derived2; // ok '2.0': string; // error } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithObjectMembers2.ts
TypeScript
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 { foo: Base; bar: Base; } interface B extends A { foo: Derived; // ok bar: string; // error } interface A2 { 1: Base; 2.0: Base; } interface B2 extends A2 { 1: Derived; // ok 2: string; // error } interface A3 { '1': Base; '2.0': Base; } interface B3 extends A3 { '1': Derived; // ok '2.0': string; // error } } // same cases as above but with optional module Optional { interface A { foo?: Base; bar?: Base; } interface B extends A { foo?: Derived; // ok bar?: string; // error } interface A2 { 1?: Base; 2.0?: Base; } interface B2 extends A2 { 1?: Derived; // ok 2?: string; // error } interface A3 { '1'?: Base; '2.0'?: Base; } interface B3 extends A3 { '1'?: Derived; // ok '2.0'?: string; // error } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithObjectMembers3.ts
TypeScript
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 { foo: Base; bar: Derived; } interface B extends A { foo: Derived; // ok bar: Base; // error } interface A2 { 1: Base; 2.0: Derived; } interface B2 extends A2 { 1: Derived; // ok 2: Base; // error } interface A3 { '1': Base; '2.0': Derived; } interface B3 extends A3 { '1': Derived; // ok '2.0': Base; // error } } module Optional { interface A { foo?: Base; bar?: Derived; } interface B extends A { foo?: Derived; // ok bar?: Base; // error } interface A2 { 1?: Base; 2.0?: Derived; } interface B2 extends A2 { 1?: Derived; // ok 2?: Base; // error } interface A3 { '1'?: Base; '2.0'?: Derived; } interface B3 extends A3 { '1'?: Derived; // ok '2.0'?: Base; // error } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithObjectMembers4.ts
TypeScript
// 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 { '1': Base; } class B3 extends A3 { '1.1': Derived; // ok, inherits '1' }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithObjectMembers5.ts
TypeScript
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 { foo: Base; } class B implements A { fooo: Derived; // error } interface A2 { 1: Base; } class B2 implements A2 { 2: Derived; // error } interface A3 { '1': Base; } class B3 implements A3 { '1.0': Derived; // error } } // same cases as above but with optional module Optional { interface A { foo?: Base; } class B implements A { fooo: Derived; // weak type error } interface A2 { 1?: Base; } class B2 implements A2 { 2: Derived; // weak type error } interface A3 { '1'?: Base; } class B3 implements A3 { '1.0': Derived; // weak type error } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithObjectMembersAccessibility.ts
TypeScript
// 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; // error } class A3 { public '1': Base; } class B3 extends A3 { private '1': Derived; // error }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithObjectMembersAccessibility2.ts
TypeScript
// 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: Base; } class B2 extends A2 { public 1: Derived; // error } class A3 { private '1': Base; } class B3 extends A3 { public '1': Derived; // error } } module ImplicitPublic { class A { private foo: Base; } class B extends A { foo: Derived; // error } class A2 { private 1: Base; } class B2 extends A2 { 1: Derived; // error } class A3 { private '1': Base; } class B3 extends A3 { '1': Derived; // error } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithObjectMembersOptionality.ts
TypeScript
// 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 apparent type (section 3.8.1) of S: // - S' and T are object types and, for each member M in T, one of the following is true: // - M is a property and S' contains a property N where // M and N have the same name, // the type of N is a subtype of that of M, // M and N are both public or both private, and // if M is a required property, N is also a required property. // - M is an optional property and S' contains no property of the same name as M. interface T { Foo?: Base; } interface S extends T { Foo: Derived } interface T2 { 1?: Base; } interface S2 extends T2 { 1: Derived; } interface T3 { '1'?: Base; } interface S3 extends T3 { '1.': Derived; } // object literal case var a: { Foo?: Base; }; var b = { Foo: <Derived>null }; var r = true ? a : b; module TwoLevels { interface T { Foo?: Base; } interface S extends T { Foo: Derived2 } interface T2 { 1?: Base; } interface S2 extends T2 { 1: Derived2; } interface T3 { '1'?: Base; } interface S3 extends T3 { '1.': Derived2; } // object literal case var a: { Foo?: Base; }; var b = { Foo: <Derived2>null }; var r = true ? a : b; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithObjectMembersOptionality2.ts
TypeScript
// Derived member is optional but base member is not, should be an error interface Base { foo: string; } interface Derived extends Base { bar: string; } interface T { Foo: Base; } interface S extends T { Foo?: Derived // error } interface T2 { 1: Base; } interface S2 extends T2 { 1?: Derived; // error } interface T3 { '1': Base; } interface S3 extends T3 { '1'?: Derived; // error } // object literal case var a: { Foo: Base; } var b: { Foo?: Derived; } var r = true ? a : b; // ok
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithObjectMembersOptionality3.ts
TypeScript
// Base property is optional and derived type has no property of that name 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; // ok } interface T3 { '1'?: Base; } interface S3 extends T3 { '1.0': Derived; // ok } // object literal case var a: { Foo?: Base; } var b: { Foo2: Derived; } var r = true ? a : b; // ok
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithObjectMembersOptionality4.ts
TypeScript
// 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; // ok } interface T3 { '1': Base; } interface S3 extends T3 { '1.0'?: Derived; // ok } // object literal case var a: { Foo: Base; } var b: { Foo2?: Derived; } var r = true ? a : b; // ok
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithOptionalProperties.ts
TypeScript
// subtyping is not transitive due to optional properties but the subtyping algorithm assumes it is for the 99% case // returns { s?: number; } function f<T>(a: T) { var b: { s?: number } = a; return b; } var r = f({ s: new Object() }); // ok r.s && r.s.toFixed(); // would blow up at runtime
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithStringIndexer.ts
TypeScript
// 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: string]: Derived2; // ok } module Generics { class A<T extends Base> { [x: string]: T; } class B extends A<Base> { [x: string]: Derived; // ok } class B2 extends A<Base> { [x: string]: Derived2; // ok } class B3<T extends Base> extends A<T> { [x: string]: Derived; // error } class B4<T extends Base> extends A<T> { [x: string]: Derived2; // error } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithStringIndexer2.ts
TypeScript
// 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 { [x: string]: Derived2; // ok } module Generics { interface A<T extends Derived> { [x: string]: T; } interface B extends A<Base> { [x: string]: Derived; // error } interface B2 extends A<Derived> { [x: string]: Derived2; // ok } interface B3<T extends Derived> extends A<T> { [x: string]: Base; // error } interface B4<T extends Derived> extends A<T> { [x: string]: Derived; // error } interface B5<T extends Derived2> extends A<T> { [x: string]: Derived2; // error } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithStringIndexer3.ts
TypeScript
// 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: string]: Derived2; // ok } module Generics { class A<T extends Derived> { [x: string]: T; } class B extends A<Base> { [x: string]: Derived; // error } class B2 extends A<Derived> { [x: string]: Derived2; // ok } class B3<T extends Derived> extends A<T> { [x: string]: Base; // error } class B4<T extends Derived> extends A<T> { [x: string]: Derived; // error } class B5<T extends Derived2> extends A<T> { [x: string]: Derived2; // error } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithStringIndexer4.ts
TypeScript
// 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]: string; // error } module Generics { class A<T extends Derived> { [x: string]: T; } class B extends A<Base> { [x: string]: string; // error } class B3<T extends Derived> extends A<T> { [x: string]: string; // error } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/superCallBeforeThisAccessing1.ts
TypeScript
declare var Factory: any class Base { constructor(c) { } } class D extends Base { private _t; constructor() { super(i); var s = { t: this._t } var i = Factory.create(s); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/superCallBeforeThisAccessing2.ts
TypeScript
class Base { constructor(c) { } } class D extends Base { private _t; constructor() { super(() => { this._t }); // no error. only check when this is directly accessing in constructor } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/superCallBeforeThisAccessing5.ts
TypeScript
class D extends null { private _t; constructor() { this._t; // No error } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/superCallBeforeThisAccessing8.ts
TypeScript
class Base { constructor(c) { } } class D extends Base { private _t; constructor() { let x = { k: super(undefined), j: this._t, // no error } } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/superCallFromClassThatHasNoBaseTypeButWithSameSymbolInterface.ts
TypeScript
interface Foo extends Array<number> {} class Foo { constructor() { super(); // error } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/superCallInConstructorWithNoBaseType.ts
TypeScript
class C { constructor() { super(); // error } } class D<T> { public constructor(public x: T) { super(); // error } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/superCallParameterContextualTyping1.ts
TypeScript
 class A<T1, T2> { constructor(private map: (value: T1) => T2) { } } class B extends A<number, string> { // Ensure 'value' is of type 'number (and not '{}') by using its 'toExponential()' method. constructor() { super(value => String(value.toExponential())); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/superCallParameterContextualTyping2.ts
TypeScript
 class A<T1, T2> { constructor(private map: (value: T1) => T2) { } } class C extends A<number, string> { // Ensure 'value' is not of type 'any' by invoking it with type arguments. constructor() { super(value => String(value<string>())); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/superCallParameterContextualTyping3.ts
TypeScript
interface ContextualType<T> { method(parameter: T): void; } class CBase<T> { constructor(param: ContextualType<T>) { } foo(param: ContextualType<T>) { } } class C extends CBase<string> { constructor() { // Should be okay. // 'p' should have type 'string'. super({ method(p) { p.length; } }); // Should be okay. // 'p' should have type 'string'. super.foo({ method(p) { p.length; } }); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/superCalls.ts
TypeScript
class Base { x = 43; constructor(n: string) { } } function v(): void { } class Derived extends Base { //super call in class constructor of derived type constructor(public q: number) { super(''); //type of super call expression is void var p = super(''); var p = v(); } } class OtherBase { } class OtherDerived extends OtherBase { constructor() { var p = ''; super(); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/superInStaticMembers1.ts
TypeScript
// @target: es5, es2015, es2021, es2022, esnext // @noTypesAndSymbols: true // @filename: external.ts export class Reflect {} export interface Foo {} export declare namespace Bar { type _ = unknown; } export const enum Baz {} export default class {}; // @filename: locals.ts export {}; declare class B { static w(): number; } class C extends B { static _ = [ (() => { var Reflect; // collision (es2015-es2021 only) super.w(); })(), (() => { var { Reflect } = { Reflect: null }; // collision (es2015-es2021 only) super.w(); })(), (() => { var [Reflect] = [null]; // collision (es2015-es2021 only) super.w(); })(), (() => { class Reflect {} // collision (es2015-es2021 only) super.w(); })(), (() => { function Reflect() {} // collision (es2015-es2021 only) super.w(); })(), (() => { enum Reflect {} // collision (es2015-es2021 only) super.w(); })(), (() => { const enum Reflect {} // collision (es2015-es2021 only) super.w(); })(), (() => { type Reflect = unknown; // no collision super.w(); })(), (() => { interface Reflect {}; // no collision super.w(); })(), (() => { (class Reflect {}); // no collision super.w(); })(), (() => { (function Reflect() {}); // no collision super.w(); })(), ]; static { var { Reflect } = { Reflect: null }; // collision (es2015-es2021 only) super.w(); } static { var [Reflect] = [null]; // collision (es2015-es2021 only) super.w(); } static { var Reflect; // collision (es2015-es2021 only) super.w(); } static { class Reflect {} // collision (es2015-es2021 only) super.w(); } static { function Reflect() {} // collision (es2015-es2021 only) super.w(); } static { enum Reflect {} // collision (es2015-es2021 only) super.w(); } static { const enum Reflect {} // collision (es2015-es2021 only) super.w(); } static { type Reflect = unknown; // no collision super.w(); } static { interface Reflect {} // no collision super.w(); } static { (class Reflect {}) // no collision super.w(); } static { (function Reflect() {}) // no collision super.w(); } } // @filename: varInContainingScopeStaticField1.ts export {}; declare class B { static w(): number; } var Reflect = null; // collision (es2015-es2021 only) class C extends B { static _ = super.w(); } // @filename: varInContainingScopeStaticField2.ts export {}; declare class B { static w(): number; } var { Reflect } = { Reflect: null }; // collision (es2015-es2021 only) class C extends B { static _ = super.w(); } // @filename: varInContainingScopeStaticField3.ts export {}; declare class B { static w(): number; } var [Reflect] = [null]; // collision (es2015-es2021 only) class C extends B { static _ = super.w(); } // @filename: varInContainingScopeStaticBlock1.ts export {}; declare class B { static w(): number; } var Reflect = null; // collision (es2015-es2021 only) class C extends B { static { super.w(); } } // @filename: varInContainingScopeStaticBlock2.ts export {}; declare class B { static w(): number; } var { Reflect } = { Reflect: null }; // collision (es2015-es2021 only) class C extends B { static { super.w(); } } // @filename: varInContainingScopeStaticBlock3.ts export {}; declare class B { static w(): number; } var [Reflect] = [null]; // collision (es2015-es2021 only) class C extends B { static { super.w(); } } // @filename: classDeclInContainingScopeStaticField.ts export {}; declare class B { static w(): number; } class Reflect {} // collision (es2015-es2021 only) class C extends B { static _ = super.w(); } // @filename: classDeclInContainingScopeStaticBlock.ts export {}; declare class B { static w(): number; } class Reflect {} // collision (es2015-es2021 only) class C extends B { static { super.w(); } } // @filename: funcDeclInContainingScopeStaticField.ts export {}; declare class B { static w(): number; } function Reflect() {} // collision (es2015-es2021 only) class C extends B { static _ = super.w(); } // @filename: funcDeclInContainingScopeStaticBlock.ts export {}; declare class B { static w(): number; } function Reflect() {} // collision (es2015-es2021 only) class C extends B { static { super.w(); } } // @filename: valueNamespaceInContainingScopeStaticField.ts export {}; declare class B { static w(): number; } namespace Reflect {} // collision (es2015-es2021 only) class C extends B { static _ = super.w(); } // @filename: valueNamespaceInContainingScopeStaticBlock.ts export {}; declare class B { static w(): number; } namespace Reflect {} // collision (es2015-es2021 only) class C extends B { static { super.w(); } } // @filename: enumInContainingScopeStaticField.ts export {}; declare class B { static w(): number; } enum Reflect {} // collision (es2015-es2021 only) class C extends B { static _ = super.w(); } // @filename: enumInContainingScopeStaticBlock.ts export {}; declare class B { static w(): number; } enum Reflect {} // collision (es2015-es2021 only) class C extends B { static { super.w(); } } // @filename: constEnumInContainingScopeStaticField.ts export {}; declare class B { static w(): number; } const enum Reflect {} // collision (es2015-es2021 only) class C extends B { static _ = super.w(); } // @filename: constEnumInContainingScopeStaticBlock.ts export {}; declare class B { static w(): number; } const enum Reflect {} // collision (es2015-es2021 only) class C extends B { static { super.w(); } } // @filename: namespaceImportInContainingScopeStaticField.ts export {}; declare class B { static w(): number; } import * as Reflect from "./external"; // collision (es2015-es2021 only) class C extends B { static _ = super.w(); } // @filename: namespaceImportInContainingScopeStaticBlock.ts export {}; declare class B { static w(): number; } import * as Reflect from "./external"; // collision (es2015-es2021 only) class C extends B { static { super.w(); } } // @filename: namedImportInContainingScopeStaticField.ts export {}; declare class B { static w(): number; } import { Reflect } from "./external"; // collision (es2015-es2021 only) class C extends B { static _ = super.w(); } // @filename: namedImportInContainingScopeStaticBlock.ts export {}; declare class B { static w(): number; } import { Reflect } from "./external"; // collision (es2015-es2021 only) class C extends B { static { super.w(); } } // @filename: namedImportOfInterfaceInContainingScopeStaticField.ts export {}; declare class B { static w(): number; } import { Foo as Reflect } from "./external"; // collision (es2015-es2021 only, not a type-only import) class C extends B { static _ = super.w(); } // @filename: namedImportOfInterfaceInContainingScopeStaticBlock.ts export {}; declare class B { static w(): number; } import { Foo as Reflect } from "./external"; // collision (es2015-es2021 only, not a type-only import) class C extends B { static { super.w(); } } // @filename: namedImportOfUninstantiatedNamespaceInContainingScopeStaticField.ts export {}; declare class B { static w(): number; } import { Bar as Reflect } from "./external"; // collision (es2015-es2021 only, not a type-only import) class C extends B { static _ = super.w(); } // @filename: namedImportOfUninstantiatedNamespaceInContainingScopeStaticBlock.ts export {}; declare class B { static w(): number; } import { Bar as Reflect } from "./external"; // collision (es2015-es2021 only, not a type-only import) class C extends B { static { super.w(); } } // @filename: namedImportOfConstEnumInContainingScopeStaticField.ts export {}; declare class B { static w(): number; } import { Baz as Reflect } from "./external"; // collision (es2015-es2021 only) class C extends B { static _ = super.w(); } // @filename: namedImportOfConstEnumInContainingScopeStaticBlock.ts export {}; declare class B { static w(): number; } import { Baz as Reflect } from "./external"; // collision (es2015-es2021 only) class C extends B { static { super.w(); } } // @filename: typeOnlyNamedImportInContainingScopeStaticField.ts export {}; declare class B { static w(): number; } import type { Reflect } from "./external"; // no collision class C extends B { static _ = super.w(); } // @filename: typeOnlyNamedImportInContainingScopeStaticBlock.ts export {}; declare class B { static w(): number; } import type { Reflect } from "./external"; // no collision class C extends B { static { super.w(); } } // @filename: defaultImportInContainingScopeStaticField.ts export {}; declare class B { static w(): number; } import Reflect from "./external"; // collision (es2015-es2021 only) class C extends B { static _ = super.w(); } // @filename: defaultImportInContainingScopeStaticBlock.ts export {}; declare class B { static w(): number; } import Reflect from "./external"; // collision (es2015-es2021 only) class C extends B { static { super.w(); } } // @filename: typeOnlyDefaultImportInContainingScopeStaticField.ts export {}; declare class B { static w(): number; } import type Reflect from "./external"; // no collision class C extends B { static _ = super.w(); } // @filename: typeOnlyDefaultImportInContainingScopeStaticBlock.ts export {}; declare class B { static w(): number; } import type Reflect from "./external"; // no collision class C extends B { static { super.w(); } } // @filename: typeInContainingScopeStaticField.ts export {}; declare class B { static w(): number; } type Reflect = unknown; // no collision class C extends B { static _ = super.w(); } // @filename: typeInContainingScopeStaticBlock.ts export {}; declare class B { static w(): number; } type Reflect = unknown; // no collision class C extends B { static { super.w(); } } // @filename: interfaceInContainingScopeStaticField.ts export {}; declare class B { static w(): number; } interface Reflect {}; // no collision class C extends B { static _ = super.w(); } // @filename: interfaceInContainingScopeStaticBlock.ts export {}; declare class B { static w(): number; } interface Reflect {}; // no collision class C extends B { static { super.w(); } } // @filename: uninstantiatedNamespaceInContainingScopeStaticField.ts export {}; declare class B { static w(): number; } declare namespace Reflect { type _ = unknown; }; // no collision class C extends B { static _ = super.w(); } // @filename: uninstantiatedNamespaceInContainingScopeStaticBlock.ts export {}; declare class B { static w(): number; } declare namespace Reflect { type _ = unknown; }; // no collision class C extends B { static { super.w(); } } // @filename: classExprInContainingScopeStaticField.ts export {}; declare class B { static w(): number; } (class Reflect {}); // no collision class C extends B { static _ = super.w(); } // @filename: classExprInContainingScopeStaticBlock.ts export {}; declare class B { static w(): number; } (class Reflect {}); // no collision class C extends B { static { super.w(); } } // @filename: inContainingClassExprStaticField.ts export {}; declare class B { static w(): number; } (class Reflect { // collision (es2015-es2021 only) static { class C extends B { static _ = super.w(); } } }); // @filename: inContainingClassExprStaticBlock.ts export {}; declare class B { static w(): number; } (class Reflect { // collision (es2015-es2021 only) static { class C extends B { static { super.w(); } } } }); // @filename: funcExprInContainingScopeStaticField.ts export {}; declare class B { static w(): number; } (function Reflect() {}); // no collision class C extends B { static _ = super.w(); } // @filename: funcExprInContainingScopeStaticBlock.ts export {}; declare class B { static w(): number; } (function Reflect() {}); // no collision class C extends B { static { super.w(); } } // @filename: inContainingFuncExprStaticField.ts export {}; declare class B { static w(): number; } (function Reflect() { // collision (es2015-es2021 only) class C extends B { static _ = super.w(); } }); // @filename: inContainingFuncExprStaticBlock.ts export {}; declare class B { static w(): number; } (function Reflect() { // collision (es2015-es2021 only) class C extends B { static { super.w(); } } });
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/superMethodCall.ts
TypeScript
// @strict: true // @target: ES6 class Base { method?() { } } class Derived extends Base { method() { return super.method?.(); } async asyncMethod() { return super.method?.(); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/superPropertyAccessNoError.ts
TypeScript
// @target: es5 //super.publicInstanceMemberFunction in constructor of derived class //super.publicInstanceMemberFunction in instance member function of derived class //super.publicInstanceMemberFunction in instance member accessor(get and set) of derived class //super.publicInstanceMemberFunction in lambda in member function //super.publicStaticMemberFunction in static member function of derived class //super.publicStaticMemberFunction in static member accessor(get and set) of derived class class SomeBaseClass { public func() { return ''; } static func() { return 3; } returnThis() { return this; } } class SomeDerivedClass extends SomeBaseClass { constructor() { super(); var x = super.func(); var x: string; } fn() { var x = super.func(); var x: string; var y = () => super.func(); } get a() { var x = super.func(); var x: string; return null; } set a(n) { var x = super.func(); var x: string; } static fn() { var x = super.func(); var x: number; } static get a() { var x = super.func(); var x: number; return null; } static set a(n) { var x = super.func(); var x: number; } returnThis() { return super.returnThis(); } } let instance = new SomeDerivedClass(); instance.returnThis().fn();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/superSymbolIndexedAccess1.ts
TypeScript
//@target: ES6 var symbol = Symbol.for('myThing'); class Foo { [symbol]() { return 0; } } class Bar extends Foo { [symbol]() { return super[symbol](); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/superSymbolIndexedAccess2.ts
TypeScript
//@target: ES6 class Foo { [Symbol.isConcatSpreadable]() { return 0; } } class Bar extends Foo { [Symbol.isConcatSpreadable]() { return super[Symbol.isConcatSpreadable](); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/superSymbolIndexedAccess3.ts
TypeScript
//@target: ES6 var symbol = Symbol.for('myThing'); class Foo { [symbol]() { return 0; } } class Bar extends Foo { [symbol]() { return super[Bar](); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/superSymbolIndexedAccess4.ts
TypeScript
//@target: ES6 var symbol = Symbol.for('myThing'); class Bar { [symbol]() { return super[symbol](); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/superSymbolIndexedAccess5.ts
TypeScript
//@target: ES5 var symbol: any; class Foo { [symbol]() { return 0; } } class Bar extends Foo { [symbol]() { return super[symbol](); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/superSymbolIndexedAccess6.ts
TypeScript
//@target: ES5 var symbol: any; class Foo { static [symbol]() { return 0; } } class Bar extends Foo { static [symbol]() { return super[symbol](); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/switchBreakStatements.ts
TypeScript
// @allowUnusedLabels: true // @allowUnreachableCode: true switch ('') { case 'a': break; } ONE: switch ('') { case 'a': break ONE; } TWO: THREE: switch ('') { case 'a': break THREE; } FOUR: switch ('') { case 'a': FIVE: switch ('') { case 'a': break FOUR; } } switch ('') { case 'a': SIX: switch ('') { case 'a': break SIX; } } SEVEN: switch ('') { case 'a': switch ('') { case 'a': switch ('') { case 'a': break SEVEN; EIGHT: switch ('') { case 'a': var fn = function () { } break EIGHT; } } } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/switchCaseWithIntersectionTypes01.ts
TypeScript
var strAndNum: string & number; var numAndBool: number & boolean; var str: string; var num: number; var bool: boolean; switch (strAndNum) { // Identical case strAndNum: break; // Constituents case str: case num: break; // Overlap in constituents case numAndBool: break; // No relation case bool: break; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/switchCaseWithUnionTypes01.ts
TypeScript
var strOrNum: string | number; var numOrBool: number | boolean; var str: string; var num: number; var bool: boolean; switch (strOrNum) { // Identical case strOrNum: break; // Constituents case str: case num: break; // Overlap in constituents case numOrBool: break; // No relation case bool: break; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/switchStatements.ts
TypeScript
module M { export function fn(x: number) { return ''; } } var x: any; switch (x) { case '': case 12: case true: case null: case undefined: case new Date(12): case new Object(): case /[a-z]/: case[]: case {}: case { id: 12 }: case['a']: case typeof x: case typeof M: case M.fn(1): case <T>(x: number) => '': case (<T>(x: number) => '')(2): default: } // basic assignable check, rest covered in tests for 'assignment compatibility' class C { id: number; } class D extends C { name: string } switch (new C()) { case new D(): case { id: 12, name: '' }: case new C(): } switch ('') { } switch (12) { } switch (true) { } switch (null) { } switch (undefined) { } switch (new Date(12)) { } switch (new Object()) { } switch (/[a-z]/) { } switch ([]) { } switch ({}) { } switch ({ id: 12 }) { } switch (['a']) { } switch (<T>(x: number) => '') { } switch ((<T>(x: T) => '')(1)) { }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/switchWithConstrainedTypeVariable.ts
TypeScript
// @strict: true // Repro from #20840 function function1<T extends 'a' | 'b'>(key: T) { switch (key) { case 'a': key.toLowerCase(); break; default: key.toLowerCase(); break; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolDeclarationEmit1.ts
TypeScript
//@target: ES6 //@declaration: true class C { [Symbol.toPrimitive]: number; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolDeclarationEmit10.ts
TypeScript
//@target: ES6 //@declaration: true var obj = { get [Symbol.isConcatSpreadable]() { return '' }, set [Symbol.isConcatSpreadable](x) { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolDeclarationEmit11.ts
TypeScript
//@target: ES6 //@declaration: true class C { static [Symbol.iterator] = 0; static [Symbol.isConcatSpreadable]() { } static get [Symbol.toPrimitive]() { return ""; } static set [Symbol.toPrimitive](x) { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolDeclarationEmit12.ts
TypeScript
//@target: ES6 //@declaration: true module M { interface I { } export class C { [Symbol.iterator]: I; [Symbol.toPrimitive](x: I) { } [Symbol.isConcatSpreadable](): I { return undefined } get [Symbol.toPrimitive]() { return undefined; } set [Symbol.toPrimitive](x: I) { } } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolDeclarationEmit13.ts
TypeScript
//@target: ES6 //@declaration: true class C { get [Symbol.toPrimitive]() { return ""; } set [Symbol.toStringTag](x) { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolDeclarationEmit14.ts
TypeScript
//@target: ES6 //@declaration: true class C { get [Symbol.toPrimitive]() { return ""; } get [Symbol.toStringTag]() { return ""; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolDeclarationEmit2.ts
TypeScript
//@target: ES6 //@declaration: true class C { [Symbol.toPrimitive] = ""; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolDeclarationEmit3.ts
TypeScript
//@target: ES6 //@declaration: true class C { [Symbol.toPrimitive](x: number); [Symbol.toPrimitive](x: string); [Symbol.toPrimitive](x: any) { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolDeclarationEmit4.ts
TypeScript
//@target: ES6 //@declaration: true class C { get [Symbol.toPrimitive]() { return ""; } set [Symbol.toPrimitive](x) { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolDeclarationEmit5.ts
TypeScript
//@target: ES6 //@declaration: true interface I { [Symbol.isConcatSpreadable](): string; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolDeclarationEmit6.ts
TypeScript
//@target: ES6 //@declaration: true interface I { [Symbol.isConcatSpreadable]: string; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolDeclarationEmit7.ts
TypeScript
//@target: ES6 //@declaration: true var obj: { [Symbol.isConcatSpreadable]: string; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolDeclarationEmit8.ts
TypeScript
//@target: ES6 //@declaration: true var obj = { [Symbol.isConcatSpreadable]: 0 }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolDeclarationEmit9.ts
TypeScript
//@target: ES6 //@declaration: true var obj = { [Symbol.isConcatSpreadable]() { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty1.ts
TypeScript
//@target: ES6 var s: symbol; var x = { [s]: 0, [s]() { }, get [s]() { return 0; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty10.ts
TypeScript
//@target: ES6 class C { [Symbol.iterator]: { x; y }; } interface I { [Symbol.iterator]?: { x }; } var i: I; i = new C; var c: C = i;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty11.ts
TypeScript
//@target: ES6 class C { } interface I { [Symbol.iterator]?: { x }; } var i: I; i = new C; var c: C = i;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty12.ts
TypeScript
//@target: ES6 class C { private [Symbol.iterator]: { x }; } interface I { [Symbol.iterator]: { x }; } var i: I; i = new C; var c: C = i;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty13.ts
TypeScript
//@target: ES6 class C { [Symbol.iterator]: { x; y }; } interface I { [Symbol.iterator]: { x }; } declare function foo(i: I): I; declare function foo(a: any): any; declare function bar(i: C): C; declare function bar(a: any): any; foo(new C); var i: I; bar(i);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty14.ts
TypeScript
//@target: ES6 class C { [Symbol.iterator]: { x; y }; } interface I { [Symbol.iterator]?: { x }; } declare function foo(i: I): I; declare function foo(a: any): any; declare function bar(i: C): C; declare function bar(a: any): any; foo(new C); var i: I; bar(i);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty15.ts
TypeScript
//@target: ES6 class C { } interface I { [Symbol.iterator]?: { x }; } declare function foo(i: I): I; declare function foo(a: any): any; declare function bar(i: C): C; declare function bar(a: any): any; foo(new C); var i: I; bar(i);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty16.ts
TypeScript
//@target: ES6 class C { private [Symbol.iterator]: { x }; } interface I { [Symbol.iterator]: { x }; } declare function foo(i: I): I; declare function foo(a: any): any; declare function bar(i: C): C; declare function bar(a: any): any; foo(new C); var i: I; bar(i);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty17.ts
TypeScript
//@target: ES6 interface I { [Symbol.iterator]: number; [s: symbol]: string; "__@iterator": string; } var i: I; var it = i[Symbol.iterator];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty18.ts
TypeScript
//@target: ES6 var i = { [Symbol.iterator]: 0, [Symbol.toStringTag]() { return "" }, set [Symbol.toPrimitive](p: boolean) { } } var it = i[Symbol.iterator]; var str = i[Symbol.toStringTag](); i[Symbol.toPrimitive] = false;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty19.ts
TypeScript
//@target: ES6 var i = { [Symbol.iterator]: { p: null }, [Symbol.toStringTag]() { return { p: undefined }; } } var it = i[Symbol.iterator]; var str = i[Symbol.toStringTag]();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty2.ts
TypeScript
//@target: ES6 var s = Symbol(); var x = { [s]: 0, [s]() { }, get [s]() { return 0; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty20.ts
TypeScript
//@target: ES6 interface I { [Symbol.iterator]: (s: string) => string; [Symbol.toStringTag](s: number): number; } var i: I = { [Symbol.iterator]: s => s, [Symbol.toStringTag](n) { return n; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty21.ts
TypeScript
//@target: ES6 interface I<T, U> { [Symbol.unscopables]: T; [Symbol.isConcatSpreadable]: U; } declare function foo<T, U>(p: I<T, U>): { t: T; u: U }; foo({ [Symbol.isConcatSpreadable]: "", [Symbol.toPrimitive]: 0, [Symbol.unscopables]: true });
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty22.ts
TypeScript
//@target: ES6 interface I<T, U> { [Symbol.unscopables](x: T): U; } declare function foo<T, U>(p1: T, p2: I<T, U>): U; foo("", { [Symbol.unscopables]: s => s.length });
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty23.ts
TypeScript
//@target: ES6 interface I { [Symbol.toPrimitive]: () => boolean; } class C implements I { [Symbol.toPrimitive]() { return true; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty24.ts
TypeScript
//@target: ES6 interface I { [Symbol.toPrimitive]: () => boolean; } class C implements I { [Symbol.toPrimitive]() { return ""; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty25.ts
TypeScript
//@target: ES6 interface I { [Symbol.toPrimitive]: () => boolean; } class C implements I { [Symbol.toStringTag]() { return ""; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty26.ts
TypeScript
//@target: ES6 class C1 { [Symbol.toStringTag]() { return ""; } } class C2 extends C1 { [Symbol.toStringTag]() { return ""; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty27.ts
TypeScript
//@target: ES6 class C1 { [Symbol.toStringTag]() { return {}; } } class C2 extends C1 { [Symbol.toStringTag]() { return ""; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty28.ts
TypeScript
//@target: ES6 class C1 { [Symbol.toStringTag]() { return { x: "" }; } } class C2 extends C1 { } var c: C2; var obj = c[Symbol.toStringTag]().x;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty29.ts
TypeScript
//@target: ES6 class C1 { [Symbol.toStringTag]() { return { x: "" }; } [s: symbol]: () => { x: string }; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty3.ts
TypeScript
//@target: ES6 var s = Symbol; var x = { [s]: 0, [s]() { }, get [s]() { return 0; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty30.ts
TypeScript
//@target: ES6 class C1 { [Symbol.toStringTag]() { return { x: "" }; } [s: symbol]: () => { x: number }; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty31.ts
TypeScript
//@target: ES6 class C1 { [Symbol.toStringTag]() { return { x: "" }; } } class C2 extends C1 { [s: symbol]: () => { x: string }; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty32.ts
TypeScript
//@target: ES6 class C1 { [Symbol.toStringTag]() { return { x: "" }; } } class C2 extends C1 { [s: symbol]: () => { x: number }; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty33.ts
TypeScript
//@target: ES6 class C1 extends C2 { [Symbol.toStringTag]() { return { x: "" }; } } class C2 { [s: symbol]: () => { x: string }; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty34.ts
TypeScript
//@target: ES6 class C1 extends C2 { [Symbol.toStringTag]() { return { x: "" }; } } class C2 { [s: symbol]: () => { x: number }; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty35.ts
TypeScript
//@target: ES6 interface I1 { [Symbol.toStringTag](): { x: string } } interface I2 { [Symbol.toStringTag](): { x: number } } interface I3 extends I1, I2 { }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty37.ts
TypeScript
//@target: ES6 interface I { [Symbol.isConcatSpreadable]: string; [Symbol.isConcatSpreadable]: string; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty38.ts
TypeScript
//@target: ES6 interface I { [Symbol.isConcatSpreadable]: string; } interface I { [Symbol.isConcatSpreadable]: string; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty39.ts
TypeScript
//@target: ES6 class C { [Symbol.iterator](x: string): string; [Symbol.iterator](x: number): number; [Symbol.iterator](x: any) { return undefined; } [Symbol.iterator](x: any) { return undefined; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University