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/decrementOperatorWithUnsupportedStringType.ts
TypeScript
// -- operator on string type var STRING: string; var STRING1: string[] = ["", ""]; function foo(): string { return ""; } class A { public a: string; static foo() { return ""; } } module M { export var n: string; } var objA = new A(); // string type var var ResultIsNumber1 = --STRING; var ResultIsNumber2 = --STRING1; var ResultIsNumber3 = STRING--; var ResultIsNumber4 = STRING1--; // string type literal var ResultIsNumber5 = --""; var ResultIsNumber6 = --{ x: "", y: "" }; var ResultIsNumber7 = --{ x: "", y: (s: string) => { return s; } }; var ResultIsNumber8 = ""--; var ResultIsNumber9 = { x: "", y: "" }--; var ResultIsNumber10 = { x: "", y: (s: string) => { return s; } }--; // string type expressions var ResultIsNumber11 = --objA.a; var ResultIsNumber12 = --M.n; var ResultIsNumber13 = --STRING1[0]; var ResultIsNumber14 = --foo(); var ResultIsNumber15 = --A.foo(); var ResultIsNumber16 = --(STRING + STRING); var ResultIsNumber17 = objA.a--; var ResultIsNumber18 = M.n--; var ResultIsNumber19 = STRING1[0]--; var ResultIsNumber20 = foo()--; var ResultIsNumber21 = A.foo()--; var ResultIsNumber22 = (STRING + STRING)--; // miss assignment operators --""; --STRING; --STRING1; --STRING1[0]; --foo(); --objA.a; --M.n; --objA.a, M.n; ""--; STRING--; STRING1--; STRING1[0]--; foo()--; objA.a--; M.n--; objA.a--, M.n--;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/defaultExportInAwaitExpression01.ts
TypeScript
// @target: ES6 // @module: umd // @filename: a.ts const x = new Promise( ( resolve, reject ) => { resolve( {} ); } ); export default x; // @filename: b.ts import x from './a'; ( async function() { const value = await x; }() );
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/defaultExportInAwaitExpression02.ts
TypeScript
// @target: ES6 // @module: commonjs // @filename: a.ts const x = new Promise( ( resolve, reject ) => { resolve( {} ); } ); export default x; // @filename: b.ts import x from './a'; ( async function() { const value = await x; }() );
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/defaultExportWithOverloads01.ts
TypeScript
// @module: commonjs // @target: ES5 export default function f(); export default function f(x: string); export default function f(...args: any[]) { }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/defaultExportsCannotMerge01.ts
TypeScript
// @module: commonjs // @target: ES5 // @filename: m1.ts export default function Decl() { return 0; } export interface Decl { p1: number; p2: number; } export namespace Decl { export var x = 10; export var y = 20; interface I { } } // @filename: m2.ts import Entity from "m1" Entity(); var x: Entity; var y: Entity.I; Entity.x; Entity.y;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/defaultExportsCannotMerge02.ts
TypeScript
// @module: commonjs // @target: ES5 // @filename: m1.ts export default class Decl { } export interface Decl { p1: number; p2: number; } export namespace Decl { interface I { } } // @filename: m2.ts import Entity from "m1" Entity(); var x: Entity; var y: Entity.I; var z = new Entity(); var sum = z.p1 + z.p2
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/defaultExportsCannotMerge03.ts
TypeScript
// @module: commonjs // @target: ES5 // @filename: m1.ts export default class Decl { } interface Decl { p1: number; p2: number; } namespace Decl { interface I { } } // @filename: m2.ts import Entity from "m1" Entity(); var x: Entity; var y: Entity.I; var z = new Entity(); var sum = z.p1 + z.p2
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/defaultExportsCannotMerge04.ts
TypeScript
// @module: commonjs // @target: ES5 export default function Foo() { } namespace Foo { export var x; } interface Foo { } export interface Foo { }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/defaultExportsGetExportedAmd.ts
TypeScript
// @target: ES6 // @module: amd // @filename: a.ts export default class Foo {} // @filename: b.ts export default function foo() {}
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/defaultExportsGetExportedCommonjs.ts
TypeScript
// @target: ES6 // @module: commonjs // @filename: a.ts export default class Foo {} // @filename: b.ts export default function foo() {}
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/defaultExportsGetExportedSystem.ts
TypeScript
// @target: ES6 // @module: system // @filename: a.ts export default class Foo {} // @filename: b.ts export default function foo() {}
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/defaultExportsGetExportedUmd.ts
TypeScript
// @target: ES6 // @module: umd // @filename: a.ts export default class Foo {} // @filename: b.ts export default function foo() {}
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/defaultPropertyAssignedClassWithPrototype.ts
TypeScript
// @noEmit: true // @allowJs: true // @checkJs: true // @Filename: bug39167.js var test = {}; test.K = test.K || function () {} test.K.prototype = { add() {} }; new test.K().add;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/defineProperty.ts
TypeScript
// @target: es5, esnext // @useDefineForClassFields: true var x: "p" = "p" class A { a = this.y b public c; ["computed"] = 13 ;[x] = 14 m() { } constructor(public readonly y: number) { } z = this.y declare notEmitted; } class B { public a; } class C extends B { declare public a; z = this.ka constructor(public ka: number) { super() } ki = this.ka }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/deleteChain.ts
TypeScript
// @strict: true declare const o1: undefined | { b: string }; delete o1?.b; delete (o1?.b); declare const o2: undefined | { b: { c: string } }; delete o2?.b.c; delete (o2?.b.c); declare const o3: { b: undefined | { c: string } }; delete o3.b?.c; delete (o3.b?.c); declare const o4: { b?: { c: { d?: { e: string } } } }; delete o4.b?.c.d?.e; delete (o4.b?.c.d)?.e; delete (o4.b?.c.d?.e); declare const o5: { b?(): { c: { d?: { e: string } } } }; delete o5.b?.().c.d?.e; delete (o5.b?.().c.d?.e); declare const o6: { b?: { c: { d?: { e: string } } } }; delete o6.b?.['c'].d?.['e']; delete (o6.b?.['c'].d?.['e']);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/deleteOperatorWithAnyOtherType.ts
TypeScript
// delete operator on any type var ANY: any; var ANY1; var ANY2: any[] = ["", ""]; var obj: () => {}; var obj1 = { x: "", y: () => { }}; function foo(): any { var a; return a; } class A { public a: any; static foo() { var a; return a; } } module M { export var n: any; } var objA = new A(); // any type var var ResultIsBoolean1 = delete ANY1; var ResultIsBoolean2 = delete ANY2; var ResultIsBoolean3 = delete A; var ResultIsBoolean4 = delete M; var ResultIsBoolean5 = delete obj; var ResultIsBoolean6 = delete obj1; // any type literal var ResultIsBoolean7 = delete undefined; var ResultIsBoolean8 = delete null; // any type expressions var ResultIsBoolean9 = delete ANY2[0]; var ResultIsBoolean10 = delete obj1.x; var ResultIsBoolean11 = delete obj1.y; var ResultIsBoolean12 = delete objA.a; var ResultIsBoolean13 = delete M.n; var ResultIsBoolean14 = delete foo(); var ResultIsBoolean15 = delete A.foo(); var ResultIsBoolean16 = delete (ANY + ANY1); var ResultIsBoolean17 = delete (null + undefined); var ResultIsBoolean18 = delete (null + null); var ResultIsBoolean19 = delete (undefined + undefined); // multiple delete operators var ResultIsBoolean20 = delete delete ANY; var ResultIsBoolean21 = delete delete delete (ANY + ANY1); // miss assignment operators delete ANY; delete ANY1; delete ANY2[0]; delete ANY, ANY1; delete obj1.x; delete obj1.y; delete objA.a; delete M.n;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/deleteOperatorWithBooleanType.ts
TypeScript
// delete operator on boolean type var BOOLEAN: boolean; function foo(): boolean { return true; } class A { public a: boolean; static foo() { return false; } } module M { export var n: boolean; } var objA = new A(); // boolean type var var ResultIsBoolean1 = delete BOOLEAN; // boolean type literal var ResultIsBoolean2 = delete true; var ResultIsBoolean3 = delete { x: true, y: false }; // boolean type expressions var ResultIsBoolean4 = delete objA.a; var ResultIsBoolean5 = delete M.n; var ResultIsBoolean6 = delete foo(); var ResultIsBoolean7 = delete A.foo(); // multiple delete operator var ResultIsBoolean8 = delete delete BOOLEAN; // miss assignment operators delete true; delete BOOLEAN; delete foo(); delete true, false; delete objA.a; delete M.n;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/deleteOperatorWithEnumType.ts
TypeScript
// delete operator on enum type enum ENUM { }; enum ENUM1 { A, B, "" }; // enum type var var ResultIsBoolean1 = delete ENUM; var ResultIsBoolean2 = delete ENUM1; // enum type expressions var ResultIsBoolean3 = delete ENUM1["A"]; var ResultIsBoolean4 = delete (ENUM[0] + ENUM1["B"]); // multiple delete operators var ResultIsBoolean5 = delete delete ENUM; var ResultIsBoolean6 = delete delete delete (ENUM[0] + ENUM1["B"]); // miss assignment operators delete ENUM; delete ENUM1; delete ENUM1.B; delete ENUM, ENUM1;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/deleteOperatorWithNumberType.ts
TypeScript
// delete operator on number type var NUMBER: number; var NUMBER1: number[] = [1, 2]; function foo(): number { return 1; } class A { public a: number; static foo() { return 1; } } module M { export var n: number; } var objA = new A(); // number type var var ResultIsBoolean1 = delete NUMBER; var ResultIsBoolean2 = delete NUMBER1; // number type literal var ResultIsBoolean3 = delete 1; var ResultIsBoolean4 = delete { x: 1, y: 2}; var ResultIsBoolean5 = delete { x: 1, y: (n: number) => { return n; } }; // number type expressions var ResultIsBoolean6 = delete objA.a; var ResultIsBoolean7 = delete M.n; var ResultIsBoolean8 = delete NUMBER1[0]; var ResultIsBoolean9 = delete foo(); var ResultIsBoolean10 = delete A.foo(); var ResultIsBoolean11 = delete (NUMBER + NUMBER); // multiple delete operator var ResultIsBoolean12 = delete delete NUMBER; var ResultIsBoolean13 = delete delete delete (NUMBER + NUMBER); // miss assignment operators delete 1; delete NUMBER; delete NUMBER1; delete foo(); delete objA.a; delete M.n; delete objA.a, M.n;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/deleteOperatorWithStringType.ts
TypeScript
// delete operator on string type var STRING: string; var STRING1: string[] = ["", "abc"]; function foo(): string { return "abc"; } class A { public a: string; static foo() { return ""; } } module M { export var n: string; } var objA = new A(); // string type var var ResultIsBoolean1 = delete STRING; var ResultIsBoolean2 = delete STRING1; // string type literal var ResultIsBoolean3 = delete ""; var ResultIsBoolean4 = delete { x: "", y: "" }; var ResultIsBoolean5 = delete { x: "", y: (s: string) => { return s; } }; // string type expressions var ResultIsBoolean6 = delete objA.a; var ResultIsBoolean7 = delete M.n; var ResultIsBoolean8 = delete STRING1[0]; var ResultIsBoolean9 = delete foo(); var ResultIsBoolean10 = delete A.foo(); var ResultIsBoolean11 = delete (STRING + STRING); var ResultIsBoolean12 = delete STRING.charAt(0); // multiple delete operator var ResultIsBoolean13 = delete delete STRING; var ResultIsBoolean14 = delete delete delete (STRING + STRING); // miss assignment operators delete ""; delete STRING; delete STRING1; delete foo(); delete objA.a,M.n;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/dependentDestructuredVariables.ts
TypeScript
// @strict: true // @declaration: true // @target: es2015 // @lib: esnext, dom type Action = | { kind: 'A', payload: number } | { kind: 'B', payload: string }; function f10({ kind, payload }: Action) { if (kind === 'A') { payload.toFixed(); } if (kind === 'B') { payload.toUpperCase(); } } function f11(action: Action) { const { kind, payload } = action; if (kind === 'A') { payload.toFixed(); } if (kind === 'B') { payload.toUpperCase(); } } function f12({ kind, payload }: Action) { switch (kind) { case 'A': payload.toFixed(); break; case 'B': payload.toUpperCase(); break; default: payload; // never } } // repro #50206 function f13<T extends Action>({ kind, payload }: T) { if (kind === 'A') { payload.toFixed(); } if (kind === 'B') { payload.toUpperCase(); } } function f14<T extends Action>(t: T) { const { kind, payload } = t; if (kind === 'A') { payload.toFixed(); } if (kind === 'B') { payload.toUpperCase(); } } type Action2 = | { kind: 'A', payload: number | undefined } | { kind: 'B', payload: string | undefined }; function f20({ kind, payload }: Action2) { if (payload) { if (kind === 'A') { payload.toFixed(); } if (kind === 'B') { payload.toUpperCase(); } } } function f21(action: Action2) { const { kind, payload } = action; if (payload) { if (kind === 'A') { payload.toFixed(); } if (kind === 'B') { payload.toUpperCase(); } } } function f22(action: Action2) { if (action.payload) { const { kind, payload } = action; if (kind === 'A') { payload.toFixed(); } if (kind === 'B') { payload.toUpperCase(); } } } function f23({ kind, payload }: Action2) { if (payload) { switch (kind) { case 'A': payload.toFixed(); break; case 'B': payload.toUpperCase(); break; default: payload; // never } } } type Foo = | { kind: 'A', isA: true } | { kind: 'B', isA: false } | { kind: 'C', isA: false }; function f30({ kind, isA }: Foo) { if (kind === 'A') { isA; // true } if (kind === 'B') { isA; // false } if (kind === 'C') { isA; // false } if (isA) { kind; // 'A' } else { kind; // 'B' | 'C' } } type Args = ['A', number] | ['B', string] function f40(...[kind, data]: Args) { if (kind === 'A') { data.toFixed(); } if (kind === 'B') { data.toUpperCase(); } } // Repro from #35283 interface A<T> { variant: 'a', value: T } interface B<T> { variant: 'b', value: Array<T> } type AB<T> = A<T> | B<T>; declare function printValue<T>(t: T): void; declare function printValueList<T>(t: Array<T>): void; function unrefined1<T>(ab: AB<T>): void { const { variant, value } = ab; if (variant === 'a') { printValue<T>(value); } else { printValueList<T>(value); } } // Repro from #38020 type Action3 = | {type: 'add', payload: { toAdd: number } } | {type: 'remove', payload: { toRemove: number } }; const reducerBroken = (state: number, { type, payload }: Action3) => { switch (type) { case 'add': return state + payload.toAdd; case 'remove': return state - payload.toRemove; } } // Repro from #46143 declare var it: Iterator<number>; const { value, done } = it.next(); if (!done) { value; // number } // Repro from #46658 declare function f50(cb: (...args: Args) => void): void f50((kind, data) => { if (kind === 'A') { data.toFixed(); } if (kind === 'B') { data.toUpperCase(); } }); const f51: (...args: ['A', number] | ['B', string]) => void = (kind, payload) => { if (kind === 'A') { payload.toFixed(); } if (kind === 'B') { payload.toUpperCase(); } }; const f52: (...args: ['A', number] | ['B']) => void = (kind, payload?) => { if (kind === 'A') { payload.toFixed(); } else { payload; // undefined } }; declare function readFile(path: string, callback: (...args: [err: null, data: unknown[]] | [err: Error, data: undefined]) => void): void; readFile('hello', (err, data) => { if (err === null) { data.length; } else { err.message; } }); type ReducerArgs = ["add", { a: number, b: number }] | ["concat", { firstArr: any[], secondArr: any[] }]; const reducer: (...args: ReducerArgs) => void = (op, args) => { switch (op) { case "add": console.log(args.a + args.b); break; case "concat": console.log(args.firstArr.concat(args.secondArr)); break; } } reducer("add", { a: 1, b: 3 }); reducer("concat", { firstArr: [1, 2], secondArr: [3, 4] }); // repro from https://github.com/microsoft/TypeScript/pull/47190#issuecomment-1057603588 type FooMethod = { method(...args: [type: "str", cb: (e: string) => void] | [type: "num", cb: (e: number) => void] ): void; } let fooM: FooMethod = { method(type, cb) { if (type == 'num') { cb(123) } else { cb("abc") } } }; type FooAsyncMethod = { method(...args: [type: "str", cb: (e: string) => void] | [type: "num", cb: (e: number) => void] ): Promise<any>; } let fooAsyncM: FooAsyncMethod = { async method(type, cb) { if (type == 'num') { cb(123) } else { cb("abc") } } }; type FooGenMethod = { method(...args: [type: "str", cb: (e: string) => void] | [type: "num", cb: (e: number) => void] ): Generator<any, any, any>; } let fooGenM: FooGenMethod = { *method(type, cb) { if (type == 'num') { cb(123) } else { cb("abc") } } }; type FooAsyncGenMethod = { method(...args: [type: "str", cb: (e: string) => void] | [type: "num", cb: (e: number) => void] ): AsyncGenerator<any, any, any>; } let fooAsyncGenM: FooAsyncGenMethod = { async *method(type, cb) { if (type == 'num') { cb(123) } else { cb("abc") } } }; // Repro from #48345 type Func = <T extends ["a", number] | ["b", string]>(...args: T) => void; const f60: Func = (kind, payload) => { if (kind === "a") { payload.toFixed(); // error } if (kind === "b") { payload.toUpperCase(); // error } }; // Repro from #48902 function foo({ value1, test1 = value1.test1, test2 = value1.test2, test3 = value1.test3, test4 = value1.test4, test5 = value1.test5, test6 = value1.test6, test7 = value1.test7, test8 = value1.test8, test9 = value1.test9 }) {} // Repro from #49772 function fa1(x: [true, number] | [false, string]) { const [guard, value] = x; if (guard) { for (;;) { value; // number } } else { while (!!true) { value; // string } } } function fa2(x: { guard: true, value: number } | { guard: false, value: string }) { const { guard, value } = x; if (guard) { for (;;) { value; // number } } else { while (!!true) { value; // string } } } const fa3: (...args: [true, number] | [false, string]) => void = (guard, value) => { if (guard) { for (;;) { value; // number } } else { while (!!true) { value; // string } } } // Repro from #52152 interface ClientEvents { warn: [message: string]; shardDisconnect: [closeEvent: CloseEvent, shardId: number]; } declare class Client { public on<K extends keyof ClientEvents>(event: K, listener: (...args: ClientEvents[K]) => void): void; } const bot = new Client(); bot.on("shardDisconnect", (event, shard) => console.log(`Shard ${shard} disconnected (${event.code},${event.wasClean}): ${event.reason}`)); bot.on("shardDisconnect", event => console.log(`${event.code} ${event.wasClean} ${event.reason}`)); // Destructuring tuple types with different arities function fz1([x, y]: [1, 2] | [3, 4] | [5]) { if (y === 2) { x; // 1 } if (y === 4) { x; // 3 } if (y === undefined) { x; // 5 } if (x === 1) { y; // 2 } if (x === 3) { y; // 4 } if (x === 5) { y; // undefined } } // Repro from #55661 function tooNarrow([x, y]: [1, 1] | [1, 2] | [1]) { if (y === undefined) { const shouldNotBeOk: never = x; // Error } } // https://github.com/microsoft/TypeScript/issues/56312 function parameterReassigned1([x, y]: [1, 2] | [3, 4]) { if (Math.random()) { x = 1; } if (y === 2) { x; // 1 | 3 } } function parameterReassigned2([x, y]: [1, 2] | [3, 4]) { if (Math.random()) { y = 2; } if (y === 2) { x; // 1 | 3 } } // https://github.com/microsoft/TypeScript/pull/56313#discussion_r1416482490 const parameterReassignedContextualRest1: (...args: [1, 2] | [3, 4]) => void = (x, y) => { if (Math.random()) { y = 2; } if (y === 2) { x; // 1 | 3 } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/dependentDestructuredVariablesFromNestedPatterns.ts
TypeScript
// @strict: true // @target: esnext // @lib: esnext // @noEmit: true function test1(arg: [[undefined, Error] | [number, undefined]]) { const [[p1, p1Error]] = arg; if (p1Error) { return; } p1; } function test2([[p1, p1Error]]: [[undefined, Error] | [number, undefined]]) { if (p1Error) { return; } p1; } async function myAllSettled<T extends readonly unknown[]>(fn: () => T) { const promises = await Promise.allSettled(fn()); return promises.map((result) => result.status === "fulfilled" ? [result.value, undefined] : [undefined, new Error(String(result.reason))], ) as { [K in keyof T]: [Awaited<T[K]>, undefined] | [undefined, Error] }; } async function test3() { const [[p1, p1Error], _] = await myAllSettled( () => [Promise.resolve(0), Promise.reject(1)] as const, ); if (p1Error) return; p1; } function test4([[p1, p1Error]]: [[undefined, Error] | [number, undefined]]) { if (Math.random()) { p1 = undefined; } if (p1Error) { return; } p1; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/derivedClassConstructorWithoutSuperCall.ts
TypeScript
// derived class constructors must contain a super call class Base { x: string; } class Derived extends Base { constructor() { // error } } class Base2<T> { x: T; } class Derived2<T> extends Base2<T> { constructor() { // error for no super call (nested scopes don't count) var r2 = () => super(); // error for misplaced super call (nested function) } } class Derived3<T> extends Base2<T> { constructor() { // error var r = function () { super() } // error } } class Derived4<T> extends Base2<T> { constructor() { var r = super(); // ok } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/derivedClassFunctionOverridesBaseClassAccessor.ts
TypeScript
class Base { get x() { return 1; } set x(v) { } } // error class Derived extends Base { x() { return 1; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/derivedClassIncludesInheritedMembers.ts
TypeScript
class Base { a: string; b() { } get c() { return ''; } set c(v) { } static r: string; static s() { } static get t() { return ''; } static set t(v) { } constructor(x) { } } class Derived extends Base { } var d: Derived = new Derived(1); var r1 = d.a; var r2 = d.b(); var r3 = d.c; d.c = ''; var r4 = Derived.r; var r5 = Derived.s(); var r6 = Derived.t; Derived.t = ''; class Base2 { [x: string]: Object; [x: number]: Date; } class Derived2 extends Base2 { } var d2: Derived2; var r7 = d2['']; var r8 = d2[1];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/derivedClassOverridesIndexersWithAssignmentCompatibility.ts
TypeScript
class Base { [x: string]: Object; } // ok, use assignment compatibility class Derived extends Base { [x: string]: any; } class Base2 { [x: number]: Object; } // ok, use assignment compatibility class Derived2 extends Base2 { [x: number]: any; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/derivedClassOverridesPrivates.ts
TypeScript
class Base { private x: { foo: string }; } class Derived extends Base { private x: { foo: string; bar: string; }; // error } class Base2 { private static y: { foo: string }; } class Derived2 extends Base2 { private static y: { foo: string; bar: string; }; // error }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/derivedClassOverridesProtectedMembers.ts
TypeScript
// @target: ES5 var x: { foo: string; } var y: { foo: string; bar: string; } class Base { protected a: typeof x; protected b(a: typeof x) { } protected get c() { return x; } protected set c(v: typeof x) { } protected d: (a: typeof x) => void; protected static r: typeof x; protected static s(a: typeof x) { } protected static get t() { return x; } protected static set t(v: typeof x) { } protected static u: (a: typeof x) => void; constructor(a: typeof x) { } } class Derived extends Base { protected a: typeof y; protected b(a: typeof y) { } protected get c() { return y; } protected set c(v: typeof y) { } protected d: (a: typeof y) => void; protected static r: typeof y; protected static s(a: typeof y) { } protected static get t() { return y; } protected static set t(a: typeof y) { } protected static u: (a: typeof y) => void; constructor(a: typeof y) { super(x) } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/derivedClassOverridesProtectedMembers2.ts
TypeScript
// @target: ES5 var x: { foo: string; } var y: { foo: string; bar: string; } class Base { protected a: typeof x; protected b(a: typeof x) { } protected get c() { return x; } protected set c(v: typeof x) { } protected d: (a: typeof x) => void ; protected static r: typeof x; protected static s(a: typeof x) { } protected static get t() { return x; } protected static set t(v: typeof x) { } protected static u: (a: typeof x) => void ; constructor(a: typeof x) { } } // Increase visibility of all protected members to public class Derived extends Base { a: typeof y; b(a: typeof y) { } get c() { return y; } set c(v: typeof y) { } d: (a: typeof y) => void; static r: typeof y; static s(a: typeof y) { } static get t() { return y; } static set t(a: typeof y) { } static u: (a: typeof y) => void; constructor(a: typeof y) { super(a); } } var d: Derived = new Derived(y); var r1 = d.a; var r2 = d.b(y); var r3 = d.c; var r3a = d.d; d.c = y; var r4 = Derived.r; var r5 = Derived.s(y); var r6 = Derived.t; var r6a = Derived.u; Derived.t = y; class Base2 { [i: string]: Object; [i: number]: typeof x; } class Derived2 extends Base2 { [i: string]: typeof x; [i: number]: typeof y; } var d2: Derived2; var r7 = d2['']; var r8 = d2[1];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/derivedClassOverridesProtectedMembers3.ts
TypeScript
// @target: ES5 var x: { foo: string; } var y: { foo: string; bar: string; } class Base { a: typeof x; b(a: typeof x) { } get c() { return x; } set c(v: typeof x) { } d: (a: typeof x) => void; static r: typeof x; static s(a: typeof x) { } static get t() { return x; } static set t(v: typeof x) { } static u: (a: typeof x) => void; constructor(a: typeof x) {} } // Errors // decrease visibility of all public members to protected class Derived1 extends Base { protected a: typeof x; constructor(a: typeof x) { super(a); } } class Derived2 extends Base { protected b(a: typeof x) { } constructor(a: typeof x) { super(a); } } class Derived3 extends Base { protected get c() { return x; } constructor(a: typeof x) { super(a); } } class Derived4 extends Base { protected set c(v: typeof x) { } constructor(a: typeof x) { super(a); } } class Derived5 extends Base { protected d: (a: typeof x) => void ; constructor(a: typeof x) { super(a); } } class Derived6 extends Base { protected static r: typeof x; constructor(a: typeof x) { super(a); } } class Derived7 extends Base { protected static s(a: typeof x) { } constructor(a: typeof x) { super(a); } } class Derived8 extends Base { protected static get t() { return x; } constructor(a: typeof x) { super(a); } } class Derived9 extends Base { protected static set t(v: typeof x) { } constructor(a: typeof x) { super(a); } } class Derived10 extends Base { protected static u: (a: typeof x) => void ; constructor(a: typeof x) { super(a); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/derivedClassOverridesProtectedMembers4.ts
TypeScript
var x: { foo: string; } var y: { foo: string; bar: string; } class Base { protected a: typeof x; } class Derived1 extends Base { public a: typeof x; } class Derived2 extends Derived1 { protected a: typeof x; // Error, parent was public }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/derivedClassOverridesPublicMembers.ts
TypeScript
var x: { foo: string; } var y: { foo: string; bar: string; } class Base { a: typeof x; b(a: typeof x) { } get c() { return x; } set c(v: typeof x) { } d: (a: typeof x) => void; static r: typeof x; static s(a: typeof x) { } static get t() { return x; } static set t(v: typeof x) { } static u: (a: typeof x) => void; constructor(a: typeof x) { } } class Derived extends Base { a: typeof y; b(a: typeof y) { } get c() { return y; } set c(v: typeof y) { } d: (a: typeof y) => void; static r: typeof y; static s(a: typeof y) { } static get t() { return y; } static set t(a: typeof y) { } static u: (a: typeof y) => void; constructor(a: typeof y) { super(x) } } var d: Derived = new Derived(y); var r1 = d.a; var r2 = d.b(y); var r3 = d.c; var r3a = d.d; d.c = y; var r4 = Derived.r; var r5 = Derived.s(y); var r6 = Derived.t; var r6a = Derived.u; Derived.t = y; class Base2 { [i: string]: Object; [i: number]: typeof x; } class Derived2 extends Base2 { [i: string]: typeof x; [i: number]: typeof y; } var d2: Derived2; var r7 = d2['']; var r8 = d2[1];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/derivedClassOverridesWithoutSubtype.ts
TypeScript
class Base { x: { foo: string; } } class Derived extends Base { x: { foo: any; } } class Base2 { static y: { foo: string; } } class Derived2 extends Base2 { static y: { foo: any; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/derivedClassTransitivity.ts
TypeScript
// subclassing is not transitive when you can remove required parameters and add optional parameters class C { foo(x: number) { } } class D extends C { foo() { } // ok to drop parameters } class E extends D { foo(x?: string) { } // ok to add optional parameters } var c: C; var d: D; var e: E; c = e; var r = c.foo(1); var r2 = e.foo('');
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/derivedClassTransitivity2.ts
TypeScript
// subclassing is not transitive when you can remove required parameters and add optional parameters class C { foo(x: number, y: number) { } } class D extends C { foo(x: number) { } // ok to drop parameters } class E extends D { foo(x: number, y?: string) { } // ok to add optional parameters } var c: C; var d: D; var e: E; c = e; var r = c.foo(1, 1); var r2 = e.foo(1, '');
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/derivedClassTransitivity3.ts
TypeScript
// subclassing is not transitive when you can remove required parameters and add optional parameters class C<T> { foo(x: T, y: T) { } } class D<T> extends C<T> { foo(x: T) { } // ok to drop parameters } class E<T> extends D<T> { foo(x: T, y?: number) { } // ok to add optional parameters } var c: C<string>; var d: D<string>; var e: E<string>; c = e; var r = c.foo('', ''); var r2 = e.foo('', 1);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/derivedClassTransitivity4.ts
TypeScript
// subclassing is not transitive when you can remove required parameters and add optional parameters on protected members class C { protected foo(x: number) { } } class D extends C { protected foo() { } // ok to drop parameters } class E extends D { public foo(x?: string) { } // ok to add optional parameters } var c: C; var d: D; var e: E; c = e; var r = c.foo(1); var r2 = e.foo('');
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/derivedClassWithAny.ts
TypeScript
class C { x: number; get X(): number { return 1; } foo(): number { return 1; } static y: number; static get Y(): number { return 1; } static bar(): number { return 1; } } class D extends C { x: any; get X(): any { return null; } foo(): any { return 1; } static y: any; static get Y(): any { return null; } static bar(): any { return null; } } // if D is a valid class definition than E is now not safe tranisitively through C class E extends D { x: string; get X(): string{ return ''; } foo(): string { return ''; } static y: string; static get Y(): string { return ''; } static bar(): string { return ''; } } var c: C; var d: D; var e: E; c = d; c = e; var r = c.foo(); // e.foo would return string
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/derivedClassWithPrivateInstanceShadowingProtectedInstance.ts
TypeScript
// @target: ES5 class Base { protected x: string; protected fn(): string { return ''; } protected get a() { return 1; } protected set a(v) { } } // error, not a subtype class Derived extends Base { private x: string; private fn(): string { return ''; } private get a() { return 1; } private set a(v) { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/derivedClassWithPrivateInstanceShadowingPublicInstance.ts
TypeScript
class Base { public x: string; public fn(): string { return ''; } public get a() { return 1; } public set a(v) { } } // error, not a subtype class Derived extends Base { private x: string; private fn(): string { return ''; } private get a() { return 1; } private set a(v) { } } var r = Base.x; // ok var r2 = Derived.x; // error var r3 = Base.fn(); // ok var r4 = Derived.fn(); // error var r5 = Base.a; // ok Base.a = 2; // ok var r6 = Derived.a; // error Derived.a = 2; // error
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/derivedClassWithPrivateStaticShadowingProtectedStatic.ts
TypeScript
// @target: ES5 class Base { protected static x: string; protected static fn(): string { return ''; } protected static get a() { return 1; } protected static set a(v) { } } // should be error class Derived extends Base { private static x: string; private static fn(): string { return ''; } private static get a() { return 1; } private static set a(v) { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/derivedClassWithPrivateStaticShadowingPublicStatic.ts
TypeScript
class Base { public static x: string; public static fn(): string { return ''; } public static get a() { return 1; } public static set a(v) { } } // BUG 847404 // should be error class Derived extends Base { private static x: string; private static fn(): string { return ''; } private static get a() { return 1; } private static set a(v) { } } var r = Base.x; // ok var r2 = Derived.x; // error var r3 = Base.fn(); // ok var r4 = Derived.fn(); // error var r5 = Base.a; // ok Base.a = 2; // ok var r6 = Derived.a; // error Derived.a = 2; // error
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/derivedClassWithoutExplicitConstructor.ts
TypeScript
class Base { a = 1; constructor(x: number) { this.a = x; } } class Derived extends Base { x = 1 y = 'hello'; } var r = new Derived(); // error var r2 = new Derived(1); class Base2<T> { a: T; constructor(x: T) { this.a = x; } } class D<T extends Date> extends Base2<T> { x = 2 y: T = null; } var d = new D(); // error var d2 = new D(new Date()); // ok
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/derivedClassWithoutExplicitConstructor2.ts
TypeScript
class Base { a = 1; constructor(x: number, y?: number, z?: number); constructor(x: number, y?: number); constructor(x: number) { this.a = x; } } class Derived extends Base { x = 1 y = 'hello'; } var r = new Derived(); // error var r2 = new Derived(1); var r3 = new Derived(1, 2); var r4 = new Derived(1, 2, 3); class Base2<T> { a: T; constructor(x: T, y?: T, z?: T); constructor(x: T, y?: T); constructor(x: T) { this.a = x; } } class D<T extends Date> extends Base2<T> { x = 2 y: T = null; } var d = new D(); // error var d2 = new D(new Date()); // ok var d3 = new D(new Date(), new Date()); var d4 = new D(new Date(), new Date(), new Date());
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/derivedClassWithoutExplicitConstructor3.ts
TypeScript
// automatic constructors with a class hieararchy of depth > 2 class Base { a = 1; constructor(x: number) { this.a = x; } } class Derived extends Base { b = ''; constructor(y: string, z: string) { super(2); this.b = y; } } class Derived2 extends Derived { x = 1 y = 'hello'; } var r = new Derived(); // error var r2 = new Derived2(1); // error var r3 = new Derived('', ''); class Base2<T> { a: T; constructor(x: T) { this.a = x; } } class D<T> extends Base { b: T = null; constructor(y: T, z: T) { super(2); this.b = y; } } class D2<T extends Date> extends D<T> { x = 2 y: T = null; } var d = new D2(); // error var d2 = new D2(new Date()); // error var d3 = new D2(new Date(), new Date()); // ok
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/derivedGenericClassWithAny.ts
TypeScript
class C<T extends number> { x: T; get X(): T { return null; } foo(): T { return null; } } class D extends C<number> { x: any; get X(): any { return null; } foo(): any { return 1; } static y: any; static get Y(): any { return null; } static bar(): any { return null; } } // if D is a valid class definition than E is now not safe tranisitively through C class E<T extends string> extends D { x: T; get X(): T { return ''; } // error foo(): T { return ''; // error } } var c: C<number>; var d: D; var e: E<string>; c = d; c = e; var r = c.foo(); // e.foo would return string
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/derivedInterfaceDoesNotHideBaseSignatures.ts
TypeScript
// Derived interfaces no longer hide signatures from base types, so these signatures are always compatible. interface Base { (): string; new (x: string): number; } interface Derived extends Base { (): number; new (x: string): string; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/derivedInterfaceIncompatibleWithBaseIndexer.ts
TypeScript
interface Base { [x: number]: { x: number; y: number; }; [x: string]: { x: number; } } interface Derived extends Base { 1: { y: number } // error } interface Derived2 extends Base { '1': { y: number } // error } interface Derived3 extends Base { foo: { y: number } // error } interface Derived4 extends Base { foo(): { x: number } // error } // satisifies string indexer but not numeric indexer interface Derived5 extends Base { 1: { x: number } // error } interface Derived5 extends Base { '1': { x: number } // error }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts
TypeScript
class Base { foo(x: { a: number }): { a: number } { return null; } } class Derived extends Base { foo(x: { a: number; b: number }): { a: number; b: number } { return null; } bar() { var r = super.foo({ a: 1 }); // { a: number } var r2 = super.foo({ a: 1, b: 2 }); // { a: number } var r3 = this.foo({ a: 1, b: 2 }); // { a: number; b: number; } } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/derivedTypeDoesNotRequireExtendsClause.ts
TypeScript
class Base { foo: string; } class Derived { foo: string; bar: number; } class Derived2 extends Base { bar: string; } var b: Base; var d1: Derived; var d2: Derived2; b = d1; b = d2; var r: Base[] = [d1, d2];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringArrayBindingPatternAndAssignment1ES5.ts
TypeScript
/* AssignmentPattern: * ObjectAssignmentPattern * ArrayAssignmentPattern * ArrayAssignmentPattern: * [Elision<opt> AssignmentRestElementopt ] * [AssignmentElementList] * [AssignmentElementList, Elision<opt> AssignmentRestElementopt ] * AssignmentElementList: * Elision<opt> AssignmentElement * AssignmentElementList, Elisionopt AssignmentElement * AssignmentElement: * LeftHandSideExpression Initialiseropt * AssignmentPattern Initialiseropt * AssignmentRestElement: * ... LeftHandSideExpression */ // In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. // An expression of type S is considered assignable to an assignment target V if one of the following is true // V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, // S is the type Any, or var [a0, a1]: any = undefined; var [a2 = false, a3 = 1]: any = undefined; // V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, // S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E, // where N is the numeric index of E in the array assignment pattern, or var [b0, b1, b2] = [2, 3, 4]; var [b3, b4, b5]: [number, number, string] = [1, 2, "string"]; function foo() { return [1, 2, 3]; } var [b6, b7] = foo(); var [...b8] = foo(); // S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. var temp = [1,2,3] var [c0, c1] = [...temp]; var [c2] = []; var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]] var [[c5], c6]: [[string|number], boolean] = [[1], true]; var [, c7] = [1, 2, 3]; var [,,, c8] = [1, 2, 3, 4]; var [,,, c9] = [1, 2, 3, 4]; var [,,,...c10] = [1, 2, 3, 4, "hello"]; var [c11, c12, ...c13] = [1, 2, "string"]; var [c14, c15, c16] = [1, 2, "string"];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringArrayBindingPatternAndAssignment1ES5iterable.ts
TypeScript
// @downlevelIteration: true /* AssignmentPattern: * ObjectAssignmentPattern * ArrayAssignmentPattern * ArrayAssignmentPattern: * [Elision<opt> AssignmentRestElementopt ] * [AssignmentElementList] * [AssignmentElementList, Elision<opt> AssignmentRestElementopt ] * AssignmentElementList: * Elision<opt> AssignmentElement * AssignmentElementList, Elisionopt AssignmentElement * AssignmentElement: * LeftHandSideExpression Initialiseropt * AssignmentPattern Initialiseropt * AssignmentRestElement: * ... LeftHandSideExpression */ // In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. // An expression of type S is considered assignable to an assignment target V if one of the following is true // V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, // S is the type Any, or var [a0, a1]: any = undefined; var [a2 = false, a3 = 1]: any = undefined; // V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, // S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E, // where N is the numeric index of E in the array assignment pattern, or var [b0, b1, b2] = [2, 3, 4]; var [b3, b4, b5]: [number, number, string] = [1, 2, "string"]; function foo() { return [1, 2, 3]; } var [b6, b7] = foo(); var [...b8] = foo(); // S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. var temp = [1,2,3] var [c0, c1] = [...temp]; var [c2] = []; var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]] var [[c5], c6]: [[string|number], boolean] = [[1], true]; var [, c7] = [1, 2, 3]; var [,,, c8] = [1, 2, 3, 4]; var [,,, c9] = [1, 2, 3, 4]; var [,,,...c10] = [1, 2, 3, 4, "hello"]; var [c11, c12, ...c13] = [1, 2, "string"]; var [c14, c15, c16] = [1, 2, "string"];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringArrayBindingPatternAndAssignment1ES6.ts
TypeScript
// @target: es6 /* AssignmentPattern: * ObjectAssignmentPattern * ArrayAssignmentPattern * ArrayAssignmentPattern: * [Elision<opt> AssignmentRestElementopt ] * [AssignmentElementList] * [AssignmentElementList, Elision<opt> AssignmentRestElementopt ] * AssignmentElementList: * Elision<opt> AssignmentElement * AssignmentElementList, Elisionopt AssignmentElement * AssignmentElement: * LeftHandSideExpression Initialiseropt * AssignmentPattern Initialiseropt * AssignmentRestElement: * ... LeftHandSideExpression */ // In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. // An expression of type S is considered assignable to an assignment target V if one of the following is true // V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, // S is the type Any, or var [a0, a1]: any = undefined; var [a2 = false, a3 = 1]: any = undefined; // V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, // S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E, // where N is the numeric index of E in the array assignment pattern, or var [b0, b1, b2] = [2, 3, 4]; var [b3, b4, b5]: [number, number, string] = [1, 2, "string"]; function foo() { return [1, 2, 3]; } var [b6, b7] = foo(); var [...b8] = foo(); // S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. var temp = [1,2,3] var [c0, c1] = [...temp]; var [c2] = []; var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]] var [[c5], c6]: [[string|number], boolean] = [[1], true]; var [, c7] = [1, 2, 3]; var [,,, c8] = [1, 2, 3, 4]; var [,,, c9] = [1, 2, 3, 4]; var [,,,...c10] = [1, 2, 3, 4, "hello"]; var [c11, c12, ...c13] = [1, 2, "string"]; var [c14, c15, c16] = [1, 2, "string"];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringArrayBindingPatternAndAssignment2.ts
TypeScript
// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, // S is the type Any, or var [[a0], [[a1]]] = [] // Error var [[a2], [[a3]]] = undefined // Error // V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, // S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E, // where N is the numeric index of E in the array assignment pattern, or var [b0, b1, b2]: [number, boolean, string] = [1, 2, "string"]; // Error interface J extends Array<Number> { 2: number; } function bar(): J { return <[number, number, number]>[1, 2, 3]; } var [b3 = "string", b4, b5] = bar(); // Error // V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, // S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. var temp = [1, 2, 3] var [c0, c1]: [number, number] = [...temp]; // Error var [c2, c3]: [string, string] = [...temp]; // Error interface F { [idx: number]: boolean } function foo(idx: number): F { return { 2: true } } var [c4, c5, c6] = foo(1); // Error
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringArrayBindingPatternAndAssignment3.ts
TypeScript
const [a, b = a] = [1]; // ok const [c, d = c, e = e] = [1]; // error for e = e const [f, g = f, h = i, i = f] = [1]; // error for h = i (function ([a, b = a]) { // ok })([1]); (function ([c, d = c, e = e]) { // error for e = e })([1]); (function ([f, g = f, h = i, i = f]) { // error for h = i })([1])
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringArrayBindingPatternAndAssignment4.ts
TypeScript
// #35497 // @target: es5 // @downlevelIteration: true // @lib: es6 // @strict: true declare const data: number[] | null; const [value] = data; // Error
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts
TypeScript
// @noImplicitAny: true // To be inferred as `number` function f1() { const [a1, b1 = a1] = [1]; const [a2, b2 = 1 + a2] = [1]; } // To be inferred as `string` function f2() { const [a1, b1 = a1] = ['hi']; const [a2, b2 = a2 + '!'] = ['hi']; } // To be inferred as `string | number` function f3() { const [a1, b1 = a1] = ['hi', 1]; const [a2, b2 = a2 + '!'] = ['hi', 1]; } // Based on comment: // - https://github.com/microsoft/TypeScript/issues/49989#issuecomment-1852694486 declare const yadda: [number, number] | undefined function f4() { const [ a, b = a ] = yadda ?? []; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringAssignabilityCheck.ts
TypeScript
// @strict: true const [] = {}; // should be error const {} = undefined; // error correctly (([]) => 0)({}); // should be error (({}) => 0)(undefined); // should be error function foo({}: undefined) { return 0 } function bar([]: {}) { return 0 } const { }: undefined = 1 const []: {} = {}
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringCatch.ts
TypeScript
// @noImplicitAny: true try { throw [0, 1]; } catch ([a, b]) { a + b; } try { throw { a: 0, b: 1 }; } catch ({a, b}) { a + b; } try { throw [{ x: [0], z: 1 }]; } catch ([{x: [y], z}]) { y + z; } // Test of comment ranges. A fix to GH#11755 should update this. try { } catch (/*Test comment ranges*/[/*a*/a]) { }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringControlFlow.ts
TypeScript
// @strict: true function f1(obj: { a?: string }) { if (obj.a) { obj = {}; let a1 = obj["a"]; // string | undefined let a2 = obj.a; // string | undefined } } function f2(obj: [number, string] | null[]) { let a0 = obj[0]; // number | null let a1 = obj[1]; // string | null let [b0, b1] = obj; ([a0, a1] = obj); if (obj[0] && obj[1]) { let c0 = obj[0]; // number let c1 = obj[1]; // string let [d0, d1] = obj; ([c0, c1] = obj); } } function f3(obj: { a?: number, b?: string }) { if (obj.a && obj.b) { let { a, b } = obj; // number, string ({ a, b } = obj); } } function f4() { let x: boolean; ({ x } = 0); // Error ({ ["x"]: x } = 0); // Error ({ ["x" + ""]: x } = 0); // Errpr } // Repro from #31770 type KeyValue = [string, string?]; let [key, value]: KeyValue = ["foo"]; value.toUpperCase(); // Error
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringEvaluationOrder.ts
TypeScript
// @target: es5,es2015 // @noTypesAndSymbols: true // https://github.com/microsoft/TypeScript/issues/39205 let trace: any[] = []; let order = (n: any): any => trace.push(n); // order(0) should evaluate before order(1) because the first element is undefined let [{ [order(1)]: x } = order(0)] = []; // order(0) should not evaluate because the first element is defined let [{ [order(1)]: y } = order(0)] = [{}]; // order(0) should evaluate first (destructuring of object literal {}) // order(1) should evaluate next (initializer because property is undefined) // order(2) should evaluate last (evaluate object binding pattern from initializer) let { [order(0)]: { [order(2)]: z } = order(1), ...w } = {} as any; // https://github.com/microsoft/TypeScript/issues/39181 // b = a must occur *after* 'a' has been assigned let [{ ...a }, b = a]: any[] = [{ x: 1 }]
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringInFunctionType.ts
TypeScript
// @declaration: true interface a { a } interface b { b } interface c { c } type T1 = ([a, b, c]); type F1 = ([a, b, c]) => void; type T2 = ({ a }); type F2 = ({ a }) => void; type T3 = ([{ a: b }, { b: a }]); type F3 = ([{ a: b }, { b: a }]) => void; type T4 = ([{ a: [b, c] }]); type F4 = ([{ a: [b, c] }]) => void; type C1 = new ([{ a: [b, c] }]) => void; var v1 = ([a, b, c]) => "hello"; var v2: ([a, b, c]) => string;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringObjectAssignmentPatternWithNestedSpread.ts
TypeScript
// @target: es5, es2015, es2018 // @noTypesAndSymbols: true let a: any, b: any, c: any = {x: {a: 1, y: 2}}, d: any; ({x: {a, ...b} = d} = c);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringObjectBindingPatternAndAssignment1ES5.ts
TypeScript
// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. // An expression of type S is considered assignable to an assignment target V if one of the following is true // V is an object assignment pattern and, for each assignment property P in V, // S is the type Any, or var { a1 }: any = undefined; var { a2 }: any = {}; // V is an object assignment pattern and, for each assignment property P in V, // S has an apparent property with the property name specified in // P of a type that is assignable to the target given in P, or var { b1, } = { b1:1, }; var { b2: { b21 } = { b21: "string" } } = { b2: { b21: "world" } }; var {1: b3} = { 1: "string" }; var {b4 = 1}: any = { b4: 100000 }; var {b5: { b52 } } = { b5: { b52 } }; // V is an object assignment pattern and, for each assignment property P in V, // P specifies a numeric property name and S has a numeric index signature // of a type that is assignable to the target given in P, or interface F { [idx: number]: boolean; } function foo(): F { return { 1: true }; } function bar(): F { return { 2: true }; } var {1: c0} = foo(); var {1: c1} = bar(); // V is an object assignment pattern and, for each assignment property P in V, // S has a string index signature of a type that is assignable to the target given in P interface F1 { [str: string]: number; } function foo1(): F1 { return { "prop1": 2 } } var {"prop1": d1} = foo1(); var {"prop2": d1} = foo1();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringObjectBindingPatternAndAssignment1ES6.ts
TypeScript
// @target: es6 // In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. // An expression of type S is considered assignable to an assignment target V if one of the following is true // V is an object assignment pattern and, for each assignment property P in V, // S is the type Any, or var { a1 }: any = undefined; var { a2 }: any = {}; // V is an object assignment pattern and, for each assignment property P in V, // S has an apparent property with the property name specified in // P of a type that is assignable to the target given in P, or var { b1, } = { b1:1, }; var { b2: { b21 } = { b21: "string" } } = { b2: { b21: "world" } }; var {1: b3} = { 1: "string" }; var {b4 = 1}: any = { b4: 100000 }; var {b5: { b52 } } = { b5: { b52 } }; // V is an object assignment pattern and, for each assignment property P in V, // P specifies a numeric property name and S has a numeric index signature // of a type that is assignable to the target given in P, or interface F { [idx: number]: boolean; } function foo(): F { return { 1: true }; } function bar(): F { return { 2: true }; } var {1: c0} = foo(); var {1: c1} = bar(); // V is an object assignment pattern and, for each assignment property P in V, // S has a string index signature of a type that is assignable to the target given in P interface F1 { [str: string]: number; } function foo1(): F1 { return { "prop1": 2 } } var {"prop1": d1} = foo1(); var {"prop2": d1} = foo1();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringObjectBindingPatternAndAssignment4.ts
TypeScript
const { a = 1, b = 2, c = b, // ok d = a, // ok e = f, // error f = f // error } = { } as any;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringObjectBindingPatternAndAssignment5.ts
TypeScript
function a () { let x: number; let y: any ({ x, ...y } = ({ } as any)); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringObjectBindingPatternAndAssignment6.ts
TypeScript
// @target: es5,esnext const a = "a"; const b = "b"; const { [a]: aVal, [b]: bVal } = (() => { return { [a]: 1, [b]: 1 }; })(); console.log(aVal, bVal);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringObjectBindingPatternAndAssignment7.ts
TypeScript
// @target: es5,esnext enum K { a = "a", b = "b" } const { [K.a]: aVal, [K.b]: bVal } = (() => { return { [K.a]: 1, [K.b]: 1 }; })(); console.log(aVal, bVal);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringObjectBindingPatternAndAssignment8.ts
TypeScript
// @target: es5,esnext const K = { a: "a", b: "b" } const { [K.a]: aVal, [K.b]: bVal } = (() => { return { [K.a]: 1, [K.b]: 1 }; })(); console.log(aVal, bVal);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts
TypeScript
// @noImplicitAny: true // To be inferred as `number` function f1() { const { a1, b1 = a1 } = { a1: 1 }; const { a2, b2 = 1 + a2 } = { a2: 1 }; } // To be inferred as `string` function f2() { const { a1, b1 = a1 } = { a1: 'hi' }; const { a2, b2 = a2 + '!' } = { a2: 'hi' }; } // To be inferred as `string | number` function f3() { const { a1, b1 = a1 } = { a1: 'hi', b1: 1 }; const { a2, b2 = a2 + '!' } = { a2: 'hi', b2: 1 }; } // Based on comment: // - https://github.com/microsoft/TypeScript/issues/49989#issuecomment-1852694486 declare const yadda: { a?: number, b?: number } | undefined function f4() { const { a, b = a } = yadda ?? {}; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringParameterDeclaration1ES5.ts
TypeScript
// A parameter declaration may specify either an identifier or a binding pattern. // The identifiers specified in parameter declarations and binding patterns // in a parameter list must be unique within that parameter list. // If the declaration includes a type annotation, the parameter is of that type function a1([a, b, [[c]]]: [number, number, string[][]]) { } function a2(o: { x: number, a: number }) { } function a3({j, k, l: {m, n}, q: [a, b, c]}: { j: number, k: string, l: { m: boolean, n: number }, q: (number|string)[] }) { }; function a4({x, a}: { x: number, a: number }) { } a1([1, 2, [["world"]]]); a1([1, 2, [["world"]], 3]); // If the declaration includes an initializer expression (which is permitted only // when the parameter list occurs in conjunction with a function body), // the parameter type is the widened form (section 3.11) of the type of the initializer expression. function b1(z = [undefined, null]) { }; function b2(z = null, o = { x: 0, y: undefined }) { } function b3({z: {x, y: {j}}} = { z: { x: "hi", y: { j: 1 } } }) { } interface F1 { b5(z, y, [, a, b], {p, m: { q, r}}); } function b6([a, z, y] = [undefined, null, undefined]) { } function b7([[a], b, [[c, d]]] = [[undefined], undefined, [[undefined, undefined]]]) { } b1([1, 2, 3]); // z is widen to the type any[] b2("string", { x: 200, y: "string" }); b2("string", { x: 200, y: true }); b6(["string", 1, 2]); // Shouldn't be an error b7([["string"], 1, [[true, false]]]); // Shouldn't be an error // If the declaration specifies a binding pattern, the parameter type is the implied type of that binding pattern (section 5.1.3) enum Foo { a } function c0({z: {x, y: {j}}}) { } function c1({z} = { z: 10 }) { } function c2({z = 10}) { } function c3({b}: { b: number|string} = { b: "hello" }) { } function c5([a, b, [[c]]]) { } function c6([a, b, [[c=1]]]) { } c0({z : { x: 1, y: { j: "world" } }}); // Implied type is { z: {x: any, y: {j: any}} } c0({z : { x: "string", y: { j: true } }}); // Implied type is { z: {x: any, y: {j: any}} } c1(); // Implied type is {z:number}? c1({ z: 1 }) // Implied type is {z:number}? c2({}); // Implied type is {z?: number} c2({z:1}); // Implied type is {z?: number} c3({ b: 1 }); // Implied type is { b: number|string }. c5([1, 2, [["string"]]]); // Implied type is is [any, any, [[any]]] c5([1, 2, [["string"]], false, true]); // Implied type is is [any, any, [[any]]] // A parameter can be marked optional by following its name or binding pattern with a question mark (?) // or by including an initializer. function d0(x?) { } function d0(x = 10) { } interface F2 { d3([a, b, c]?); d4({x, y, z}?); e0([a, b, c]); } class C2 implements F2 { constructor() { } d3() { } d4() { } e0([a, b, c]) { } } class C3 implements F2 { d3([a, b, c]) { } d4({x, y, z}) { } e0([a, b, c]) { } } function d5({x, y} = { x: 1, y: 2 }) { } d5(); // Parameter is optional as its declaration included an initializer // Destructuring parameter declarations do not permit type annotations on the individual binding patterns, // as such annotations would conflict with the already established meaning of colons in object literals. // Type annotations must instead be written on the top- level parameter declaration function e1({x: number}) { } // x has type any NOT number function e2({x}: { x: number }) { } // x is type number function e3({x}: { x?: number }) { } // x is an optional with type number function e4({x: [number,string,any] }) { } // x has type [any, any, any] function e5({x: [a, b, c]}: { x: [number, number, number] }) { } // x has type [any, any, any]
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringParameterDeclaration1ES5iterable.ts
TypeScript
// @downlevelIteration: true // A parameter declaration may specify either an identifier or a binding pattern. // The identifiers specified in parameter declarations and binding patterns // in a parameter list must be unique within that parameter list. // If the declaration includes a type annotation, the parameter is of that type function a1([a, b, [[c]]]: [number, number, string[][]]) { } function a2(o: { x: number, a: number }) { } function a3({j, k, l: {m, n}, q: [a, b, c]}: { j: number, k: string, l: { m: boolean, n: number }, q: (number|string)[] }) { }; function a4({x, a}: { x: number, a: number }) { } a1([1, 2, [["world"]]]); a1([1, 2, [["world"]], 3]); // If the declaration includes an initializer expression (which is permitted only // when the parameter list occurs in conjunction with a function body), // the parameter type is the widened form (section 3.11) of the type of the initializer expression. function b1(z = [undefined, null]) { }; function b2(z = null, o = { x: 0, y: undefined }) { } function b3({z: {x, y: {j}}} = { z: { x: "hi", y: { j: 1 } } }) { } interface F1 { b5(z, y, [, a, b], {p, m: { q, r}}); } function b6([a, z, y] = [undefined, null, undefined]) { } function b7([[a], b, [[c, d]]] = [[undefined], undefined, [[undefined, undefined]]]) { } b1([1, 2, 3]); // z is widen to the type any[] b2("string", { x: 200, y: "string" }); b2("string", { x: 200, y: true }); b6(["string", 1, 2]); // Shouldn't be an error b7([["string"], 1, [[true, false]]]); // Shouldn't be an error // If the declaration specifies a binding pattern, the parameter type is the implied type of that binding pattern (section 5.1.3) enum Foo { a } function c0({z: {x, y: {j}}}) { } function c1({z} = { z: 10 }) { } function c2({z = 10}) { } function c3({b}: { b: number|string} = { b: "hello" }) { } function c5([a, b, [[c]]]) { } function c6([a, b, [[c=1]]]) { } c0({z : { x: 1, y: { j: "world" } }}); // Implied type is { z: {x: any, y: {j: any}} } c0({z : { x: "string", y: { j: true } }}); // Implied type is { z: {x: any, y: {j: any}} } c1(); // Implied type is {z:number}? c1({ z: 1 }) // Implied type is {z:number}? c2({}); // Implied type is {z?: number} c2({z:1}); // Implied type is {z?: number} c3({ b: 1 }); // Implied type is { b: number|string }. c5([1, 2, [["string"]]]); // Implied type is is [any, any, [[any]]] c5([1, 2, [["string"]], false, true]); // Implied type is is [any, any, [[any]]] // A parameter can be marked optional by following its name or binding pattern with a question mark (?) // or by including an initializer. function d0(x?) { } function d0(x = 10) { } interface F2 { d3([a, b, c]?); d4({x, y, z}?); e0([a, b, c]); } class C2 implements F2 { constructor() { } d3() { } d4() { } e0([a, b, c]) { } } class C3 implements F2 { d3([a, b, c]) { } d4({x, y, z}) { } e0([a, b, c]) { } } function d5({x, y} = { x: 1, y: 2 }) { } d5(); // Parameter is optional as its declaration included an initializer // Destructuring parameter declarations do not permit type annotations on the individual binding patterns, // as such annotations would conflict with the already established meaning of colons in object literals. // Type annotations must instead be written on the top- level parameter declaration function e1({x: number}) { } // x has type any NOT number function e2({x}: { x: number }) { } // x is type number function e3({x}: { x?: number }) { } // x is an optional with type number function e4({x: [number,string,any] }) { } // x has type [any, any, any] function e5({x: [a, b, c]}: { x: [number, number, number] }) { } // x has type [any, any, any]
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringParameterDeclaration1ES6.ts
TypeScript
// Conformance for emitting ES6 // @target: es6 // A parameter declaration may specify either an identifier or a binding pattern. // The identifiers specified in parameter declarations and binding patterns // in a parameter list must be unique within that parameter list. // If the declaration includes a type annotation, the parameter is of that type function a1([a, b, [[c]]]: [number, number, string[][]]) { } function a2(o: { x: number, a: number }) { } function a3({j, k, l: {m, n}, q: [a, b, c]}: { j: number, k: string, l: { m: boolean, n: number }, q: (number|string)[] }) { }; function a4({x, a}: { x: number, a: number }) { } a1([1, 2, [["world"]]]); a1([1, 2, [["world"]], 3]); // If the declaration includes an initializer expression (which is permitted only // when the parameter list occurs in conjunction with a function body), // the parameter type is the widened form (section 3.11) of the type of the initializer expression. function b1(z = [undefined, null]) { }; function b2(z = null, o = { x: 0, y: undefined }) { } function b3({z: {x, y: {j}}} = { z: { x: "hi", y: { j: 1 } } }) { } interface F1 { b5(z, y, [, a, b], {p, m: { q, r}}); } function b6([a, z, y] = [undefined, null, undefined]) { } function b7([[a], b, [[c, d]]] = [[undefined], undefined, [[undefined, undefined]]]) { } b1([1, 2, 3]); // z is widen to the type any[] b2("string", { x: 200, y: "string" }); b2("string", { x: 200, y: true }); // If the declaration specifies a binding pattern, the parameter type is the implied type of that binding pattern (section 5.1.3) enum Foo { a } function c0({z: {x, y: {j}}}) { } function c1({z} = { z: 10 }) { } function c2({z = 10}) { } function c3({b}: { b: number|string} = { b: "hello" }) { } function c5([a, b, [[c]]]) { } function c6([a, b, [[c=1]]]) { } c0({z : { x: 1, y: { j: "world" } }}); // Implied type is { z: {x: any, y: {j: any}} } c0({z : { x: "string", y: { j: true } }}); // Implied type is { z: {x: any, y: {j: any}} } c1(); // Implied type is {z:number}? c1({ z: 1 }) // Implied type is {z:number}? c2({}); // Implied type is {z?: number} c2({z:1}); // Implied type is {z?: number} c3({ b: 1 }); // Implied type is { b: number|string }. c5([1, 2, [["string"]]]); // Implied type is is [any, any, [[any]]] c5([1, 2, [["string"]], false, true]); // Implied type is is [any, any, [[any]]] // A parameter can be marked optional by following its name or binding pattern with a question mark (?) // or by including an initializer. interface F2 { d3([a, b, c]?); d4({x, y, z}?); e0([a, b, c]); } class C2 implements F2 { constructor() { } d3() { } d4() { } e0([a, b, c]) { } } class C3 implements F2 { d3([a, b, c]) { } d4({x, y, z}) { } e0([a, b, c]) { } } function d5({x, y} = { x: 1, y: 2 }) { } d5(); // Parameter is optional as its declaration included an initializer // Destructuring parameter declarations do not permit type annotations on the individual binding patterns, // as such annotations would conflict with the already established meaning of colons in object literals. // Type annotations must instead be written on the top- level parameter declaration function e1({x: number}) { } // x has type any NOT number function e2({x}: { x: number }) { } // x is type number function e3({x}: { x?: number }) { } // x is an optional with type number function e4({x: [number,string,any] }) { } // x has type [any, any, any] function e5({x: [a, b, c]}: { x: [number, number, number] }) { } // x has type [any, any, any] function e6({x: [number, number, number]}) { } // error, duplicate identifier;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringParameterDeclaration3ES5.ts
TypeScript
// @target: es6 // If the parameter is a rest parameter, the parameter type is any[] // A type annotation for a rest parameter must denote an array type. // RestParameter: // ... Identifier TypeAnnotation(opt) type arrayString = Array<String> type someArray = Array<String> | number[]; type stringOrNumArray = Array<String|Number>; function a1(...x: (number|string)[]) { } function a2(...a) { } function a3(...a: Array<String>) { } function a4(...a: arrayString) { } function a5(...a: stringOrNumArray) { } function a9([a, b, [[c]]]) { } function a10([a, b, [[c]], ...x]) { } function a11([a, b, c, ...x]: number[]) { } var array = [1, 2, 3]; var array2 = [true, false, "hello"]; a2([...array]); a1(...array); a9([1, 2, [["string"]], false, true]); // Parameter type is [any, any, [[any]]] a10([1, 2, [["string"]], false, true]); // Parameter type is any[] a10([1, 2, 3, false, true]); // Parameter type is any[] a10([1, 2]); // Parameter type is any[] a11([1, 2]); // Parameter type is number[] // Rest parameter with generic function foo<T>(...a: T[]) { } foo<number|string>("hello", 1, 2); foo("hello", "world"); enum E { a, b } const enum E1 { a, b } function foo1<T extends Number>(...a: T[]) { } foo1(1, 2, 3, E.a); foo1(1, 2, 3, E1.a, E.b);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringParameterDeclaration3ES5iterable.ts
TypeScript
// @target: es5 // @downlevelIteration: true // If the parameter is a rest parameter, the parameter type is any[] // A type annotation for a rest parameter must denote an array type. // RestParameter: // ... Identifier TypeAnnotation(opt) type arrayString = Array<String> type someArray = Array<String> | number[]; type stringOrNumArray = Array<String|Number>; function a1(...x: (number|string)[]) { } function a2(...a) { } function a3(...a: Array<String>) { } function a4(...a: arrayString) { } function a5(...a: stringOrNumArray) { } function a9([a, b, [[c]]]) { } function a10([a, b, [[c]], ...x]) { } function a11([a, b, c, ...x]: number[]) { } var array = [1, 2, 3]; var array2 = [true, false, "hello"]; a2([...array]); a1(...array); a9([1, 2, [["string"]], false, true]); // Parameter type is [any, any, [[any]]] a10([1, 2, [["string"]], false, true]); // Parameter type is any[] a10([1, 2, 3, false, true]); // Parameter type is any[] a10([1, 2]); // Parameter type is any[] a11([1, 2]); // Parameter type is number[] // Rest parameter with generic function foo<T>(...a: T[]) { } foo<number|string>("hello", 1, 2); foo("hello", "world"); enum E { a, b } const enum E1 { a, b } function foo1<T extends Number>(...a: T[]) { } foo1(1, 2, 3, E.a); foo1(1, 2, 3, E1.a, E.b);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringParameterDeclaration3ES6.ts
TypeScript
// @target: es6 // If the parameter is a rest parameter, the parameter type is any[] // A type annotation for a rest parameter must denote an array type. // RestParameter: // ... Identifier TypeAnnotation(opt) type arrayString = Array<String> type someArray = Array<String> | number[]; type stringOrNumArray = Array<String|Number>; function a1(...x: (number|string)[]) { } function a2(...a) { } function a3(...a: Array<String>) { } function a4(...a: arrayString) { } function a5(...a: stringOrNumArray) { } function a9([a, b, [[c]]]) { } function a10([a, b, [[c]], ...x]) { } function a11([a, b, c, ...x]: number[]) { } var array = [1, 2, 3]; var array2 = [true, false, "hello"]; a2([...array]); a1(...array); a9([1, 2, [["string"]], false, true]); // Parameter type is [any, any, [[any]]] a10([1, 2, [["string"]], false, true]); // Parameter type is any[] a10([1, 2, 3, false, true]); // Parameter type is any[] a10([1, 2]); // Parameter type is any[] a11([1, 2]); // Parameter type is number[] // Rest parameter with generic function foo<T>(...a: T[]) { } foo<number|string>("hello", 1, 2); foo("hello", "world"); enum E { a, b } const enum E1 { a, b } function foo1<T extends Number>(...a: T[]) { } foo1(1, 2, 3, E.a); foo1(1, 2, 3, E1.a, E.b);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringParameterDeclaration5.ts
TypeScript
// Parameter Declaration with generic interface F { } class Class implements F { constructor() { } } class SubClass extends Class { foo: boolean; constructor() { super(); } } class D implements F { foo: boolean constructor() { } } class SubD extends D { bar: number constructor() { super(); } } function d0<T extends Class>({x} = { x: new Class() }) { } function d1<T extends F>({x}: { x: F }) { } function d2<T extends Class>({x}: { x: Class }) { } function d3<T extends D>({y}: { y: D }) { } function d4<T extends D>({y} = { y: new D() }) { } var obj = new Class(); d0({ x: 1 }); d0({ x: {} }); d0({ x: "string" }); d1({ x: new Class() }); d1({ x: {} }); d1({ x: "string" }); d2({ x: new SubClass() }); d2({ x: {} }); d3({ y: new SubD() }); d3({ y: new SubClass() }); // Error d3({ y: new Class() }); d3({}); d3({ y: 1 }); d3({ y: "world" });
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringParameterDeclaration7ES5.ts
TypeScript
// @target: es5 interface ISomething { foo: string, bar: string } function foo({}, {foo, bar}: ISomething) {} function baz([], {foo, bar}: ISomething) {} function one([], {}) {} function two([], [a, b, c]: number[]) {}
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringParameterDeclaration7ES5iterable.ts
TypeScript
// @target: es5 // @downlevelIteration: true interface ISomething { foo: string, bar: string } function foo({}, {foo, bar}: ISomething) {} function baz([], {foo, bar}: ISomething) {} function one([], {}) {} function two([], [a, b, c]: number[]) {}
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringParameterDeclaration8.ts
TypeScript
// explicit type annotation should cause `method` to have type 'x' | 'y' // both inside and outside `test`. function test({ method = 'z', nested: { p = 'c' } }: { method?: 'x' | 'y', nested?: { p: 'a' | 'b' } }) { method p } test({}); test({ method: 'x', nested: { p: 'a' } }) test({ method: 'z', nested: { p: 'b' } }) test({ method: 'one', nested: { p: 'a' } })
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringReassignsRightHandSide.ts
TypeScript
// @target: es5 var foo: any = { foo: 1, bar: 2 }; var bar: any; // reassignment in destructuring pattern ({ foo, bar } = foo); // reassignment in subsequent var var { foo, baz } = foo;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringSameNames.ts
TypeScript
// Valid cases let { foo, foo: bar } = { foo: 1 }; ({ foo, foo } = { foo: 2 }); ({ foo, foo: bar } = { foo: 3 }); ({ foo: bar, foo } = { foo: 4 }); ({ foo, bar: foo } = { foo: 3, bar: 33 }); ({ bar: foo, foo } = { foo: 4, bar: 44 }); ({ foo: bar, foo: bar } = { foo: 5 }); ({ foo: bar, bar: foo } = { foo: 6, bar: 66 }); ({ foo: bar, foo: bar } = { foo: 7 }); [foo, foo] = [111, 1111]; [foo, foo] = [222, 2222]; [bar, foo, foo] = [333, 3333, 33333]; [foo, bar, foo] = [333, 3333, 33333]; [foo, foo, bar] = [444, 4444, 44444]; // Error cases let { foo1, foo1 } = { foo1: 10 }; let { foo2, bar2: foo2 } = { foo2: 20, bar2: 220 }; let { bar3: foo3, foo3 } = { foo3: 30, bar3: 330 }; const { foo4, foo4 } = { foo4: 40 }; const { foo5, bar5: foo5 } = { foo5: 50, bar5: 550 }; const { bar6: foo6, foo6 } = { foo6: 60, bar6: 660 }; let [blah1, blah1] = [111, 222]; const [blah2, blah2] = [333, 444];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringSpread.ts
TypeScript
const { x } = { ...{}, x: 0 }; const { y } = { y: 0, ...{} }; const { z, a, b } = { z: 0, ...{ a: 0, b: 0 } }; const { c, d, e, f, g } = { ...{ ...{ ...{ c: 0, }, d: 0 }, e: 0 }, f: 0 };
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringTypeAssertionsES5_1.ts
TypeScript
//@target: ES5 var { x } = <any>foo();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringTypeAssertionsES5_2.ts
TypeScript
//@target: ES5 var { x } = (<any>foo());
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringTypeAssertionsES5_3.ts
TypeScript
//@target: ES5 var { x } = <any>(foo());
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringTypeAssertionsES5_4.ts
TypeScript
//@target: ES5 var { x } = <any><any>foo();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringTypeAssertionsES5_5.ts
TypeScript
//@target: ES5 var { x } = <any>0;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringTypeAssertionsES5_6.ts
TypeScript
//@target: ES5 var { x } = <any>new Foo;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringTypeAssertionsES5_7.ts
TypeScript
//@target: ES5 var { x } = <any><any>new Foo;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringVariableDeclaration1ES5.ts
TypeScript
// The type T associated with a destructuring variable declaration is determined as follows: // If the declaration includes a type annotation, T is that type. var {a1, a2}: { a1: number, a2: string } = { a1: 10, a2: "world" } var [a3, [[a4]], a5]: [number, [[string]], boolean] = [1, [["hello"]], true]; // The type T associated with a destructuring variable declaration is determined as follows: // Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. var { b1: { b11 } = { b11: "string" } } = { b1: { b11: "world" } }; var temp = { t1: true, t2: "false" }; var [b2 = 3, b3 = true, b4 = temp] = [3, false, { t1: false, t2: "hello" }]; var [b5 = 3, b6 = true, b7 = temp] = [undefined, undefined, undefined]; // The type T associated with a binding element is determined as follows: // If the binding element is a rest element, T is an array type with // an element type E, where E is the type of the numeric index signature of S. var [...c1] = [1,2,3]; var [...c2] = [1,2,3, "string"]; // The type T associated with a binding element is determined as follows: // Otherwise, if S is a tuple- like type (section 3.3.3): // Let N be the zero-based index of the binding element in the array binding pattern. // If S has a property with the numerical name N, T is the type of that property. var [d1,d2] = [1,"string"] // The type T associated with a binding element is determined as follows: // Otherwise, if S is a tuple- like type (section 3.3.3): // Otherwise, if S has a numeric index signature, T is the type of the numeric index signature. var temp1 = [true, false, true] var [d3, d4] = [1, "string", ...temp1]; // Combining both forms of destructuring, var {e: [e1, e2, e3 = { b1: 1000, b4: 200 }]} = { e: [1, 2, { b1: 4, b4: 0 }] }; var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] }; // When a destructuring variable declaration, binding property, or binding element specifies // an initializer expression, the type of the initializer expression is required to be assignable // to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. var {g: {g1 = [undefined, null]}}: { g: { g1: any[] } } = { g: { g1: [1, 2] } }; var {h: {h1 = [undefined, null]}}: { h: { h1: number[] } } = { h: { h1: [1, 2] } };
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringVariableDeclaration1ES5iterable.ts
TypeScript
// @downlevelIteration: true // The type T associated with a destructuring variable declaration is determined as follows: // If the declaration includes a type annotation, T is that type. var {a1, a2}: { a1: number, a2: string } = { a1: 10, a2: "world" } var [a3, [[a4]], a5]: [number, [[string]], boolean] = [1, [["hello"]], true]; // The type T associated with a destructuring variable declaration is determined as follows: // Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. var { b1: { b11 } = { b11: "string" } } = { b1: { b11: "world" } }; var temp = { t1: true, t2: "false" }; var [b2 = 3, b3 = true, b4 = temp] = [3, false, { t1: false, t2: "hello" }]; var [b5 = 3, b6 = true, b7 = temp] = [undefined, undefined, undefined]; // The type T associated with a binding element is determined as follows: // If the binding element is a rest element, T is an array type with // an element type E, where E is the type of the numeric index signature of S. var [...c1] = [1,2,3]; var [...c2] = [1,2,3, "string"]; // The type T associated with a binding element is determined as follows: // Otherwise, if S is a tuple- like type (section 3.3.3): // Let N be the zero-based index of the binding element in the array binding pattern. // If S has a property with the numerical name N, T is the type of that property. var [d1,d2] = [1,"string"] // The type T associated with a binding element is determined as follows: // Otherwise, if S is a tuple- like type (section 3.3.3): // Otherwise, if S has a numeric index signature, T is the type of the numeric index signature. var temp1 = [true, false, true] var [d3, d4] = [1, "string", ...temp1]; // Combining both forms of destructuring, var {e: [e1, e2, e3 = { b1: 1000, b4: 200 }]} = { e: [1, 2, { b1: 4, b4: 0 }] }; var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] }; // When a destructuring variable declaration, binding property, or binding element specifies // an initializer expression, the type of the initializer expression is required to be assignable // to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. var {g: {g1 = [undefined, null]}}: { g: { g1: any[] } } = { g: { g1: [1, 2] } }; var {h: {h1 = [undefined, null]}}: { h: { h1: number[] } } = { h: { h1: [1, 2] } };
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringVariableDeclaration1ES6.ts
TypeScript
// @target: es6 // The type T associated with a destructuring variable declaration is determined as follows: // If the declaration includes a type annotation, T is that type. var {a1, a2}: { a1: number, a2: string } = { a1: 10, a2: "world" } var [a3, [[a4]], a5]: [number, [[string]], boolean] = [1, [["hello"]], true]; // The type T associated with a destructuring variable declaration is determined as follows: // Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. var { b1: { b11 } = { b11: "string" } } = { b1: { b11: "world" } }; var temp = { t1: true, t2: "false" }; var [b2 = 3, b3 = true, b4 = temp] = [3, false, { t1: false, t2: "hello" }]; var [b5 = 3, b6 = true, b7 = temp] = [undefined, undefined, undefined]; // The type T associated with a binding element is determined as follows: // If the binding element is a rest element, T is an array type with // an element type E, where E is the type of the numeric index signature of S. var [...c1] = [1,2,3]; var [...c2] = [1,2,3, "string"]; // The type T associated with a binding element is determined as follows: // Otherwise, if S is a tuple- like type (section 3.3.3): // Let N be the zero-based index of the binding element in the array binding pattern. // If S has a property with the numerical name N, T is the type of that property. var [d1,d2] = [1,"string"] // The type T associated with a binding element is determined as follows: // Otherwise, if S is a tuple- like type (section 3.3.3): // Otherwise, if S has a numeric index signature, T is the type of the numeric index signature. var temp1 = [true, false, true] var [d3, d4] = [1, "string", ...temp1]; // Combining both forms of destructuring, var {e: [e1, e2, e3 = { b1: 1000, b4: 200 }]} = { e: [1, 2, { b1: 4, b4: 0 }] }; var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] }; // When a destructuring variable declaration, binding property, or binding element specifies // an initializer expression, the type of the initializer expression is required to be assignable // to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. var {g: {g1 = [undefined, null]}}: { g: { g1: any[] } } = { g: { g1: [1, 2] } }; var {h: {h1 = [undefined, null]}}: { h: { h1: number[] } } = { h: { h1: [1, 2] } };
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringVariableDeclaration2.ts
TypeScript
// The type T associated with a destructuring variable declaration is determined as follows: // If the declaration includes a type annotation, T is that type. var {a1, a2}: { a1: number, a2: string } = { a1: true, a2: 1 } // Error var [a3, [[a4]], a5]: [number, [[string]], boolean] = [1, [[false]], true]; // Error // The type T associated with a destructuring variable declaration is determined as follows: // Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. var temp = { t1: true, t2: "false" }; var [b0 = 3, b1 = true, b2 = temp] = [3, false, { t1: false, t2: 5}]; // Error // The type T associated with a binding element is determined as follows: // If the binding element is a rest element, T is an array type with // an element type E, where E is the type of the numeric index signature of S. var [c1, c2, { c3: c4, c5 }, , ...c6] = [1, 2, { c3: 4, c5: 0 }]; // Error // When a destructuring variable declaration, binding property, or binding element specifies // an initializer expression, the type of the initializer expression is required to be assignable // to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. var {d: {d1 = ["string", null]}}: { d: { d1: number[] } } = { d: { d1: [1, 2] } }; // Error
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringVoid.ts
TypeScript
// @strictNullChecks: false declare const v: void; const {} = v;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringVoidStrictNullChecks.ts
TypeScript
// @strictNullChecks: true declare const v: void; const {} = v;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringWithLiteralInitializers.ts
TypeScript
// (arg: { x: any, y: any }) => void function f1({ x, y }) { } f1({ x: 1, y: 1 }); // (arg: { x: any, y?: number }) => void function f2({ x, y = 0 }) { } f2({ x: 1 }); f2({ x: 1, y: 1 }); // (arg: { x?: number, y?: number }) => void function f3({ x = 0, y = 0 }) { } f3({}); f3({ x: 1 }); f3({ y: 1 }); f3({ x: 1, y: 1 }); // (arg?: { x: number, y: number }) => void function f4({ x, y } = { x: 0, y: 0 }) { } f4(); f4({ x: 1, y: 1 }); // (arg?: { x: number, y?: number }) => void function f5({ x, y = 0 } = { x: 0 }) { } f5(); f5({ x: 1 }); f5({ x: 1, y: 1 }); // (arg?: { x?: number, y?: number }) => void function f6({ x = 0, y = 0 } = {}) { } f6(); f6({}); f6({ x: 1 }); f6({ y: 1 }); f6({ x: 1, y: 1 }); // (arg?: { a: { x?: number, y?: number } }) => void function f7({ a: { x = 0, y = 0 } } = { a: {} }) { } f7(); f7({ a: {} }); f7({ a: { x: 1 } }); f7({ a: { y: 1 } }); f7({ a: { x: 1, y: 1 } }); // (arg: [any, any]) => void function g1([x, y]) { } g1([1, 1]); // (arg: [number, number]) => void function g2([x = 0, y = 0]) { } g2([1, 1]); // (arg?: [number, number]) => void function g3([x, y] = [0, 0]) { } g3(); g3([1, 1]); // (arg?: [number, number]) => void function g4([x, y = 0] = [0]) { } g4(); g4([1, 1]); // (arg?: [number, number]) => void function g5([x = 0, y = 0] = []) { } g5(); g5([1, 1]);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/destructuringWithLiteralInitializers2.ts
TypeScript
// @strict: true function f00([x, y]) {} function f01([x, y] = []) {} function f02([x, y] = [1]) {} function f03([x, y] = [1, 'foo']) {} function f10([x = 0, y]) {} function f11([x = 0, y] = []) {} function f12([x = 0, y] = [1]) {} function f13([x = 0, y] = [1, 'foo']) {} function f20([x = 0, y = 'bar']) {} function f21([x = 0, y = 'bar'] = []) {} function f22([x = 0, y = 'bar'] = [1]) {} function f23([x = 0, y = 'bar'] = [1, 'foo']) {} declare const nx: number | undefined; declare const sx: string | undefined; function f30([x = 0, y = 'bar']) {} function f31([x = 0, y = 'bar'] = []) {} function f32([x = 0, y = 'bar'] = [nx]) {} function f33([x = 0, y = 'bar'] = [nx, sx]) {} function f40([x = 0, y = 'bar']) {} function f41([x = 0, y = 'bar'] = []) {} function f42([x = 0, y = 'bar'] = [sx]) {} function f43([x = 0, y = 'bar'] = [sx, nx]) {}
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/directDependenceBetweenTypeAliases.ts
TypeScript
// It is an error for the type specified in a type alias to depend on that type alias // A type alias directly depends on the type it aliases. type T0 = T0 type T0_1 = T0_2 type T0_2 = T0_3 type T0_3 = T0_1 // A type reference directly depends on the referenced type and each of the type arguments, if any. interface I<T> {} type T1 = I<T1> // A union type directly depends on each of the constituent types. type T2 = T2 | string class C<T> {} type T2_1 = T2_1[] | number // An array type directly depends on its element type. type T3 = T3[] // A tuple type directly depends on each of its element types. type T4 = [number, T4] // A type query directly depends on the type of the referenced entity. var x: T5[] = [] type T5 = typeof x class C1<T> {} type T6 = T7 | number type T7 = typeof yy var yy: [string, T8[]]; type T8 = C<T6> // legal cases type T9 = () => T9 type T10 = { x: T10 } | { new(v: T10): string } type T11 = T12[] type T12 = [T13, string] type T13 = typeof zz var zz: { x: T11 }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University