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/symbolProperty4.ts
TypeScript
//@target: ES6 var x = { [Symbol()]: 0, [Symbol()]() { }, get [Symbol()]() { return 0; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty40.ts
TypeScript
//@target: ES6 class C { [Symbol.iterator](x: string): string; [Symbol.iterator](x: number): number; [Symbol.iterator](x: any) { return undefined; } } var c = new C; c[Symbol.iterator](""); c[Symbol.iterator](0);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty41.ts
TypeScript
//@target: ES6 class C { [Symbol.iterator](x: string): { x: string }; [Symbol.iterator](x: "hello"): { x: string; hello: string }; [Symbol.iterator](x: any) { return undefined; } } var c = new C; c[Symbol.iterator](""); c[Symbol.iterator]("hello");
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty42.ts
TypeScript
//@target: ES6 class C { [Symbol.iterator](x: string): string; static [Symbol.iterator](x: number): number; [Symbol.iterator](x: any) { return undefined; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty43.ts
TypeScript
//@target: ES6 class C { [Symbol.iterator](x: string): string; [Symbol.iterator](x: number): number; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty44.ts
TypeScript
//@target: ES6 class C { get [Symbol.hasInstance]() { return ""; } get [Symbol.hasInstance]() { return ""; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty45.ts
TypeScript
//@target: ES6 class C { get [Symbol.hasInstance]() { return ""; } get [Symbol.toPrimitive]() { return ""; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty46.ts
TypeScript
//@target: ES6 class C { get [Symbol.hasInstance]() { return ""; } // Should take a string set [Symbol.hasInstance](x) { } } (new C)[Symbol.hasInstance] = 0; (new C)[Symbol.hasInstance] = "";
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty47.ts
TypeScript
//@target: ES6 class C { get [Symbol.hasInstance]() { return ""; } // Should take a string set [Symbol.hasInstance](x: number) { } } (new C)[Symbol.hasInstance] = 0; (new C)[Symbol.hasInstance] = "";
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty48.ts
TypeScript
//@target: ES6 module M { var Symbol; class C { [Symbol.iterator]() { } } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty49.ts
TypeScript
//@target: ES6 module M { export var Symbol; class C { [Symbol.iterator]() { } } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty5.ts
TypeScript
//@target: ES6 var x = { [Symbol.iterator]: 0, [Symbol.toPrimitive]() { }, get [Symbol.toStringTag]() { return 0; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty50.ts
TypeScript
//@target: ES6 module M { interface Symbol { } class C { [Symbol.iterator]() { } } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty51.ts
TypeScript
//@target: ES6 module M { module Symbol { } class C { [Symbol.iterator]() { } } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty52.ts
TypeScript
//@target: ES6 var obj = { [Symbol.nonsense]: 0 }; obj = {}; obj[Symbol.nonsense];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty53.ts
TypeScript
//@target: ES6 var obj = { [Symbol.for]: 0 }; obj[Symbol.for];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty54.ts
TypeScript
//@target: ES6 var obj = { [Symbol.prototype]: 0 };
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty55.ts
TypeScript
//@target: ES6 var obj = { [Symbol.iterator]: 0 }; module M { var Symbol: SymbolConstructor; // The following should be of type 'any'. This is because even though obj has a property keyed by Symbol.iterator, // the key passed in here is the *wrong* Symbol.iterator. It is not the iterator property of the global Symbol. obj[Symbol.iterator]; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty56.ts
TypeScript
//@target: ES6 var obj = { [Symbol.iterator]: 0 }; module M { var Symbol: {}; // The following should be of type 'any'. This is because even though obj has a property keyed by Symbol.iterator, // the key passed in here is the *wrong* Symbol.iterator. It is not the iterator property of the global Symbol. obj[Symbol["iterator"]]; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty57.ts
TypeScript
//@target: ES6 var obj = { [Symbol.iterator]: 0 }; // Should give type 'any'. obj[Symbol["nonsense"]];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty58.ts
TypeScript
//@target: ES6 interface SymbolConstructor { foo: string; } var obj = { [Symbol.foo]: 0 }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty6.ts
TypeScript
//@target: ES6 class C { [Symbol.iterator] = 0; [Symbol.unscopables]: number; [Symbol.toPrimitive]() { } get [Symbol.toStringTag]() { return 0; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty60.ts
TypeScript
// @target: es2015 // https://github.com/Microsoft/TypeScript/issues/20146 interface I1 { [Symbol.toStringTag]: string; [key: string]: number; } interface I2 { [Symbol.toStringTag]: string; [key: number]: boolean; } declare const mySymbol: unique symbol; interface I3 { [mySymbol]: string; [key: string]: number; } interface I4 { [mySymbol]: string; [key: number]: boolean; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty61.ts
TypeScript
// @target: ES6 // @declaration: true declare global { interface SymbolConstructor { readonly obs: symbol } } const observable: typeof Symbol.obs = Symbol.obs export class MyObservable<T> { constructor(private _val: T) {} subscribe(next: (val: T) => void) { next(this._val) } [observable]() { return this } } type InteropObservable<T> = { [Symbol.obs]: () => { subscribe(next: (val: T) => void): void } } function from<T>(obs: InteropObservable<T>) { return obs[Symbol.obs]() } from(new MyObservable(42))
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty8.ts
TypeScript
//@target: ES6 interface I { [Symbol.unscopables]: number; [Symbol.toPrimitive](); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolProperty9.ts
TypeScript
//@target: ES6 class C { [Symbol.iterator]: { x; y }; } interface I { [Symbol.iterator]: { x }; } var i: I; i = new C; var c: C = i;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolType1.ts
TypeScript
//@target: ES6 Symbol() instanceof Symbol; Symbol instanceof Symbol(); (Symbol() || {}) instanceof Object; // This one should be okay, it's a valid way of distinguishing types Symbol instanceof (Symbol() || {});
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolType10.ts
TypeScript
//@target: ES6 var s = Symbol.for("bitwise"); s & s; s | s; s ^ s; s & 0; 0 | s;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolType11.ts
TypeScript
//@target: ES6 var s = Symbol.for("logical"); s && s; s && []; 0 && s; s || s; s || 1; ({}) || s;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolType12.ts
TypeScript
//@target: ES6 var s = Symbol.for("assign"); var str = ""; s *= s; s *= 0; s /= s; s /= 0; s %= s; s %= 0; s += s; s += 0; s += ""; str += s; s -= s; s -= 0; s <<= s; s <<= 0; s >>= s; s >>= 0; s >>>= s; s >>>= 0; s &= s; s &= 0; s ^= s; s ^= 0; s |= s; s |= 0; str += (s || str);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolType13.ts
TypeScript
//@target: ES6 var s = Symbol(); var x: any; for (s in {}) { } for (x in s) { } for (var y in s) { }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolType14.ts
TypeScript
//@target: ES6 new Symbol();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolType15.ts
TypeScript
//@target: ES6 var sym: symbol; var symObj: Symbol; symObj = sym; sym = symObj;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolType16.ts
TypeScript
//@target: ES6 interface Symbol { newSymbolProp: number; } var sym: symbol; sym.newSymbolProp;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolType17.ts
TypeScript
//@target: ES6 interface Foo { prop } var x: symbol | Foo; x; if (typeof x === "symbol") { x; } else { x; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolType18.ts
TypeScript
//@target: ES6 interface Foo { prop } var x: symbol | Foo; x; if (typeof x === "object") { x; } else { x; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolType19.ts
TypeScript
//@target: ES6 enum E { } var x: symbol | E; x; if (typeof x === "number") { x; } else { x; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolType2.ts
TypeScript
//@target: ES6 Symbol.isConcatSpreadable in {}; "" in Symbol.toPrimitive;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolType20.ts
TypeScript
//@target: ES6 interface symbol { }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolType3.ts
TypeScript
//@target: ES6 var s = Symbol(); delete Symbol.iterator; void Symbol.toPrimitive; typeof Symbol.toStringTag; ++s; --s; + Symbol(); - Symbol(); ~ Symbol(); ! Symbol(); +(Symbol() || 0);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolType4.ts
TypeScript
//@target: ES6 var s = Symbol.for("postfix"); s++; s--;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolType5.ts
TypeScript
//@target: ES6 var s = Symbol.for("multiply"); s * s; s / s; s % s; s * 0; 0 / s;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolType6.ts
TypeScript
//@target: ES6 var s = Symbol.for("add"); var a: any; s + s; s - s; s + ""; s + a; s + 0; "" + s; a + s; 0 + s; s - 0; 0 - s; (s || "") + ""; "" + (s || "");
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolType7.ts
TypeScript
//@target: ES6 var s = Symbol.for("shift"); s << s; s << 0; s >> s; s >> 0; s >>> s; s >>> 0;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolType8.ts
TypeScript
//@target: ES6 var s = Symbol.for("compare"); s < s; s < 0; s > s; s > 0; s <= s; s <= 0; s >= s; s >= 0; 0 >= (s || 0); (s || 0) >= s;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/symbolType9.ts
TypeScript
//@target: ES6 var s = Symbol.for("equal"); s == s; s == true; s != s; 0 != s; s === s; s === 1; s !== s; false !== s;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/syntaxErrors.ts
TypeScript
// @checkJs: true // @allowJs: true // @noEmit: true // @Filename: dummyType.d.ts declare class C<T> { t: T } // @Filename: badTypeArguments.js /** @param {C.<>} x */ /** @param {C.<number,>} y */ // @ts-ignore /** @param {C.<number,>} skipped */ function f(x, y, skipped) { return x.t + y.t; } var x = f({ t: 1000 }, { t: 3000 }, { t: 5000 });
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/taggedTemplateContextualTyping1.ts
TypeScript
// @target: ES6 type FuncType = (x: <T>(p: T) => T) => typeof x; function tempTag1<T>(templateStrs: TemplateStringsArray, f: FuncType, x: T): T; function tempTag1<T>(templateStrs: TemplateStringsArray, f: FuncType, h: FuncType, x: T): T; function tempTag1<T>(...rest: any[]): T { return undefined; } // If contextual typing takes place, these functions should work. // Otherwise, the arrow functions' parameters will be typed as 'any', // and it is an error to invoke an any-typed value with type arguments, // so this test will error. tempTag1 `${ x => { x<number>(undefined); return x; } }${ 10 }`; tempTag1 `${ x => { x<number>(undefined); return x; } }${ y => { y<number>(undefined); return y; } }${ 10 }`; tempTag1 `${ x => { x<number>(undefined); return x; } }${ (y: <T>(p: T) => T) => { y<number>(undefined); return y } }${ undefined }`; tempTag1 `${ (x: <T>(p: T) => T) => { x<number>(undefined); return x; } }${ y => { y<number>(undefined); return y; } }${ undefined }`;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/taggedTemplateContextualTyping2.ts
TypeScript
// @target: ES6 type FuncType1 = (x: <T>(p: T) => T) => typeof x; type FuncType2 = (x: <S, T>(p: T) => T) => typeof x; function tempTag2(templateStrs: TemplateStringsArray, f: FuncType1, x: number): number; function tempTag2(templateStrs: TemplateStringsArray, f: FuncType2, h: FuncType2, x: string): string; function tempTag2(...rest: any[]): any { return undefined; } // If contextual typing takes place, these functions should work. // Otherwise, the arrow functions' parameters will be typed as 'any', // and it is an error to invoke an any-typed value with type arguments, // so this test will error. tempTag2 `${ x => { x<number>(undefined); return x; } }${ 0 }`; tempTag2 `${ x => { x<number, string>(undefined); return x; } }${ y => { y<string, number>(null); return y; } }${ "hello" }`; tempTag2 `${ x => { x<number, string>(undefined); return x; } }${ undefined }${ "hello" }`;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes01.ts
TypeScript
 function f(...x: any[]) { } f `0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2028 2029 0085 t v f b r n`
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes01_ES6.ts
TypeScript
// @target: es6 function f(...x: any[]) { } f `0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2028 2029 0085 t v f b r n`
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes02.ts
TypeScript
 `0${ " " }1${ " " }2${ " " }3${ " " }4${ " " }5${ " " }6${ " " }7${ " " }8${ " " }9${ " " }10${ " " }11${ " " }12${ " " }13${ " " }14${ " " }15${ " " }16${ " " }17${ " " }18${ " " }19${ " " }20${ " " }2028${ " " }2029${ " " }0085${ " " }t${ " " }v${ " " }f${ " " }b${ " " }r${ " " }n`
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes02_ES6.ts
TypeScript
// @target: es6 function f(...x: any[]) { } f `0${ " " }1${ " " }2${ " " }3${ " " }4${ " " }5${ " " }6${ " " }7${ " " }8${ " " }9${ " " }10${ " " }11${ " " }12${ " " }13${ " " }14${ " " }15${ " " }16${ " " }17${ " " }18${ " " }19${ " " }20${ " " }2028${ " " }2029${ " " }0085${ " " }t${ " " }v${ " " }f${ " " }b${ " " }r${ " " }n`
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/taggedTemplateStringsTypeArgumentInference.ts
TypeScript
 // Generic tag with one parameter function noParams<T>(n: T) { } noParams ``; // Generic tag with parameter which does not use type parameter function noGenericParams<T>(n: TemplateStringsArray) { } noGenericParams ``; // Generic tag with multiple type parameters and only one used in parameter type annotation function someGenerics1a<T, U>(n: T, m: number) { } someGenerics1a `${3}`; function someGenerics1b<T, U>(n: TemplateStringsArray, m: U) { } someGenerics1b `${3}`; // Generic tag with argument of function type whose parameter is of type parameter type function someGenerics2a<T>(strs: TemplateStringsArray, n: (x: T) => void) { } someGenerics2a `${(n: string) => n}`; function someGenerics2b<T, U>(strs: TemplateStringsArray, n: (x: T, y: U) => void) { } someGenerics2b `${ (n: string, x: number) => n }`; // Generic tag with argument of function type whose parameter is not of type parameter type but body/return type uses type parameter function someGenerics3<T>(strs: TemplateStringsArray, producer: () => T) { } someGenerics3 `${() => ''}`; someGenerics3 `${() => undefined}`; someGenerics3 `${() => 3}`; // 2 parameter generic tag with argument 1 of type parameter type and argument 2 of function type whose parameter is of type parameter type function someGenerics4<T, U>(strs: TemplateStringsArray, n: T, f: (x: U) => void) { } someGenerics4 `${4}${ () => null }`; someGenerics4 `${''}${ () => 3 }`; someGenerics4 `${ null }${ null }`; // 2 parameter generic tag with argument 2 of type parameter type and argument 1 of function type whose parameter is of type parameter type function someGenerics5<U, T>(strs: TemplateStringsArray, n: T, f: (x: U) => void) { } someGenerics5 `${ 4 } ${ () => null }`; someGenerics5 `${ '' }${ () => 3 }`; someGenerics5 `${null}${null}`; // Generic tag with multiple arguments of function types that each have parameters of the same generic type function someGenerics6<A>(strs: TemplateStringsArray, a: (a: A) => A, b: (b: A) => A, c: (c: A) => A) { } someGenerics6 `${ n => n }${ n => n}${ n => n}`; someGenerics6 `${ n => n }${ n => n}${ n => n}`; someGenerics6 `${ (n: number) => n }${ (n: number) => n }${ (n: number) => n }`; // Generic tag with multiple arguments of function types that each have parameters of different generic type function someGenerics7<A, B, C>(strs: TemplateStringsArray, a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) { } someGenerics7 `${ n => n }${ n => n }${ n => n }`; someGenerics7 `${ n => n }${ n => n }${ n => n }`; someGenerics7 `${(n: number) => n}${ (n: string) => n}${ (n: number) => n}`; // Generic tag with argument of generic function type function someGenerics8<T>(strs: TemplateStringsArray, n: T): T { return n; } var x = someGenerics8 `${ someGenerics7 }`; x `${null}${null}${null}`; // Generic tag with multiple parameters of generic type passed arguments with no best common type function someGenerics9<T>(strs: TemplateStringsArray, a: T, b: T, c: T): T { return null; } var a9a = someGenerics9 `${ '' }${ 0 }${ [] }`; var a9a: {}; // Generic tag with multiple parameters of generic type passed arguments with multiple best common types interface A91 { x: number; y?: string; } interface A92 { x: number; z?: Date; } var a9e = someGenerics9 `${ undefined }${ { x: 6, z: new Date() } }${ { x: 6, y: '' } }`; var a9e: {}; // Generic tag with multiple parameters of generic type passed arguments with a single best common type var a9d = someGenerics9 `${ { x: 3 }}${ { x: 6 }}${ { x: 6 } }`; var a9d: { x: number; }; // Generic tag with multiple parameters of generic type where one argument is of type 'any' var anyVar: any; var a = someGenerics9 `${ 7 }${ anyVar }${ 4 }`; var a: any; // Generic tag with multiple parameters of generic type where one argument is [] and the other is not 'any' var arr = someGenerics9 `${ [] }${ null }${ undefined }`; var arr: any[];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/taggedTemplateStringsTypeArgumentInferenceES6.ts
