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/emitExponentiationOperatorInTemplateString3ES6.ts
TypeScript
// @target: es6 var t1 = 10; var t2 = 10; var s; // With TemplateTail `${t1 ** t2} world`; `${t1 ** t2 ** t1} world`; `${t1 + t2 ** t1} world`; `${t1 ** t2 + t1} world`; `${t1 + t2 ** t2 + t1 } world`; `${typeof (t1 ** t2 ** t1) } world`; `${1 + typeof (t1 ** t2 ** t1) } world`; `${t1 ** t2}${t1 ** t2} world`; `${t1 ** t2 ** t1}${t1 ** t2 ** t1} world`; `${t1 + t2 ** t1}${t1 + t2 ** t1} world`; `${t1 ** t2 + t1}${t1 ** t2 + t1} world`; `${t1 + t2 ** t2 + t1}${t1 + t2 ** t2 + t1} world`; `${typeof (t1 ** t2 ** t1) }${typeof (t1 ** t2 ** t1) } world`; `${t1 ** t2} hello world ${t1 ** t2} !!`; `${t1 ** t2 ** t1} hello world ${t1 ** t2 ** t1} !!`; `${t1 + t2 ** t1} hello world ${t1 + t2 ** t1} !!`; `${t1 ** t2 + t1} hello world ${t1 ** t2 + t1} !!`; `${t1 + t2 ** t2 + t1} hello world ${t1 + t2 ** t2 + t1} !!`; `${typeof (t1 ** t2 ** t1) } hello world ${typeof (t1 ** t2 ** t1)} !!`;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emitRestParametersFunction.ts
TypeScript
// @target: es5 function bar(...rest) { } function foo(x: number, y: string, ...rest) { }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emitRestParametersFunctionES6.ts
TypeScript
// @target: es6 function bar(...rest) { } function foo(x: number, y: string, ...rest) { }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emitRestParametersFunctionExpression.ts
TypeScript
// @target: es5 var funcExp = (...rest) => { } var funcExp1 = (X: number, ...rest) => { } var funcExp2 = function (...rest) { } var funcExp3 = (function (...rest) { })()
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emitRestParametersFunctionExpressionES6.ts
TypeScript
// @target: es6 var funcExp = (...rest) => { } var funcExp1 = (X: number, ...rest) => { } var funcExp2 = function (...rest) { } var funcExp3 = (function (...rest) { })()
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emitRestParametersFunctionProperty.ts
TypeScript
// @target: es5 var obj: { func1: (...rest) => void } var obj2 = { func(...rest) { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emitRestParametersFunctionPropertyES6.ts
TypeScript
// @target: es6 var obj: { func1: (...rest) => void } var obj2 = { func(...rest) { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emitRestParametersMethod.ts
TypeScript
// @target: es5 class C { constructor(name: string, ...rest) { } public bar(...rest) { } public foo(x: number, ...rest) { } } class D { constructor(...rest) { } public bar(...rest) { } public foo(x: number, ...rest) { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emitRestParametersMethodES6.ts
TypeScript
// @target: es6 class C { constructor(name: string, ...rest) { } public bar(...rest) { } public foo(x: number, ...rest) { } } class D { constructor(...rest) { } public bar(...rest) { } public foo(x: number, ...rest) { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emitStatementsBeforeSuperCall.ts
TypeScript
// @useDefineForClassFields: false // @target: es2015 class Base { } class Sub extends Base { // @ts-ignore constructor(public p: number) { console.log('hi'); // should emit before super super(); } field = 0; } class Test extends Base { prop: number; // @ts-ignore constructor(public p: number) { 1; // should emit before super super(); this.prop = 1; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emitStatementsBeforeSuperCallWithDefineFields.ts
TypeScript
// @useDefineForClassFields: true // @target: es2015 class Base { } class Sub extends Base { // @ts-ignore constructor(public p: number) { console.log('hi'); super(); } field = 0; } class Test extends Base { prop: number; // @ts-ignore constructor(public p: number) { 1; super(); this.prop = 1; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emitter.asyncGenerators.classMethods.es2015.ts
TypeScript
// @target: es2015 // @lib: esnext // @filename: C1.ts class C1 { async * f() { } } // @filename: C2.ts class C2 { async * f() { const x = yield; } } // @filename: C3.ts class C3 { async * f() { const x = yield 1; } } // @filename: C4.ts class C4 { async * f() { const x = yield* [1]; } } // @filename: C5.ts class C5 { async * f() { const x = yield* (async function*() { yield 1; })(); } } // @filename: C6.ts class C6 { async * f() { const x = await 1; } } // @filename: C7.ts class C7 { async * f() { return 1; } } // @filename: C8.ts class C8 { g() { } async * f() { this.g(); } } // @filename: C9.ts class B9 { g() {} } class C9 extends B9 { async * f() { super.g(); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emitter.asyncGenerators.classMethods.es2018.ts
TypeScript
// @target: es2018 // @lib: esnext // @filename: C1.ts class C1 { async * f() { } } // @filename: C2.ts class C2 { async * f() { const x = yield; } } // @filename: C3.ts class C3 { async * f() { const x = yield 1; } } // @filename: C4.ts class C4 { async * f() { const x = yield* [1]; } } // @filename: C5.ts class C5 { async * f() { const x = yield* (async function*() { yield 1; })(); } } // @filename: C6.ts class C6 { async * f() { const x = await 1; } } // @filename: C7.ts class C7 { async * f() { return 1; } } // @filename: C8.ts class C8 { g() { } async * f() { this.g(); } } // @filename: C9.ts class B9 { g() {} } class C9 extends B9 { async * f() { super.g(); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emitter.asyncGenerators.classMethods.es5.ts
TypeScript
// @target: es5 // @lib: esnext // @filename: C1.ts class C1 { async * f() { } } // @filename: C2.ts class C2 { async * f() { const x = yield; } } // @filename: C3.ts class C3 { async * f() { const x = yield 1; } } // @filename: C4.ts class C4 { async * f() { const x = yield* [1]; } } // @filename: C5.ts class C5 { async * f() { const x = yield* (async function*() { yield 1; })(); } } // @filename: C6.ts class C6 { async * f() { const x = await 1; } } // @filename: C7.ts class C7 { async * f() { return 1; } } // @filename: C8.ts class C8 { g() { } async * f() { this.g(); } } // @filename: C9.ts class B9 { g() {} } class C9 extends B9 { async * f() { super.g(); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emitter.asyncGenerators.functionDeclarations.es2015.ts
TypeScript
// @target: es2015 // @lib: esnext // @filename: F1.ts async function * f1() { } // @filename: F2.ts async function * f2() { const x = yield; } // @filename: F3.ts async function * f3() { const x = yield 1; } // @filename: F4.ts async function * f4() { const x = yield* [1]; } // @filename: F5.ts async function * f5() { const x = yield* (async function*() { yield 1; })(); } // @filename: F6.ts async function * f6() { const x = await 1; } // @filename: F7.ts async function * f7() { return 1; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emitter.asyncGenerators.functionDeclarations.es2018.ts
TypeScript
// @target: es2018 // @lib: esnext // @filename: F1.ts async function * f1() { } // @filename: F2.ts async function * f2() { const x = yield; } // @filename: F3.ts async function * f3() { const x = yield 1; } // @filename: F4.ts async function * f4() { const x = yield* [1]; } // @filename: F5.ts async function * f5() { const x = yield* (async function*() { yield 1; })(); } // @filename: F6.ts async function * f6() { const x = await 1; } // @filename: F7.ts async function * f7() { return 1; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emitter.asyncGenerators.functionDeclarations.es5.ts
TypeScript
// @target: es5 // @lib: esnext // @filename: F1.ts async function * f1() { } // @filename: F2.ts async function * f2() { const x = yield; } // @filename: F3.ts async function * f3() { const x = yield 1; } // @filename: F4.ts async function * f4() { const x = yield* [1]; } // @filename: F5.ts async function * f5() { const x = yield* (async function*() { yield 1; })(); } // @filename: F6.ts async function * f6() { const x = await 1; } // @filename: F7.ts async function * f7() { return 1; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emitter.asyncGenerators.functionExpressions.es2015.ts
TypeScript
// @target: es2015 // @lib: esnext // @filename: F1.ts const f1 = async function * () { } // @filename: F2.ts const f2 = async function * () { const x = yield; } // @filename: F3.ts const f3 = async function * () { const x = yield 1; } // @filename: F4.ts const f4 = async function * () { const x = yield* [1]; } // @filename: F5.ts const f5 = async function * () { const x = yield* (async function*() { yield 1; })(); } // @filename: F6.ts const f6 = async function * () { const x = await 1; } // @filename: F7.ts const f7 = async function * () { return 1; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emitter.asyncGenerators.functionExpressions.es2018.ts
TypeScript
// @target: es2018 // @lib: esnext // @filename: F1.ts const f1 = async function * () { } // @filename: F2.ts const f2 = async function * () { const x = yield; } // @filename: F3.ts const f3 = async function * () { const x = yield 1; } // @filename: F4.ts const f4 = async function * () { const x = yield* [1]; } // @filename: F5.ts const f5 = async function * () { const x = yield* (async function*() { yield 1; })(); } // @filename: F6.ts const f6 = async function * () { const x = await 1; } // @filename: F7.ts const f7 = async function * () { return 1; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emitter.asyncGenerators.functionExpressions.es5.ts
TypeScript
// @target: es5 // @lib: esnext // @filename: F1.ts const f1 = async function * () { } // @filename: F2.ts const f2 = async function * () { const x = yield; } // @filename: F3.ts const f3 = async function * () { const x = yield 1; } // @filename: F4.ts const f4 = async function * () { const x = yield* [1]; } // @filename: F5.ts const f5 = async function * () { const x = yield* (async function*() { yield 1; })(); } // @filename: F6.ts const f6 = async function * () { const x = await 1; } // @filename: F7.ts const f7 = async function * () { return 1; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emitter.asyncGenerators.objectLiteralMethods.es2015.ts
TypeScript
// @target: es2015 // @lib: esnext // @filename: O1.ts const o1 = { async * f() { } } // @filename: O2.ts const o2 = { async * f() { const x = yield; } } // @filename: O3.ts const o3 = { async * f() { const x = yield 1; } } // @filename: O4.ts const o4 = { async * f() { const x = yield* [1]; } } // @filename: O5.ts const o5 = { async * f() { const x = yield* (async function*() { yield 1; })(); } } // @filename: O6.ts const o6 = { async * f() { const x = await 1; } } // @filename: O7.ts const o7 = { async * f() { return 1; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emitter.asyncGenerators.objectLiteralMethods.es2018.ts
TypeScript
// @target: es2018 // @lib: esnext // @filename: O1.ts const o1 = { async * f() { } } // @filename: O2.ts const o2 = { async * f() { const x = yield; } } // @filename: O3.ts const o3 = { async * f() { const x = yield 1; } } // @filename: O4.ts const o4 = { async * f() { const x = yield* [1]; } } // @filename: O5.ts const o5 = { async * f() { const x = yield* (async function*() { yield 1; })(); } } // @filename: O6.ts const o6 = { async * f() { const x = await 1; } } // @filename: O7.ts const o7 = { async * f() { return 1; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emitter.asyncGenerators.objectLiteralMethods.es5.ts
TypeScript
// @target: es5 // @lib: esnext // @filename: O1.ts const o1 = { async * f() { } } // @filename: O2.ts const o2 = { async * f() { const x = yield; } } // @filename: O3.ts const o3 = { async * f() { const x = yield 1; } } // @filename: O4.ts const o4 = { async * f() { const x = yield* [1]; } } // @filename: O5.ts const o5 = { async * f() { const x = yield* (async function*() { yield 1; })(); } } // @filename: O6.ts const o6 = { async * f() { const x = await 1; } } // @filename: O7.ts const o7 = { async * f() { return 1; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emitter.forAwait.ts
TypeScript
// @target: es2018,es2017,es2015,es5 // @lib: esnext // @filename: file1.ts async function f1() { let y: any; for await (const x of y) { } } // @filename: file2.ts async function f2() { let x: any, y: any; for await (x of y) { } } // @filename: file3.ts async function* f3() { let y: any; for await (const x of y) { } } // @filename: file4.ts async function* f4() { let x: any, y: any; for await (x of y) { } } // @filename: file5.ts // https://github.com/Microsoft/TypeScript/issues/21363 async function f5() { let y: any; outer: for await (const x of y) { continue outer; } } // @filename: file6.ts // https://github.com/Microsoft/TypeScript/issues/21363 async function* f6() { let y: any; outer: for await (const x of y) { continue outer; } } // @filename: file7.ts // https://github.com/microsoft/TypeScript/issues/36166 async function* f7() { let y: any; for (;;) { for await (const x of y) { } } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emitter.noCatchBinding.es2019.ts
TypeScript
// @target: es2019 function f() { try { } catch { } try { } catch { try { } catch { } } try { } catch { } finally { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emptyArrayBindingPatternParameter01.ts
TypeScript
// @declaration: true function f([]) { var x, y, z; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emptyArrayBindingPatternParameter02.ts
TypeScript
// @declaration: true function f(a, []) { var x, y, z; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emptyArrayBindingPatternParameter03.ts
TypeScript
// @declaration: true function f(a, []) { var x, y, z; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emptyArrayBindingPatternParameter04.ts
TypeScript
// @declaration: true function f([] = [1,2,3,4]) { var x, y, z; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emptyAssignmentPatterns01_ES5.ts
TypeScript
// @target: es5 // @declaration: true var a: any; ({} = a); ([] = a); var [,] = [1,2];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emptyAssignmentPatterns01_ES5iterable.ts
TypeScript
// @target: es5 // @declaration: true // @downlevelIteration: true var a: any; ({} = a); ([] = a);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emptyAssignmentPatterns01_ES6.ts
TypeScript
// @target: es6 // @declaration: true var a: any; ({} = a); ([] = a);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emptyAssignmentPatterns02_ES5.ts
TypeScript
// @target: es5 // @declaration: true var a: any; let x, y, z, a1, a2, a3; ({} = { x, y, z } = a); ([] = [ a1, a2, a3] = a);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emptyAssignmentPatterns02_ES5iterable.ts
TypeScript
// @target: es5 // @declaration: true // @downlevelIteration: true var a: any; let x, y, z, a1, a2, a3; ({} = { x, y, z } = a); ([] = [ a1, a2, a3] = a);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emptyAssignmentPatterns02_ES6.ts
TypeScript
// @target: es6 // @declaration: true var a: any; let x, y, z, a1, a2, a3; ({} = { x, y, z } = a); ([] = [ a1, a2, a3] = a);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emptyAssignmentPatterns03_ES5.ts
TypeScript
// @target: es5 // @declaration: true var a: any; ({} = {} = a); ([] = [] = a);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emptyAssignmentPatterns03_ES5iterable.ts
TypeScript
// @target: es5 // @declaration: true // @downlevelIteration: true var a: any; ({} = {} = a); ([] = [] = a);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emptyAssignmentPatterns03_ES6.ts
TypeScript
// @target: es6 // @declaration: true var a: any; ({} = {} = a); ([] = [] = a);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emptyAssignmentPatterns04_ES5.ts
TypeScript
// @target: es5 // @declaration: true var a: any; let x, y, z, a1, a2, a3; ({ x, y, z } = {} = a); ([ a1, a2, a3] = [] = a);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emptyAssignmentPatterns04_ES5iterable.ts
TypeScript
// @target: es5 // @declaration: true // @downlevelIteration: true var a: any; let x, y, z, a1, a2, a3; ({ x, y, z } = {} = a); ([ a1, a2, a3] = [] = a);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emptyAssignmentPatterns04_ES6.ts
TypeScript
// @target: es6 // @declaration: true var a: any; let x, y, z, a1, a2, a3; ({ x, y, z } = {} = a); ([ a1, a2, a3] = [] = a);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emptyObjectBindingPatternParameter01.ts
TypeScript
// @declaration: true function f({}) { var x, y, z; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emptyObjectBindingPatternParameter02.ts
TypeScript
// @declaration: true function f(a, {}) { var x, y, z; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emptyObjectBindingPatternParameter03.ts
TypeScript
// @declaration: true function f({}, a) { var x, y, z; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emptyObjectBindingPatternParameter04.ts
TypeScript
// @declaration: true function f({} = {a: 1, b: "2", c: true}) { var x, y, z; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emptyTuplesTypeAssertion01.ts
TypeScript
// @declaration: true let x = <[]>[]; let y = x[0];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emptyTuplesTypeAssertion02.ts
TypeScript
// @declaration: true let x = [] as []; let y = x[0];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emptyVariableDeclarationBindingPatterns01_ES5.ts
TypeScript
// @target: es5 (function () { var a: any; var {} = a; let {} = a; const {} = a; var [] = a; let [] = a; const [] = a; var {} = a, [] = a; let {} = a, [] = a; const {} = a, [] = a; var { p1: {}, p2: [] } = a; let { p1: {}, p2: [] } = a; const { p1: {}, p2: [] } = a; for (var {} = {}, {} = {}; false; void 0) { } function f({} = a, [] = a, { p: {} = a} = a) { return ({} = a, [] = a, { p: {} = a } = a) => a; } })(); (function () { const ns: number[][] = []; for (var {} of ns) { } for (let {} of ns) { } for (const {} of ns) { } for (var [] of ns) { } for (let [] of ns) { } for (const [] of ns) { } })();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emptyVariableDeclarationBindingPatterns01_ES5iterable.ts
TypeScript
// @target: es5 // @downlevelIteration: true (function () { var a: any; var {} = a; let {} = a; const {} = a; var [] = a; let [] = a; const [] = a; var {} = a, [] = a; let {} = a, [] = a; const {} = a, [] = a; var { p1: {}, p2: [] } = a; let { p1: {}, p2: [] } = a; const { p1: {}, p2: [] } = a; for (var {} = {}, {} = {}; false; void 0) { } function f({} = a, [] = a, { p: {} = a} = a) { return ({} = a, [] = a, { p: {} = a } = a) => a; } })(); (function () { const ns: number[][] = []; for (var {} of ns) { } for (let {} of ns) { } for (const {} of ns) { } for (var [] of ns) { } for (let [] of ns) { } for (const [] of ns) { } })();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/emptyVariableDeclarationBindingPatterns01_ES6.ts
TypeScript
// @target: es6 (function () { var a: any; var {} = a; let {} = a; const {} = a; var [] = a; let [] = a; const [] = a; var {} = a, [] = a; let {} = a, [] = a; const {} = a, [] = a; var { p1: {}, p2: [] } = a; let { p1: {}, p2: [] } = a; const { p1: {}, p2: [] } = a; for (var {} = {}, {} = {}; false; void 0) { } function f({} = a, [] = a, { p: {} = a} = a) { return ({} = a, [] = a, { p: {} = a } = a) => a; } })(); (function () { const ns: number[][] = []; for (var {} of ns) { } for (let {} of ns) { } for (const {} of ns) { } for (var [] of ns) { } for (let [] of ns) { } for (const [] of ns) { } })();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/enumAssignability.ts
TypeScript
// enums assignable to number, any, Object, errors unless otherwise noted enum E { A } enum F { B } var e = E.A; var f = F.B; e = f; f = e; e = 1; // ok f = 1; // ok var x: number = e; // ok x = f; // ok module Others { var a: any = e; // ok class C { foo: string; } var ac: C; interface I { foo: string; } var ai: I; var b: number = e; // ok var c: string = e; var d: boolean = e; var ee: Date = e; var f: any = e; // ok var g: void = e; var h: Object = e; var i: {} = e; var j: () => {} = e; var k: Function = e; var l: (x: number) => string = e; ac = e; ai = e; var m: number[] = e; var n: { foo: string } = e; var o: <T>(x: T) => T = e; var p: Number = e; var q: String = e; function foo<T, U extends T, V extends Date, A extends Number, B extends E>(x: T, y: U, z: V) { x = e; y = e; z = e; var a: A = e; var b: B = e; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/enumAssignabilityInInheritance.ts
TypeScript
// enum is only a subtype of number, no types are subtypes of enum, all of these except the first are errors enum E { A } interface I0 { [x: string]: E; foo: E; // identical and subtype, ok } declare function foo(x: E): E; declare function foo(x: number): number; declare function foo(x: any): any; var r = foo(E.A); // E var r2 = foo(1); // number var r3 = foo(<any>null); // any declare function foo2(x: string): string; declare function foo2(x: E): E; var r4 = foo2(E.A); declare function foo3(x: boolean): boolean; declare function foo3(x: E): E; var r4 = foo3(E.A); declare function foo4(x: Date): Date; declare function foo4(x: E): E; var r4 = foo4(E.A); declare function foo5(x: RegExp): RegExp; declare function foo5(x: E): E; var r4 = foo5(E.A); declare function foo6(x: { bar: number }): { bar: number }; declare function foo6(x: E): E; var r4 = foo6(E.A); declare function foo7(x: number[]): number[]; declare function foo7(x: E): E; var r4 = foo7(E.A); interface I8 { foo: string; } declare function foo8(x: I8): I8; declare function foo8(x: E): E; var r4 = foo8(E.A); class A { foo: number; } declare function foo9(x: A): A; declare function foo9(x: E): E; var r4 = foo9(E.A); class A2<T> { foo: T; } declare function foo10(x: A2<number>): A2<number>; declare function foo10(x: E): E; var r4 = foo10(E.A); declare function foo11(x: (x) => number): (x) => number; declare function foo11(x: E): E; var r4 = foo11(E.A); declare function foo12(x: <T>(x: T) => T): <T>(x: T) => T; declare function foo12(x: E): E; var r4 = foo12(E.A); enum E2 { A } declare function foo13(x: E2): E2; declare function foo13(x: E): E; var r4 = foo13(E.A); function f() { } module f { export var bar = 1; } declare function foo14(x: typeof f): typeof f; declare function foo14(x: E): E; var r4 = foo14(E.A); class CC { baz: string } module CC { export var bar = 1; } declare function foo15(x: CC): CC; declare function foo15(x: E): E; var r4 = foo15(E.A); declare function foo16(x: Object): Object; declare function foo16(x: E): E; var r4 = foo16(E.A); declare function foo17(x: {}): {}; declare function foo17(x: E): E; var r4 = foo16(E.A);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/enumBasics.ts
TypeScript
// Enum without initializers have first member = 0 and successive members = N + 1 enum E1 { A, B, C } // Enum type is a subtype of Number var x: number = E1.A; // Enum object type is anonymous with properties of the enum type and numeric indexer var e = E1; var e: { readonly A: E1.A; readonly B: E1.B; readonly C: E1.C; readonly [n: number]: string; }; var e: typeof E1; // Reverse mapping of enum returns string name of property var s = E1[e.A]; var s: string; // Enum with only constant members enum E2 { A = 1, B = 2, C = 3 } // Enum with only computed members enum E3 { X = 'foo'.length, Y = 4 + 3, Z = +'foo' } // Enum with constant members followed by computed members enum E4 { X = 0, Y, Z = 'foo'.length } // Enum with > 2 constant members with no initializer for first member, non zero initializer for second element enum E5 { A, B = 3, C // 4 } enum E6 { A, B = 0, C // 1 } // Enum with computed member initializer of type 'any' enum E7 { A = 'foo'['foo'] } // Enum with computed member initializer of type number enum E8 { B = 'foo'['foo'] } //Enum with computed member intializer of same enum type enum E9 { A, B = A } // (refer to .js to validate) // Enum constant members are propagated var doNotPropagate = [ E8.B, E7.A, E4.Z, E3.X, E3.Y, E3.Z ]; // Enum computed members are not propagated var doPropagate = [ E9.A, E9.B, E6.B, E6.C, E6.A, E5.A, E5.B, E5.C ];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/enumClassification.ts
TypeScript
// @declaration: true // An enum type where each member has no initializer or an initializer that specififes // a numeric literal, a string literal, or a single identifier naming another member in // the enum type is classified as a literal enum type. An enum type that doesn't adhere // to this pattern is classified as a numeric enum type. // Examples of literal enum types enum E01 { A } enum E02 { A = 123 } enum E03 { A = "hello" } enum E04 { A, B, C } enum E05 { A, B = 10, C } enum E06 { A = "one", B = "two", C = "three" } enum E07 { A, B, C = "hi", D = 10, E, F = "bye" } enum E08 { A = 10, B = "hello", C = A, D = B, E = C, } // Examples of numeric enum types with only constant members enum E10 {} enum E11 { A = +0, B, C } enum E12 { A = 1 << 0, B = 1 << 1, C = 1 << 2 } // Examples of numeric enum types with constant and computed members enum E20 { A = "foo".length, B = A + 1, C = +"123", D = Math.sin(1) }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/enumConstantMemberWithString.ts
TypeScript
enum T1 { a = "1", b = "1" + "2", c = "1" + "2" + "3", d = "a" - "a", e = "a" + 1 } enum T2 { a = "1", b = "1" + "2" } enum T3 { a = "1", b = "1" + "2", c = 1, d = 1 + 2 } enum T4 { a = "1" } enum T5 { a = "1" + "2" } declare enum T6 { a = "1", b = "1" + "2" }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/enumConstantMemberWithStringEmitDeclaration.ts
TypeScript
// @declaration: true enum T1 { a = "1", b = "1" + "2", c = "1" + "2" + "3" } enum T2 { a = "1", b = "1" + "2" } enum T3 { a = "1", b = "1" + "2" } enum T4 { a = "1" } enum T5 { a = "1" + "2" } declare enum T6 { a = "1", b = "1" + "2" }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/enumConstantMemberWithTemplateLiterals.ts
TypeScript
enum T1 { a = `1` } enum T2 { a = `1`, b = "2", c = 3 } enum T3 { a = `1` + `1` } enum T4 { a = `1`, b = `1` + `1`, c = `1` + "2", d = "2" + `1`, e = "2" + `1` + `1` } enum T5 { a = `1`, b = `1` + `2`, c = `1` + `2` + `3`, d = 1, e = `1` - `1`, f = `1` + 1, g = `1${"2"}3`, h = `1`.length } enum T6 { a = 1, b = `12`.length } declare enum T7 { a = `1`, b = `1` + `1`, c = "2" + `1` }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/enumConstantMemberWithTemplateLiteralsEmitDeclaration.ts
TypeScript
// @declaration: true enum T1 { a = `1` } enum T2 { a = `1`, b = "2", c = 3 } enum T3 { a = `1` + `1` } enum T4 { a = `1`, b = `1` + `1`, c = `1` + "2", d = "2" + `1`, e = "2" + `1` + `1` } enum T5 { a = `1`, b = `1` + `2`, c = `1` + `2` + `3`, d = 1 } enum T6 { a = 1, b = `12`.length } declare enum T7 { a = `1`, b = `1` + `1`, c = "2" + `1` }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/enumConstantMembers.ts
TypeScript
// Constant members allow negatives, but not decimals. Also hex literals are allowed enum E1 { a = 1, b } enum E2 { a = - 1, b } enum E3 { a = 0.1, b // Error because 0.1 is not a constant } declare enum E4 { a = 1, b = -1, c = 0.1 // Not a constant } enum E5 { a = 1 / 0, b = 2 / 0.0, c = 1.0 / 0.0, d = 0.0 / 0.0, e = NaN, f = Infinity, g = -Infinity } const enum E6 { a = 1 / 0, b = 2 / 0.0, c = 1.0 / 0.0, d = 0.0 / 0.0, e = NaN, f = Infinity, g = -Infinity }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/enumExportMergingES6.ts
TypeScript
// @target: es6 export enum Animals { Cat = 1 } export enum Animals { Dog = 2 } export enum Animals { CatDog = Cat | Dog }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/enumIsNotASubtypeOfAnythingButNumber.ts
TypeScript
// enums are only subtypes of number, any and no other types enum E { A } interface I { [x: string]: any; foo: E; // ok } interface I2 { [x: string]: number; foo: E; // ok } // error cases interface I3 { [x: string]: string; foo: E; } interface I4 { [x: string]: boolean; foo: E; } interface I5 { [x: string]: Date; foo: E; } interface I6 { [x: string]: RegExp; foo: E; } interface I7 { [x: string]: { bar: number }; foo: E; } interface I8 { [x: string]: number[]; foo: E; } interface I9 { [x: string]: I8; foo: E; } class A { foo: number; } interface I10 { [x: string]: A; foo: E; } class A2<T> { foo: T; } interface I11 { [x: string]: A2<number>; foo: E; } interface I12 { [x: string]: (x) => number; foo: E; } interface I13 { [x: string]: <T>(x: T) => T; foo: E; } enum E2 { A } interface I14 { [x: string]: E2; foo: E; } function f() { } module f { export var bar = 1; } interface I15 { [x: string]: typeof f; foo: E; } class c { baz: string } module c { export var bar = 1; } interface I16 { [x: string]: typeof c; foo: E; } interface I17<T> { [x: string]: T; foo: E; } interface I18<T, U extends T> { [x: string]: U; foo: E; } interface I19 { [x: string]: Object; foo: E; // BUG 831833 } interface I20 { [x: string]: {}; foo: E; // BUG 831833 }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/enumLiteralTypes1.ts
TypeScript
const enum Choice { Unknown, Yes, No }; type YesNo = Choice.Yes | Choice.No; type NoYes = Choice.No | Choice.Yes; type UnknownYesNo = Choice.Unknown | Choice.Yes | Choice.No; function f1() { var a: YesNo; var a: NoYes; var a: Choice.Yes | Choice.No; var a: Choice.No | Choice.Yes; } function f2(a: YesNo, b: UnknownYesNo, c: Choice) { b = a; c = a; c = b; } function f3(a: Choice.Yes, b: YesNo) { var x = a + b; var x = a - b; var x = a * b; var x = a / b; var x = a % b; var x = a | b; var x = a & b; var x = a ^ b; var x = -b; var x = ~b; var y = a == b; var y = a != b; var y = a === b; var y = a !== b; var y = a > b; var y = a < b; var y = a >= b; var y = a <= b; var y = !b; } function f4(a: Choice.Yes, b: YesNo) { a++; b++; } declare function g(x: Choice.Yes): string; declare function g(x: Choice.No): boolean; declare function g(x: Choice): number; function f5(a: YesNo, b: UnknownYesNo, c: Choice) { var z1 = g(Choice.Yes); var z2 = g(Choice.No); var z3 = g(a); var z4 = g(b); var z5 = g(c); } function assertNever(x: never): never { throw new Error("Unexpected value"); } function f10(x: YesNo) { switch (x) { case Choice.Yes: return "true"; case Choice.No: return "false"; } } function f11(x: YesNo) { switch (x) { case Choice.Yes: return "true"; case Choice.No: return "false"; } return assertNever(x); } function f12(x: UnknownYesNo) { if (x) { x; } else { x; } } function f13(x: UnknownYesNo) { if (x === Choice.Yes) { x; } else { x; } } type Item = { kind: Choice.Yes, a: string } | { kind: Choice.No, b: string }; function f20(x: Item) { switch (x.kind) { case Choice.Yes: return x.a; case Choice.No: return x.b; } } function f21(x: Item) { switch (x.kind) { case Choice.Yes: return x.a; case Choice.No: return x.b; } return assertNever(x); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/enumLiteralTypes2.ts
TypeScript
// @strictNullChecks: true const enum Choice { Unknown, Yes, No }; type YesNo = Choice.Yes | Choice.No; type NoYes = Choice.No | Choice.Yes; type UnknownYesNo = Choice.Unknown | Choice.Yes | Choice.No; function f1() { var a: YesNo; var a: NoYes; var a: Choice.Yes | Choice.No; var a: Choice.No | Choice.Yes; } function f2(a: YesNo, b: UnknownYesNo, c: Choice) { b = a; c = a; c = b; } function f3(a: Choice.Yes, b: UnknownYesNo) { var x = a + b; var x = a - b; var x = a * b; var x = a / b; var x = a % b; var x = a | b; var x = a & b; var x = a ^ b; var x = -b; var x = ~b; var y = a == b; var y = a != b; var y = a === b; var y = a !== b; var y = a > b; var y = a < b; var y = a >= b; var y = a <= b; var y = !b; } function f4(a: Choice.Yes, b: UnknownYesNo) { a++; b++; } declare function g(x: Choice.Yes): string; declare function g(x: Choice.No): boolean; declare function g(x: Choice): number; function f5(a: YesNo, b: UnknownYesNo, c: Choice) { var z1 = g(Choice.Yes); var z2 = g(Choice.No); var z3 = g(a); var z4 = g(b); var z5 = g(c); } function assertNever(x: never): never { throw new Error("Unexpected value"); } function f10(x: YesNo) { switch (x) { case Choice.Yes: return "true"; case Choice.No: return "false"; } } function f11(x: YesNo) { switch (x) { case Choice.Yes: return "true"; case Choice.No: return "false"; } return assertNever(x); } function f12(x: UnknownYesNo) { if (x) { x; } else { x; } } function f13(x: UnknownYesNo) { if (x === Choice.Yes) { x; } else { x; } } type Item = { kind: Choice.Yes, a: string } | { kind: Choice.No, b: string }; function f20(x: Item) { switch (x.kind) { case Choice.Yes: return x.a; case Choice.No: return x.b; } } function f21(x: Item) { switch (x.kind) { case Choice.Yes: return x.a; case Choice.No: return x.b; } return assertNever(x); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/enumLiteralTypes3.ts
TypeScript
const enum Choice { Unknown, Yes, No }; type Yes = Choice.Yes; type YesNo = Choice.Yes | Choice.No; type NoYes = Choice.No | Choice.Yes; type UnknownYesNo = Choice.Unknown | Choice.Yes | Choice.No; function f1(a: Yes, b: YesNo, c: UnknownYesNo, d: Choice) { a = a; a = b; a = c; a = d; } function f2(a: Yes, b: YesNo, c: UnknownYesNo, d: Choice) { b = a; b = b; b = c; b = d; } function f3(a: Yes, b: YesNo, c: UnknownYesNo, d: Choice) { c = a; c = b; c = c; c = d; } function f4(a: Yes, b: YesNo, c: UnknownYesNo, d: Choice) { d = a; d = b; d = c; d = d; } function f5(a: Yes, b: YesNo, c: UnknownYesNo, d: Choice) { a = Choice.Unknown; a = Choice.Yes; a = Choice.No; b = Choice.Unknown; b = Choice.Yes; b = Choice.No; c = Choice.Unknown; c = Choice.Yes; c = Choice.No; d = Choice.Unknown; d = Choice.Yes; d = Choice.No; } function f6(a: Yes, b: YesNo, c: UnknownYesNo, d: Choice) { a === Choice.Unknown; a === Choice.Yes; a === Choice.No; b === Choice.Unknown; b === Choice.Yes; b === Choice.No; c === Choice.Unknown; c === Choice.Yes; c === Choice.No; d === Choice.Unknown; d === Choice.Yes; d === Choice.No; } function f7(a: Yes, b: YesNo, c: UnknownYesNo, d: Choice) { a === a; a === b; a === c; a === d; b === a; b === b; b === c; b === d; c === a; c === b; c === c; c === d; d === a; d === b; d === c; d === d; } function f10(x: Yes): Yes { switch (x) { case Choice.Unknown: return x; case Choice.Yes: return x; case Choice.No: return x; } return x; } function f11(x: YesNo): YesNo { switch (x) { case Choice.Unknown: return x; case Choice.Yes: return x; case Choice.No: return x; } return x; } function f12(x: UnknownYesNo): UnknownYesNo { switch (x) { case Choice.Unknown: return x; case Choice.Yes: return x; case Choice.No: return x; } return x; } function f13(x: Choice): Choice { switch (x) { case Choice.Unknown: return x; case Choice.Yes: return x; case Choice.No: return x; } return x; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/enumMergeWithExpando.ts
TypeScript
// @noEmit: true // @allowJs: true // @checkJs: true // @Filename: lovefield-ts.d.ts // bug #27352, crashes from github.com/google/lovefield declare namespace lf { export enum Order { ASC, DESC } } // @Filename: enums.js lf.Order = {} lf.Order.DESC = 0; lf.Order.ASC = 1;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/enumMerging.ts
TypeScript
// Enum with only constant members across 2 declarations with the same root module // Enum with initializer in all declarations with constant members with the same root module module M1 { enum EImpl1 { A, B, C } enum EImpl1 { D = 1, E, F } export enum EConst1 { A = 3, B = 2, C = 1 } export enum EConst1 { D = 7, E = 9, F = 8 } var x = [EConst1.A, EConst1.B, EConst1.C, EConst1.D, EConst1.E, EConst1.F]; } // Enum with only computed members across 2 declarations with the same root module module M2 { export enum EComp2 { A = 'foo'.length, B = 'foo'.length, C = 'foo'.length } export enum EComp2 { D = 'foo'.length, E = 'foo'.length, F = 'foo'.length } var x = [EComp2.A, EComp2.B, EComp2.C, EComp2.D, EComp2.E, EComp2.F]; } // Enum with initializer in only one of two declarations with constant members with the same root module module M3 { enum EInit { A, B } enum EInit { C = 1, D, E } } // Enums with same name but different root module module M4 { export enum Color { Red, Green, Blue } } module M5 { export enum Color { Red, Green, Blue } } module M6.A { export enum Color { Red, Green, Blue } } module M6 { export module A { export enum Color { Yellow = 1 } } var t = A.Color.Yellow; t = A.Color.Red; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/enumMergingErrors.ts
TypeScript
// Enum with constant, computed, constant members split across 3 declarations with the same root module module M { export enum E1 { A = 0 } export enum E2 { C } export enum E3 { A = 0 } } module M { export enum E1 { B = 'foo'.length } export enum E2 { B = 'foo'.length } export enum E3 { C } } module M { export enum E1 { C } export enum E2 { A = 0 } export enum E3 { B = 'foo'.length } } // Enum with no initializer in either declaration with constant members with the same root module module M1 { export enum E1 { A = 0 } } module M1 { export enum E1 { B } } module M1 { export enum E1 { C } } // Enum with initializer in only one of three declarations with constant members with the same root module module M2 { export enum E1 { A } } module M2 { export enum E1 { B = 0 } } module M2 { export enum E1 { C } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/enumTag.ts
TypeScript
// @allowJs: true // @checkJs: true // @noEmit: true // @Filename: a.js /** @enum {string} */ const Target = { START: "start", MIDDLE: "middle", END: "end", MISTAKE: 1, /** @type {number} */ OK_I_GUESS: 2 } /** @enum number */ const Second = { MISTAKE: "end", OK: 1, /** @type {number} */ FINE: 2, } /** @enum {function(number): number} */ const Fs = { ADD1: n => n + 1, ID: n => n, SUB1: n => n - 1 } /** @param {Target} t * @param {Second} s * @param {Fs} f */ function consume(t,s,f) { /** @type {string} */ var str = t /** @type {number} */ var num = s /** @type {(n: number) => number} */ var fun = f /** @type {Target} */ var v = Target.START v = Target.UNKNOWN // error, can't find 'UNKNOWN' v = Second.MISTAKE // meh..ok, I guess? v = 'something else' // allowed, like Typescript's classic enums and unlike its string enums } /** @param {string} s */ function ff(s) { // element access with arbitrary string is an error only with noImplicitAny if (!Target[s]) { return null } else { return Target[s] } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/enumTagCircularReference.ts
TypeScript
// @noEmit: true // @allowJs: true // @checkJs: true // @Filename: bug27142.js /** @enum {E} */ const E = { x: 0 };
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/enumTagImported.ts
TypeScript
// @allowJs: true // @checkJs: true // @noEmit: true // @Filename: type.js /** @typedef {import("./mod1").TestEnum} TE */ /** @type {TE} */ const test = 'add' /** @type {import("./mod1").TestEnum} */ const tost = 'remove' // @Filename: value.js import { TestEnum } from "./mod1" /** @type {TestEnum} */ const tist = TestEnum.ADD // @Filename: mod1.js /** @enum {string} */ export const TestEnum = { ADD: 'add', REMOVE: 'remove' }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/enumTagOnExports.ts
TypeScript
// @filename: enumTagOnExports.js // @allowjs: true // @checkjs: true // @noemit: true /** @enum {number} */ exports.a = {}; /** @enum {string} */ module.exports.b = {};
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/enumTagOnExports2.ts
TypeScript
// @filename: enumTagOnExports.js // @allowjs: true // @checkjs: true // @noemit: true /** @enum {string} */ module.exports = {};
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/enumTagUseBeforeDefCrash.ts
TypeScript
// @noEmit: true // @allowJs: true // @checkJs: true // @Filename: bug27134.js /** * @enum {number} */ var foo = { }; /** * @type {foo} */ var s;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/enums.ts
TypeScript
// @Filename: /a.ts enum SyntaxKind { ImportClause, ExportDeclaration } const enum SymbolFlags { Type = "Type", Value = "Value" } export type { SyntaxKind }; export { SymbolFlags }; // @Filename: /b.ts import type { SyntaxKind, SymbolFlags } from './a'; SyntaxKind.ImportClause; SymbolFlags.Type; let kind: SyntaxKind.ImportClause; let flags: SymbolFlags; type TypeFlag = SymbolFlags.Type; export type { TypeFlag }; // @Filename: /c.ts import { SymbolFlags } from './a'; import type { TypeFlag } from './b'; const flags: TypeFlag = SymbolFlags.Type;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/equalityWithEnumTypes.ts
TypeScript
// @strict: true // Literal enum type enum E1 { a = 1, b = 2, } // Numeric enum type enum E2 { a = 1 << 0, b = 1 << 1 } function f1(v: E1) { if (v !== 0) { // Error v; } if (v !== 1) { v; } if (v !== 2) { v; } if (v !== 3) { // Error v; } } function f2(v: E2) { if (v !== 0) { v; } if (v !== 1) { v; } if (v !== 2) { v; } if (v !== 3) { v; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/equalityWithIntersectionTypes01.ts
TypeScript
interface I1 { p1: number } interface I2 extends I1 { p2: number; } interface I3 { p3: number; } var x = { p1: 10, p2: 20, p3: 30 }; var y: I1 & I3 = x; var z: I2 = x; if (y === z || z === y) { } else if (y !== z || z !== y) { } else if (y == z || z == y) { } else if (y != z || z != y) { }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/equalityWithUnionTypes01.ts
TypeScript
interface I1 { p1: number } interface I2 extends I1 { p2: number; } var x = { p1: 10, p2: 20 }; var y: number | I2 = x; var z: I1 = x; if (y === z || z === y) { } else if (y !== z || z !== y) { } else if (y == z || z == y) { } else if (y != z || z != y) { }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/equalityWithtNullishCoalescingAssignment.ts
TypeScript
// @strict: true, false function f1(a?: boolean): void { a ??= true; if (a === false) { console.log(a); } } f1(false); function f2() { let x: 0 | 1 | 2 | 3 = 0 as any; x ??= 1; if (x === 0) { console.log(x); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/errorIsolation.ts
TypeScript
// @noEmit: true // @checkJs: true // @filename: errorIsolation.js const async = { doSomething: _ => {} }; async.doSomething( /***/ () => {} );
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/errorOnFunctionReturnType.ts
TypeScript
// @noEmit: true // @allowJs: true // @checkJs: true // @Filename: foo.js /** * @callback FunctionReturningPromise * @returns {Promise<number>} */ /** @type {FunctionReturningPromise} */ function testPromise1() { console.log("Nope"); } /** @type {FunctionReturningPromise} */ async function testPromise2() { return "asd"; } var testPromise3 = /** @type {FunctionReturningPromise} */ function() { console.log("test") } /** @type {FunctionReturningPromise} */ var testPromise4 = function() { console.log("test") } /** * @callback FunctionReturningNever * @returns {never} */ /** @type {FunctionReturningNever} */ function testNever1() { } /** @type {FunctionReturningNever} */ async function testNever2() { return "asd"; } var testNever3 = /** @type {FunctionReturningNever} */ function() { console.log("test") } /** @type {FunctionReturningNever} */ var testNever4 = function() { console.log("test") }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/errorSuperCalls.ts
TypeScript
//super call in class constructor with no base type class NoBase { constructor() { super(); } //super call in class member function with no base type fn() { super(); } //super call in class accessor (get and set) with no base type get foo() { super(); return null; } set foo(v) { super(); } //super call in class member initializer with no base type p = super(); //super call in static class member function with no base type static fn() { super(); } //super call in static class member initializer with no base type static k = super(); //super call in static class accessor (get and set) with no base type static get q() { super(); return null; } static set q(n) { super(); } } class Base<T> { private n: T; } class Derived<T> extends Base<T> { //super call with type arguments constructor() { super<string>(); super(); } } class OtherBase { private n: string; } class OtherDerived extends OtherBase { //super call in class member initializer of derived type t = super(); fn() { //super call in class member function of derived type super(); } //super call in class accessor (get and set) of derived type get foo() { super(); return null; } set foo(n) { super(); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/errorSuperPropertyAccess.ts
TypeScript
//super property access in constructor of class with no base type //super property access in instance member function of class with no base type //super property access in instance member accessor(get and set) of class with no base type class NoBase { constructor() { var a = super.prototype; var b = super.hasOwnProperty(''); } fn() { var a = super.prototype; var b = super.hasOwnProperty(''); } m = super.prototype; n = super.hasOwnProperty(''); //super static property access in static member function of class with no base type //super static property access in static member accessor(get and set) of class with no base type public static static1() { super.hasOwnProperty(''); } public static get static2() { super.hasOwnProperty(''); return ''; } public static set static2(n) { super.hasOwnProperty(''); } } class SomeBase { private privateFunc() { } private privateMember = 0; public publicFunc() { } public publicMember = 0; private static privateStaticFunc() { } private static privateStaticMember = 0; public static publicStaticFunc() { } public static publicStaticMember = 0; } //super.publicInstanceMemberNotFunction in constructor of derived class //super.publicInstanceMemberNotFunction in instance member function of derived class //super.publicInstanceMemberNotFunction in instance member accessor(get and set) of derived class //super property access only available with typed this class SomeDerived1 extends SomeBase { constructor() { super(); super.publicMember = 1; } fn() { var x = super.publicMember; } get a() { var x = super.publicMember; return undefined; } set a(n) { n = super.publicMember; } fn2() { function inner() { super.publicFunc(); } var x = { test: function () { return super.publicFunc(); } } } } //super.privateProperty in constructor of derived class //super.privateProperty in instance member function of derived class //super.privateProperty in instance member accessor(get and set) of derived class class SomeDerived2 extends SomeBase { constructor() { super(); super.privateMember = 1; } fn() { var x = super.privateMember; } get a() { var x = super.privateMember; return undefined; } set a(n) { n = super.privateMember; } } //super.publicStaticMemberNotFunction in static member function of derived class //super.publicStaticMemberNotFunction in static member accessor(get and set) of derived class //super.privateStaticProperty in static member function of derived class //super.privateStaticProperty in static member accessor(get and set) of derived class class SomeDerived3 extends SomeBase { static fn() { super.publicStaticMember = 3; super.privateStaticMember = 3; super.privateStaticFunc(); } static get a() { super.publicStaticMember = 3; super.privateStaticMember = 3; super.privateStaticFunc(); return ''; } static set a(n) { super.publicStaticMember = 3; super.privateStaticMember = 3; super.privateStaticFunc(); } } // In object literal var obj = { n: super.wat, p: super.foo() };
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/es2016IntlAPIs.ts
TypeScript
// @target: es2016 // Sample from // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/getCanonicalLocales console.log(Intl.getCanonicalLocales('EN-US')); // Expected output: Array ["en-US"] console.log(Intl.getCanonicalLocales(['EN-US', 'Fr'])); // Expected output: Array ["en-US", "fr"] try { Intl.getCanonicalLocales('EN_US'); } catch (err) { console.log(err.toString()); // Expected output: RangeError: invalid language tag: EN_US }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/es2017DateAPIs.ts
TypeScript
// @lib: es2017 Date.UTC(2017);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/es2018IntlAPIs.ts
TypeScript
// @target: es2018 // Sample from // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/supportedLocalesOf const locales = ['ban', 'id-u-co-pinyin', 'de-ID']; const options = { localeMatcher: 'lookup' } as const; console.log(Intl.PluralRules.supportedLocalesOf(locales, options).join(', ')); const [ part ] = new Intl.NumberFormat().formatToParts(); console.log(part.type, part.value);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/es2020IntlAPIs.ts
TypeScript
// @target: es2020 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation const count = 26254.39; const date = new Date("2012-05-24"); function log(locale: string) { console.log( `${new Intl.DateTimeFormat(locale).format(date)} ${new Intl.NumberFormat(locale).format(count)}` ); } log("en-US"); // expected output: 5/24/2012 26,254.39 log("de-DE"); // expected output: 24.5.2012 26.254,39 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat const rtf1 = new Intl.RelativeTimeFormat('en', { style: 'narrow' }); console.log(rtf1.format(3, 'quarter')); //expected output: "in 3 qtrs." console.log(rtf1.format(-1, 'day')); //expected output: "1 day ago" const rtf2 = new Intl.RelativeTimeFormat('es', { numeric: 'auto' }); console.log(rtf2.format(2, 'day')); //expected output: "pasado mañana" // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames const regionNamesInEnglish = new Intl.DisplayNames(['en'], { type: 'region' }); const regionNamesInTraditionalChinese = new Intl.DisplayNames(['zh-Hant'], { type: 'region' }); console.log(regionNamesInEnglish.of('US')); // expected output: "United States" console.log(regionNamesInTraditionalChinese.of('US')); // expected output: "美國" const locales1 = ['ban', 'id-u-co-pinyin', 'de-ID']; const options1 = { localeMatcher: 'lookup' } as const; console.log(Intl.DisplayNames.supportedLocalesOf(locales1, options1).join(', ')); new Intl.Locale(); // should error new Intl.Locale(new Intl.Locale('en-US')); new Intl.DisplayNames(); // TypeError: invalid_argument new Intl.DisplayNames('en'); // TypeError: invalid_argument new Intl.DisplayNames('en', {}); // TypeError: invalid_argument console.log((new Intl.DisplayNames(undefined, {type: 'language'})).of('en-GB')); // "British English" const localesArg = ["es-ES", new Intl.Locale("en-US")]; console.log((new Intl.DisplayNames(localesArg, {type: 'language'})).resolvedOptions().locale); // "es-ES" console.log(Intl.DisplayNames.supportedLocalesOf(localesArg)); // ["es-ES", "en-US"] console.log(Intl.DisplayNames.supportedLocalesOf()); // [] console.log(Intl.DisplayNames.supportedLocalesOf(localesArg, {})); // ["es-ES", "en-US"]
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/es2021LocalesObjectArgument.ts
TypeScript
// @target: es2021 const enUS = new Intl.Locale("en-US"); const deDE = new Intl.Locale("de-DE"); const jaJP = new Intl.Locale("ja-JP"); new Intl.ListFormat(enUS); new Intl.ListFormat([deDE, jaJP]); Intl.ListFormat.supportedLocalesOf(enUS); Intl.ListFormat.supportedLocalesOf([deDE, jaJP]);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/es2022IntlAPIs.ts
TypeScript
// @target: es2022 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat#using_timezonename const timezoneNames = ['short', 'long', 'shortOffset', 'longOffset', 'shortGeneric', 'longGeneric'] as const; for (const zoneName of timezoneNames) { var formatter = new Intl.DateTimeFormat('en-US', { timeZone: 'America/Los_Angeles', timeZoneName: zoneName, }); } const enumerationKeys = ['calendar', 'collation', 'currency', 'numberingSystem', 'timeZone', 'unit'] as const; for (const key of enumerationKeys) { var supported = Intl.supportedValuesOf(key); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/es2022LocalesObjectArgument.ts
TypeScript
// @target: es2022 const enUS = new Intl.Locale("en-US"); const deDE = new Intl.Locale("de-DE"); const jaJP = new Intl.Locale("ja-JP"); new Intl.Segmenter(enUS); new Intl.Segmenter([deDE, jaJP]); Intl.Segmenter.supportedLocalesOf(enUS); Intl.Segmenter.supportedLocalesOf([deDE, jaJP]);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/es2022SharedMemory.ts
TypeScript
// @target: esnext // @lib: es2022 // @noemit: true // @strict: true const sab = new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 1024); const int32 = new Int32Array(sab); const sab64 = new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 1024); const int64 = new BigInt64Array(sab64); const waitValue = Atomics.wait(int32, 0, 0); const { async, value } = Atomics.waitAsync(int32, 0, 0); const { async: async64, value: value64 } = Atomics.waitAsync(int64, 0, BigInt(0)); const main = async () => { if (async) { await value; } if (async64) { await value64; } } main();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/es5DateAPIs.ts
TypeScript
// @lib: es5 Date.UTC(2017); // should error
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/es6modulekind.ts
TypeScript
// @target: ES6 // @sourcemap: false // @declaration: false // @module: es6 export default class A { constructor () { } public B() { return 42; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/es6modulekindExportClassNameWithObject.ts
TypeScript
// @target: ES5 // @module: es2015 export class Object {}
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/es6modulekindWithES2015Target.ts
TypeScript
// @target: es2015 // @sourcemap: false // @declaration: false // @module: es6 export default class A { constructor () { } public B() { return 42; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/es6modulekindWithES5Target.ts
TypeScript
// @target: es5 // @module: es2015 // @experimentalDecorators: true export class C { static s = 0; p = 1; method() { } } export { C as C2 }; declare function foo(...args: any[]): any; @foo export class D { static s = 0; p = 1; method() { } } export { D as D2 }; class E { } export {E};
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/es6modulekindWithES5Target10.ts
TypeScript
// @target: es5 // @module: es2015 import i = require("mod"); // Error; namespace N { } export = N; // Error
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/es6modulekindWithES5Target11.ts
TypeScript
// @target: es5 // @module: es2015 // @experimentalDecorators: true declare function foo(...args: any[]): any; @foo export default class C { static x() { return C.y; } static y = 1 p = 1; method() { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/es6modulekindWithES5Target12.ts
TypeScript
// @target: es5 // @module: es2015 export class C { } export namespace C { export const x = 1; } export enum E { w = 1 } export enum E { x = 2 } export namespace E { export const y = 1; } export namespace E { export const z = 1; } export namespace N { } export namespace N { export const x = 1; } export function F() { } export namespace F { export const x = 1; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/es6modulekindWithES5Target2.ts
TypeScript
// @target: es5 // @module: es2015 export default class C { static s = 0; p = 1; method() { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/es6modulekindWithES5Target3.ts
TypeScript
// @target: es5 // @module: es2015 // @experimentalDecorators: true declare function foo(...args: any[]): any; @foo export default class D { static s = 0; p = 1; method() { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University