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/objectSpreadSetonlyAccessor.ts | TypeScript | // @strict: true
// @target: esnext
const o1: { foo: number, bar: undefined } = { foo: 1, ... { set bar(_v: number) { } } }
const o2: { foo: undefined } = { foo: 1, ... { set foo(_v: number) { } } }
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectSpreadStrictNull.ts | TypeScript | // @strictNullChecks: true
function f(
definiteBoolean: { sn: boolean },
definiteString: { sn: string },
optionalString: { sn?: string },
optionalNumber: { sn?: number },
undefinedString: { sn: string | undefined },
undefinedNumber: { sn: number | undefined }) {
// optional
let optionalUnionStops: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...optionalNumber };
let optionalUnionDuplicates: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...optionalString, ...optionalNumber };
let allOptional: { sn?: string | number } = { ...optionalString, ...optionalNumber };
// undefined
let undefinedUnionStops: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...undefinedNumber };
let undefinedUnionDuplicates: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...undefinedString, ...undefinedNumber };
let allUndefined: { sn: string | number | undefined } = { ...undefinedString, ...undefinedNumber };
let undefinedWithOptionalContinues: { sn: string | number | boolean } = { ...definiteBoolean, ...undefinedString, ...optionalNumber };
}
type Movie = {
title: string;
yearReleased: number;
}
const m = { title: "The Matrix", yearReleased: 1999 };
// should error here because title: undefined is not assignable to string
const x: Movie = { ...m, title: undefined };
interface Fields {
foo: number;
bar: string;
}
interface NearlyPartialFields {
foo: number | undefined;
bar: string | undefined;
}
function g(fields: Fields, partialFields: Partial<Fields>, nearlyPartialFields: NearlyPartialFields) {
// ok, undefined is stripped from optional properties when spread
fields = { ...fields, ...partialFields };
// error: not optional, undefined remains
fields = { ...fields, ...nearlyPartialFields };
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypeHidingMembersOfExtendedObject.ts | TypeScript | // @skipDefaultLibCheck: false
class A {
foo: string;
}
class B extends A {
bar: string;
}
interface Object {
data: A;
[x: string]: Object;
}
class C {
valueOf() { }
data: B;
[x: string]: any;
}
var c: C;
var r1: void = c.valueOf();
var r1b: B = c.data;
var r1c = r1b['hm']; // should be 'Object'
var r1d = c['hm']; // should be 'any'
interface I {
valueOf(): void;
data: B;
[x: string]: any;
}
var i: I;
var r2: void = i.valueOf();
var r2b: B = i.data;
var r2c = r2b['hm']; // should be 'Object'
var r2d = i['hm']; // should be 'any'
var a = {
valueOf: () => { },
data: new B()
}
var r3: void = a.valueOf();
var r3b: B = a.data;
var r3c = r3b['hm']; // should be 'Object'
var r3d = i['hm'];
var b: {
valueOf(): void;
data: B;
[x: string]: any;
}
var r4: void = b.valueOf(); | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypeHidingMembersOfObject.ts | TypeScript | // all of these valueOf calls should return the type shown in the overriding signatures here
class C {
valueOf() { }
}
var c: C;
var r1: void = c.valueOf();
interface I {
valueOf(): void;
}
var i: I;
var r2: void = i.valueOf();
var a = {
valueOf: () => { }
}
var r3: void = a.valueOf();
var b: {
valueOf(): void;
}
var r4: void = b.valueOf(); | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypeHidingMembersOfObjectAssignmentCompat.ts | TypeScript | interface I {
toString(): void;
}
var i: I;
var o: Object;
o = i; // error
i = o; // ok
class C {
toString(): void { }
}
var c: C;
o = c; // error
c = o; // ok
var a = {
toString: () => { }
}
o = a; // error
a = o; // ok | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypeHidingMembersOfObjectAssignmentCompat2.ts | TypeScript | interface I {
toString(): number;
}
var i: I;
var o: Object;
o = i; // error
i = o; // error
class C {
toString(): number { return 1; }
}
var c: C;
o = c; // error
c = o; // error
var a = {
toString: () => { }
}
o = a; // error
a = o; // ok | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypeLiteralSyntax.ts | TypeScript | var x: {
foo: string;
bar: string;
}
var y: {
foo: string;
bar: string
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypePropertyAccess.ts | TypeScript | // Index notation should resolve to the type of a declared property with that same name
class C {
foo: string;
}
var c: C;
var r1 = c.toString();
var r2 = c['toString']();
var r3 = c.foo;
var r4 = c['foo'];
interface I {
bar: string;
}
var i: I;
var r4 = i.toString();
var r5 = i['toString']();
var r6 = i.bar;
var r7 = i['bar'];
var a = {
foo: ''
}
var r8 = a.toString();
var r9 = a['toString']();
var r10 = a.foo;
var r11 = a['foo'];
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypeWithCallSignatureAppearsToBeFunctionType.ts | TypeScript | // objects with call signatures should be permitted where function types are expected
// no errors expected below
interface I {
(): void;
}
var i: I;
var r2: void = i();
var r2b: (x: any, y?: any) => any = i.apply;
var b: {
(): void;
}
var r4: void = b();
var rb4: (x: any, y?: any) => any = b.apply; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypeWithCallSignatureHidingMembersOfExtendedFunction.ts | TypeScript | // object types with call signatures can override members of Function
// no errors expected below
interface Function {
data: number;
[x: string]: Object;
}
interface I {
(): void;
apply(a: any, b?: any): void;
call(thisArg: number, ...argArray: number[]): any;
}
var i: I;
var r1: (a: any, b?: any) => void = i.apply;
var r1b: (thisArg: number, ...argArray: number[]) => void = i.call;
var r1c = i.arguments;
var r1d = i.data;
var r1e = i['hm']; // should be Object
var x: {
(): void;
apply(a: any, b?: any): void;
call(thisArg: number, ...argArray: number[]): any;
}
var r2: (a: any, b?: any) => void = x.apply;
var r2b: (thisArg: number, ...argArray: number[]) => void = x.call;
var r2c = x.arguments;
var r2d = x.data;
var r2e = x['hm']; // should be Object | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypeWithCallSignatureHidingMembersOfFunction.ts | TypeScript | // object types with call signatures can override members of Function
// no errors expected below
interface I {
(): void;
apply(a: any, b?: any): void;
call(thisArg: number, ...argArray: number[]): any;
}
var i: I;
var r1: (a: any, b?: any) => void = i.apply;
var r1b: (thisArg: number, ...argArray: number[]) => void = i.call;
var r1c = i.arguments;
var x: {
(): void;
apply(a: any, b?: any): void;
call(thisArg: number, ...argArray: number[]): any;
}
var r2: (a: any, b?: any) => void = x.apply;
var r2b: (thisArg: number, ...argArray: number[]) => void = x.call;
var r2c = x.arguments;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypeWithCallSignatureHidingMembersOfFunctionAssignmentCompat.ts | TypeScript | interface I {
(): void;
}
var i: I;
var f: Object;
f = i;
i = f;
var a: {
(): void
}
f = a;
a = f; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypeWithConstructSignatureAppearsToBeFunctionType.ts | TypeScript | // no errors expected below
interface I {
new(): number;
}
var i: I;
var r2: number = i();
var r2b: number = new i();
var r2c: (x: any, y?: any) => any = i.apply;
var b: {
new(): number;
}
var r4: number = b();
var r4b: number = new b();
var r4c: (x: any, y?: any) => any = b.apply; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypeWithConstructSignatureHidingMembersOfExtendedFunction.ts | TypeScript | interface Function {
data: number;
[x: string]: Object;
}
interface I {
new(): number;
apply(a: any, b?: any): void;
call(thisArg: number, ...argArray: number[]): any;
}
var i: I;
var r1: (a: any, b?: any) => void = i.apply;
var r1b: (thisArg: number, ...argArray: number[]) => void = i.call;
var r1c = i.arguments;
var r1d = i.data;
var r1e = i['hm']; // should be Object
var x: {
new(): number;
apply(a: any, b?: any): void;
call(thisArg: number, ...argArray: number[]): any;
}
var r2: (a: any, b?: any) => void = x.apply;
var r2b: (thisArg: number, ...argArray: number[]) => void = x.call;
var r2c = x.arguments;
var r2d = x.data;
var r2e = x['hm']; // should be Object | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypeWithConstructSignatureHidingMembersOfFunction.ts | TypeScript | interface I {
new(): number;
apply(a: any, b?: any): void;
call(thisArg: number, ...argArray: number[]): any;
}
var i: I;
var r1: (a: any, b?: any) => void = i.apply;
var r1b: (thisArg: number, ...argArray: number[]) => void = i.call;
var r1c = i.arguments;
var x: {
new(): number;
apply(a: any, b?: any): void;
call(thisArg: number, ...argArray: number[]): any;
}
var r2: (a: any, b?: any) => void = x.apply;
var r2b: (thisArg: number, ...argArray: number[]) => void = x.call;
var r2c = x.arguments;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypeWithConstructSignatureHidingMembersOfFunctionAssignmentCompat.ts | TypeScript | interface I {
new(): any;
}
var i: I;
var f: Object;
f = i;
i = f;
var a: {
new(): any
}
f = a;
a = f; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypeWithNumericProperty.ts | TypeScript | // no errors here
class C {
1: number;
1.1: string;
}
var c: C;
var r1 = c[1];
var r2 = c[1.1];
var r3 = c['1'];
var r4 = c['1.1'];
interface I {
1: number;
1.1: string;
}
var i: I;
var r1 = i[1];
var r2 = i[1.1];
var r3 = i['1'];
var r4 = i['1.1'];
var a: {
1: number;
1.1: string;
}
var r1 = a[1];
var r2 = a[1.1];
var r3 = a['1'];
var r4 = a['1.1'];
var b = {
1: 1,
1.1: ""
}
var r1 = b[1];
var r2 = b[1.1];
var r3 = b['1'];
var r4 = b['1.1']; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypeWithRecursiveWrappedProperty.ts | TypeScript | // Basic recursive type
class List<T> {
data: T;
next: List<List<T>>;
}
var list1 = new List<number>();
var list2 = new List<number>();
var list3 = new List<string>();
list1 = list2; // ok
list1 = list3; // error | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypeWithRecursiveWrappedProperty2.ts | TypeScript | // Basic recursive type
class List<T> {
data: T;
next: List<List<T>>;
}
var list1 = new List<number>();
var list2 = new List<number>();
var list3 = new List<string>();
list1 = list2; // ok
list1 = list3; // error | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypeWithRecursiveWrappedPropertyCheckedNominally.ts | TypeScript | // Types with infinitely expanding recursive types are type checked nominally
class List<T> {
data: T;
next: List<List<T>>;
}
class MyList<T> {
data: T;
next: MyList<MyList<T>>;
}
var list1 = new List<number>();
var list2 = new List<string>();
var myList1 = new MyList<number>();
var myList2 = new MyList<string>();
list1 = myList1; // error, not nominally equal
list1 = myList2; // error, type mismatch
list2 = myList1; // error, not nominally equal
list2 = myList2; // error, type mismatch
var rList1 = new List<List<number>>();
var rMyList1 = new List<MyList<number>>();
rList1 = rMyList1; // error, not nominally equal
function foo<T extends List<number>, U extends MyList<number>>(t: T, u: U) {
t = u; // error
u = t; // error
var a: List<number>;
var b: MyList<number>;
a = t; // ok
a = u; // error
b = t; // error
b = u; // ok
}
function foo2<T extends U, U extends MyList<number>>(t: T, u: U) {
t = u; // error
u = t; // was error, ok after constraint made illegal, doesn't matter
var a: List<number>;
var b: MyList<number>;
a = t; // error
a = u; // error
b = t; // ok
b = u; // ok
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypeWithStringAndNumberIndexSignatureToAny.ts | TypeScript | // @strict: true
// When checking compatibility between two types,
// TypeScript should not require an index signature if
// the target side index signature maps to `any` *and*
// the target side has *any* string index signature to `any`.
//
// So an index signature like in
//
// { [x: number]: any }
//
// is still required of a source type, but neither index signature in
//
// { [x: number]: any, [x: string]: any; }
//
// should be required; *however*, the number index signature in
//
// { [x: number]: number, [x: string]: any; }
//
// should always be required.
interface StringTo<T> {
[x: string]: T;
}
interface NumberTo<T> {
[x: number]: T;
}
interface StringAndNumberTo<T> extends StringTo<T>, NumberTo<T> {
}
interface Obj {
hello: string;
world: number;
}
function f1(sToAny: StringTo<any>, nToAny: NumberTo<any>, bothToAny: StringAndNumberTo<any>, someObj: Obj) {
sToAny = nToAny;
sToAny = bothToAny;
sToAny = someObj;
nToAny = sToAny;
nToAny = bothToAny;
nToAny = someObj;
bothToAny = sToAny;
bothToAny = nToAny;
bothToAny = someObj;
someObj = sToAny;
someObj = nToAny;
someObj = bothToAny;
}
function f2(sToAny: StringTo<any>, nToAny: NumberTo<any>, bothToAny: StringTo<any> & NumberTo<any>, someObj: Obj) {
sToAny = nToAny;
sToAny = bothToAny;
sToAny = someObj;
nToAny = sToAny;
nToAny = bothToAny;
nToAny = someObj;
bothToAny = sToAny;
bothToAny = nToAny;
bothToAny = someObj;
someObj = sToAny;
someObj = nToAny;
someObj = bothToAny;
}
type NumberToNumber = NumberTo<number>;
interface StringToAnyNumberToNumber extends StringTo<any>, NumberToNumber {
}
function f3(sToAny: StringTo<any>, nToNumber: NumberToNumber, strToAnyNumToNum: StringToAnyNumberToNumber, someObj: Obj) {
sToAny = nToNumber;
sToAny = strToAnyNumToNum;
sToAny = someObj;
nToNumber = sToAny;
nToNumber = strToAnyNumToNum;
nToNumber = someObj;
strToAnyNumToNum = sToAny;
strToAnyNumToNum = nToNumber;
strToAnyNumToNum = someObj;
someObj = sToAny;
someObj = nToNumber;
someObj = someObj;
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypeWithStringIndexerHidingObjectIndexer.ts | TypeScript | // @skipDefaultLibCheck: false
// object types can define string indexers that are more specific than the default 'any' that would be returned
// no errors expected below
interface Object {
[x: string]: Object;
}
var o = {};
var r = o['']; // should be Object
class C {
foo: string;
[x: string]: string;
}
var c: C;
var r2: string = c[''];
interface I {
bar: string;
[x: string]: string;
}
var i: I;
var r3: string = i[''];
var o2: {
baz: string;
[x: string]: string;
}
var r4: string = o2[''];
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypeWithStringNamedPropertyOfIllegalCharacters.ts | TypeScript | class C {
" ": number;
"a b": string;
"~!@#$%^&*()_+{}|:'<>?\/.,`": number;
"a\a": number;
static "a ": number
}
var c: C;
var r = c[" "];
var r2 = c[" "];
var r3 = c["a b"];
// BUG 817263
var r4 = c["~!@#$%^&*()_+{}|:'<>?\/.,`"];
interface I {
" ": number;
"a b": string;
"~!@#$%^&*()_+{}|:'<>?\/.,`": number;
}
var i: I;
var r = i[" "];
var r2 = i[" "];
var r3 = i["a b"];
// BUG 817263
var r4 = i["~!@#$%^&*()_+{}|:'<>?\/.,`"];
var a: {
" ": number;
"a b": string;
"~!@#$%^&*()_+{}|:'<>?\/.,`": number;
}
var r = a[" "];
var r2 = a[" "];
var r3 = a["a b"];
// BUG 817263
var r4 = a["~!@#$%^&*()_+{}|:'<>?\/.,`"];
var b = {
" ": 1,
"a b": "",
"~!@#$%^&*()_+{}|:'<>?\/.,`": 1,
}
var r = b[" "];
var r2 = b[" "];
var r3 = b["a b"];
// BUG 817263
var r4 = b["~!@#$%^&*()_+{}|:'<>?\/.,`"];
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentity.ts | TypeScript | // object types are identical structurally
class A {
foo: string;
}
class B {
foo: string;
}
class C<T> {
foo: T;
}
interface I {
foo: string;
}
var a: { foo: string; }
var b = { foo: '' };
function foo1(x: A);
function foo1(x: A); // error
function foo1(x: any) { }
function foo1b(x: B);
function foo1b(x: B); // error
function foo1b(x: any) { }
function foo1c(x: C<string>);
function foo1c(x: C<string>); // error
function foo1c(x: any) { }
function foo2(x: I);
function foo2(x: I); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo5(x: A);
function foo5(x: B); // error
function foo5(x: any) { }
function foo5b(x: A);
function foo5b(x: C<string>); // error
function foo5b(x: any) { }
function foo6(x: A);
function foo6(x: I); // error
function foo6(x: any) { }
function foo7(x: A);
function foo7(x: typeof a); // error
function foo7(x: any) { }
function foo8(x: B);
function foo8(x: I); // error
function foo8(x: any) { }
function foo9(x: B);
function foo9(x: C<string>); // error
function foo9(x: any) { }
function foo10(x: B);
function foo10(x: typeof a); // error
function foo10(x: any) { }
function foo11(x: B);
function foo11(x: typeof b); // error
function foo11(x: any) { }
function foo12(x: I);
function foo12(x: C<string>); // error
function foo12(x: any) { }
function foo13(x: I);
function foo13(x: typeof a); // error
function foo13(x: any) { }
function foo14(x: I);
function foo14(x: typeof b); // error
function foo14(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentity2.ts | TypeScript | // object types are identical structurally
class A {
foo: number;
}
class B {
foo: boolean;
}
class C<T> {
foo: T;
}
interface I {
foo: Date;
}
var a: { foo: RegExp; }
enum E { A }
var b = { foo: E.A };
function foo5(x: A);
function foo5(x: B); // ok
function foo5(x: any) { }
function foo5b(x: A);
function foo5b(x: C<string>); // ok
function foo5b(x: any) { }
function foo6(x: A);
function foo6(x: I); // ok
function foo6(x: any) { }
function foo7(x: A);
function foo7(x: typeof a); // ok
function foo7(x: any) { }
function foo8(x: B);
function foo8(x: I); // ok
function foo8(x: any) { }
function foo9(x: B);
function foo9(x: C<string>); // ok
function foo9(x: any) { }
function foo10(x: B);
function foo10(x: typeof a); // ok
function foo10(x: any) { }
function foo11(x: B);
function foo11(x: typeof b); // ok
function foo11(x: any) { }
function foo12(x: I);
function foo12(x: C<string>); // ok
function foo12(x: any) { }
function foo13(x: I);
function foo13(x: typeof a); // ok
function foo13(x: any) { }
function foo14(x: I);
function foo14(x: typeof b); // ok
function foo14(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithCallSignatures.ts | TypeScript | // object types are identical structurally
class A {
foo(x: string): string { return null; }
}
class B {
foo(x: string): string { return null; }
}
class C<T> {
foo(x: T): T { return null; }
}
interface I {
foo(x: string): string;
}
interface I2<T> {
foo(x: T): T;
}
var a: { foo(x: string): string }
var b = { foo(x: string) { return ''; } };
function foo1(x: A);
function foo1(x: A); // error
function foo1(x: any) { }
function foo1b(x: B);
function foo1b(x: B); // error
function foo1b(x: any) { }
function foo1c(x: C<string>);
function foo1c(x: C<string>); // error
function foo1c(x: any) { }
function foo2(x: I);
function foo2(x: I); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo5(x: A);
function foo5(x: B); // error
function foo5(x: any) { }
function foo5b(x: A);
function foo5b(x: C<string>); // error
function foo5b(x: any) { }
function foo6(x: A);
function foo6(x: I); // error
function foo6(x: any) { }
function foo7(x: A);
function foo7(x: typeof a); // error
function foo7(x: any) { }
function foo8(x: B);
function foo8(x: I); // error
function foo8(x: any) { }
function foo9(x: B);
function foo9(x: C<string>); // error
function foo9(x: any) { }
function foo10(x: B);
function foo10(x: typeof a); // error
function foo10(x: any) { }
function foo11(x: B);
function foo11(x: typeof b); // error
function foo11(x: any) { }
function foo12(x: I);
function foo12(x: C<string>); // error
function foo12(x: any) { }
function foo12b(x: I2<string>);
function foo12b(x: C<string>); // error
function foo12b(x: any) { }
function foo13(x: I);
function foo13(x: typeof a); // error
function foo13(x: any) { }
function foo14(x: I);
function foo14(x: typeof b); // error
function foo14(x: any) { }
function foo15(x: I2<string>);
function foo15(x: C<number>); // ok
function foo15(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithCallSignatures2.ts | TypeScript | // object types are identical structurally
class A {
foo(x: string): string { return null; }
}
class B {
foo(x: number): string { return null; }
}
class C<T> {
foo(x: T): T { return null; }
}
interface I {
foo(x: boolean): string;
}
interface I2<T> {
foo(x: T): T;
}
var a: { foo(x: Date): string }
var b = { foo(x: RegExp) { return ''; } };
function foo1(x: A);
function foo1(x: A); // error
function foo1(x: any) { }
function foo1b(x: B);
function foo1b(x: B); // error
function foo1b(x: any) { }
function foo1c(x: C<string>);
function foo1c(x: C<string>); // error
function foo1c(x: any) { }
function foo2(x: I);
function foo2(x: I); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo5(x: A);
function foo5(x: B); // ok
function foo5(x: any) { }
function foo5b(x: A);
function foo5b(x: C<string>); // error
function foo5b(x: any) { }
function foo6(x: A);
function foo6(x: I); // ok
function foo6(x: any) { }
function foo7(x: A);
function foo7(x: typeof a); // ok
function foo7(x: any) { }
function foo8(x: B);
function foo8(x: I); // ok
function foo8(x: any) { }
function foo9(x: B);
function foo9(x: C<string>); // ok
function foo9(x: any) { }
function foo10(x: B);
function foo10(x: typeof a); // ok
function foo10(x: any) { }
function foo11(x: B);
function foo11(x: typeof b); // ok
function foo11(x: any) { }
function foo12(x: I);
function foo12(x: C<string>); // ok
function foo12(x: any) { }
function foo12b(x: I2<string>);
function foo12b(x: C<string>); // error
function foo12b(x: any) { }
function foo13(x: I);
function foo13(x: typeof a); // ok
function foo13(x: any) { }
function foo14(x: I);
function foo14(x: typeof b); // ok
function foo14(x: any) { }
function foo15(x: I2<string>);
function foo15(x: C<number>); // ok
function foo15(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithCallSignatures3.ts | TypeScript | // object types are identical structurally
interface I {
(x: string): string;
}
interface I2<T> {
(x: T): T;
}
var a: { (x: string): string }
function foo2(x: I);
function foo2(x: I); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo13(x: I);
function foo13(x: typeof a); // error
function foo13(x: any) { }
function foo14(x: I);
function foo14(x: I2<string>); // error
function foo14(x: any) { }
function foo14b(x: typeof a);
function foo14b(x: I2<string>); // error
function foo14b(x: any) { }
function foo15(x: I);
function foo15(x: I2<number>); // ok
function foo15(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithCallSignaturesDifferingParamCounts.ts | TypeScript | // object types are identical structurally
class A {
foo(x: string): string { return null; }
}
class B {
foo(x: string, y: string): string { return null; }
}
class C<T> {
foo(x: T, y: T): T { return null; }
}
interface I {
foo(x: string): string;
}
interface I2<T> {
foo(x: T): T;
}
var a: { foo(x: string, y: string): string }
var b = { foo(x: string) { return ''; } };
function foo1(x: A);
function foo1(x: A); // error
function foo1(x: any) { }
function foo1b(x: B);
function foo1b(x: B); // error
function foo1b(x: any) { }
function foo1c(x: C<string>);
function foo1c(x: C<string>); // error
function foo1c(x: any) { }
function foo2(x: I);
function foo2(x: I); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo5(x: A);
function foo5(x: B); // ok
function foo5(x: any) { }
function foo5b(x: A);
function foo5b(x: C<string>); // ok
function foo5b(x: any) { }
function foo6(x: A);
function foo6(x: I); // error
function foo6(x: any) { }
function foo7(x: A);
function foo7(x: typeof a); // ok
function foo7(x: any) { }
function foo8(x: B);
function foo8(x: I); // ok
function foo8(x: any) { }
function foo9(x: B);
function foo9(x: C<string>); // ok
function foo9(x: any) { }
function foo10(x: B);
function foo10(x: typeof a); // error
function foo10(x: any) { }
function foo11(x: B);
function foo11(x: typeof b); // ok
function foo11(x: any) { }
function foo12(x: I);
function foo12(x: C<string>); // ok
function foo12(x: any) { }
function foo12b(x: I2<string>);
function foo12b(x: C<string>); // ok
function foo12b(x: any) { }
function foo13(x: I);
function foo13(x: typeof a); // ok
function foo13(x: any) { }
function foo14(x: I);
function foo14(x: typeof b); // error
function foo14(x: any) { }
function foo15(x: I2<string>);
function foo15(x: C<number>); // ok
function foo15(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithCallSignaturesDifferingParamCounts2.ts | TypeScript | // object types are identical structurally
interface I {
(x: string): string;
}
interface I2<T> {
(x: T): T;
}
var a: { (x: string, y: string): string }
function foo2(x: I);
function foo2(x: I); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: I2<string>);
function foo4(x: I2<string>); // error
function foo4(x: any) { }
function foo5(x: I2<string>);
function foo5(x: I2<number>); // ok
function foo5(x: any) { }
function foo13(x: I);
function foo13(x: typeof a); // ok
function foo13(x: any) { }
function foo14(x: I);
function foo14(x: I2<string>); // error
function foo14(x: any) { }
function foo14b(x: typeof a);
function foo14b(x: I2<string>); // ok
function foo14b(x: any) { }
function foo15(x: I);
function foo15(x: I2<number>); // ok
function foo15(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithCallSignaturesWithOverloads.ts | TypeScript | // object types are identical structurally
class A {
foo(x: number): number;
foo(x: string): string;
foo(x: any): any { return null; }
}
class B {
foo(x: number): number;
foo(x: string): string;
foo(x: any): any { return null; }
}
class C<T> {
foo(x: number): number;
foo(x: string): string;
foo(x: T): T;
foo(x: any): any { return null; }
}
interface I {
foo(x: number): number;
foo(x: string): string;
}
interface I2<T> {
foo(x: number): number;
foo(x: string): string;
foo(x: T): T;
}
var a: {
foo(x: number): number
foo(x: string): string
}
var b = {
foo(x: any) { return <any>''; }
};
function foo1(x: A);
function foo1(x: A); // error
function foo1(x: any) { }
function foo1b(x: B);
function foo1b(x: B); // error
function foo1b(x: any) { }
function foo1c(x: C<string>);
function foo1c(x: C<string>); // error
function foo1c(x: any) { }
function foo2(x: I);
function foo2(x: I); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo5(x: A);
function foo5(x: B); // error
function foo5(x: any) { }
function foo5b(x: A);
function foo5b(x: C<string>); // ok
function foo5b(x: any) { }
function foo6(x: A);
function foo6(x: I); // BUG 831930
function foo6(x: any) { }
function foo7(x: A);
function foo7(x: typeof a); // BUG 831930
function foo7(x: any) { }
function foo8(x: B);
function foo8(x: I); // BUG 831930
function foo8(x: any) { }
function foo9(x: B);
function foo9(x: C<string>); // ok
function foo9(x: any) { }
function foo10(x: B);
function foo10(x: typeof a); // BUG 831930
function foo10(x: any) { }
function foo11(x: B);
function foo11(x: typeof b); // ok
function foo11(x: any) { }
function foo12(x: I);
function foo12(x: C<string>); // ok
function foo12(x: any) { }
function foo12b(x: I2<string>);
function foo12b(x: C<string>); // ok
function foo12b(x: any) { }
function foo13(x: I);
function foo13(x: typeof a); // error
function foo13(x: any) { }
function foo14(x: I);
function foo14(x: typeof b); // ok
function foo14(x: any) { }
function foo15(x: I2<string>);
function foo15(x: C<number>); // ok
function foo15(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithComplexConstraints.ts | TypeScript | interface A {
<T extends {
<S extends A>(x: T, y: S): void
}>(x: T, y: T): void
}
interface B {
<U extends B>(x: U, y: U): void
}
// ok, not considered identical because the steps of contextual signature instantiation create fresh type parameters
function foo(x: A);
function foo(x: B); // error after constraints above made illegal
function foo(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithConstructSignatures.ts | TypeScript | // object types are identical structurally
class A {
constructor(x: string) { }
}
class B {
constructor(x: string) { }
}
class C<T> {
constructor(x: T) { }
}
interface I {
new(x: string);
}
interface I2<T> {
new(x: T): T;
}
var a: { new(x: string) }
function foo1(x: A);
function foo1(x: A); // error
function foo1(x: any) { }
function foo1b(x: B);
function foo1b(x: B); // error
function foo1b(x: any) { }
function foo1c(x: C<string>);
function foo1c(x: C<string>); // error
function foo1c(x: any) { }
function foo2(x: I);
function foo2(x: I); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo5(x: A);
function foo5(x: B); // error
function foo5(x: any) { }
function foo5b(x: A);
function foo5b(x: C<string>); // error
function foo5b(x: any) { }
function foo6(x: A);
function foo6(x: I); // ok
function foo6(x: any) { }
function foo7(x: A);
function foo7(x: typeof a); // ok
function foo7(x: any) { }
function foo8(x: B);
function foo8(x: I); // ok
function foo8(x: any) { }
function foo9(x: B);
function foo9(x: C<string>); // error
function foo9(x: any) { }
function foo10(x: B);
function foo10(x: typeof a); // ok
function foo10(x: any) { }
function foo12(x: I);
function foo12(x: C<string>); // ok
function foo12(x: any) { }
function foo12b(x: I2<string>);
function foo12b(x: C<string>); // ok
function foo12b(x: any) { }
function foo13(x: I);
function foo13(x: typeof a); // error
function foo13(x: any) { }
function foo15(x: I2<string>);
function foo15(x: C<number>); // ok
function foo15(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithConstructSignatures2.ts | TypeScript | // object types are identical structurally
class B {
constructor(x: number) { return null; }
}
class C<T> {
constructor(x: T) { return null; }
}
interface I {
new(x: boolean): string;
}
interface I2<T> {
new(x: T): T;
}
var a: { new(x: Date): string }
var b = { new(x: RegExp) { return ''; } }; // not a construct signature, function called new
function foo1b(x: B);
function foo1b(x: B); // error
function foo1b(x: any) { }
function foo1c(x: C<string>);
function foo1c(x: C<string>); // error
function foo1c(x: any) { }
function foo2(x: I);
function foo2(x: I); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo8(x: B);
function foo8(x: I); // ok
function foo8(x: any) { }
function foo9(x: B);
function foo9(x: C<string>); // error, types are structurally equal
function foo9(x: any) { }
function foo10(x: B);
function foo10(x: typeof a); // ok
function foo10(x: any) { }
function foo11(x: B);
function foo11(x: typeof b); // ok
function foo11(x: any) { }
function foo12(x: I);
function foo12(x: C<string>); // ok
function foo12(x: any) { }
function foo12b(x: I2<string>);
function foo12b(x: C<string>); // ok
function foo12b(x: any) { }
function foo13(x: I);
function foo13(x: typeof a); // ok
function foo13(x: any) { }
function foo14(x: I);
function foo14(x: typeof b); // ok
function foo14(x: any) { }
function foo15(x: I2<string>);
function foo15(x: C<number>); // ok
function foo15(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithConstructSignaturesDifferingParamCounts.ts | TypeScript | // object types are identical structurally
class B {
constructor(x: string, y: string) { return null; }
}
class C<T> {
constructor(x: T, y: T) { return null; }
}
interface I {
new(x: string): string;
}
interface I2<T> {
new(x: T): T;
}
var a: { new(x: string, y: string): string }
var b = { new(x: string) { return ''; } }; // not a construct signature, function called new
function foo1b(x: B);
function foo1b(x: B); // error
function foo1b(x: any) { }
function foo1c(x: C<string>);
function foo1c(x: C<string>); // error
function foo1c(x: any) { }
function foo2(x: I);
function foo2(x: I); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo8(x: B);
function foo8(x: I); // ok
function foo8(x: any) { }
function foo9(x: B);
function foo9(x: C<string>); // error, types are structurally equal
function foo9(x: any) { }
function foo10(x: B);
function foo10(x: typeof a); // ok
function foo10(x: any) { }
function foo11(x: B);
function foo11(x: typeof b); // ok
function foo11(x: any) { }
function foo12(x: I);
function foo12(x: C<string>); // ok
function foo12(x: any) { }
function foo12b(x: I2<string>);
function foo12b(x: C<string>); // ok
function foo12b(x: any) { }
function foo13(x: I);
function foo13(x: typeof a); // ok
function foo13(x: any) { }
function foo14(x: I);
function foo14(x: typeof b); // ok
function foo14(x: any) { }
function foo15(x: I2<string>);
function foo15(x: C<number>); // ok
function foo15(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithGenericCallSignatures.ts | TypeScript | // object types are identical structurally
class A {
foo<T>(x: T): T { return null; }
}
class B<T> {
foo(x: T): T { return null; }
}
class C<T> {
foo(x: T): T { return null; }
}
interface I<T> {
foo(x: T): T;
}
interface I2 {
foo<T>(x: T): T;
}
var a: { foo<T>(x: T): T }
var b = { foo<T>(x: T) { return x; } };
function foo1(x: A);
function foo1(x: A); // error
function foo1(x: any) { }
function foo1b(x: B<string>);
function foo1b(x: B<string>); // error
function foo1b(x: any) { }
function foo1c(x: C<string>);
function foo1c(x: C<string>); // error
function foo1c(x: any) { }
function foo2(x: I<string>);
function foo2(x: I<string>); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo5(x: A);
function foo5(x: B<string>); // ok
function foo5(x: any) { }
function foo5b(x: A);
function foo5b(x: C<string>); // ok
function foo5b(x: any) { }
function foo6(x: A);
function foo6(x: I<string>); // ok
function foo6(x: any) { }
function foo7(x: A);
function foo7(x: typeof a); // error
function foo7(x: any) { }
function foo8(x: B<string>);
function foo8(x: I<string>); // error
function foo8(x: any) { }
function foo9(x: B<string>);
function foo9(x: C<string>); // error
function foo9(x: any) { }
function foo10(x: B<string>);
function foo10(x: typeof a); // ok
function foo10(x: any) { }
function foo11(x: B<string>);
function foo11(x: typeof b); // ok
function foo11(x: any) { }
function foo12(x: I<string>);
function foo12(x: C<string>); // error
function foo12(x: any) { }
function foo12b(x: I2);
function foo12b(x: C<string>); // ok
function foo12b(x: any) { }
function foo13(x: I<string>);
function foo13(x: typeof a); // ok
function foo13(x: any) { }
function foo14(x: I<string>);
function foo14(x: typeof b); // ok
function foo14(x: any) { }
function foo15(x: I2);
function foo15(x: C<number>); // ok
function foo15(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithGenericCallSignatures2.ts | TypeScript | // object types are identical structurally
class A {
foo<T, U>(x: T, y: U): T { return null; }
}
class B<T, U> {
foo(x: T, y: U): T { return null; }
}
class C<T, U> {
foo(x: T, y: U): T { return null; }
}
interface I<T, U> {
foo(x: T, y: U): T;
}
interface I2 {
foo<T, U>(x: T, y: U): T;
}
var a: { foo<T, U>(x: T, y: U): T }
var b = { foo<T, U>(x: T, y: U) { return x; } };
function foo1(x: A);
function foo1(x: A); // error
function foo1(x: any) { }
function foo1b(x: B<string, number>);
function foo1b(x: B<string, number>); // error
function foo1b(x: any) { }
function foo1c(x: C<string, number>);
function foo1c(x: C<string, number>); // error
function foo1c(x: any) { }
function foo2(x: I<string, number>);
function foo2(x: I<string, number>); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo5(x: A);
function foo5(x: B<string, number>); // ok
function foo5(x: any) { }
function foo5b(x: A);
function foo5b(x: C<string, number>); // ok
function foo5b(x: any) { }
function foo6(x: A);
function foo6(x: I<string, number>); // ok
function foo6(x: any) { }
function foo7(x: A);
function foo7(x: typeof a); // no error, bug?
function foo7(x: any) { }
function foo8(x: B<string, number>);
function foo8(x: I<string, number>); // error
function foo8(x: any) { }
function foo9(x: B<string, number>);
function foo9(x: C<string, number>); // error
function foo9(x: any) { }
function foo10(x: B<string, number>);
function foo10(x: typeof a); // ok
function foo10(x: any) { }
function foo11(x: B<string, number>);
function foo11(x: typeof b); // ok
function foo11(x: any) { }
function foo12(x: I<string, number>);
function foo12(x: C<string, number>); // error
function foo12(x: any) { }
function foo12b(x: I2);
function foo12b(x: C<string, number>); // ok
function foo12b(x: any) { }
function foo13(x: I<string, number>);
function foo13(x: typeof a); // ok
function foo13(x: any) { }
function foo14(x: I<string, number>);
function foo14(x: typeof b); // ok
function foo14(x: any) { }
function foo15(x: I2);
function foo15(x: C<string, number>); // ok
function foo15(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithGenericCallSignaturesDifferingByConstraints.ts | TypeScript | // Two call or construct signatures are considered identical when they have the same number of type parameters and, considering those
// parameters pairwise identical, have identical type parameter constraints, identical number of parameters with identical kind(required,
// optional or rest) and types, and identical return types.
class A {
foo<T extends Date>(x: T): string { return null; }
}
class B<T extends Array<number>> {
foo(x: T): string { return null; }
}
class C<T extends String> {
foo(x: T): string { return null; }
}
interface I<T extends Number> {
foo(x: T): string;
}
interface I2 {
foo<T extends Boolean>(x: T): string;
}
var a: { foo<T extends Array<string>>(x: T): string }
var b = { foo<T extends RegExp>(x: T) { return ''; } };
function foo1(x: A);
function foo1(x: A); // error
function foo1(x: any) { }
function foo1b(x: B<Array<number>>);
function foo1b(x: B<Array<number>>); // error
function foo1b(x: any) { }
function foo1c(x: C<String>);
function foo1c(x: C<String>); // error
function foo1c(x: any) { }
function foo2(x: I<Number>);
function foo2(x: I<Number>); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo5(x: A);
function foo5(x: B<Array<number>>); // ok
function foo5(x: any) { }
function foo5b(x: A);
function foo5b(x: C<String>); // ok
function foo5b(x: any) { }
function foo6(x: A);
function foo6(x: I<Number>); // ok
function foo6(x: any) { }
function foo7(x: A);
function foo7(x: typeof a); // ok
function foo7(x: any) { }
function foo8(x: B<Array<number>>);
function foo8(x: I<Number>); // ok
function foo8(x: any) { }
function foo9(x: B<Array<number>>);
function foo9(x: C<String>); // ok
function foo9(x: any) { }
function foo10(x: B<Array<number>>);
function foo10(x: typeof a); // ok
function foo10(x: any) { }
function foo11(x: B<Array<number>>);
function foo11(x: typeof b); // ok
function foo11(x: any) { }
function foo12(x: I<Number>);
function foo12(x: C<String>); // ok
function foo12(x: any) { }
function foo12b(x: I2);
function foo12b(x: C<String>); // ok
function foo12b(x: any) { }
function foo13(x: I<Number>);
function foo13(x: typeof a); // ok
function foo13(x: any) { }
function foo14(x: I<Number>);
function foo14(x: typeof b); // ok
function foo14(x: any) { }
function foo15(x: I2);
function foo15(x: C<String>); // ok
function foo15(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithGenericCallSignaturesDifferingByConstraints2.ts | TypeScript | // Two call or construct signatures are considered identical when they have the same number of type parameters and, considering those
// parameters pairwise identical, have identical type parameter constraints, identical number of parameters with identical kind(required,
// optional or rest) and types, and identical return types.
class A {
foo<T extends U, U extends Date>(x: T, y: U): string { return null; }
}
class B<T extends U, U extends Array<number>> {
foo(x: T, y: U): string { return null; }
}
class C<T extends U, U extends String> {
foo(x: T, y: U): string { return null; }
}
class D<T extends U, U extends Number> {
foo(x: T, y: U): string { return null; }
}
interface I<T extends U, U extends Number> {
foo(x: T, y: U): string;
}
interface I2 {
foo<T extends U, U extends Boolean>(x: T, y: U): string;
}
var a: { foo<T extends U, U extends Array<string>>(x: T, y: U): string }
var b = { foo<T extends U, U extends RegExp>(x: T, y: U) { return ''; } };
function foo1(x: A);
function foo1(x: A); // error
function foo1(x: any) { }
function foo1b(x: B<Array<number>, Array<number>>);
function foo1b(x: B<Array<number>, Array<number>>); // error
function foo1b(x: any) { }
function foo1c(x: C<String, String>);
function foo1c(x: C<String, String>); // error
function foo1c(x: any) { }
function foo2(x: I<Number, Number>);
function foo2(x: I<Number, Number>); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo5(x: A);
function foo5(x: B<Array<number>, Array<number>>); // ok
function foo5(x: any) { }
function foo5b(x: A);
function foo5b(x: C<String, String>); // ok
function foo5b(x: any) { }
function foo5c(x: C<String, String>);
function foo5c(x: D<Number, Number>); // ok
function foo5c(x: any) { }
function foo6c(x: C<String, String>);
function foo6c(x: D<any, Number>); // error, "any" does not satisfy the constraint
function foo6c(x: any) { }
function foo6(x: A);
function foo6(x: I<Number, Number>); // ok
function foo6(x: any) { }
function foo7(x: A);
function foo7(x: typeof a); // ok
function foo7(x: any) { }
function foo8(x: B<Array<number>, Array<number>>);
function foo8(x: I<Number, Number>); // ok
function foo8(x: any) { }
function foo9(x: B<Array<number>, Array<number>>);
function foo9(x: C<String, String>); // ok
function foo9(x: any) { }
function foo10(x: B<Array<number>, Array<number>>);
function foo10(x: typeof a); // ok
function foo10(x: any) { }
function foo11(x: B<Array<number>, Array<number>>);
function foo11(x: typeof b); // ok
function foo11(x: any) { }
function foo12(x: I<Number, Number>);
function foo12(x: C<String, String>); // ok
function foo12(x: any) { }
function foo12b(x: I2);
function foo12b(x: C<String, String>); // ok
function foo12b(x: any) { }
function foo13(x: I<Number, Number>);
function foo13(x: typeof a); // ok
function foo13(x: any) { }
function foo14(x: I<Number, Number>);
function foo14(x: typeof b); // ok
function foo14(x: any) { }
function foo15(x: I2);
function foo15(x: C<String, String>); // ok
function foo15(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithGenericCallSignaturesDifferingByConstraints3.ts | TypeScript | // Two call or construct signatures are considered identical when they have the same number of type parameters and, considering those
// parameters pairwise identical, have identical type parameter constraints, identical number of parameters with identical kind(required,
// optional or rest) and types, and identical return types.
class One { foo: string }
class Two { foo: string }
interface Three { foo: string }
interface Four<T> { foo: T }
interface Five<T> extends Four<T> { }
interface Six<T, U> {
foo: T;
}
class A {
foo<T extends U, U extends One>(x: T, y: U): string { return null; }
}
class B<T extends U, U extends Two> {
foo(x: T, y: U): string { return null; }
}
class C<T extends U, U extends Three> {
foo(x: T, y: U): string { return null; }
}
class D<T extends U, U extends Four<string>> {
foo(x: T, y: U): string { return null; }
}
interface I<T extends U, U extends Five<string>> {
foo(x: T, y: U): string;
}
interface I2 {
foo<T extends U, U extends Six<string, string>>(x: T, y: U): string;
}
var a: { foo<T extends U, U extends One>(x: T, y: U): string }
var b = { foo<T extends U, U extends Two>(x: T, y: U) { return ''; } };
function foo1(x: A);
function foo1(x: A); // error
function foo1(x: any) { }
function foo1b(x: B<Two, Two>);
function foo1b(x: B<Two, Two>); // error
function foo1b(x: any) { }
function foo1c(x: C<Three, Three>);
function foo1c(x: C<Three, Three>); // error
function foo1c(x: any) { }
function foo2(x: I<Five<string>, Five<string>>);
function foo2(x: I<Five<string>, Five<string>>); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo5(x: A);
function foo5(x: B<Two, Two>); // ok
function foo5(x: any) { }
function foo5b(x: A);
function foo5b(x: C<Three, Three>); // ok
function foo5b(x: any) { }
function foo5c(x: C<Three, Three>);
function foo5c(x: D<Four<string>, Four<string>>); // error
function foo5c(x: any) { }
function foo6c(x: C<Three, Three>);
function foo6c(x: D<Four<string>, Four<string>>); // error
function foo6c(x: any) { }
function foo6(x: A);
function foo6(x: I<Five<string>, Five<string>>); // ok
function foo6(x: any) { }
function foo7(x: A);
function foo7(x: typeof a); // error
function foo7(x: any) { }
function foo8(x: B<Two, Two>);
function foo8(x: I<Five<string>, Five<string>>); // error
function foo8(x: any) { }
function foo9(x: B<Two, Two>);
function foo9(x: C<Three, Three>); // error
function foo9(x: any) { }
function foo10(x: B<Two, Two>);
function foo10(x: typeof a); // ok
function foo10(x: any) { }
function foo11(x: B<Two, Two>);
function foo11(x: typeof b); // ok
function foo11(x: any) { }
function foo12(x: I<Five<string>, Five<string>>);
function foo12(x: C<Three, Three>); // error
function foo12(x: any) { }
function foo12b(x: I2);
function foo12b(x: C<Three, Three>); // ok
function foo12b(x: any) { }
function foo13(x: I<Five<string>, Five<string>>);
function foo13(x: typeof a); // ok
function foo13(x: any) { }
function foo14(x: I<Five<string>, Five<string>>);
function foo14(x: typeof b); // ok
function foo14(x: any) { }
function foo15(x: I2);
function foo15(x: C<Three, Three>); // ok
function foo15(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithGenericCallSignaturesDifferingByReturnType.ts | TypeScript | // Two call or construct signatures are considered identical when they have the same number of type parameters and, considering those
// parameters pairwise identical, have identical type parameter constraints, identical number of parameters with identical kind(required,
// optional or rest) and types, and identical return types.
class A {
foo<T>(x: T): string { return null; }
}
class B<T> {
foo(x: T): number { return null; }
}
class C<T> {
foo(x: T): boolean { return null; }
}
interface I<T> {
foo(x: T): Date;
}
interface I2 {
foo<T>(x: T): RegExp;
}
var a: { foo<T>(x: T): T }
var b = { foo<T>(x: T) { return null; } };
function foo1(x: A);
function foo1(x: A); // error
function foo1(x: any) { }
function foo1b(x: B<string>);
function foo1b(x: B<string>); // error
function foo1b(x: any) { }
function foo1c(x: C<string>);
function foo1c(x: C<string>); // error
function foo1c(x: any) { }
function foo2(x: I<string>);
function foo2(x: I<string>); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo5(x: A);
function foo5(x: B<string>); // ok
function foo5(x: any) { }
function foo5b(x: A);
function foo5b(x: C<string>); // ok
function foo5b(x: any) { }
function foo6(x: A);
function foo6(x: I<string>); // ok
function foo6(x: any) { }
function foo7(x: A);
function foo7(x: typeof a); // ok
function foo7(x: any) { }
function foo8(x: B<string>);
function foo8(x: I<string>); // ok
function foo8(x: any) { }
function foo9(x: B<string>);
function foo9(x: C<string>); // ok
function foo9(x: any) { }
function foo10(x: B<string>);
function foo10(x: typeof a); // ok
function foo10(x: any) { }
function foo11(x: B<string>);
function foo11(x: typeof b); // ok
function foo11(x: any) { }
function foo12(x: I<string>);
function foo12(x: C<string>); // ok
function foo12(x: any) { }
function foo12b(x: I2);
function foo12b(x: C<string>); // ok
function foo12b(x: any) { }
function foo13(x: I<string>);
function foo13(x: typeof a); // ok
function foo13(x: any) { }
function foo14(x: I<string>);
function foo14(x: typeof b); // ok
function foo14(x: any) { }
function foo15(x: I2);
function foo15(x: C<number>); // ok
function foo15(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithGenericCallSignaturesDifferingByReturnType2.ts | TypeScript | // Two call or construct signatures are considered identical when they have the same number of type parameters and, considering those
// parameters pairwise identical, have identical type parameter constraints, identical number of parameters with identical kind(required,
// optional or rest) and types, and identical return types.
class A {
foo<T extends Date>(x: T): string { return null; }
}
class B<T extends Date> {
foo(x: T): number { return null; }
}
class C<T extends Date> {
foo(x: T): boolean { return null; }
}
interface I<T extends Date> {
foo(x: T): Date;
}
interface I2 {
foo<T extends Date>(x: T): RegExp;
}
var a: { foo<T extends Date>(x: T): T }
var b = { foo<T extends Date>(x: T) { return null; } };
function foo1(x: A);
function foo1(x: A); // error
function foo1(x: any) { }
function foo1b(x: B<Date>);
function foo1b(x: B<Date>); // error
function foo1b(x: any) { }
function foo1c(x: C<Date>);
function foo1c(x: C<Date>); // error
function foo1c(x: any) { }
function foo2(x: I<Date>);
function foo2(x: I<Date>); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo5(x: A);
function foo5(x: B<Date>); // ok
function foo5(x: any) { }
function foo5b(x: A);
function foo5b(x: C<Date>); // ok
function foo5b(x: any) { }
function foo6(x: A);
function foo6(x: I<Date>); // ok
function foo6(x: any) { }
function foo7(x: A);
function foo7(x: typeof a); // ok
function foo7(x: any) { }
function foo8(x: B<Date>);
function foo8(x: I<Date>); // ok
function foo8(x: any) { }
function foo9(x: B<Date>);
function foo9(x: C<Date>); // ok
function foo9(x: any) { }
function foo10(x: B<Date>);
function foo10(x: typeof a); // ok
function foo10(x: any) { }
function foo11(x: B<Date>);
function foo11(x: typeof b); // ok
function foo11(x: any) { }
function foo12(x: I<Date>);
function foo12(x: C<Date>); // ok
function foo12(x: any) { }
function foo12b(x: I2);
function foo12b(x: C<Date>); // ok
function foo12b(x: any) { }
function foo13(x: I<Date>);
function foo13(x: typeof a); // ok
function foo13(x: any) { }
function foo14(x: I<Date>);
function foo14(x: typeof b); // ok
function foo14(x: any) { }
function foo15(x: I2);
function foo15(x: C<Date>); // ok
function foo15(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithGenericCallSignaturesDifferingTypeParameterCounts.ts | TypeScript | // object types are identical structurally
class A {
foo<T>(x: T): T { return null; }
}
class B<U, V> {
foo(x: U): U { return null; }
}
class C<V, W, X> {
foo(x: V): V { return null; }
}
interface I<X, Y, Z, A> {
foo(x: X): X;
}
interface I2 {
foo<Y, Z, A, B>(x: Y): Y;
}
var a: { foo<Z, A, B, C, D>(x: Z): Z }
var b = { foo<A, B, C, D, E, F>(x: A) { return x; } };
function foo1(x: A);
function foo1(x: A); // error
function foo1(x: any) { }
function foo1b(x: B<string, string>);
function foo1b(x: B<string, string>); // error
function foo1b(x: any) { }
function foo1c(x: C<string, number, boolean>);
function foo1c(x: C<string, number, boolean>); // error
function foo1c(x: any) { }
function foo2(x: I<string, boolean, number, string>);
function foo2(x: I<string, boolean, number, string>); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo5(x: A);
function foo5(x: B<string, string>); // ok
function foo5(x: any) { }
function foo5b(x: A);
function foo5b(x: C<string, number, boolean>); // ok
function foo5b(x: any) { }
function foo6(x: A);
function foo6(x: I<string, number, boolean, Date>); // ok
function foo6(x: any) { }
function foo7(x: A);
function foo7(x: typeof a); // no error, bug?
function foo7(x: any) { }
function foo8(x: B<string, string>);
function foo8(x: I<string, string, boolean, Date>); // error
function foo8(x: any) { }
function foo9(x: B<string, number>);
function foo9(x: C<string, number, B<string, string>>); // error
function foo9(x: any) { }
function foo10(x: B<string, boolean>);
function foo10(x: typeof a); // ok
function foo10(x: any) { }
function foo11(x: B<string, boolean>);
function foo11(x: typeof b); // ok
function foo11(x: any) { }
function foo12(x: I<B<string, number>, number, Date, string>);
function foo12(x: C<B<string, number>, number, Date>); // error
function foo12(x: any) { }
function foo12b(x: I2);
function foo12b(x: C<string, string, boolean>); // ok
function foo12b(x: any) { }
function foo13(x: I<string, Date, RegExp, Date>);
function foo13(x: typeof a); // ok
function foo13(x: any) { }
function foo14(x: I<string, Date, RegExp, boolean>);
function foo14(x: typeof b); // ok
function foo14(x: any) { }
function foo15(x: I2);
function foo15(x: C<number, B<string, string>, B<number, string>>); // ok
function foo15(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithGenericCallSignaturesDifferingTypeParameterCounts2.ts | TypeScript | // object types are identical structurally
interface I<X, Y, Z, A> {
(x: X): X;
}
interface I2 {
<Y, Z, A, B>(x: Y): Y;
}
var a: { <Z, A, B, C, D>(x: Z): Z }
function foo1(x: I<string, boolean, number, string>);
function foo1(x: I<string, boolean, number, string>); // error
function foo1(x: any) { }
function foo2(x: I2);
function foo2(x: I2); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo13(x: I<boolean, string, number, Date>);
function foo13(x: typeof a); // ok
function foo13(x: any) { }
function foo14(x: I<boolean, string, number, Date>);
function foo14(x: I2); // error
function foo14(x: any) { }
function foo14b(x: typeof a);
function foo14b(x: I2); // ok
function foo14b(x: any) { }
function foo15(x: I<boolean, string, number, Date>);
function foo15(x: I2); // ok
function foo15(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithGenericCallSignaturesDifferingTypeParameterNames.ts | TypeScript | // object types are identical structurally
class A {
foo<T>(x: T): T { return null; }
}
class B<U> {
foo(x: U): U { return null; }
}
class C<V> {
foo(x: V): V { return null; }
}
interface I<X> {
foo(x: X): X;
}
interface I2 {
foo<Y>(x: Y): Y;
}
var a: { foo<Z>(x: Z): Z }
var b = { foo<A>(x: A) { return x; } };
function foo1(x: A);
function foo1(x: A); // error
function foo1(x: any) { }
function foo1b(x: B<string>);
function foo1b(x: B<string>); // error
function foo1b(x: any) { }
function foo1c(x: C<string>);
function foo1c(x: C<string>); // error
function foo1c(x: any) { }
function foo2(x: I<string>);
function foo2(x: I<string>); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo5(x: A);
function foo5(x: B<string>); // ok
function foo5(x: any) { }
function foo5b(x: A);
function foo5b(x: C<string>); // ok
function foo5b(x: any) { }
function foo6(x: A);
function foo6(x: I<string>); // ok
function foo6(x: any) { }
function foo7(x: A);
function foo7(x: typeof a); // error
function foo7(x: any) { }
function foo8(x: B<string>);
function foo8(x: I<string>); // error
function foo8(x: any) { }
function foo9(x: B<string>);
function foo9(x: C<string>); // error
function foo9(x: any) { }
function foo10(x: B<string>);
function foo10(x: typeof a); // ok
function foo10(x: any) { }
function foo11(x: B<string>);
function foo11(x: typeof b); // ok
function foo11(x: any) { }
function foo12(x: I<string>);
function foo12(x: C<string>); // error
function foo12(x: any) { }
function foo12b(x: I2);
function foo12b(x: C<string>); // ok
function foo12b(x: any) { }
function foo13(x: I<string>);
function foo13(x: typeof a); // ok
function foo13(x: any) { }
function foo14(x: I<string>);
function foo14(x: typeof b); // ok
function foo14(x: any) { }
function foo15(x: I2);
function foo15(x: C<number>); // ok
function foo15(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithGenericCallSignaturesOptionalParams.ts | TypeScript | // Two call or construct signatures are considered identical when they have the same number of type parameters and, considering those
// parameters pairwise identical, have identical type parameter constraints, identical number of parameters with identical kind(required,
// optional or rest) and types, and identical return types.
class A {
foo<T>(x: T, y?: T): T { return null; }
}
class B<T> {
foo(x: T, y?: T): T { return null; }
}
class C<T> {
foo(x: T, y?: T): T { return null; }
}
interface I<T> {
foo(x: T, y?: T): T;
}
interface I2 {
foo<T>(x: T, y?: T): T;
}
var a: { foo<T>(x: T, y?: T): T }
var b = { foo<T>(x: T, y?: T) { return x; } };
function foo1(x: A);
function foo1(x: A); // error
function foo1(x: any) { }
function foo1b(x: B<string>);
function foo1b(x: B<string>); // error
function foo1b(x: any) { }
function foo1c(x: C<string>);
function foo1c(x: C<string>); // error
function foo1c(x: any) { }
function foo2(x: I<string>);
function foo2(x: I<string>); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo5(x: A);
function foo5(x: B<string>); // ok
function foo5(x: any) { }
function foo5b(x: A);
function foo5b(x: C<string>); // ok
function foo5b(x: any) { }
function foo6(x: A);
function foo6(x: I<string>); // ok
function foo6(x: any) { }
function foo7(x: A);
function foo7(x: typeof a); // no error, bug?
function foo7(x: any) { }
function foo8(x: B<string>);
function foo8(x: I<string>); // error
function foo8(x: any) { }
function foo9(x: B<string>);
function foo9(x: C<string>); // error
function foo9(x: any) { }
function foo10(x: B<string>);
function foo10(x: typeof a); // ok
function foo10(x: any) { }
function foo11(x: B<string>);
function foo11(x: typeof b); // ok
function foo11(x: any) { }
function foo12(x: I<string>);
function foo12(x: C<string>); // error
function foo12(x: any) { }
function foo12b(x: I2);
function foo12b(x: C<string>); // ok
function foo12b(x: any) { }
function foo13(x: I<string>);
function foo13(x: typeof a); // ok
function foo13(x: any) { }
function foo14(x: I<string>);
function foo14(x: typeof b); // ok
function foo14(x: any) { }
function foo15(x: I2);
function foo15(x: C<number>); // ok
function foo15(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithGenericCallSignaturesOptionalParams2.ts | TypeScript | // Two call or construct signatures are considered identical when they have the same number of type parameters and, considering those
// parameters pairwise identical, have identical type parameter constraints, identical number of parameters with identical kind(required,
// optional or rest) and types, and identical return types.
class A {
foo<T, U>(x: T, y?: U): T { return null; }
}
class B<T, U> {
foo(x: T, y?: U): T { return null; }
}
class C<T, U> {
foo(x: T, y?: U): T { return null; }
}
interface I<T, U> {
foo(x: T, y?: U): T;
}
interface I2 {
foo<T, U>(x: T, y?: U): T;
}
var a: { foo<T, U>(x: T, y?: U): T }
var b = { foo<T, U>(x: T, y?: U) { return x; } };
function foo1(x: A);
function foo1(x: A); // error
function foo1(x: any) { }
function foo1b(x: B<string, number>);
function foo1b(x: B<string, number>); // error
function foo1b(x: any) { }
function foo1c(x: C<string, number>);
function foo1c(x: C<string, number>); // error
function foo1c(x: any) { }
function foo2(x: I<string, number>);
function foo2(x: I<string, number>); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo5(x: A);
function foo5(x: B<string, number>); // ok
function foo5(x: any) { }
function foo5b(x: A);
function foo5b(x: C<string, number>); // ok
function foo5b(x: any) { }
function foo6(x: A);
function foo6(x: I<string, number>); // ok
function foo6(x: any) { }
function foo7(x: A);
function foo7(x: typeof a); // no error, bug?
function foo7(x: any) { }
function foo8(x: B<string, number>);
function foo8(x: I<string, number>); // error
function foo8(x: any) { }
function foo9(x: B<string, number>);
function foo9(x: C<string, number>); // error
function foo9(x: any) { }
function foo10(x: B<string, number>);
function foo10(x: typeof a); // ok
function foo10(x: any) { }
function foo11(x: B<string, number>);
function foo11(x: typeof b); // ok
function foo11(x: any) { }
function foo12(x: I<string, number>);
function foo12(x: C<string, number>); // error
function foo12(x: any) { }
function foo12b(x: I2);
function foo12b(x: C<string, number>); // ok
function foo12b(x: any) { }
function foo13(x: I<string, number>);
function foo13(x: typeof a); // ok
function foo13(x: any) { }
function foo14(x: I<string, number>);
function foo14(x: typeof b); // ok
function foo14(x: any) { }
function foo15(x: I2);
function foo15(x: C<string, number>); // ok
function foo15(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithGenericCallSignaturesOptionalParams3.ts | TypeScript | // Two call or construct signatures are considered identical when they have the same number of type parameters and, considering those
// parameters pairwise identical, have identical type parameter constraints, identical number of parameters with identical kind(required,
// optional or rest) and types, and identical return types.
class A {
foo<T, U>(x: T, y?: U): T { return null; }
}
class B<T, U> {
foo(x: T, y: U): T { return null; }
}
class C<T, U> {
foo(x: T, y?: U): T { return null; }
}
interface I<T, U> {
foo(x: T, y?: U): T;
}
interface I2 {
foo<T, U>(x: T, y: U): T;
}
var a: { foo<T, U>(x: T, y?: U): T }
var b = { foo<T, U>(x: T, y: U) { return x; } };
function foo1(x: A);
function foo1(x: A); // error
function foo1(x: any) { }
function foo1b(x: B<string, number>);
function foo1b(x: B<string, number>); // error
function foo1b(x: any) { }
function foo1c(x: C<string, number>);
function foo1c(x: C<string, number>); // error
function foo1c(x: any) { }
function foo2(x: I<string, number>);
function foo2(x: I<string, number>); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo5(x: A);
function foo5(x: B<string, number>); // ok
function foo5(x: any) { }
function foo5b(x: A);
function foo5b(x: C<string, number>); // ok
function foo5b(x: any) { }
function foo6(x: A);
function foo6(x: I<string, number>); // ok
function foo6(x: any) { }
function foo7(x: A);
function foo7(x: typeof a); // no error, bug?
function foo7(x: any) { }
function foo8(x: B<string, number>);
function foo8(x: I<string, number>); // ok
function foo8(x: any) { }
function foo9(x: B<string, number>);
function foo9(x: C<string, number>); // ok
function foo9(x: any) { }
function foo10(x: B<string, number>);
function foo10(x: typeof a); // ok
function foo10(x: any) { }
function foo11(x: B<string, number>);
function foo11(x: typeof b); // ok
function foo11(x: any) { }
function foo12(x: I<string, number>);
function foo12(x: C<string, number>); // error
function foo12(x: any) { }
function foo12b(x: I2);
function foo12b(x: C<string, number>); // ok
function foo12b(x: any) { }
function foo13(x: I<string, number>);
function foo13(x: typeof a); // ok
function foo13(x: any) { }
function foo14(x: I<string, number>);
function foo14(x: typeof b); // ok
function foo14(x: any) { }
function foo15(x: I2);
function foo15(x: C<string, number>); // ok
function foo15(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints.ts | TypeScript | // Two call or construct signatures are considered identical when they have the same number of type parameters and, considering those
// parameters pairwise identical, have identical type parameter constraints, identical number of parameters with identical kind(required,
// optional or rest) and types, and identical return types.
class B<T extends Array<number>> {
constructor(x: T) { return null; }
}
class C<T extends String> {
constructor(x: T) { return null; }
}
interface I<T extends Number> {
new(x: T): string;
}
interface I2 {
new<T extends Boolean>(x: T): string;
}
var a: { new<T extends Array<string>>(x: T): string }
var b = { new<T extends RegExp>(x: T) { return ''; } }; // not a construct signature, function called new
function foo1b(x: B<Array<number>>);
function foo1b(x: B<Array<number>>); // error
function foo1b(x: any) { }
function foo1c(x: C<String>);
function foo1c(x: C<String>); // error
function foo1c(x: any) { }
function foo2(x: I<Number>);
function foo2(x: I<Number>); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo8(x: B<Array<number>>);
function foo8(x: I<Number>); // ok
function foo8(x: any) { }
function foo9(x: B<Array<number>>);
function foo9(x: C<String>); // error, types are structurally equal
function foo9(x: any) { }
function foo10(x: B<Array<number>>);
function foo10(x: typeof a); // ok
function foo10(x: any) { }
function foo11(x: B<Array<number>>);
function foo11(x: typeof b); // ok
function foo11(x: any) { }
function foo12(x: I<Number>);
function foo12(x: C<String>); // ok
function foo12(x: any) { }
function foo12b(x: I2);
function foo12b(x: C<String>); // ok
function foo12b(x: any) { }
function foo13(x: I<Number>);
function foo13(x: typeof a); // ok
function foo13(x: any) { }
function foo14(x: I<Number>);
function foo14(x: typeof b); // ok
function foo14(x: any) { }
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints2.ts | TypeScript | // Two call or construct signatures are considered identical when they have the same number of type parameters and, considering those
// parameters pairwise identical, have identical type parameter constraints, identical number of parameters with identical kind(required,
// optional or rest) and types, and identical return types.
class B<T extends U, U extends Array<number>> {
constructor(x: T, y: U) { return null; }
}
class C<T extends U, U extends String> {
constructor(x: T, y: U) { return null; }
}
class D<T extends U, U extends Number> {
constructor(x: T, y: U) { return null; }
}
interface I<T extends U, U extends Number> {
new(x: T, y: U): string;
}
interface I2 {
new<T extends U, U extends Boolean>(x: T, y: U): string;
}
var a: { new<T extends U, U extends Array<string>>(x: T, y: U): string }
var b = { new<T extends U, U extends RegExp>(x: T, y: U) { return ''; } }; // not a construct signature, function called new
function foo1b(x: B<Array<number>, Array<number>>);
function foo1b(x: B<Array<number>, Array<number>>); // error
function foo1b(x: any) { }
function foo1c(x: C<String, String>);
function foo1c(x: C<String, String>); // error
function foo1c(x: any) { }
function foo2(x: I<Number, Number>);
function foo2(x: I<Number, Number>); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo5c(x: C<String, String>);
function foo5c(x: D<Number, Number>); // ok
function foo5c(x: any) { }
function foo6c(x: C<String, String>);
function foo6c(x: D<any, Number>); // ok
function foo6c(x: any) { }
function foo8(x: B<Array<number>, Array<number>>);
function foo8(x: I<Number, Number>); // ok
function foo8(x: any) { }
function foo9(x: B<Array<number>, Array<number>>);
function foo9(x: C<String, String>); // error, types are structurally equal
function foo9(x: any) { }
function foo10(x: B<Array<number>, Array<number>>);
function foo10(x: typeof a); // ok
function foo10(x: any) { }
function foo11(x: B<Array<number>, Array<number>>);
function foo11(x: typeof b); // ok
function foo11(x: any) { }
function foo12(x: I<Number, Number>);
function foo12(x: C<String, String>); // ok
function foo12(x: any) { }
function foo12b(x: I2);
function foo12b(x: C<String, String>); // ok
function foo12b(x: any) { }
function foo13(x: I<Number, Number>);
function foo13(x: typeof a); // ok
function foo13(x: any) { }
function foo14(x: I<Number, Number>);
function foo14(x: typeof b); // ok
function foo14(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints3.ts | TypeScript | // Two call or construct signatures are considered identical when they have the same number of type parameters and, considering those
// parameters pairwise identical, have identical type parameter constraints, identical number of parameters with identical kind(required,
// optional or rest) and types, and identical return types.
class One { foo: string }
class Two { foo: string }
interface Three { foo: string }
interface Four<T> { foo: T }
interface Five<T> extends Four<T> { }
interface Six<T, U> {
foo: T;
}
class B<T extends U, U extends Two> {
constructor(x: T, y: U) { return null; }
}
class C<T extends U, U extends Three> {
constructor(x: T, y: U) { return null; }
}
class D<T extends U, U extends Four<string>> {
constructor(x: T, y: U) { return null; }
}
interface I<T extends U, U extends Five<string>> {
new(x: T, y: U): string;
}
interface I2 {
new<T extends U, U extends Six<string, string>>(x: T, y: U): string;
}
var a: { new<T extends U, U extends One>(x: T, y: U): string }
var b = { new<T extends U, U extends Two>(x: T, y: U) { return ''; } }; // not a construct signature, function called new
function foo1b(x: B<Two, Two>);
function foo1b(x: B<Two, Two>); // error
function foo1b(x: any) { }
function foo1c(x: C<Three, Three>);
function foo1c(x: C<Three, Three>); // error
function foo1c(x: any) { }
function foo2(x: I<Five<string>, Five<string>>);
function foo2(x: I<Five<string>, Five<string>>); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo5c(x: C<Three, Three>);
function foo5c(x: D<Four<string>, Four<string>>); // error
function foo5c(x: any) { }
function foo6c(x: C<Three, Three>);
function foo6c(x: D<Four<string>, Four<string>>); // error
function foo6c(x: any) { }
function foo8(x: B<Two, Two>);
function foo8(x: I<Five<string>, Five<string>>); // error
function foo8(x: any) { }
function foo9(x: B<Two, Two>);
function foo9(x: C<Three, Three>); // error
function foo9(x: any) { }
function foo10(x: B<Two, Two>);
function foo10(x: typeof a); // ok
function foo10(x: any) { }
function foo11(x: B<Two, Two>);
function foo11(x: typeof b); // ok
function foo11(x: any) { }
function foo12(x: I<Five<string>, Five<string>>);
function foo12(x: C<Three, Three>); // ok
function foo12(x: any) { }
function foo12b(x: I2);
function foo12b(x: C<Three, Three>); // ok
function foo12b(x: any) { }
function foo13(x: I<Five<string>, Five<string>>);
function foo13(x: typeof a); // ok
function foo13(x: any) { }
function foo14(x: I<Five<string>, Five<string>>);
function foo14(x: typeof b); // ok
function foo14(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithGenericConstructSignaturesDifferingByReturnType.ts | TypeScript | // Two call or construct signatures are considered identical when they have the same number of type parameters and, considering those
// parameters pairwise identical, have identical type parameter constraints, identical number of parameters with identical kind(required,
// optional or rest) and types, and identical return types.
class B<T> {
constructor(x: T) { return null; }
}
class C<T> {
constructor(x: T) { return null; }
}
interface I<T> {
new(x: T): Date;
}
interface I2 {
new<T>(x: T): RegExp;
}
var a: { new<T>(x: T): T }
var b = { new<T>(x: T): T { return null; } }; // not a construct signature, function called new
function foo1b(x: B<string>);
function foo1b(x: B<string>); // error
function foo1b(x: any) { }
function foo1c(x: C<string>);
function foo1c(x: C<string>); // error
function foo1c(x: any) { }
function foo2(x: I<string>);
function foo2(x: I<string>); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo5(x: typeof a): number;
function foo5(x: typeof b): string; // ok
function foo5(x: any): any { }
function foo8(x: B<string>);
function foo8(x: I<string>); // ok
function foo8(x: any) { }
function foo9(x: B<string>);
function foo9(x: C<string>); // error since types are structurally equal
function foo9(x: any) { }
function foo10(x: B<string>);
function foo10(x: typeof a); // ok
function foo10(x: any) { }
function foo11(x: B<string>);
function foo11(x: typeof b); // ok
function foo11(x: any) { }
function foo12(x: I<string>);
function foo12(x: C<string>); // ok
function foo12(x: any) { }
function foo12b(x: I2);
function foo12b(x: C<string>); // ok
function foo12b(x: any) { }
function foo13(x: I<string>);
function foo13(x: typeof a); // ok
function foo13(x: any) { }
function foo14(x: I<string>);
function foo14(x: typeof b); // ok
function foo14(x: any) { }
function foo15(x: I2);
function foo15(x: C<number>); // ok
function foo15(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithGenericConstructSignaturesDifferingByReturnType2.ts | TypeScript | // Two call or construct signatures are considered identical when they have the same number of type parameters and, considering those
// parameters pairwise identical, have identical type parameter constraints, identical number of parameters with identical kind(required,
// optional or rest) and types, and identical return types.
class B<T extends Date> {
constructor(x: T) { return null; }
}
class C<T extends Date> {
constructor(x: T) { return null; }
}
interface I<T extends Date> {
new(x: T): Date;
}
interface I2 {
new<T extends Date>(x: T): RegExp;
}
var a: { new<T extends Date>(x: T): T }
var b = { new<T extends Date>(x: T) { return null; } }; // not a construct signature, function called new
function foo1b(x: B<Date>);
function foo1b(x: B<Date>); // error
function foo1b(x: any) { }
function foo1c(x: C<Date>);
function foo1c(x: C<Date>); // error
function foo1c(x: any) { }
function foo2(x: I<Date>);
function foo2(x: I<Date>); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo8(x: B<Date>);
function foo8(x: I<Date>); // ok
function foo8(x: any) { }
function foo9(x: B<Date>);
function foo9(x: C<Date>); // error since types are structurally equal
function foo9(x: any) { }
function foo10(x: B<Date>);
function foo10(x: typeof a); // ok
function foo10(x: any) { }
function foo11(x: B<Date>);
function foo11(x: typeof b); // ok
function foo11(x: any) { }
function foo12(x: I<Date>);
function foo12(x: C<Date>); // ok
function foo12(x: any) { }
function foo12b(x: I2);
function foo12b(x: C<Date>); // ok
function foo12b(x: any) { }
function foo13(x: I<Date>);
function foo13(x: typeof a); // ok
function foo13(x: any) { }
function foo14(x: I<Date>);
function foo14(x: typeof b); // ok
function foo14(x: any) { }
function foo15(x: I2);
function foo15(x: C<Date>); // ok
function foo15(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithGenericConstructSignaturesDifferingTypeParameterCounts.ts | TypeScript | // object types are identical structurally
class B<U, V> {
constructor(x: U) { return null; }
}
class C<V, W, X> {
constructor(x: V) { return null; }
}
interface I<X, Y, Z, A> {
new(x: X): B<X,Y>;
}
interface I2 {
new <Y, Z, A, B>(x: Y): C<Y, Z, A>;
}
var a: { new <Z, A, B, CC, D>(x: Z): C<Z, A, B>; }
var b = { new<A, B, C, D, E, F>(x: A) { return x; } };
function foo1b(x: B<string, string>);
function foo1b(x: B<string, string>); // error
function foo1b(x: any) { }
function foo1c(x: C<string, number, boolean>);
function foo1c(x: C<string, number, boolean>); // error
function foo1c(x: any) { }
function foo2(x: I<string, boolean, number, string>);
function foo2(x: I<string, boolean, number, string>); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo8(x: B<string, string>);
function foo8(x: I<string, string, boolean, Date>); // BUG 832086
function foo8(x: any) { }
function foo9(x: B<string, number>);
function foo9(x: C<string, number, B<string, string>>); // error
function foo9(x: any) { }
function foo10(x: B<string, boolean>);
function foo10(x: typeof a); // ok
function foo10(x: any) { }
function foo11(x: B<string, boolean>);
function foo11(x: typeof b); // ok
function foo11(x: any) { }
function foo12(x: I<B<string, number>, number, Date, string>);
function foo12(x: C<B<string, number>, number, Date>); // ok
function foo12(x: any) { }
function foo12b(x: I2);
function foo12b(x: C<string, string, boolean>); // BUG 832086
function foo12b(x: any) { }
function foo13(x: I<string, Date, RegExp, Date>);
function foo13(x: typeof a); // ok
function foo13(x: any) { }
function foo14(x: I<string, Date, RegExp, boolean>);
function foo14(x: typeof b); // ok
function foo14(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithGenericConstructSignaturesDifferingTypeParameterNames.ts | TypeScript | // object types are identical structurally
class B<U> {
constructor(x: U) { return null; }
}
class C<V> {
constructor(x: V) { return null; }
}
interface I<X> {
new(x: X): B<X>;
}
interface I2 {
new<Y>(x: Y): C<Y>;
}
var a: { new<Z>(x: Z): B<Z> }
var b = { new<A>(x: A) { return new C<A>(x); } };
function foo1b(x: B<string>);
function foo1b(x: B<string>); // error
function foo1b(x: any) { }
function foo1c(x: C<string>);
function foo1c(x: C<string>); // error
function foo1c(x: any) { }
function foo2(x: I<string>);
function foo2(x: I<string>); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo8(x: B<string>);
function foo8(x: I<string>); // BUG 832086
function foo8(x: any) { }
function foo9(x: B<string>);
function foo9(x: C<string>); // error
function foo9(x: any) { }
function foo10(x: B<string>);
function foo10(x: typeof a); // BUG 832086
function foo10(x: any) { }
function foo11(x: B<string>);
function foo11(x: typeof b); // ok
function foo11(x: any) { }
function foo12(x: I<string>);
function foo12(x: C<string>); // error
function foo12(x: any) { }
function foo12b(x: I2);
function foo12b(x: C<string>); // BUG 832086
function foo12b(x: any) { }
function foo13(x: I<string>);
function foo13(x: typeof a); // BUG 832086
function foo13(x: any) { }
function foo14(x: I<string>);
function foo14(x: typeof b); // ok
function foo14(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithGenericConstructSignaturesOptionalParams.ts | TypeScript | // Two call or construct signatures are considered identical when they have the same number of type parameters and, considering those
// parameters pairwise identical, have identical type parameter constraints, identical number of parameters with identical kind(required,
// optional or rest) and types, and identical return types.
class B<T> {
constructor(x: T, y?: T) { return null; }
}
class C<T> {
constructor(x: T, y?: T) { return null; }
}
interface I<T> {
new(x: T, y?: T): B<T>;
}
interface I2 {
new<T>(x: T, y?: T): C<T>;
}
var a: { new<T>(x: T, y?: T): B<T> }
var b = { new<T>(x: T, y?: T) { return new C<T>(x, y); } }; // not a construct signature, function called new
function foo1b(x: B<string>);
function foo1b(x: B<string>); // error
function foo1b(x: any) { }
function foo1c(x: C<string>);
function foo1c(x: C<string>); // error
function foo1c(x: any) { }
function foo2(x: I<string>);
function foo2(x: I<string>); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo8(x: B<string>): string;
function foo8(x: I<string>): number; // BUG 832086
function foo8(x: any): any { }
function foo9(x: B<string>);
function foo9(x: C<string>); // error, differ only by return type
function foo9(x: any) { }
function foo10(x: B<string>);
function foo10(x: typeof a); // BUG 832086
function foo10(x: any) { }
function foo11(x: B<string>);
function foo11(x: typeof b); // ok
function foo11(x: any) { }
function foo12(x: I<string>);
function foo12(x: C<string>); // ok
function foo12(x: any) { }
function foo12b(x: I2);
function foo12b(x: C<string>); // BUG 832086
function foo12b(x: any) { }
function foo13(x: I<string>);
function foo13(x: typeof a); // BUG 832086
function foo13(x: any) { }
function foo14(x: I<string>);
function foo14(x: typeof b); // ok
function foo14(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithGenericConstructSignaturesOptionalParams2.ts | TypeScript | // Two call or construct signatures are considered identical when they have the same number of type parameters and, considering those
// parameters pairwise identical, have identical type parameter constraints, identical number of parameters with identical kind(required,
// optional or rest) and types, and identical return types.
class B<T, U> {
constructor(x: T, y?: U) { return null; }
}
class C<T, U> {
constructor(x: T, y?: U) { return null; }
}
interface I<T, U> {
new (x: T, y?: U): B<T, U>;
}
interface I2 {
new <T, U>(x: T, y?: U): C<T, U>;
}
var a: { new<T, U>(x: T, y?: U): B<T,U> }
var b = { new<T, U>(x: T, y?: U) { return new C<T, U>(x, y); } }; // not a construct signature, function called new
function foo1b(x: B<string, number>);
function foo1b(x: B<string, number>); // error
function foo1b(x: any) { }
function foo1c(x: C<string, number>);
function foo1c(x: C<string, number>); // error
function foo1c(x: any) { }
function foo2(x: I<string, number>);
function foo2(x: I<string, number>); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo8(x: B<string, number>);
function foo8(x: I<string, number>); // BUG 832086
function foo8(x: any) { }
function foo9(x: B<string, number>);
function foo9(x: C<string, number>); // error
function foo9(x: any) { }
function foo10(x: B<string, number>);
function foo10(x: typeof a); // BUG 832086
function foo10(x: any) { }
function foo11(x: B<string, number>);
function foo11(x: typeof b); // ok
function foo11(x: any) { }
function foo12(x: I<string, number>);
function foo12(x: C<string, number>); // BUG 832086
function foo12(x: any) { }
function foo12b(x: I2);
function foo12b(x: C<string, number>); // ok
function foo12b(x: any) { }
function foo13(x: I<string, number>);
function foo13(x: typeof a); // BUG 832086
function foo13(x: any) { }
function foo14(x: I<string, number>);
function foo14(x: typeof b); // ok
function foo14(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithGenericConstructSignaturesOptionalParams3.ts | TypeScript | // Two call or construct signatures are considered identical when they have the same number of type parameters and, considering those
// parameters pairwise identical, have identical type parameter constraints, identical number of parameters with identical kind(required,
// optional or rest) and types, and identical return types.
class B<T, U> {
constructor(x: T, y: U) { return null; }
}
class C<T, U> {
constructor(x: T, y?: U) { return null; }
}
interface I<T, U> {
new(x: T, y?: U): B<T, U>;
}
interface I2 {
new<T, U>(x: T, y: U): C<T, U>;
}
var a: { new <T, U>(x: T, y?: U): B<T, U> };
var b = { new<T, U>(x: T, y: U) { return new C<T, U>(x, y); } }; // not a construct signature, function called new
function foo1b(x: B<string, number>);
function foo1b(x: B<string, number>); // error
function foo1b(x: any) { }
function foo1c(x: C<string, number>);
function foo1c(x: C<string, number>); // error
function foo1c(x: any) { }
function foo2(x: I<string, number>);
function foo2(x: I<string, number>); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo8(x: B<string, number>);
function foo8(x: I<string, number>); // BUG 832086
function foo8(x: any) { }
function foo9(x: B<string, number>);
function foo9(x: C<string, number>); // error, differ only by return type
function foo9(x: any) { }
function foo10(x: B<string, number>);
function foo10(x: typeof a); // BUG 832086
function foo10(x: any) { }
function foo11(x: B<string, number>);
function foo11(x: typeof b); // ok
function foo11(x: any) { }
function foo12(x: I<string, number>);
function foo12(x: C<string, number>); // ok
function foo12(x: any) { }
function foo12b(x: I2);
function foo12b(x: C<string, number>); // BUG 832086
function foo12b(x: any) { }
function foo13(x: I<string, number>);
function foo13(x: typeof a); // BUG 832086
function foo13(x: any) { }
function foo14(x: I<string, number>);
function foo14(x: typeof b); // ok
function foo14(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithNumericIndexers1.ts | TypeScript | // object types are identical structurally
class A {
[x: number]: string;
}
class B {
[x: number]: string;
}
class C<T> {
[x: number]: T;
}
interface I {
[x: number]: string;
}
class PA extends A {
}
class PB extends B {
}
var a: {
[x: number]: string;
}
var b: { [x: number]: string; } = { 0: '' };
function foo1(x: A);
function foo1(x: A); // error
function foo1(x: any) { }
function foo1b(x: B);
function foo1b(x: B); // error
function foo1b(x: any) { }
function foo1c(x: C<string>);
function foo1c(x: C<string>); // error
function foo1c(x: any) { }
function foo2(x: I);
function foo2(x: I); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo5(x: A);
function foo5(x: B); // error
function foo5(x: any) { }
function foo5b(x: A);
function foo5b(x: C<string>); // error
function foo5b(x: any) { }
function foo5c(x: A);
function foo5c(x: PA); // error
function foo5c(x: any) { }
function foo5d(x: A);
function foo5d(x: PB); // error
function foo5d(x: any) { }
function foo6(x: A);
function foo6(x: I); // error
function foo6(x: any) { }
function foo7(x: A);
function foo7(x: typeof a); // error
function foo7(x: any) { }
function foo8(x: B);
function foo8(x: I); // error
function foo8(x: any) { }
function foo9(x: B);
function foo9(x: C<string>); // error
function foo9(x: any) { }
function foo10(x: B);
function foo10(x: typeof a); // error
function foo10(x: any) { }
function foo11(x: B);
function foo11(x: typeof b); // error
function foo11(x: any) { }
function foo11b(x: B);
function foo11b(x: PA); // error
function foo11b(x: any) { }
function foo11c(x: B);
function foo11c(x: PB); // error
function foo11c(x: any) { }
function foo12(x: I);
function foo12(x: C<string>); // error
function foo12(x: any) { }
function foo13(x: I);
function foo13(x: typeof a); // error
function foo13(x: any) { }
function foo14(x: I);
function foo14(x: typeof b); // error
function foo14(x: any) { }
function foo15(x: I);
function foo15(x: PA); // error
function foo15(x: any) { }
function foo16(x: I);
function foo16(x: PB); // error
function foo16(x: any) { }
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithNumericIndexers2.ts | TypeScript | // object types are identical structurally
class Base { foo: string; }
class Derived extends Base { bar: string; }
class A {
[x: number]: Base;
}
class B {
[x: number]: Derived;
}
class C<T> {
[x: number]: T;
}
interface I {
[x: number]: Derived;
}
class PA extends A {
}
class PB extends B {
}
var a: {
[x: number]: Base;
}
var b: { [x: number]: Derived; } = { 0: <Derived>null };
function foo1(x: A);
function foo1(x: A); // error
function foo1(x: any) { }
function foo1b(x: B);
function foo1b(x: B); // error
function foo1b(x: any) { }
function foo1c(x: C<string>);
function foo1c(x: C<string>); // error
function foo1c(x: any) { }
function foo2(x: I);
function foo2(x: I); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo5(x: A);
function foo5(x: B); // ok
function foo5(x: any) { }
function foo5b(x: A);
function foo5b(x: C<Derived>); // ok
function foo5b(x: any) { }
function foo5c(x: A);
function foo5c(x: PA); // error
function foo5c(x: any) { }
function foo5d(x: A);
function foo5d(x: PB); // ok
function foo5d(x: any) { }
function foo6(x: A);
function foo6(x: I); // ok
function foo6(x: any) { }
function foo7(x: A);
function foo7(x: typeof a); // error
function foo7(x: any) { }
function foo8(x: B);
function foo8(x: I); // error
function foo8(x: any) { }
function foo9(x: B);
function foo9(x: C<Base>); // ok
function foo9(x: any) { }
function foo10(x: B);
function foo10(x: typeof a); // ok
function foo10(x: any) { }
function foo11(x: B);
function foo11(x: typeof b); // error
function foo11(x: any) { }
function foo11b(x: B);
function foo11b(x: PA); // ok
function foo11b(x: any) { }
function foo11c(x: B);
function foo11c(x: PB); // error
function foo11c(x: any) { }
function foo12(x: I);
function foo12(x: C<Derived>); // error
function foo12(x: any) { }
function foo13(x: I);
function foo13(x: typeof a); // ok
function foo13(x: any) { }
function foo14(x: I);
function foo14(x: typeof b); // error
function foo14(x: any) { }
function foo15(x: I);
function foo15(x: PA); // ok
function foo15(x: any) { }
function foo16(x: I);
function foo16(x: PB); // error
function foo16(x: any) { }
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithNumericIndexers3.ts | TypeScript | // object types are identical structurally
class A {
[x: number]: string;
}
class B {
[x: string]: string;
}
class C<T> {
[x: number]: T;
}
interface I {
[x: string]: string;
}
class PA extends A {
}
class PB extends B {
}
var a: {
[x: string]: string;
}
var b: { [x: number]: string; } = { 0: '' };
function foo1(x: A);
function foo1(x: A); // error
function foo1(x: any) { }
function foo1b(x: B);
function foo1b(x: B); // error
function foo1b(x: any) { }
function foo1c(x: C<string>);
function foo1c(x: C<string>); // error
function foo1c(x: any) { }
function foo2(x: I);
function foo2(x: I); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo5(x: A);
function foo5(x: B); // ok
function foo5(x: any) { }
function foo5b(x: A);
function foo5b(x: C<string>); // error
function foo5b(x: any) { }
function foo5c(x: A);
function foo5c(x: PA); // error
function foo5c(x: any) { }
function foo5d(x: A);
function foo5d(x: PB); // ok
function foo5d(x: any) { }
function foo6(x: A);
function foo6(x: I); // ok
function foo6(x: any) { }
function foo7(x: A);
function foo7(x: typeof a); // ok
function foo7(x: any) { }
function foo8(x: B);
function foo8(x: I); // error
function foo8(x: any) { }
function foo9(x: B);
function foo9(x: C<string>); // ok
function foo9(x: any) { }
function foo10(x: B);
function foo10(x: typeof a); // error
function foo10(x: any) { }
function foo11(x: B);
function foo11(x: typeof b); // ok
function foo11(x: any) { }
function foo11b(x: B);
function foo11b(x: PA); // ok
function foo11b(x: any) { }
function foo11c(x: B);
function foo11c(x: PB); // error
function foo11c(x: any) { }
function foo12(x: I);
function foo12(x: C<string>); // ok
function foo12(x: any) { }
function foo13(x: I);
function foo13(x: typeof a); // error
function foo13(x: any) { }
function foo14(x: I);
function foo14(x: typeof b); // ok
function foo14(x: any) { }
function foo15(x: I);
function foo15(x: PA); // ok
function foo15(x: any) { }
function foo16(x: I);
function foo16(x: PB); // error
function foo16(x: any) { }
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithOptionality.ts | TypeScript | // object types are identical structurally
class A {
foo: string;
}
class B {
foo: string;
}
class C<T> {
foo: T;
}
interface I {
foo?: string;
}
var a: { foo?: string; }
var b = { foo: '' };
function foo2(x: I);
function foo2(x: I); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo6(x: A);
function foo6(x: I); // ok
function foo6(x: any) { }
function foo7(x: A);
function foo7(x: typeof a); // ok
function foo7(x: any) { }
function foo8(x: B);
function foo8(x: I); // ok
function foo8(x: any) { }
function foo10(x: B);
function foo10(x: typeof a); // ok
function foo10(x: any) { }
function foo12(x: I);
function foo12(x: C<string>); // ok
function foo12(x: any) { }
function foo13(x: I);
function foo13(x: typeof a); // error
function foo13(x: any) { }
function foo14(x: I);
function foo14(x: typeof b); // ok
function foo14(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithPrivates.ts | TypeScript | // object types are identical structurally
class A {
private foo: string;
}
class B {
private foo: string;
}
class C<T> {
private foo: T;
}
interface I {
foo: string;
}
class PA extends A {
}
class PB extends B {
}
var a: { foo: string; }
var b = { foo: '' };
function foo1(x: A);
function foo1(x: A); // error
function foo1(x: any) { }
function foo1b(x: B);
function foo1b(x: B); // error
function foo1b(x: any) { }
function foo1c(x: C<string>);
function foo1c(x: C<string>); // error
function foo1c(x: any) { }
function foo2(x: I);
function foo2(x: I); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo5(x: A);
function foo5(x: B); // no error
function foo5(x: any) { }
function foo5b(x: A);
function foo5b(x: C<string>); // no error
function foo5b(x: any) { }
function foo5c(x: A);
function foo5c(x: PA); // error
function foo5c(x: any) { }
function foo5d(x: A);
function foo5d(x: PB); // no error
function foo5d(x: any) { }
function foo6(x: A);
function foo6(x: I); // no error
function foo6(x: any) { }
function foo7(x: A);
function foo7(x: typeof a); // no error
function foo7(x: any) { }
function foo8(x: B);
function foo8(x: I); // no error
function foo8(x: any) { }
function foo9(x: B);
function foo9(x: C<string>); // no error
function foo9(x: any) { }
function foo10(x: B);
function foo10(x: typeof a); // no error
function foo10(x: any) { }
function foo11(x: B);
function foo11(x: typeof b); // no error
function foo11(x: any) { }
function foo11b(x: B);
function foo11b(x: PA); // no error
function foo11b(x: any) { }
function foo11c(x: B);
function foo11c(x: PB); // error
function foo11c(x: any) { }
function foo12(x: I);
function foo12(x: C<string>); // no error
function foo12(x: any) { }
function foo13(x: I);
function foo13(x: typeof a); // error
function foo13(x: any) { }
function foo14(x: I);
function foo14(x: typeof b); // error
function foo14(x: any) { }
function foo15(x: I);
function foo15(x: PA); // no error
function foo15(x: any) { }
function foo16(x: I);
function foo16(x: PB); // no error
function foo16(x: any) { }
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithPrivates2.ts | TypeScript | // object types are identical structurally
class C<T> {
private foo: T;
}
class D<T> extends C<T> {
}
function foo1(x: C<string>);
function foo1(x: C<number>); // ok
function foo1(x: any) { }
function foo2(x: D<string>);
function foo2(x: D<number>); // ok
function foo2(x: any) { }
function foo3(x: C<string>);
function foo3(x: D<number>); // ok
function foo3(x: any) { }
function foo4(x: C<number>): number;
function foo4(x: D<number>): string; // BUG 831926
function foo4(x: any): any { }
var r = foo4(new C<number>());
var r = foo4(new D<number>());
function foo5(x: C<number>): number;
function foo5(x: C<number>): string; // error
function foo5(x: any): any { }
function foo6(x: D<number>): number;
function foo6(x: D<number>): string; // error
function foo6(x: any): any { }
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithPrivates3.ts | TypeScript | interface T1 { }
interface T2 { z }
class C1<T> {
private x;
}
class C2 extends C1<T1> {
y;
}
var c1: C1<T2>;
<C2>c1; // Should succeed (private x originates in the same declaration)
class C3<T> {
private x: T; // This T is the difference between C3 and C1
}
class C4 extends C3<T1> {
y;
}
var c3: C3<T2>;
<C4>c3; // Should fail (private x originates in the same declaration, but different types) | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithPublics.ts | TypeScript | // object types are identical structurally
class A {
public foo: string;
}
class B {
public foo: string;
}
class C<T> {
public foo: T;
}
interface I {
foo: string;
}
var a: { foo: string; }
var b = { foo: '' };
function foo1(x: A);
function foo1(x: A); // error
function foo1(x: any) { }
function foo1b(x: B);
function foo1b(x: B); // error
function foo1b(x: any) { }
function foo1c(x: C<string>);
function foo1c(x: C<string>); // error
function foo1c(x: any) { }
function foo2(x: I);
function foo2(x: I); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo5(x: A);
function foo5(x: B); // error
function foo5(x: any) { }
function foo5b(x: A);
function foo5b(x: C<string>); // error
function foo5b(x: any) { }
function foo6(x: A);
function foo6(x: I); // error
function foo6(x: any) { }
function foo7(x: A);
function foo7(x: typeof a); // error
function foo7(x: any) { }
function foo8(x: B);
function foo8(x: I); // error
function foo8(x: any) { }
function foo9(x: B);
function foo9(x: C<string>); // error
function foo9(x: any) { }
function foo10(x: B);
function foo10(x: typeof a); // error
function foo10(x: any) { }
function foo11(x: B);
function foo11(x: typeof b); // error
function foo11(x: any) { }
function foo12(x: I);
function foo12(x: C<string>); // error
function foo12(x: any) { }
function foo13(x: I);
function foo13(x: typeof a); // error
function foo13(x: any) { }
function foo14(x: I);
function foo14(x: typeof b); // error
function foo14(x: any) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithStringIndexers.ts | TypeScript | // object types are identical structurally
class A {
[x: string]: string;
}
class B {
[x: string]: string;
}
class C<T> {
[x: string]: T;
}
interface I {
[x: string]: string;
}
class PA extends A {
}
class PB extends B {
}
var a: {
[x: string]: string;
}
var b: { [x: string]: string; } = { foo: '' };
function foo1(x: A);
function foo1(x: A); // error
function foo1(x: any) { }
function foo1b(x: B);
function foo1b(x: B); // error
function foo1b(x: any) { }
function foo1c(x: C<string>);
function foo1c(x: C<string>); // error
function foo1c(x: any) { }
function foo2(x: I);
function foo2(x: I); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo5(x: A);
function foo5(x: B); // error
function foo5(x: any) { }
function foo5b(x: A);
function foo5b(x: C<string>); // error
function foo5b(x: any) { }
function foo5c(x: A);
function foo5c(x: PA); // error
function foo5c(x: any) { }
function foo5d(x: A);
function foo5d(x: PB); // error
function foo5d(x: any) { }
function foo6(x: A);
function foo6(x: I); // error
function foo6(x: any) { }
function foo7(x: A);
function foo7(x: typeof a); // error
function foo7(x: any) { }
function foo8(x: B);
function foo8(x: I); // error
function foo8(x: any) { }
function foo9(x: B);
function foo9(x: C<string>); // error
function foo9(x: any) { }
function foo10(x: B);
function foo10(x: typeof a); // error
function foo10(x: any) { }
function foo11(x: B);
function foo11(x: typeof b); // error
function foo11(x: any) { }
function foo11b(x: B);
function foo11b(x: PA); // error
function foo11b(x: any) { }
function foo11c(x: B);
function foo11c(x: PB); // error
function foo11c(x: any) { }
function foo12(x: I);
function foo12(x: C<string>); // error
function foo12(x: any) { }
function foo13(x: I);
function foo13(x: typeof a); // error
function foo13(x: any) { }
function foo14(x: I);
function foo14(x: typeof b); // error
function foo14(x: any) { }
function foo15(x: I);
function foo15(x: PA); // error
function foo15(x: any) { }
function foo16(x: I);
function foo16(x: PB); // error
function foo16(x: any) { }
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesIdentityWithStringIndexers2.ts | TypeScript | // object types are identical structurally
class Base { foo: string; }
class Derived extends Base { bar: string; }
class A {
[x: string]: Base;
}
class B {
[x: string]: Derived;
}
class C<T> {
[x: string]: T;
}
interface I {
[x: string]: Derived;
}
class PA extends A {
}
class PB extends B {
}
var a: {
[x: string]: Base;
}
var b: { [x: string]: Derived; } = { foo: <Derived>null };
function foo1(x: A);
function foo1(x: A); // error
function foo1(x: any) { }
function foo1b(x: B);
function foo1b(x: B); // error
function foo1b(x: any) { }
function foo1c(x: C<string>);
function foo1c(x: C<string>); // error
function foo1c(x: any) { }
function foo2(x: I);
function foo2(x: I); // error
function foo2(x: any) { }
function foo3(x: typeof a);
function foo3(x: typeof a); // error
function foo3(x: any) { }
function foo4(x: typeof b);
function foo4(x: typeof b); // error
function foo4(x: any) { }
function foo5(x: A);
function foo5(x: B); // ok
function foo5(x: any) { }
function foo5b(x: A);
function foo5b(x: C<Derived>); // ok
function foo5b(x: any) { }
function foo5c(x: A);
function foo5c(x: PA); // error
function foo5c(x: any) { }
function foo5d(x: A);
function foo5d(x: PB); // ok
function foo5d(x: any) { }
function foo6(x: A);
function foo6(x: I); // ok
function foo6(x: any) { }
function foo7(x: A);
function foo7(x: typeof a); // error
function foo7(x: any) { }
function foo8(x: B);
function foo8(x: I); // error
function foo8(x: any) { }
function foo9(x: B);
function foo9(x: C<Base>); // ok
function foo9(x: any) { }
function foo10(x: B);
function foo10(x: typeof a); // ok
function foo10(x: any) { }
function foo11(x: B);
function foo11(x: typeof b); // error
function foo11(x: any) { }
function foo11b(x: B);
function foo11b(x: PA); // ok
function foo11b(x: any) { }
function foo11c(x: B);
function foo11c(x: PB); // error
function foo11c(x: any) { }
function foo12(x: I);
function foo12(x: C<Derived>); // error
function foo12(x: any) { }
function foo13(x: I);
function foo13(x: typeof a); // ok
function foo13(x: any) { }
function foo14(x: I);
function foo14(x: typeof b); // error
function foo14(x: any) { }
function foo15(x: I);
function foo15(x: PA); // ok
function foo15(x: any) { }
function foo16(x: I);
function foo16(x: PB); // error
function foo16(x: any) { }
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectTypesWithPredefinedTypesAsName.ts | TypeScript | // it is an error to use a predefined type as a type name
class any { }
class number { }
class boolean { }
class bool { } // not a predefined type anymore
class string { }
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/octalIntegerLiteral.ts | TypeScript | // @target: es5
var oct1 = 0o45436;
var oct2 = 0O45436;
var oct3 = 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777;
var oct4 = 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777;
var obj1 = {
0o45436: "Hello",
a: 0o45436,
b: oct1,
oct1,
0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: true
}
var obj2 = {
0O45436: "hi",
a: 0O45436,
b: oct2,
oct2,
0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: false,
}
obj1[0o45436]; // string
obj1["0o45436"]; // any
obj1["19230"]; // string
obj1[19230]; // string
obj1["a"]; // number
obj1["b"]; // number
obj1["oct1"]; // number
obj1["Infinity"]; // boolean
obj2[0O45436]; // string
obj2["0O45436"]; // any
obj2["19230"]; // string
obj2[19230]; // string
obj2["a"]; // number
obj2["b"]; // number
obj2["oct2"]; // number
obj2[5.462437423415177e+244]; // boolean
obj2["5.462437423415177e+244"]; // boolean
obj2["Infinity"]; // any | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/octalIntegerLiteralES6.ts | TypeScript | // @target: es6
var oct1 = 0o45436;
var oct2 = 0O45436;
var oct3 = 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777;
var oct4 = 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777;
var obj1 = {
0o45436: "Hello",
a: 0o45436,
b: oct1,
oct1,
0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: true
}
var obj2 = {
0O45436: "hi",
a: 0O45436,
b: oct2,
oct2,
0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: false,
}
obj1[0o45436]; // string
obj1["0o45436"]; // any
obj1["19230"]; // string
obj1[19230]; // string
obj1["a"]; // number
obj1["b"]; // number
obj1["oct1"]; // number
obj1["Infinity"]; // boolean
obj2[0O45436]; // string
obj2["0O45436"]; // any
obj2["19230"]; // string
obj2[19230]; // string
obj2["a"]; // number
obj2["b"]; // number
obj2["oct2"]; // number
obj2[5.462437423415177e+244]; // boolean
obj2["5.462437423415177e+244"]; // boolean
obj2["Infinity"]; // any | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/operatorsAndIntersectionTypes.ts | TypeScript | type Guid = string & { $Guid }; // Tagged string type
type SerialNo = number & { $SerialNo }; // Tagged number type
function createGuid() {
return "21EC2020-3AEA-4069-A2DD-08002B30309D" as Guid;
}
function createSerialNo() {
return 12345 as SerialNo;
}
let map1: { [x: string]: number } = {};
let guid = createGuid();
map1[guid] = 123; // Can with tagged string
let map2: { [x: number]: string } = {};
let serialNo = createSerialNo();
map2[serialNo] = "hello"; // Can index with tagged number
const s1 = "{" + guid + "}";
const s2 = guid.toLowerCase();
const s3 = guid + guid;
const s4 = guid + serialNo;
const s5 = serialNo.toPrecision(0);
const n1 = serialNo * 3;
const n2 = serialNo + serialNo;
const b1 = guid === "";
const b2 = guid === guid;
const b3 = serialNo === 0;
const b4 = serialNo === serialNo;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/optionalBindingParameters1.ts | TypeScript |
function foo([x,y,z]?: [string, number, boolean]) {
}
foo(["", 0, false]);
foo([false, 0, ""]); | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/optionalBindingParameters2.ts | TypeScript |
function foo({ x, y, z }?: { x: string; y: number; z: boolean }) {
}
foo({ x: "", y: 0, z: false });
foo({ x: false, y: 0, z: "" }); | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/optionalBindingParameters3.ts | TypeScript | // @checkJs: true
// @allowJs: true
// @noEmit: true
// @filename: /a.js
/**
* @typedef Foo
* @property {string} a
*/
/**
* @param {Foo} [options]
*/
function f({ a = "a" }) {}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/optionalBindingParameters4.ts | TypeScript | // @checkJs: true
// @allowJs: true
// @noEmit: true
// @filename: /a.js
/**
* @param {{ cause?: string }} [options]
*/
function foo({ cause } = {}) {
return cause;
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/optionalBindingParametersInOverloads1.ts | TypeScript |
function foo([x, y, z] ?: [string, number, boolean]);
function foo(...rest: any[]) {
}
foo(["", 0, false]);
foo([false, 0, ""]); | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/optionalBindingParametersInOverloads2.ts | TypeScript |
function foo({ x, y, z }?: { x: string; y: number; z: boolean });
function foo(...rest: any[]) {
}
foo({ x: "", y: 0, z: false });
foo({ x: false, y: 0, z: "" }); | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/optionalChainingInArrow.ts | TypeScript | // @target: es5
// @noTypesAndSymbols: true
// https://github.com/microsoft/TypeScript/issues/41814
const test = (names: string[]) =>
// single-line comment
names?.filter(x => x);
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/optionalChainingInLoop.ts | TypeScript | // @target: es5
// @lib: es2015
// @noTypesAndSymbols: true
// https://github.com/microsoft/TypeScript/issues/40643
const list: any[] = []
for (const comp of list) {
comp.sp.y = comp.sp.r.find((k: any) => k.c == (comp.xp ? '1' : '0'))
for (const item of comp.c) {
item.v = !!item.t?.length
}
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/optionalChainingInParameterBindingPattern.2.ts | TypeScript | // @target: esnext,es2015,es5
// @noTypesAndSymbols: true
// @noEmit: true
// https://github.com/microsoft/TypeScript/issues/36295
const a = (): { d: string } | undefined => undefined;
(({ [a()?.d]: c = "" }) => { var a; })();
const x = "";
(({ [a()?.d]: c }, d = x) => { var x; })(); | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/optionalChainingInParameterBindingPattern.ts | TypeScript | // @target: esnext,es2015,es5
// @noTypesAndSymbols: true
// https://github.com/microsoft/TypeScript/issues/36295
const a = (): { d: string } | undefined => undefined;
(({ [a()?.d]: c = "" }) => {})(); | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/optionalChainingInParameterInitializer.2.ts | TypeScript | // @target: esnext,es2015,es5
// @noTypesAndSymbols: true
// @noEmit: true
// https://github.com/microsoft/TypeScript/issues/36295
const a = (): { d: string } | undefined => undefined;
((b = a()?.d) => { var a; })();
const x = "";
((b = a()?.d, d = x) => { var x; })(); | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/optionalChainingInParameterInitializer.ts | TypeScript | // @target: esnext,es2015,es5
// @noTypesAndSymbols: true
// https://github.com/microsoft/TypeScript/issues/36295
const a = (): { d: string } | undefined => undefined;
((b = a()?.d) => {})(); | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/optionalChainingInTypeAssertions.ts | TypeScript | // @target: es2015, esnext
class Foo {
m() {}
}
const foo = new Foo();
(foo.m as any)?.();
(<any>foo.m)?.();
/*a1*/(/*a2*/foo.m as any/*a3*/)/*a4*/?.();
/*b1*/(/*b2*/<any>foo.m/*b3*/)/*b4*/?.();
// https://github.com/microsoft/TypeScript/issues/50148
(foo?.m as any).length;
(<any>foo?.m).length;
(foo?.["m"] as any).length;
(<any>foo?.["m"]).length; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/optionalChainingInference.ts | TypeScript | // https://github.com/microsoft/TypeScript/issues/34579
declare function unbox<T>(box: { value: T | undefined }): T;
declare const su: string | undefined;
declare const fnu: (() => number) | undefined;
declare const osu: { prop: string } | undefined;
declare const ofnu: { prop: () => number } | undefined;
const b1 = { value: su?.length };
const v1: number = unbox(b1);
const b2 = { value: su?.length as number | undefined };
const v2: number = unbox(b2);
const b3: { value: number | undefined } = { value: su?.length };
const v3: number = unbox(b3);
const b4 = { value: fnu?.() };
const v4: number = unbox(b4);
const b5 = { value: su?.["length"] };
const v5: number = unbox(b5);
const b6 = { value: osu?.prop.length };
const v6: number = unbox(b6);
const b7 = { value: osu?.prop["length"] };
const v7: number = unbox(b7);
const b8 = { value: ofnu?.prop() };
const v8: number = unbox(b8);
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/optionalMethod.ts | TypeScript | // @target: esnext
// @noTypesAndSymbols: true
class Base {
method?() { }
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/optionalMethodDeclarations.ts | TypeScript | // @target: esnext,es2016
// @noTypesAndSymbols: true
// https://github.com/microsoft/TypeScript/issues/34952#issuecomment-552025027
class C {
// ? should be removed in emit
method?() {}
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/optionalMethods.ts | TypeScript | // @strictNullChecks: true
// @declaration: true
interface Foo {
a: number;
b?: number;
f(): number;
g?(): number;
}
function test1(x: Foo) {
x.a;
x.b;
x.f;
x.g;
let f1 = x.f();
let g1 = x.g && x.g();
let g2 = x.g ? x.g() : 0;
}
class Bar {
a: number;
b?: number;
c? = 2;
constructor(public d?: number, public e = 10) {}
f() {
return 1;
}
g?(): number; // Body of optional method can be omitted
h?() {
return 2;
}
}
function test2(x: Bar) {
x.a;
x.b;
x.c;
x.d;
x.e;
x.f;
x.g;
let f1 = x.f();
let g1 = x.g && x.g();
let g2 = x.g ? x.g() : 0;
let h1 = x.h && x.h();
let h2 = x.h ? x.h() : 0;
}
class Base {
a?: number;
f?(): number;
}
class Derived extends Base {
a = 1;
f(): number { return 1; }
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/optionalProperties01.ts | TypeScript | // @strictNullChecks: true
// @declaration: true
interface Foo {
required1: string;
required2: string;
optional?: string;
}
const foo1 = { required1: "hello" } as Foo;
const foo2 = { required1: "hello", optional: "bar" } as Foo;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/optionalProperties02.ts | TypeScript | // @strictNullChecks: true
// @declaration: true
interface Foo {
a?: string;
b: string;
}
<Foo>{ a: undefined }; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/optionalProperty.ts | TypeScript | // @target: esnext
// @useDefineForClassFields: true
// @noTypesAndSymbols: true
class C {
prop?;
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/optionalPropertyAssignableToStringIndexSignature.ts | TypeScript | // @strict: true
declare let optionalProperties: { k1?: string };
declare let undefinedProperties: { k1: string | undefined };
declare let stringDictionary: { [key: string]: string };
stringDictionary = optionalProperties; // ok
stringDictionary = undefinedProperties; // error
declare let probablyArray: { [key: number]: string };
declare let numberLiteralKeys: { 1?: string };
probablyArray = numberLiteralKeys; // error
declare let optionalUndefined: { k1?: undefined };
let dict: { [key: string]: string } = optionalUndefined; // error
function f<T>() {
let optional: { k1?: T } = undefined!;
let dict: { [key: string]: T | number } = optional; // ok
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/outFilerootDirModuleNamesAmd.ts | TypeScript | // @target: ES6
// @module: amd
// @rootDir: src
// @outFile: output.js
// @filename: src/a.ts
import foo from "./b";
export default class Foo {}
foo();
// @filename: src/b.ts
import Foo from "./a";
export default function foo() { new Foo(); }
// https://github.com/microsoft/TypeScript/issues/37429
import("./a"); | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/outFilerootDirModuleNamesSystem.ts | TypeScript | // @target: ES6
// @module: system
// @rootDir: src
// @outFile: output.js
// @filename: src/a.ts
import foo from "./b";
export default class Foo {}
foo();
// @filename: src/b.ts
import Foo from "./a";
export default function foo() { new Foo(); }
// https://github.com/microsoft/TypeScript/issues/37429
import("./a");
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/overloadResolution.ts | TypeScript | class SomeBase {
private n;
public s: string;
}
class SomeDerived1 extends SomeBase {
private m;
}
class SomeDerived2 extends SomeBase {
private m;
}
class SomeDerived3 extends SomeBase {
private m;
}
// Ambiguous call picks the first overload in declaration order
function fn1(s: string): string;
function fn1(s: number): number;
function fn1() { return null; }
var s = fn1(undefined);
var s: string;
// No candidate overloads found
fn1({}); // Error
// Generic and non - generic overload where generic overload is the only candidate when called with type arguments
function fn2(s: string, n: number): number;
function fn2<T>(n: number, t: T): T;
function fn2() { return undefined; }
var d = fn2<Date>(0, undefined);
var d: Date;
// Generic and non - generic overload where generic overload is the only candidate when called without type arguments
var s = fn2(0, '');
// Generic and non - generic overload where non - generic overload is the only candidate when called with type arguments
fn2<Date>('', 0); // Error
// Generic and non - generic overload where non - generic overload is the only candidate when called without type arguments
fn2('', 0); // OK
// Generic overloads with differing arity called without type arguments
function fn3<T>(n: T): string;
function fn3<T, U>(s: string, t: T, u: U): U;
function fn3<T, U, V>(v: V, u: U, t: T): number;
function fn3() { return null; }
var s = fn3(3);
var s = fn3('', 3, '');
var n = fn3(5, 5, 5);
var n: number;
// Generic overloads with differing arity called with type arguments matching each overload type parameter count
var s = fn3<number>(4);
var s = fn3<string, string>('', '', '');
var n = fn3<number, string, string>('', '', 3);
// Generic overloads with differing arity called with type argument count that doesn't match any overload
fn3<number, number, number, number>(); // Error
// Generic overloads with constraints called with type arguments that satisfy the constraints
function fn4<T extends string, U extends number>(n: T, m: U);
function fn4<T extends number, U extends string>(n: T, m: U);
function fn4() { }
fn4<string, number>('', 3);
fn4<string, number>(3, ''); // Error
fn4<number, string>('', 3); // Error
fn4<number, string>(3, '');
// Generic overloads with constraints called without type arguments but with types that satisfy the constraints
fn4('', 3);
fn4(3, '');
fn4(3, undefined);
fn4('', null);
// Generic overloads with constraints called with type arguments that do not satisfy the constraints
fn4<boolean, Date>(null, null); // Error
// Generic overloads with constraints called without type arguments but with types that do not satisfy the constraints
fn4(true, null); // Error
fn4(null, true); // Error
// Non - generic overloads where contextual typing of function arguments has errors
function fn5(f: (n: string) => void): string;
function fn5(f: (n: number) => void): number;
function fn5() { return undefined; }
var n = fn5((n) => n.toFixed());
var s = fn5((n) => n.substr(0));
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/overloadResolutionClassConstructors.ts | TypeScript | class SomeBase {
private n;
public s: string;
}
class SomeDerived1 extends SomeBase {
private m;
}
class SomeDerived2 extends SomeBase {
private m;
}
class SomeDerived3 extends SomeBase {
private m;
}
// Ambiguous call picks the first overload in declaration order
class fn1 {
constructor(s: string);
constructor(s: number);
constructor() { }
}
new fn1(undefined);
// No candidate overloads found
new fn1({}); // Error
// Generic and non - generic overload where generic overload is the only candidate when called with type arguments
class fn2<T> {
constructor(s: string, n: number);
constructor(n: number, t: T);
constructor() { }
}
var d = new fn2<Date>(0, undefined);
// Generic and non - generic overload where generic overload is the only candidate when called without type arguments
var s = new fn2(0, '');
// Generic and non - generic overload where non - generic overload is the only candidate when called with type arguments
new fn2<Date>('', 0); // OK
// Generic and non - generic overload where non - generic overload is the only candidate when called without type arguments
new fn2('', 0); // OK
// Generic overloads with differing arity called without type arguments
class fn3<T, U, V> {
constructor(n: T);
constructor(s: string, t: T, u: U);
constructor(v: V, u: U, t: T);
constructor() { }
}
new fn3(3);
new fn3('', 3, '');
new fn3(5, 5, 5);
// Generic overloads with differing arity called with type arguments matching each overload type parameter count
new fn3<number>(4); // Error
new fn3<string, string>('', '', ''); // Error
new fn3<number, string, string>('', '', 3);
// Generic overloads with differing arity called with type argument count that doesn't match any overload
new fn3<number, number, number, number>(); // Error
// Generic overloads with constraints called with type arguments that satisfy the constraints
class fn4<T extends string, U extends number> {
constructor(n: T, m: U);
constructor() { }
}
new fn4<string, number>('', 3);
new fn4<string, number>(3, ''); // Error
new fn4<number, string>('', 3); // Error
new fn4<number, string>(3, ''); // Error
// Generic overloads with constraints called without type arguments but with types that satisfy the constraints
new fn4('', 3);
new fn4(3, ''); // Error
new fn4(3, undefined); // Error
new fn4('', null);
// Generic overloads with constraints called with type arguments that do not satisfy the constraints
new fn4<boolean, Date>(null, null); // Error
// Generic overloads with constraints called without type arguments but with types that do not satisfy the constraints
new fn4(true, null); // Error
new fn4(null, true); // Error
// Non - generic overloads where contextual typing of function arguments has errors
class fn5 {
constructor(f: (n: string) => void);
constructor(f: (n: number) => void);
constructor() { return undefined; }
}
new fn5((n) => n.toFixed());
new fn5((n) => n.substr(0));
new fn5((n) => n.blah); // Error
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/overloadResolutionConstructors.ts | TypeScript | class SomeBase {
private n;
public s: string;
}
class SomeDerived1 extends SomeBase {
private m;
}
class SomeDerived2 extends SomeBase {
private m;
}
class SomeDerived3 extends SomeBase {
private m;
}
interface fn1 {
new (s: string): string;
new (s: number): number;
}
var fn1: fn1;
// Ambiguous call picks the first overload in declaration order
var s = new fn1(undefined);
var s: string;
// No candidate overloads found
new fn1({}); // Error
// Generic and non - generic overload where generic overload is the only candidate when called with type arguments
interface fn2 {
new (s: string, n: number): number;
new <T>(n: number, t: T): T;
}
var fn2: fn2;
var d = new fn2<Date>(0, undefined);
var d: Date;
// Generic and non - generic overload where generic overload is the only candidate when called without type arguments
var s = new fn2(0, '');
// Generic and non - generic overload where non - generic overload is the only candidate when called with type arguments
new fn2<Date>('', 0); // Error
// Generic and non - generic overload where non - generic overload is the only candidate when called without type arguments
new fn2('', 0); // OK
// Generic overloads with differing arity called without type arguments
interface fn3 {
new<T>(n: T): string;
new<T, U>(s: string, t: T, u: U): U;
new<T, U, V>(v: V, u: U, t: T): number;
}
var fn3: fn3;
var s = new fn3(3);
var s = new fn3('', 3, '');
var n = new fn3(5, 5, 5);
var n: number;
// Generic overloads with differing arity called with type arguments matching each overload type parameter count
var s = new fn3<number>(4);
var s = new fn3<string, string>('', '', '');
var n = new fn3<number, string, string>('', '', 3);
// Generic overloads with differing arity called with type argument count that doesn't match any overload
new fn3<number, number, number, number>(); // Error
// Generic overloads with constraints called with type arguments that satisfy the constraints
interface fn4 {
new<T extends string, U extends number>(n: T, m: U);
new<T extends number, U extends string>(n: T, m: U);
}
var fn4: fn4;
new fn4<string, number>('', 3);
new fn4<string, number>(3, ''); // Error
new fn4<number, string>('', 3); // Error
new fn4<number, string>(3, '');
// Generic overloads with constraints called without type arguments but with types that satisfy the constraints
new fn4('', 3);
new fn4(3, '');
new fn4(3, undefined);
new fn4('', null);
// Generic overloads with constraints called with type arguments that do not satisfy the constraints
new fn4<boolean, Date>(null, null); // Error
// Generic overloads with constraints called without type arguments but with types that do not satisfy the constraints
new fn4(true, null); // Error
new fn4(null, true); // Error
// Non - generic overloads where contextual typing of function arguments has errors
interface fn5 {
new(f: (n: string) => void): string;
new(f: (n: number) => void): number;
}
var fn5: fn5;
var n = new fn5((n) => n.toFixed());
var s = new fn5((n) => n.substr(0));
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/overloadTag1.ts | TypeScript | // @checkJs: true
// @allowJs: true
// @outdir: foo
// @declaration: true
// @filename: overloadTag1.js
/**
* @overload
* @param {number} a
* @param {number} b
* @returns {number}
*
* @overload
* @param {string} a
* @param {boolean} b
* @returns {string}
*
* @param {string | number} a
* @param {string | number} b
* @returns {string | number}
*/
export function overloaded(a,b) {
if (typeof a === "string" && typeof b === "string") {
return a + b;
} else if (typeof a === "number" && typeof b === "number") {
return a + b;
}
throw new Error("Invalid arguments");
}
var o1 = overloaded(1,2)
var o2 = overloaded("zero", "one")
var o3 = overloaded("a",false)
/**
* @overload
* @param {number} a
* @param {number} b
* @returns {number}
*
* @overload
* @param {string} a
* @param {boolean} b
* @returns {string}
*/
export function uncheckedInternally(a, b) {
return a + b;
}
uncheckedInternally(1,2)
uncheckedInternally("zero", "one")
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/overloadTag2.ts | TypeScript | // @checkJs: true
// @allowJs: true
// @target: esnext
// @outdir: foo
// @declaration: true
// @filename: overloadTag2.js
// @strict: true
export class Foo {
#a = true ? 1 : "1"
#b
/**
* Should not have an implicit any error, because constructor's return type is always implicit
* @constructor
* @overload
* @param {string} a
* @param {number} b
*/
/**
* @constructor
* @overload
* @param {number} a
*/
/**
* @constructor
* @overload
* @param {string} a
*//**
* @constructor
* @param {number | string} a
*/
constructor(a, b) {
this.#a = a
this.#b = b
}
}
var a = new Foo()
var b = new Foo('str')
var c = new Foo(2)
var d = new Foo('str', 2)
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.