TypeScript
//@target: es6 // Generic tag with one parameter function noParams<T>(n: T) { } noParams ``; // Generic tag with parameter which does not use type parameter function noGenericParams<T>(n: TemplateStringsArray) { } noGenericParams ``; // Generic tag with multiple type parameters and only one used in parameter type annotation function someGenerics1a<T, U>(n: T, m: number) { } someGenerics1a `${3}`; function someGenerics1b<T, U>(n: TemplateStringsArray, m: U) { } someGenerics1b `${3}`; // Generic tag with argument of function type whose parameter is of type parameter type function someGenerics2a<T>(strs: TemplateStringsArray, n: (x: T) => void) { } someGenerics2a `${(n: string) => n}`; function someGenerics2b<T, U>(strs: TemplateStringsArray, n: (x: T, y: U) => void) { } someGenerics2b `${ (n: string, x: number) => n }`; // Generic tag with argument of function type whose parameter is not of type parameter type but body/return type uses type parameter function someGenerics3<T>(strs: TemplateStringsArray, producer: () => T) { } someGenerics3 `${() => ''}`; someGenerics3 `${() => undefined}`; someGenerics3 `${() => 3}`; // 2 parameter generic tag with argument 1 of type parameter type and argument 2 of function type whose parameter is of type parameter type function someGenerics4<T, U>(strs: TemplateStringsArray, n: T, f: (x: U) => void) { } someGenerics4 `${4}${ () => null }`; someGenerics4 `${''}${ () => 3 }`; someGenerics4 `${ null }${ null }`; // 2 parameter generic tag with argument 2 of type parameter type and argument 1 of function type whose parameter is of type parameter type function someGenerics5<U, T>(strs: TemplateStringsArray, n: T, f: (x: U) => void) { } someGenerics5 `${ 4 } ${ () => null }`; someGenerics5 `${ '' }${ () => 3 }`; someGenerics5 `${null}${null}`; // Generic tag with multiple arguments of function types that each have parameters of the same generic type function someGenerics6<A>(strs: TemplateStringsArray, a: (a: A) => A, b: (b: A) => A, c: (c: A) => A) { } someGenerics6 `${ n => n }${ n => n}${ n => n}`; someGenerics6 `${ n => n }${ n => n}${ n => n}`; someGenerics6 `${ (n: number) => n }${ (n: number) => n }${ (n: number) => n }`; // Generic tag with multiple arguments of function types that each have parameters of different generic type function someGenerics7<A, B, C>(strs: TemplateStringsArray, a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) { } someGenerics7 `${ n => n }${ n => n }${ n => n }`; someGenerics7 `${ n => n }${ n => n }${ n => n }`; someGenerics7 `${(n: number) => n}${ (n: string) => n}${ (n: number) => n}`; // Generic tag with argument of generic function type function someGenerics8<T>(strs: TemplateStringsArray, n: T): T { return n; } var x = someGenerics8 `${ someGenerics7 }`; x `${null}${null}${null}`; // Generic tag with multiple parameters of generic type passed arguments with no best common type function someGenerics9<T>(strs: TemplateStringsArray, a: T, b: T, c: T): T { return null; } var a9a = someGenerics9 `${ '' }${ 0 }${ [] }`; var a9a: {}; // Generic tag with multiple parameters of generic type passed arguments with multiple best common types interface A91 { x: number; y?: string; } interface A92 { x: number; z?: Date; } var a9e = someGenerics9 `${ undefined }${ { x: 6, z: new Date() } }${ { x: 6, y: '' } }`; var a9e: {}; // Generic tag with multiple parameters of generic type passed arguments with a single best common type var a9d = someGenerics9 `${ { x: 3 }}${ { x: 6 }}${ { x: 6 } }`; var a9d: { x: number; }; // Generic tag with multiple parameters of generic type where one argument is of type 'any' var anyVar: any; var a = someGenerics9 `${ 7 }${ anyVar }${ 4 }`; var a: any; // Generic tag with multiple parameters of generic type where one argument is [] and the other is not 'any' var arr = someGenerics9 `${ [] }${ null }${ undefined }`; var arr: any[];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/taggedTemplateStringsWithIncompatibleTypedTags.ts
TypeScript
interface I { (stringParts: TemplateStringsArray, ...rest: boolean[]): I; g: I; h: I; member: I; thisIsNotATag(x: string): void [x: number]: I; } var f: I; f `abc` f `abc${1}def${2}ghi`; f `abc`.member f `abc${1}def${2}ghi`.member; f `abc`["member"]; f `abc${1}def${2}ghi`["member"]; f `abc`[0].member `abc${1}def${2}ghi`; f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`; f `abc${ true }def${ true }ghi`["member"].member `abc${ 1 }def${ 2 }ghi`; f.thisIsNotATag(`abc`); f.thisIsNotATag(`abc${1}def${2}ghi`);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts
TypeScript
// @target: ES6 interface I { (stringParts: TemplateStringsArray, ...rest: boolean[]): I; g: I; h: I; member: I; thisIsNotATag(x: string): void [x: number]: I; } var f: I; f `abc` f `abc${1}def${2}ghi`; f `abc`.member f `abc${1}def${2}ghi`.member; f `abc`["member"]; f `abc${1}def${2}ghi`["member"]; f `abc`[0].member `abc${1}def${2}ghi`; f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`; f `abc${ true }def${ true }ghi`["member"].member `abc${ 1 }def${ 2 }ghi`; f.thisIsNotATag(`abc`); f.thisIsNotATag(`abc${1}def${2}ghi`);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/taggedTemplateStringsWithManyCallAndMemberExpressions.ts
TypeScript
interface I { (strs: TemplateStringsArray, ...subs: number[]): I; member: { new (s: string): { new (n: number): { new (): boolean; } } }; } var f: I; var x = new new new f `abc${ 0 }def`.member("hello")(42) === true;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/taggedTemplateStringsWithManyCallAndMemberExpressionsES6.ts
TypeScript
// @target: ES6 interface I { (strs: TemplateStringsArray, ...subs: number[]): I; member: { new (s: string): { new (n: number): { new (): boolean; } } }; } var f: I; var x = new new new f `abc${ 0 }def`.member("hello")(42) === true;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/taggedTemplateStringsWithOverloadResolution1.ts
TypeScript
function foo(strs: TemplateStringsArray): number; function foo(strs: TemplateStringsArray, x: number): string; function foo(strs: TemplateStringsArray, x: number, y: number): boolean; function foo(strs: TemplateStringsArray, x: number, y: string): {}; function foo(...stuff: any[]): any { return undefined; } var a = foo([]); // number var b = foo([], 1); // string var c = foo([], 1, 2); // boolean var d = foo([], 1, true); // boolean (with error) var e = foo([], 1, "2"); // {} var f = foo([], 1, 2, 3); // any (with error) var u = foo ``; // number var v = foo `${1}`; // string var w = foo `${1}${2}`; // boolean var x = foo `${1}${true}`; // boolean (with error) var y = foo `${1}${"2"}`; // {} var z = foo `${1}${2}${3}`; // any (with error)
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/taggedTemplateStringsWithOverloadResolution1_ES6.ts
TypeScript
//@target: es6 function foo(strs: TemplateStringsArray): number; function foo(strs: TemplateStringsArray, x: number): string; function foo(strs: TemplateStringsArray, x: number, y: number): boolean; function foo(strs: TemplateStringsArray, x: number, y: string): {}; function foo(...stuff: any[]): any { return undefined; } var a = foo([]); // number var b = foo([], 1); // string var c = foo([], 1, 2); // boolean var d = foo([], 1, true); // boolean (with error) var e = foo([], 1, "2"); // {} var f = foo([], 1, 2, 3); // any (with error) var u = foo ``; // number var v = foo `${1}`; // string var w = foo `${1}${2}`; // boolean var x = foo `${1}${true}`; // boolean (with error) var y = foo `${1}${"2"}`; // {} var z = foo `${1}${2}${3}`; // any (with error)
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/taggedTemplateStringsWithOverloadResolution2.ts
TypeScript
 function foo1(strs: TemplateStringsArray, x: number): string; function foo1(strs: string[], x: number): number; function foo1(...stuff: any[]): any { return undefined; } var a = foo1 `${1}`; var b = foo1([], 1); function foo2(strs: string[], x: number): number; function foo2(strs: TemplateStringsArray, x: number): string; function foo2(...stuff: any[]): any { return undefined; } var c = foo2 `${1}`; var d = foo2([], 1);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/taggedTemplateStringsWithOverloadResolution2_ES6.ts
TypeScript
//@target: es6 function foo1(strs: TemplateStringsArray, x: number): string; function foo1(strs: string[], x: number): number; function foo1(...stuff: any[]): any { return undefined; } var a = foo1 `${1}`; var b = foo1([], 1); function foo2(strs: string[], x: number): number; function foo2(strs: TemplateStringsArray, x: number): string; function foo2(...stuff: any[]): any { return undefined; } var c = foo2 `${1}`; var d = foo2([], 1);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/taggedTemplateStringsWithOverloadResolution3.ts
TypeScript
 // Ambiguous call picks the first overload in declaration order function fn1(strs: TemplateStringsArray, s: string): string; function fn1(strs: TemplateStringsArray, n: number): number; function fn1() { return null; } var s: string = fn1 `${ undefined }`; // No candidate overloads found fn1 `${ {} }`; // Error function fn2(strs: TemplateStringsArray, s: string, n: number): number; function fn2<T>(strs: TemplateStringsArray, n: number, t: T): T; function fn2() { return undefined; } var d1: Date = fn2 `${ 0 }${ undefined }`; // contextually typed var d2 = fn2 `${ 0 }${ undefined }`; // any d1.foo(); // error d2(); // no error (typed as any) // Generic and non-generic overload where generic overload is the only candidate fn2 `${ 0 }${ '' }`; // OK // Generic and non-generic overload where non-generic overload is the only candidate fn2 `${ '' }${ 0 }`; // OK // Generic overloads with differing arity function fn3<T>(strs: TemplateStringsArray, n: T): string; function fn3<T, U>(strs: TemplateStringsArray, s: string, t: T, u: U): U; function fn3<T, U, V>(strs: TemplateStringsArray, v: V, u: U, t: T): number; function fn3() { return null; } var s = fn3 `${ 3 }`; var s = fn3 `${'' }${ 3 }${ '' }`; var n = fn3 `${ 5 }${ 5 }${ 5 }`; var n: number; // Generic overloads with differing arity tagging with arguments matching each overload type parameter count var s = fn3 `${ 4 }` var s = fn3 `${ '' }${ '' }${ '' }`; var n = fn3 `${ '' }${ '' }${ 3 }`; // Generic overloads with differing arity tagging with argument count that doesn't match any overload fn3 ``; // Error // Generic overloads with constraints function fn4<T extends string, U extends number>(strs: TemplateStringsArray, n: T, m: U); function fn4<T extends number, U extends string>(strs: TemplateStringsArray, n: T, m: U); function fn4(strs: TemplateStringsArray) function fn4() { } // Generic overloads with constraints tagged with types that satisfy the constraints fn4 `${ '' }${ 3 }`; fn4 `${ 3 }${ '' }`; fn4 `${ 3 }${ undefined }`; fn4 `${ '' }${ null }`; // Generic overloads with constraints called with type arguments that do not satisfy the constraints fn4 `${ null }${ null }`; // Error // Generic overloads with constraints called without type arguments but with types that do not satisfy the constraints fn4 `${ true }${ null }`; fn4 `${ null }${ true }`; // Non - generic overloads where contextual typing of function arguments has errors function fn5(strs: TemplateStringsArray, f: (n: string) => void): string; function fn5(strs: TemplateStringsArray, f: (n: number) => void): number; function fn5() { return undefined; } fn5 `${ (n) => n.toFixed() }`; // will error; 'n' should have type 'string'. fn5 `${ (n) => n.substr(0) }`;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/taggedTemplateStringsWithOverloadResolution3_ES6.ts
TypeScript
//@target: es6 // Ambiguous call picks the first overload in declaration order function fn1(strs: TemplateStringsArray, s: string): string; function fn1(strs: TemplateStringsArray, n: number): number; function fn1() { return null; } var s: string = fn1 `${ undefined }`; // No candidate overloads found fn1 `${ {} }`; // Error function fn2(strs: TemplateStringsArray, s: string, n: number): number; function fn2<T>(strs: TemplateStringsArray, n: number, t: T): T; function fn2() { return undefined; } var d1: Date = fn2 `${ 0 }${ undefined }`; // contextually typed var d2 = fn2 `${ 0 }${ undefined }`; // any d1.foo(); // error d2(); // no error (typed as any) // Generic and non-generic overload where generic overload is the only candidate fn2 `${ 0 }${ '' }`; // OK // Generic and non-generic overload where non-generic overload is the only candidate fn2 `${ '' }${ 0 }`; // OK // Generic overloads with differing arity function fn3<T>(strs: TemplateStringsArray, n: T): string; function fn3<T, U>(strs: TemplateStringsArray, s: string, t: T, u: U): U; function fn3<T, U, V>(strs: TemplateStringsArray, v: V, u: U, t: T): number; function fn3() { return null; } var s = fn3 `${ 3 }`; var s = fn3 `${'' }${ 3 }${ '' }`; var n = fn3 `${ 5 }${ 5 }${ 5 }`; var n: number; // Generic overloads with differing arity tagging with arguments matching each overload type parameter count var s = fn3 `${ 4 }` var s = fn3 `${ '' }${ '' }${ '' }`; var n = fn3 `${ '' }${ '' }${ 3 }`; // Generic overloads with differing arity tagging with argument count that doesn't match any overload fn3 ``; // Error // Generic overloads with constraints function fn4<T extends string, U extends number>(strs: TemplateStringsArray, n: T, m: U); function fn4<T extends number, U extends string>(strs: TemplateStringsArray, n: T, m: U); function fn4(strs: TemplateStringsArray) function fn4() { } // Generic overloads with constraints tagged with types that satisfy the constraints fn4 `${ '' }${ 3 }`; fn4 `${ 3 }${ '' }`; fn4 `${ 3 }${ undefined }`; fn4 `${ '' }${ null }`; // Generic overloads with constraints called with type arguments that do not satisfy the constraints fn4 `${ null }${ null }`; // Error // Generic overloads with constraints called without type arguments but with types that do not satisfy the constraints fn4 `${ true }${ null }`; fn4 `${ null }${ true }`; // Non - generic overloads where contextual typing of function arguments has errors function fn5(strs: TemplateStringsArray, f: (n: string) => void): string; function fn5(strs: TemplateStringsArray, f: (n: number) => void): number; function fn5() { return undefined; } fn5 `${ (n) => n.toFixed() }`; // will error; 'n' should have type 'string'. fn5 `${ (n) => n.substr(0) }`;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/taggedTemplateStringsWithTagNamedDeclare.ts
TypeScript
 function declare(x: any, ...ys: any[]) { } declare `Hello ${0} world!`;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/taggedTemplateStringsWithTagNamedDeclareES6.ts
TypeScript
//@target: es6 function declare(x: any, ...ys: any[]) { } declare `Hello ${0} world!`;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/taggedTemplateStringsWithTagsTypedAsAny.ts
TypeScript
var f: any; f `abc` f `abc${1}def${2}ghi`; f.g.h `abc` f.g.h `abc${1}def${2}ghi`; f `abc`.member f `abc${1}def${2}ghi`.member; f `abc`["member"]; f `abc${1}def${2}ghi`["member"]; f `abc`["member"].someOtherTag `abc${1}def${2}ghi`; f `abc${1}def${2}ghi`["member"].someOtherTag `abc${1}def${2}ghi`; f.thisIsNotATag(`abc`); f.thisIsNotATag(`abc${1}def${2}ghi`);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/taggedTemplateStringsWithTagsTypedAsAnyES6.ts
TypeScript
// @target: ES6 var f: any; f `abc` f `abc${1}def${2}ghi`; f.g.h `abc` f.g.h `abc${1}def${2}ghi`; f `abc`.member f `abc${1}def${2}ghi`.member; f `abc`["member"]; f `abc${1}def${2}ghi`["member"]; f `abc`["member"].someOtherTag `abc${1}def${2}ghi`; f `abc${1}def${2}ghi`["member"].someOtherTag `abc${1}def${2}ghi`; f.thisIsNotATag(`abc`); f.thisIsNotATag(`abc${1}def${2}ghi`);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts
TypeScript
 function foo(...rest: any[]) { } foo `${function (x: number) { x = "bad"; } }`;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts
TypeScript
//@target: es6 function foo(...rest: any[]) { } foo `${function (x: number) { x = "bad"; } }`;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/taggedTemplateStringsWithTypedTags.ts
TypeScript
interface I { (stringParts: TemplateStringsArray, ...rest: number[]): I; g: I; h: I; member: I; thisIsNotATag(x: string): void [x: number]: I; } var f: I; f `abc` f `abc${1}def${2}ghi`; f `abc`.member f `abc${1}def${2}ghi`.member; f `abc`["member"]; f `abc${1}def${2}ghi`["member"]; f `abc`[0].member `abc${1}def${2}ghi`; f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`; f.thisIsNotATag(`abc`); f.thisIsNotATag(`abc${1}def${2}ghi`);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/taggedTemplateStringsWithTypedTagsES6.ts
TypeScript
// @target: ES6 interface I { (stringParts: TemplateStringsArray, ...rest: number[]): I; g: I; h: I; member: I; thisIsNotATag(x: string): void [x: number]: I; } var f: I; f `abc` f `abc${1}def${2}ghi`; f `abc`.member f `abc${1}def${2}ghi`.member; f `abc`["member"]; f `abc${1}def${2}ghi`["member"]; f `abc`[0].member `abc${1}def${2}ghi`; f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`; f.thisIsNotATag(`abc`); f.thisIsNotATag(`abc${1}def${2}ghi`);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/taggedTemplateUntypedTagCall01.ts
TypeScript
var tag: Function; tag `Hello world!`;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/taggedTemplateWithConstructableTag01.ts
TypeScript
class CtorTag { } CtorTag `Hello world!`;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/taggedTemplateWithConstructableTag02.ts
TypeScript
interface I { new (...args: any[]): string; new (): number; } var tag: I; tag `Hello world!`;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/taggedTemplatesWithTypeArguments1.ts
TypeScript
// @target: esnext declare function f<T>(strs: TemplateStringsArray, ...callbacks: Array<(x: T) => any>): void; interface Stuff { x: number; y: string; z: boolean; } export const a = f<Stuff> ` hello ${stuff => stuff.x} brave ${stuff => stuff.y} world ${stuff => stuff.z} `; declare function g<Input, T, U, V>( strs: TemplateStringsArray, t: (i: Input) => T, u: (i: Input) => U, v: (i: Input) => V): T | U | V; export const b = g<Stuff, number, string, boolean> ` hello ${stuff => stuff.x} brave ${stuff => stuff.y} world ${stuff => stuff.z} `; declare let obj: { prop: <T>(strs: TemplateStringsArray, x: (input: T) => T) => { returnedObjProp: T } } export let c = obj["prop"]<Stuff> `${(input) => ({ ...input })}` c.returnedObjProp.x; c.returnedObjProp.y; c.returnedObjProp.z; c = obj.prop<Stuff> `${(input) => ({ ...input })}` c.returnedObjProp.x; c.returnedObjProp.y; c.returnedObjProp.z;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateInsideCallback.ts
TypeScript
// @checkJs: true // @strict: true // @outDir: dist/ // @declaration: true // @filename: templateInsideCallback.js /** * @typedef Oops * @template T * @property {T} a * @property {T} b */ /** * @callback Call * @template T * @param {T} x * @returns {T} */ /** * @template T * @type {Call<T>} */ const identity = x => x; /** * @typedef Nested * @property {Object} oh * @property {number} oh.no * @template T * @property {string} oh.noooooo */ /** * @overload * @template T * @template U * @param {T[]} array * @param {(x: T) => U[]} iterable * @returns {U[]} */ /** * @overload * @template T * @param {T[][]} array * @returns {T[]} */ /** * @param {unknown[]} array * @param {(x: unknown) => unknown} iterable * @returns {unknown[]} */ function flatMap(array, iterable = identity) { /** @type {unknown[]} */ const result = []; for (let i = 0; i < array.length; i += 1) { result.push(.../** @type {unknown[]} */(iterable(array[i]))); } return result; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateLiteralTypes2.ts
TypeScript
// @strict: true // @declaration: true function ft1<T extends string>(s: string, n: number, u: 'foo' | 'bar' | 'baz', t: T) { const c1 = `abc${s}`; const c2 = `abc${n}`; const c3 = `abc${u}`; const c4 = `abc${t}`; const d1: `abc${string}` = `abc${s}`; const d2: `abc${number}` = `abc${n}`; const d3: `abc${'foo' | 'bar' | 'baz'}` = `abc${u}`; const d4: `abc${T}` = `abc${t}`; } function ft2(s: string) { return `abc${s}`; } function ft10(s: string) { const c1 = `abc${s}`; // Type string let v1 = c1; // Type string const c2 = c1; // Type string let v2 = c2; // Type string const c3: `abc${string}` = `abc${s}`; let v3 = c3; // Type `abc${string}` const c4: `abc${string}` = c1; // Type `abc${string}` let v4 = c4; // Type `abc${string}` } function ft11(s: string, cond: boolean) { const c1 = cond ? `foo${s}` : `bar${s}`; // string const c2: `foo${string}` | `bar${string}` = c1; // `foo${string}` | `bar${string}` const c3 = cond ? c1 : c2; // string const c4 = cond ? c3 : `baz${s}`; // string const c5: `foo${string}` | `bar${string}` | `baz${string}` = c4; // `foo${string}` | `bar${string}` | `baz${string}` let v1 = c1; // string let v2 = c2; // `foo${string}` | `bar${string}` let v3 = c3; // string let v4 = c4; // string let v5 = c5; // `foo${string}` | `bar${string}` | `baz${string}` } function ft12(s: string) { const c1 = `foo${s}`; let v1 = c1; const c2: `foo${string}` = `foo${s}`; let v2 = c2; const c3 = `foo${s}` as `foo${string}`; let v3 = c3; const c4 = <`foo${string}`>`foo${s}`; let v4 = c4; const c5 = `foo${s}` as const; let v5 = c5; } declare function widening<T>(x: T): T; declare function nonWidening<T extends string | number | symbol>(x: T): T; function ft13(s: string, cond: boolean) { let x1 = widening(`foo${s}`); let x2 = widening(cond ? 'a' : `foo${s}`); let y1 = nonWidening(`foo${s}`); let y2 = nonWidening(cond ? 'a' : `foo${s}`); } type T0 = string | `${number}px`; function ft14(t: `foo${number}`) { let x1: string = t; let x2: String = t; let x3: Object = t; let x4: {} = t; let x6: { length: number } = t; } declare function g1<T>(x: T): T; declare function g2<T extends string>(x: T): T; function ft20(s: string) { let x1 = g1(`xyz-${s}`); // string let x2 = g2(`xyz-${s}`); // `xyz-${string}` } // Repro from #41631 declare function takesLiteral<T extends string>(literal: T): T extends `foo.bar.${infer R}` ? R : unknown; const t1 = takesLiteral("foo.bar.baz"); // "baz" const id2 = "foo.bar.baz"; const t2 = takesLiteral(id2); // "baz" declare const someString: string; const t3 = takesLiteral(`foo.bar.${someString}`); // string const id4 = `foo.bar.${someString}`; const t4 = takesLiteral(id4); // unknown declare const someUnion: 'abc' | 'def' | 'ghi'; const t5 = takesLiteral(`foo.bar.${someUnion}`); // "abc" | "def" | "ghi" // Repro from #41732 const pixelValue: number = 22; type PixelValueType = `${number}px`; const pixelString: PixelValueType = `22px`; const pixelStringWithTemplate: PixelValueType = `${pixelValue}px`; // Repro from #43143 function getCardTitle(title: string): `test-${string}` { return `test-${title}`; } // Repro from #43424 const interpolatedStyle = { rotate: 12 }; function C2(transform: "-moz-initial" | (string & {})) { return 12; } C2(`rotate(${interpolatedStyle.rotate}dig)`);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateLiteralTypes3.ts
TypeScript
// @strict: true // @declaration: true // Inference from template literal type to template literal type type Foo1<T> = T extends `*${infer U}*` ? U : never; type T01 = Foo1<'hello'>; type T02 = Foo1<'*hello*'>; type T03 = Foo1<'**hello**'>; type T04 = Foo1<`*${string}*`>; type T05 = Foo1<`*${number}*`>; type T06 = Foo1<`*${bigint}*`>; type T07 = Foo1<`*${any}*`>; type T08 = Foo1<`**${string}**`>; type T09 = Foo1<`**${string}**${string}**`>; type T10 = Foo1<`**${'a' | 'b' | 'c'}**`>; type T11 = Foo1<`**${boolean}**${boolean}**`>; declare function foo1<V extends string>(arg: `*${V}*`): V; function f1<T extends string>(s: string, n: number, b: boolean, t: T) { let x1 = foo1('hello'); // Error let x2 = foo1('*hello*'); let x3 = foo1('**hello**'); let x4 = foo1(`*${s}*` as const); let x5 = foo1(`*${n}*` as const); let x6 = foo1(`*${b}*` as const); let x7 = foo1(`*${t}*` as const); let x8 = foo1(`**${s}**` as const); } // Inference to a placeholder immediately followed by another placeholder infers a single // character or placeholder from the source. type Parts<T> = T extends '' ? [] : T extends `${infer Head}${infer Tail}` ? [Head, ...Parts<Tail>] : never; type T20 = Parts<`abc`>; type T21 = Parts<`*${string}*`>; type T22 = Parts<`*${number}*`>; type T23 = Parts<`*${number}*${string}*${bigint}*`>; function f2() { let x: `${number}.${number}.${number}`; x = '1.1.1'; x = '1.1.1' as `1.1.${number}`; x = '1.1.1' as `1.${number}.1`; x = '1.1.1' as `1.${number}.${number}`; x = '1.1.1' as `${number}.1.1`; x = '1.1.1' as `${number}.1.${number}`; x = '1.1.1' as `${number}.${number}.1`; x = '1.1.1' as `${number}.${number}.${number}`; } function f3<T extends string>(s: string, n: number, b: boolean, t: T) { let x: `*${string}*`; x = 'hello'; // Error x = '*hello*'; x = '**hello**'; x = `*${s}*` as const; x = `*${n}*` as const; x = `*${b}*` as const; x = `*${t}*` as const; x = `**${s}**` as const; } function f4<T extends number>(s: string, n: number, b: boolean, t: T) { let x: `*${number}*`; x = '123'; // Error x = '*123*'; x = '**123**'; // Error x = `*${s}*` as const; // Error x = `*${n}*` as const; x = `*${b}*` as const; // Error x = `*${t}*` as const; } // Repro from #43060 type A<T> = T extends `${infer U}.${infer V}` ? U | V : never type B = A<`test.1024`>; // "test" | "1024" type C = A<`test.${number}`>; // "test" | `${number}` type D<T> = T extends `${infer U}.${number}` ? U : never type E = D<`test.1024`>; // "test" type F = D<`test.${number}`>; // "test" type G<T> = T extends `${infer U}.${infer V}` ? U | V : never type H = G<`test.hoge`>; // "test" | "hoge" type I = G<`test.${string}`>; // string ("test" | string reduces to string) type J<T> = T extends `${infer U}.${string}` ? U : never type K = J<`test.hoge`>; // "test" type L = J<`test.${string}`>; // "test"" // Repro from #43243 type Templated = `${string} ${string}`; const value1: string = "abc"; const templated1: Templated = `${value1} abc` as const; // Type '`${string} abc`' is not assignable to type '`${string} ${string}`'. const value2 = "abc"; const templated2: Templated = `${value2} abc` as const; // Repro from #43620 type Prefixes = "foo" | "bar"; type AllPrefixData = "foo:baz" | "bar:baz"; type PrefixData<P extends Prefixes> = `${P}:baz`; interface ITest<P extends Prefixes, E extends AllPrefixData = PrefixData<P>> { blah: string; } // Repro from #45906 type Schema = { a: { b: { c: number } } }; declare function chain<F extends keyof Schema>(field: F | `${F}.${F}`): void; chain("a"); // Repro from #46125 function ff1(x: `foo-${string}`, y: `${string}-bar`, z: `baz-${string}`) { if (x === y) { x; // `foo-${string}` } if (x === z) { // Error } } function ff2<T extends string>(x: `foo-${T}`, y: `${T}-bar`, z: `baz-${T}`) { if (x === y) { x; // `foo-${T}` } if (x === z) { // Error } } function ff3(x: string, y: `foo-${string}` | 'bar') { if (x === y) { x; // `foo-${string}` | 'bar' } } function ff4(x: string, y: `foo-${string}`) { if (x === 'foo-test') { x; // 'foo-test' } if (y === 'foo-test') { y; // 'foo-test' } } // Repro from #46045 type Action = | { type: `${string}_REQUEST` } | { type: `${string}_SUCCESS`, response: string }; function reducer(action: Action) { if (action.type === 'FOO_SUCCESS') { action.type; action.response; } } // Repro from #46768 type DotString = `${string}.${string}.${string}`; declare function noSpread<P extends DotString>(args: P[]): P; declare function spread<P extends DotString>(...args: P[]): P; noSpread([`1.${'2'}.3`, `1.${'2'}.4`]); noSpread([`1.${'2' as string}.3`, `1.${'2' as string}.4`]); spread(`1.${'2'}.3`, `1.${'2'}.4`); spread(`1.${'2' as string}.3`, `1.${'2' as string}.4`); function ft1<T extends string>(t: T, u: Uppercase<T>, u1: Uppercase<`1.${T}.3`>, u2: Uppercase<`1.${T}.4`>) { spread(`1.${t}.3`, `1.${t}.4`); spread(`1.${u}.3`, `1.${u}.4`); spread(u1, u2); } // Repro from #52685 type Boom = 'abc' | 'def' | `a${string}` | Lowercase<string>; // Repro from #56582 function a<T extends {id: string}>() { let x: keyof T & string | `-${keyof T & string}`; x = "id"; x = "-id"; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateLiteralTypes4.ts
TypeScript
// @strict: true // @target: esnext // @declaration: true // infer from number type TNumber0 = "100" extends `${infer N extends number}` ? N : never; // 100 type TNumber1 = "-100" extends `${infer N extends number}` ? N : never; // -100 type TNumber2 = "1.1" extends `${infer N extends number}` ? N : never; // 1.1 type TNumber3 = "8e-11" extends `${infer N extends number}` ? N : never; // 8e-11 (0.00000000008) type TNumber4 = "0x10" extends `${infer N extends number}` ? N : never; // number (not round-trippable) type TNumber5 = "0o10" extends `${infer N extends number}` ? N : never; // number (not round-trippable) type TNumber6 = "0b10" extends `${infer N extends number}` ? N : never; // number (not round-trippable) type TNumber7 = "10e2" extends `${infer N extends number}` ? N : never; // number (not round-trippable) type TNumber8 = "abcd" extends `${infer N extends number}` ? N : never; // never // infer from bigint type TBigInt0 = "100" extends `${infer N extends bigint}` ? N : never; // 100n type TBigInt1 = "-100" extends `${infer N extends bigint}` ? N : never; // -100n type TBigInt2 = "0x10" extends `${infer N extends bigint}` ? N : never; // bigint (not round-trippable) type TBigInt3 = "0o10" extends `${infer N extends bigint}` ? N : never; // bigint (not round-trippable) type TBigInt4 = "0b10" extends `${infer N extends bigint}` ? N : never; // bigint (not round-trippable) type TBigInt5 = "1.1" extends `${infer N extends bigint}` ? N : never; // never type TBigInt6 = "10e2" extends `${infer N extends bigint}` ? N : never; // never type TBigInt7 = "abcd" extends `${infer N extends bigint}` ? N : never; // never // infer from boolean type TBoolean0 = "true" extends `${infer T extends boolean}` ? T : never; // true type TBoolean1 = "false" extends `${infer T extends boolean}` ? T : never; // false type TBoolean2 = "abcd" extends `${infer T extends boolean}` ? T : never; // never // infer from null type TNull0 = "null" extends `${infer T extends null}` ? T : never; // null type TNull1 = "abcd" extends `${infer T extends null}` ? T : never; // never // infer from undefined type TUndefined0 = "undefined" extends `${infer T extends undefined}` ? T : never; // undefined type TUndefined1 = "abcd" extends `${infer T extends undefined}` ? T : never; // never // infer from literal enums const enum StringLiteralEnum { Zero = "0", True = "true", False = "false", Undefined = "undefined", Null = "null" } type TStringLiteralEnum0 = "0" extends `${infer T extends StringLiteralEnum}` ? T : never; // StringLiteralEnum.Zero const enum NumberLiteralEnum { Zero, One } type TNumberLiteralEnum0 = "0" extends `${infer T extends NumberLiteralEnum}` ? T : never; // NumberLiteralEnum.Zero // infer from non-literal enums const enum NonLiteralEnum { Zero = NumberLiteralEnum.Zero, One = NumberLiteralEnum.One } type TNonLiteralEnum0 = "0" extends `${infer T extends NonLiteralEnum}` ? T : never; // 0 // infer using priority: // string > template-literal > (string-literal | string-literal-enum) > // number > enum > (number-literal | number-literal-enum) > // bigint > bigint-literal > // boolean > (boolean-literal | undefined | null) // #region string // string > string-literal-enum type PString00 = "0" extends `${infer T extends string | StringLiteralEnum}` ? T : never; // "0" // string > number type PString01 = "0" extends `${infer T extends string | number}` ? T : never; // "0" // string > enum type PString02 = "0" extends `${infer T extends string | NonLiteralEnum}` ? T : never; // "0" // string > (number-literal | number-literal-enum) type PString03 = "0" extends `${infer T extends string | 0}` ? T : never; // "0" type PString04 = "0" extends `${infer T extends string | NumberLiteralEnum}` ? T : never; // "0" // string > bigint type PString05 = "0" extends `${infer T extends string | bigint}` ? T : never; // "0" // string > bigint-literal type PString06 = "0" extends `${infer T extends string | 0n}` ? T : never; // "0" // string > boolean type PString07 = "true" extends `${infer T extends string | boolean}` ? T : never; // "true" type PString08 = "false" extends `${infer T extends string | boolean}` ? T : never; // "false" // string > (boolean-literal | undefined | null) type PString09 = "true" extends `${infer T extends string | true}` ? T : never; // "true" type PString10 = "false" extends `${infer T extends string | false}` ? T : never; // "false" type PString11 = "undefined" extends `${infer T extends string | undefined}` ? T : never; // "undefined" type PString12 = "null" extends `${infer T extends string | null}` ? T : never; // "null" // #endregion string // #region template-literal // template-literal > number type PTemplate00 = "10" extends `${infer T extends `1${string}` | number}` ? T : never; // "10" // template-literal > enum type PTemplate01 = "10" extends `${infer T extends `1${string}` | NonLiteralEnum}` ? T : never; // "10" // template-literal > (number-literal | number-literal-enum) type PTemplate02 = "10" extends `${infer T extends `1${string}` | 10}` ? T : never; // "10" type PTemplate03 = "10" extends `${infer T extends `1${string}` | NumberLiteralEnum}` ? T : never; // "10" // template-literal > bigint type PTemplate04 = "10" extends `${infer T extends `1${string}` | bigint}` ? T : never; // "10" // template-literal > bigint-literal type PTemplate05 = "10" extends `${infer T extends `1${string}` | 10n}` ? T : never; // "10" // template-literal > boolean type PTemplate06 = "true" extends `${infer T extends `${string}e` | boolean}` ? T : never; // "true" type PTemplate07 = "false" extends `${infer T extends `${string}e` | boolean}` ? T : never; // "false" // template-literal > (boolean-literal | undefined | null) type PTemplate08 = "true" extends `${infer T extends `${"t"}${string}` | true}` ? T : never; // "true" type PTemplate09 = "false" extends `${infer T extends `${"f"}${string}` | false}` ? T : never; // "false" type PTemplate10 = "undefined" extends `${infer T extends `${"u"}${string}` | undefined}` ? T : never; // "undefined" type PTemplate11 = "null" extends `${infer T extends `${"n"}${string}` | null}` ? T : never; // "null" // #endregion template-literal // #region string-literal // string-literal > number type PStringLiteral00 = "0" extends `${infer T extends "0" | number}` ? T : never; // "0" // string-literal > enum type PStringLiteral01 = "0" extends `${infer T extends "0" | NonLiteralEnum}` ? T : never; // "0" // string-literal > (number-literal | number-literal-enum) type PStringLiteral02 = "0" extends `${infer T extends "0" | 0}` ? T : never; // "0" type PStringLiteral03 = "0" extends `${infer T extends "0" | NumberLiteralEnum}` ? T : never; // "0" // string-literal > bigint type PStringLiteral04 = "0" extends `${infer T extends "0" | bigint}` ? T : never; // "0" // string-literal > bigint-literal type PStringLiteral05 = "0" extends `${infer T extends "0" | 0n}` ? T : never; // "0" // string-literal > boolean type PStringLiteral06 = "true" extends `${infer T extends "true" | "false" | boolean}` ? T : never; // "true" type PStringLiteral07 = "false" extends `${infer T extends "true" | "false" | boolean}` ? T : never; // "false" // string-literal > (boolean-literal | undefined | null) type PStringLiteral08 = "true" extends `${infer T extends "true" | true}` ? T : never; // "true" type PStringLiteral09 = "false" extends `${infer T extends "false" | false}` ? T : never; // "false" type PStringLiteral10 = "undefined" extends `${infer T extends "undefined" | undefined}` ? T : never; // "undefined" type PStringLiteral11 = "null" extends `${infer T extends "null" | null}` ? T : never; // "null" // #endregion string-literal // #region string-literal-enum // string-literal-enum > number type PStringLiteralEnum00 = "0" extends `${infer T extends StringLiteralEnum | number}` ? T : never; // StringLiteralEnum.Zero // string-literal-enum > enum type PStringLiteralEnum01 = "0" extends `${infer T extends StringLiteralEnum | NonLiteralEnum}` ? T : never; // StringLiteralEnum.Zero // string-literal-enum > (number-literal | number-literal-enum) type PStringLiteralEnum02 = "0" extends `${infer T extends StringLiteralEnum | 0}` ? T : never; // StringLiteralEnum.Zero type PStringLiteralEnum03 = "0" extends `${infer T extends StringLiteralEnum | NumberLiteralEnum}` ? T : never; // StringLiteralEnum.Zero // string-literal-enum > bigint type PStringLiteralEnum04 = "0" extends `${infer T extends StringLiteralEnum | bigint}` ? T : never; // StringLiteralEnum.Zero // string-literal-enum > bigint-literal type PStringLiteralEnum05 = "0" extends `${infer T extends StringLiteralEnum | 0n}` ? T : never; // StringLiteralEnum.Zero // string-literal-enum > boolean type PStringLiteralEnum06 = "true" extends `${infer T extends StringLiteralEnum | boolean}` ? T : never; // StringLiteralEnum.True type PStringLiteralEnum07 = "false" extends `${infer T extends StringLiteralEnum | boolean}` ? T : never; // StringLiteralEnum.False // string-literal-enum > (boolean-literal | undefined | null) type PStringLiteralEnum08 = "true" extends `${infer T extends StringLiteralEnum | true}` ? T : never; // StringLiteralEnum.True type PStringLiteralEnum09 = "false" extends `${infer T extends StringLiteralEnum | false}` ? T : never; // StringLiteralEnum.False type PStringLiteralEnum10 = "undefined" extends `${infer T extends StringLiteralEnum | undefined}` ? T : never; // StringLiteralEnum.Undefined type PStringLiteralEnum11 = "null" extends `${infer T extends StringLiteralEnum | null}` ? T : never; // StringLiteralEnum.Null // #endregion string-literal-enum // #region number // number > enum type PNumber0 = "0" extends `${infer T extends number | NonLiteralEnum}` ? T : never; // 0 // number > number-literal-enum type PNumber1 = "0" extends `${infer T extends number | NumberLiteralEnum}` ? T : never; // 0 // number > bigint type PNumber2 = "0" extends `${infer T extends number | bigint}` ? T : never; // 0 // number > bigint-literal type PNumber3 = "0" extends `${infer T extends number | 0n}` ? T : never; // 0 // #endregion number // #region enum // enum > number-literal-enum type PEnum0 = "0" extends `${infer T extends NonLiteralEnum | NumberLiteralEnum}` ? T : never; // 0 // enum > bigint type PEnum1 = "0" extends `${infer T extends NonLiteralEnum | bigint}` ? T : never; // 0 // enum > bigint-literal type PEnum2 = "0" extends `${infer T extends NonLiteralEnum | 0n}` ? T : never; // 0 // #endregion enum // #region number-literal // number-literal > bigint type PNumberLiteral0 = "0" extends `${infer T extends 0 | bigint}` ? T : never; // 0 // number-literal > bigint-literal type PNumberLiteral1 = "0" extends `${infer T extends 0 | 0n}` ? T : never; // 0 // #endregion number-literal // #region number-literal-enum // number-literal-enum > bigint type PNumberLiteralEnum0 = "0" extends `${infer T extends NumberLiteralEnum | bigint}` ? T : never; // NumberLiteralEnum.Zero // number-literal-enum > bigint-literal type PNumberLiteralEnum1 = "0" extends `${infer T extends NumberLiteralEnum | 0n}` ? T : never; // NumberLiteralEnum.Zero // #endregion number-literal-enum // non-matchable constituents are excluded type PExclude0 = "0" extends `${infer T extends "1" | number}` ? T : never; // 0 type PExclude1 = "0" extends `${infer T extends `1${string}` | number}` ? T : never; // 0 type PExclude2 = "0" extends `${infer T extends 1 | bigint}` ? T : never; // 0n type PExclude3 = "0" extends `${infer T extends NumberLiteralEnum.One | bigint}` ? T : never; // 0n type PExclude4 = "100000000000000000000000" extends `${infer T extends number | bigint}` ? T : never; // 100000000000000000000000n // infer to prefix from string type TPrefix0 = "100" extends `${infer T extends number}${string}` ? T : never; // 1 type TPrefix1 = "trueabc" extends `${infer T extends boolean}${string}` ? T : never; // boolean (T only receives 't', not the whole string) type TPrefix2 = `100:${string}` extends `${infer T extends number}:${string}` ? T : never; // 100 (T receives '100' because it scans until ':') // can use union w/multiple branches to extract each possibility type ExtractPrimitives<T extends string> = | T | (T extends `${infer U extends number}` ? U : never) | (T extends `${infer U extends bigint}` ? U : never) | (T extends `${infer U extends boolean | null | undefined}` ? U : never) ; type TExtract0 = ExtractPrimitives<"100">; // "100" | 100 | 100n type TExtract1 = ExtractPrimitives<"1.1">; // "1.1" | 1.1 type TExtract2 = ExtractPrimitives<"true">; // "true" | true // example use case (based on old TypedObjects proposal): // Use constrained `infer` in template literal to get ordinal indices as numbers: type IndexFor<S extends string> = S extends `${infer N extends number}` ? N : never; type IndicesOf<T> = IndexFor<Extract<keyof T, string>>; // ordinal indices as number literals interface FieldDefinition { readonly name: string; readonly type: "i8" | "i16" | "i32" | "i64" | "u8" | "u16" | "u32" | "u64" | "f32" | "f64"; } type FieldType<T extends FieldDefinition["type"]> = T extends "i8" | "i16" | "i32" | "u8" | "u16" | "u32" | "f32" | "f64" ? number : T extends "f32" | "f64" ? bigint : never; // Generates named members like `{ x: number, y: bigint }` from `[{ name: "x", type: "i32" }, { name: "y", type: "i64" }]` type TypedObjectNamedMembers<TDef extends readonly FieldDefinition[]> = { [P in TDef[number]["name"]]: FieldType<Extract<TDef[number], { readonly name: P }>["type"]>; }; // Generates ordinal members like `{ 0: number, 1: bigint }` from `[{ name: "x", type: "i32" }, { name: "y", type: "i64" }]` type TypedObjectOrdinalMembers<TDef extends readonly FieldDefinition[]> = { [I in Extract<keyof TDef, `${number}`>]: FieldType<Extract<TDef[I], FieldDefinition>["type"]>; }; // Default members interface TypedObjectMembers<TDef extends readonly FieldDefinition[]> { // get/set a field by name get<K extends TDef[number]["name"]>(key: K): FieldType<Extract<TDef[number], { readonly name: K }>["type"]>; set<K extends TDef[number]["name"]>(key: K, value: FieldType<Extract<TDef[number], { readonly name: K }>["type"]>): void; // get/set a field by index getIndex<I extends IndicesOf<TDef>>(index: I): FieldType<Extract<TDef[I], FieldDefinition>["type"]>; setIndex<I extends IndicesOf<TDef>>(index: I, value: FieldType<Extract<TDef[I], FieldDefinition>["type"]>): void; } type TypedObject<TDef extends readonly FieldDefinition[]> = & TypedObjectMembers<TDef> & TypedObjectNamedMembers<TDef> & TypedObjectOrdinalMembers<TDef>; // NOTE: type would normally be created from something like `const Point = TypedObject([...])` from which we would infer the type type Point = TypedObject<[ { name: "x", type: "f64" }, { name: "y", type: "f64" }, ]>; declare const p: Point; p.getIndex(0); // ok, 0 is a valid index p.getIndex(1); // ok, 1 is a valid index p.getIndex(2); // error, 2 is not a valid index p.setIndex(0, 0); // ok, 0 is a valid index p.setIndex(1, 0); // ok, 1 is a valid index p.setIndex(2, 3); // error, 2 is not a valid index // function inference declare function f1<T extends string | number>(s: `**${T}**`): T; f1("**123**"); // "123" declare function f2<T extends number>(s: `**${T}**`): T; f2("**123**"); // 123 declare function f3<T extends bigint>(s: `**${T}**`): T; f3("**123**"); // 123n declare function f4<T extends boolean>(s: `**${T}**`): T; f4("**true**"); // true | "true" f4("**false**"); // false | "false"
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateLiteralTypes5.ts
TypeScript
// @strict: true // @target: esnext // @noEmit: true // https://github.com/microsoft/TypeScript/issues/55364 interface TypeMap { a: "A"; b: "B"; } declare const f: <T0 extends "a" | "b">(x: `${T0}`) => TypeMap[T0]; type F1 = <T1 extends "a" | "b">(x: `${T1}`) => TypeMap[T1]; const f1: F1 = f; type F2 = <T2 extends 'a' | 'b'>(x: `${T2}`) => TypeMap[`${T2}`] const f2: F2 = f function f3<T3 extends "a" | "b">(x: T3) { const test1: `${T3}` = x const test2: T3 = "" as `${T3}`; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateLiteralTypes6.ts
TypeScript
// @strict: true // @target: esnext // @noEmit: true // https://github.com/microsoft/TypeScript/issues/56659 type Registry = { a: { a1: {} }; b: { b1: {} }; }; type Keyof<T> = keyof T & string; declare function f1< Scope extends Keyof<Registry>, Event extends Keyof<Registry[Scope]>, >(eventPath: `${Scope}:${Event}`): void; function f2< Scope extends Keyof<Registry>, Event extends Keyof<Registry[Scope]>, >(scope: Scope, event: Event) { f1(`${scope}:${event}`); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateLiteralTypes7.ts
TypeScript
// @strict: true // @target: esnext // @noEmit: true // https://github.com/microsoft/TypeScript/issues/57807 interface NMap { 1: 'A' 2: 'B' 3: 'C' 4: 'D' } declare const g: <T extends 1 | 2 | 3>(x: `${T}`) => NMap[T] type G1 = <T extends 1 | 2 | 3>(x: `${T}`) => NMap[T] const g1: G1 = g; // ok type G2 = <T extends 1 | 2 | 3 | 4>(x: `${T}`) => NMap[T] const g2: G2 = g; // error type G3 = <T extends 1 | 2>(x: `${T}`) => NMap[T] const g3: G3 = g; // ok
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateLiteralTypesPatterns.ts
TypeScript
// @strict: true type RequiresLeadingSlash = `/${string}`; // ok const a: RequiresLeadingSlash = "/bin"; // not ok const b: RequiresLeadingSlash = "no slash"; type Protocol<T extends string, U extends string> = `${T}://${U}`; function download(hostSpec: Protocol<"http" | "https" | "ftp", string>) { } // ok, has protocol download("http://example.com/protocol"); // issues error - no protocol download("example.com/noprotocol"); // issues error, incorrect protocol download("gopher://example.com/protocol"); const q: RequiresLeadingSlash extends string ? true : false = true; declare function bools(x: `${boolean}`): void; // ok bools("true"); bools("false"); // not ok bools("other"); type Pat<T extends string | null | undefined> = `${T}` declare function nullishes(x: Pat<null | undefined>): void; // ok nullishes("null"); nullishes("undefined"); // not ok nullishes("0"); nullishes("false"); nullishes("NaN"); nullishes(""); nullishes("other"); declare function numbers(x: `${number}`): void; // the following should work numbers("1"); numbers("-1"); numbers("0"); numbers("0b1"); numbers("0x1"); numbers("0o1"); numbers("1e21"); numbers("1E21"); numbers("1e-21"); numbers("1E-21"); numbers("1.1"); numbers("-1.1"); numbers("-1.1e-10"); numbers("-1.1E-10"); numbers("1.1e-10"); // the following should be errors since they're not numbers numbers("?"); numbers("NaN"); numbers("Infinity"); numbers("+Infinity"); numbers("-Infinity"); numbers("1_000"); // the following should be errors since they don't match the pattern numbers("a10"); numbers("10a"); // whitespace and comments aren't part of numbers numbers("- 1"); numbers("-/**/1"); declare function bigints(x: `${bigint}`): void; // the following should work bigints("1"); bigints("-1"); bigints("0"); bigints("0b1"); bigints("0x1"); bigints("0o1"); // bigints do not allow scientific notation in their parsing/scanning, so these are all errors bigints("1e21"); bigints("1E21"); bigints("1e-21"); bigints("1E-21"); // these are all errors because they're not big_int_s bigints("1.0"); bigints("1.1"); bigints("-1.1"); bigints("-1.1e-10"); bigints("-1.1E-10"); bigints("1.1e-10"); // the following should be errors since they're not numbers bigints("?"); bigints("NaN"); bigints("Infinity"); bigints("+Infinity"); bigints("-Infinity"); bigints("1_000"); // whitespace and comments aren't part of numbers bigints("- 1"); bigints("-/**/1"); // the following should be errors since they don't match the pattern bigints("a10n"); bigints("10an"); // the following should all be errors because the `BigInt` constructor (and thus bigint parsing) doesn't take the trailing `n` used in literals bigints("1n"); bigints("-1n"); bigints("0n"); bigints("0b1n"); bigints("0x1n"); bigints("0o1n"); bigints("1e21n"); bigints("1E21n"); bigints("1e-21n"); bigints("1E-21n"); bigints("1.1n"); bigints("-1.1n"); bigints("-1.1e-10n"); bigints("-1.1E-10n"); bigints("1.1e-10n"); type AStr = `a${string}`; type ANum = `a${number}`; type AAny = `a${any}`; declare var str: AStr; declare var num: ANum; declare var anyish: AAny; // not ok num = str; anyish = `bno` // ok str = num; anyish = str; str = anyish; anyish = num; num = anyish; anyish = `aok` // Validates variance isn't measured as strictly covariant type AGen<T extends string | number> = {field: `a${T}`}; const shouldWork1: AGen<string> = null as any as AGen<"yes">; const shouldWork2: AGen<string> = null as any as AGen<number>; // validates concatenation of patterns type A = `${number}`; type B = `${A} ${A}`; const exampleBad: B = "anything"; // fails const exampleGood: B = "1 2"; // ok // Repro from #41161 var aa: '0'; var aa: '0' & `${number}`; // Remove string literals from unions with matching template literals let t1: `foo${string}` | 'foo1' | '1foo'; // `foo${string}` | '1foo' let t2: `foo1` | '1foo' | 'foofoo' | `foo${string}` | 'foox' | 'xfoo'; // `foo${string}` | '1foo' | 'xfoo' let t3: `foo1` | '1foo' | 'foofoo' | `foo${string}` | 'foox' | 'xfoo' | `${number}foo`; // `foo${string}` | xfoo' | `${number}foo` var bb: `${number}`; var bb: `${number}` | '0'; // Normalize `${string}` to just string type T2S<A extends string, B extends string> = `${A}${B}`; type S10 = `${string}`; // string type S11 = `${string}${string}${string}`; // string type S12 = T2S<string, string>; // string function ff1(x: `${string}-${string}`) { let s1 = x && 42; // number let s2 = x || 42; // `${string}-${string}` } // Repro from #41651 export type Id<TA, TId extends string = string> = `${TId}-${TId}`; export class AA {} export abstract class BB { abstract get(id: Id<AA>): void; update(id: Id<AA>): void { this.get(id!); } } // repro from https://github.com/microsoft/TypeScript/issues/54177#issuecomment-1538436654 function conversionTest(groupName: | "downcast" | "dataDowncast" | "editingDowncast" | `${string}Downcast` & {}) {} conversionTest("testDowncast"); function conversionTest2(groupName: | "downcast" | "dataDowncast" | "editingDowncast" | {} & `${string}Downcast`) {} conversionTest2("testDowncast"); function conversionTest3(groupName: | "downcast" | "dataDowncast" | "editingDowncast" | `${string & {}}Downcast`) {} conversionTest3("testDowncast"); function conversionTest4(groupName: | "downcast" | "dataDowncast" | "editingDowncast" | `${{} & string}Downcast`) {} conversionTest4("testDowncast"); function foo(str: `${`a${string}` & `${string}a`}Test`) {} foo("abaTest"); // ok foo("abcTest"); // error
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateLiteralTypesPatternsPrefixSuffixAssignability.ts
TypeScript
const s1: `:${string}:` = ":"; // should error const s2: `:${string}:` = "::"; // ok const s3: `:${string}:${string}:` = "::"; // should error const s4: `:${string}:${string}:` = ":::"; // ok
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateStringBinaryOperations.ts
TypeScript
var a = 1 + `${ 3 }`; var b = 1 + `2${ 3 }`; var c = 1 + `${ 3 }4`; var d = 1 + `2${ 3 }4`; var e = `${ 3 }` + 5; var f = `2${ 3 }` + 5; var g = `${ 3 }4` + 5; var h = `2${ 3 }4` + 5; var i = 1 + `${ 3 }` + 5; var j = 1 + `2${ 3 }` + 5; var k = 1 + `${ 3 }4` + 5; var l = 1 + `2${ 3 }4` + 5; var a2 = 1 + `${ 3 - 4 }`; var b2 = 1 + `2${ 3 - 4 }`; var c2 = 1 + `${ 3 - 4 }5`; var d2 = 1 + `2${ 3 - 4 }5`; var e2 = `${ 3 - 4 }` + 6; var f2 = `2${ 3 - 4 }` + 6; var g2 = `${ 3 - 4 }5` + 6; var h2 = `2${ 3 - 4 }5` + 6; var i2 = 1 + `${ 3 - 4 }` + 6; var j2 = 1 + `2${ 3 - 4 }` + 6; var k2 = 1 + `${ 3 - 4 }5` + 6; var l2 = 1 + `2${ 3 - 4 }5` + 6; var a3 = 1 + `${ 3 * 4 }`; var b3 = 1 + `2${ 3 * 4 }`; var c3 = 1 + `${ 3 * 4 }5`; var d3 = 1 + `2${ 3 * 4 }5`; var e3 = `${ 3 * 4 }` + 6; var f3 = `2${ 3 * 4 }` + 6; var g3 = `${ 3 * 4 }5` + 6; var h3 = `2${ 3 * 4 }5` + 6; var i3 = 1 + `${ 3 * 4 }` + 6; var j3 = 1 + `2${ 3 * 4 }` + 6; var k3 = 1 + `${ 3 * 4 }5` + 6; var l3 = 1 + `2${ 3 * 4 }5` + 6; var a4 = 1 + `${ 3 & 4 }`; var b4 = 1 + `2${ 3 & 4 }`; var c4 = 1 + `${ 3 & 4 }5`; var d4 = 1 + `2${ 3 & 4 }5`; var e4 = `${ 3 & 4 }` + 6; var f4 = `2${ 3 & 4 }` + 6; var g4 = `${ 3 & 4 }5` + 6; var h4 = `2${ 3 & 4 }5` + 6; var i4 = 1 + `${ 3 & 4 }` + 6; var j4 = 1 + `2${ 3 & 4 }` + 6; var k4 = 1 + `${ 3 & 4 }5` + 6; var l4 = 1 + `2${ 3 & 4 }5` + 6;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateStringBinaryOperationsES6.ts
TypeScript
// @target: ES6 var a = 1 + `${ 3 }`; var b = 1 + `2${ 3 }`; var c = 1 + `${ 3 }4`; var d = 1 + `2${ 3 }4`; var e = `${ 3 }` + 5; var f = `2${ 3 }` + 5; var g = `${ 3 }4` + 5; var h = `2${ 3 }4` + 5; var i = 1 + `${ 3 }` + 5; var j = 1 + `2${ 3 }` + 5; var k = 1 + `${ 3 }4` + 5; var l = 1 + `2${ 3 }4` + 5; var a2 = 1 + `${ 3 - 4 }`; var b2 = 1 + `2${ 3 - 4 }`; var c2 = 1 + `${ 3 - 4 }5`; var d2 = 1 + `2${ 3 - 4 }5`; var e2 = `${ 3 - 4 }` + 6; var f2 = `2${ 3 - 4 }` + 6; var g2 = `${ 3 - 4 }5` + 6; var h2 = `2${ 3 - 4 }5` + 6; var i2 = 1 + `${ 3 - 4 }` + 6; var j2 = 1 + `2${ 3 - 4 }` + 6; var k2 = 1 + `${ 3 - 4 }5` + 6; var l2 = 1 + `2${ 3 - 4 }5` + 6; var a3 = 1 + `${ 3 * 4 }`; var b3 = 1 + `2${ 3 * 4 }`; var c3 = 1 + `${ 3 * 4 }5`; var d3 = 1 + `2${ 3 * 4 }5`; var e3 = `${ 3 * 4 }` + 6; var f3 = `2${ 3 * 4 }` + 6; var g3 = `${ 3 * 4 }5` + 6; var h3 = `2${ 3 * 4 }5` + 6; var i3 = 1 + `${ 3 * 4 }` + 6; var j3 = 1 + `2${ 3 * 4 }` + 6; var k3 = 1 + `${ 3 * 4 }5` + 6; var l3 = 1 + `2${ 3 * 4 }5` + 6; var a4 = 1 + `${ 3 & 4 }`; var b4 = 1 + `2${ 3 & 4 }`; var c4 = 1 + `${ 3 & 4 }5`; var d4 = 1 + `2${ 3 & 4 }5`; var e4 = `${ 3 & 4 }` + 6; var f4 = `2${ 3 & 4 }` + 6; var g4 = `${ 3 & 4 }5` + 6; var h4 = `2${ 3 & 4 }5` + 6; var i4 = 1 + `${ 3 & 4 }` + 6; var j4 = 1 + `2${ 3 & 4 }` + 6; var k4 = 1 + `${ 3 & 4 }5` + 6; var l4 = 1 + `2${ 3 & 4 }5` + 6;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateStringBinaryOperationsES6Invalid.ts
TypeScript
// @target: ES6 var a = 1 - `${ 3 }`; var b = 1 - `2${ 3 }`; var c = 1 - `${ 3 }4`; var d = 1 - `2${ 3 }4`; var e = `${ 3 }` - 5; var f = `2${ 3 }` - 5; var g = `${ 3 }4` - 5; var h = `2${ 3 }4` - 5; var a2 = 1 * `${ 3 }`; var b2 = 1 * `2${ 3 }`; var c2 = 1 * `${ 3 }4`; var d2 = 1 * `2${ 3 }4`; var e2 = `${ 3 }` * 5; var f2 = `2${ 3 }` * 5; var g2 = `${ 3 }4` * 5; var h2 = `2${ 3 }4` * 5; var a3 = 1 & `${ 3 }`; var b3 = 1 & `2${ 3 }`; var c3 = 1 & `${ 3 }4`; var d3 = 1 & `2${ 3 }4`; var e3 = `${ 3 }` & 5; var f3 = `2${ 3 }` & 5; var g3 = `${ 3 }4` & 5; var h3 = `2${ 3 }4` & 5; var a4 = 1 - `${ 3 - 4 }`; var b4 = 1 - `2${ 3 - 4 }`; var c4 = 1 - `${ 3 - 4 }5`; var d4 = 1 - `2${ 3 - 4 }5`; var e4 = `${ 3 - 4 }` - 6; var f4 = `2${ 3 - 4 }` - 6; var g4 = `${ 3 - 4 }5` - 6; var h4 = `2${ 3 - 4 }5` - 6; var a5 = 1 - `${ 3 * 4 }`; var b5 = 1 - `2${ 3 * 4 }`; var c5 = 1 - `${ 3 * 4 }5`; var d5 = 1 - `2${ 3 * 4 }5`; var e5 = `${ 3 * 4 }` - 6; var f5 = `2${ 3 * 4 }` - 6; var g5 = `${ 3 * 4 }5` - 6; var h5 = `2${ 3 * 4 }5` - 6; var a6 = 1 - `${ 3 & 4 }`; var b6 = 1 - `2${ 3 & 4 }`; var c6 = 1 - `${ 3 & 4 }5`; var d6 = 1 - `2${ 3 & 4 }5`; var e6 = `${ 3 & 4 }` - 6; var f6 = `2${ 3 & 4 }` - 6; var g6 = `${ 3 & 4 }5` - 6; var h6 = `2${ 3 & 4 }5` - 6; var a7 = 1 * `${ 3 - 4 }`; var b7 = 1 * `2${ 3 - 4 }`; var c7 = 1 * `${ 3 - 4 }5`; var d7 = 1 * `2${ 3 - 4 }5`; var e7 = `${ 3 - 4 }` * 6; var f7 = `2${ 3 - 4 }` * 6; var g7 = `${ 3 - 4 }5` * 6; var h7 = `2${ 3 - 4 }5` * 6; var a8 = 1 * `${ 3 * 4 }`; var b8 = 1 * `2${ 3 * 4 }`; var c8 = 1 * `${ 3 * 4 }5`; var d8 = 1 * `2${ 3 * 4 }5`; var e8 = `${ 3 * 4 }` * 6; var f8 = `2${ 3 * 4 }` * 6; var g8 = `${ 3 * 4 }5` * 6; var h8 = `2${ 3 * 4 }5` * 6; var a9 = 1 * `${ 3 & 4 }`; var b9 = 1 * `2${ 3 & 4 }`; var c9 = 1 * `${ 3 & 4 }5`; var d9 = 1 * `2${ 3 & 4 }5`; var e9 = `${ 3 & 4 }` * 6; var f9 = `2${ 3 & 4 }` * 6; var g9 = `${ 3 & 4 }5` * 6; var h9 = `2${ 3 & 4 }5` * 6; var aa = 1 & `${ 3 - 4 }`; var ba = 1 & `2${ 3 - 4 }`; var ca = 1 & `${ 3 - 4 }5`; var da = 1 & `2${ 3 - 4 }5`; var ea = `${ 3 - 4 }` & 6; var fa = `2${ 3 - 4 }` & 6; var ga = `${ 3 - 4 }5` & 6; var ha = `2${ 3 - 4 }5` & 6; var ab = 1 & `${ 3 * 4 }`; var bb = 1 & `2${ 3 * 4 }`; var cb = 1 & `${ 3 * 4 }5`; var db = 1 & `2${ 3 * 4 }5`; var eb = `${ 3 * 4 }` & 6; var fb = `2${ 3 * 4 }` & 6; var gb = `${ 3 * 4 }5` & 6; var hb = `2${ 3 * 4 }5` & 6; var ac = 1 & `${ 3 & 4 }`; var bc = 1 & `2${ 3 & 4 }`; var cc = 1 & `${ 3 & 4 }5`; var dc = 1 & `2${ 3 & 4 }5`; var ec = `${ 3 & 4 }` & 6; var fc = `2${ 3 & 4 }` & 6; var gc = `${ 3 & 4 }5` & 6; var hc = `2${ 3 & 4 }5` & 6;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateStringBinaryOperationsInvalid.ts
TypeScript
var a = 1 - `${ 3 }`; var b = 1 - `2${ 3 }`; var c = 1 - `${ 3 }4`; var d = 1 - `2${ 3 }4`; var e = `${ 3 }` - 5; var f = `2${ 3 }` - 5; var g = `${ 3 }4` - 5; var h = `2${ 3 }4` - 5; var a2 = 1 * `${ 3 }`; var b2 = 1 * `2${ 3 }`; var c2 = 1 * `${ 3 }4`; var d2 = 1 * `2${ 3 }4`; var e2 = `${ 3 }` * 5; var f2 = `2${ 3 }` * 5; var g2 = `${ 3 }4` * 5; var h2 = `2${ 3 }4` * 5; var a3 = 1 & `${ 3 }`; var b3 = 1 & `2${ 3 }`; var c3 = 1 & `${ 3 }4`; var d3 = 1 & `2${ 3 }4`; var e3 = `${ 3 }` & 5; var f3 = `2${ 3 }` & 5; var g3 = `${ 3 }4` & 5; var h3 = `2${ 3 }4` & 5; var a4 = 1 - `${ 3 - 4 }`; var b4 = 1 - `2${ 3 - 4 }`; var c4 = 1 - `${ 3 - 4 }5`; var d4 = 1 - `2${ 3 - 4 }5`; var e4 = `${ 3 - 4 }` - 6; var f4 = `2${ 3 - 4 }` - 6; var g4 = `${ 3 - 4 }5` - 6; var h4 = `2${ 3 - 4 }5` - 6; var a5 = 1 - `${ 3 * 4 }`; var b5 = 1 - `2${ 3 * 4 }`; var c5 = 1 - `${ 3 * 4 }5`; var d5 = 1 - `2${ 3 * 4 }5`; var e5 = `${ 3 * 4 }` - 6; var f5 = `2${ 3 * 4 }` - 6; var g5 = `${ 3 * 4 }5` - 6; var h5 = `2${ 3 * 4 }5` - 6; var a6 = 1 - `${ 3 & 4 }`; var b6 = 1 - `2${ 3 & 4 }`; var c6 = 1 - `${ 3 & 4 }5`; var d6 = 1 - `2${ 3 & 4 }5`; var e6 = `${ 3 & 4 }` - 6; var f6 = `2${ 3 & 4 }` - 6; var g6 = `${ 3 & 4 }5` - 6; var h6 = `2${ 3 & 4 }5` - 6; var a7 = 1 * `${ 3 - 4 }`; var b7 = 1 * `2${ 3 - 4 }`; var c7 = 1 * `${ 3 - 4 }5`; var d7 = 1 * `2${ 3 - 4 }5`; var e7 = `${ 3 - 4 }` * 6; var f7 = `2${ 3 - 4 }` * 6; var g7 = `${ 3 - 4 }5` * 6; var h7 = `2${ 3 - 4 }5` * 6; var a8 = 1 * `${ 3 * 4 }`; var b8 = 1 * `2${ 3 * 4 }`; var c8 = 1 * `${ 3 * 4 }5`; var d8 = 1 * `2${ 3 * 4 }5`; var e8 = `${ 3 * 4 }` * 6; var f8 = `2${ 3 * 4 }` * 6; var g8 = `${ 3 * 4 }5` * 6; var h8 = `2${ 3 * 4 }5` * 6; var a9 = 1 * `${ 3 & 4 }`; var b9 = 1 * `2${ 3 & 4 }`; var c9 = 1 * `${ 3 & 4 }5`; var d9 = 1 * `2${ 3 & 4 }5`; var e9 = `${ 3 & 4 }` * 6; var f9 = `2${ 3 & 4 }` * 6; var g9 = `${ 3 & 4 }5` * 6; var h9 = `2${ 3 & 4 }5` * 6; var aa = 1 & `${ 3 - 4 }`; var ba = 1 & `2${ 3 - 4 }`; var ca = 1 & `${ 3 - 4 }5`; var da = 1 & `2${ 3 - 4 }5`; var ea = `${ 3 - 4 }` & 6; var fa = `2${ 3 - 4 }` & 6; var ga = `${ 3 - 4 }5` & 6; var ha = `2${ 3 - 4 }5` & 6; var ab = 1 & `${ 3 * 4 }`; var bb = 1 & `2${ 3 * 4 }`; var cb = 1 & `${ 3 * 4 }5`; var db = 1 & `2${ 3 * 4 }5`; var eb = `${ 3 * 4 }` & 6; var fb = `2${ 3 * 4 }` & 6; var gb = `${ 3 * 4 }5` & 6; var hb = `2${ 3 * 4 }5` & 6; var ac = 1 & `${ 3 & 4 }`; var bc = 1 & `2${ 3 & 4 }`; var cc = 1 & `${ 3 & 4 }5`; var dc = 1 & `2${ 3 & 4 }5`; var ec = `${ 3 & 4 }` & 6; var fc = `2${ 3 & 4 }` & 6; var gc = `${ 3 & 4 }5` & 6; var hc = `2${ 3 & 4 }5` & 6;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateStringControlCharacterEscapes01.ts
TypeScript
 var x = `\0\x00\u0000 0 00 0000`;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateStringControlCharacterEscapes01_ES6.ts
TypeScript
// @target: es6 var x = `\0\x00\u0000 0 00 0000`;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateStringControlCharacterEscapes02.ts
TypeScript
 var x = `\x19\u0019 19`;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateStringControlCharacterEscapes02_ES6.ts
TypeScript
// @target: es6 var x = `\x19\u0019 19`;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateStringControlCharacterEscapes03.ts
TypeScript
 var x = `\x1F\u001f 1F 1f`;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateStringControlCharacterEscapes03_ES6.ts
TypeScript
// @target: es6 var x = `\x1F\u001f 1F 1f`;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateStringControlCharacterEscapes04.ts
TypeScript
 var x = `\x20\u0020 20`;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateStringControlCharacterEscapes04_ES6.ts
TypeScript
// @target: es6 var x = `\x20\u0020 20`;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateStringInArray.ts
TypeScript
var x = [1, 2, `abc${ 123 }def`];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateStringInArrowFunction.ts
TypeScript
var x = x => `abc${ x }def`;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University