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/unicodeExtendedEscapesInRegularExpressions11_ES5.ts | TypeScript | // @target: es5
// ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp)
// 2. Let cu2 be ((cp – 65536) modulo 1024) + 0xDC00.
// Although we should just get back a single code point value of 0xDC00,
// this is a useful edge-case test.
var x = /\u{DC00}/g;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions11_ES6.ts | TypeScript | // @target: es6
// ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp)
// 2. Let cu2 be ((cp – 65536) modulo 1024) + 0xDC00.
// Although we should just get back a single code point value of 0xDC00,
// this is a useful edge-case test.
var x = /\u{DC00}/g;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions12_ES5.ts | TypeScript | // @target: es5
var x = /\u{FFFFFFFF}/g;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions12_ES6.ts | TypeScript | // @target: es6
var x = /\u{FFFFFFFF}/g;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions13_ES5.ts | TypeScript | // @target: es5
var x = /\u{DDDDD}/g;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions13_ES6.ts | TypeScript | // @target: es6
var x = /\u{DDDDD}/g;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions14_ES5.ts | TypeScript | // @target: es5
// Shouldn't work, negatives are not allowed.
var x = /\u{-DDDD}/g;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions14_ES6.ts | TypeScript | // @target: es6
// Shouldn't work, negatives are not allowed.
var x = /\u{-DDDD}/g;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions15_ES5.ts | TypeScript | // @target: es5
var x = /\u{abcd}\u{ef12}\u{3456}\u{7890}/g;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions15_ES6.ts | TypeScript | // @target: es6
var x = /\u{abcd}\u{ef12}\u{3456}\u{7890}/g;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions16_ES5.ts | TypeScript | // @target: es5
var x = /\u{ABCD}\u{EF12}\u{3456}\u{7890}/g;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions16_ES6.ts | TypeScript | // @target: es6
var x = /\u{ABCD}\u{EF12}\u{3456}\u{7890}/g;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions17_ES5.ts | TypeScript | // @target: es5
var x = /\u{r}\u{n}\u{t}/g;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions17_ES6.ts | TypeScript | // @target: es6
var x = /\u{r}\u{n}\u{t}/g;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions18_ES5.ts | TypeScript | // @target: es5
var x = /\u{65}\u{65}/g;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions18_ES6.ts | TypeScript | // @target: es6
var x = /\u{65}\u{65}/g;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions19_ES5.ts | TypeScript | // @target: es5
var x = /\u{}/g;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions19_ES6.ts | TypeScript | // @target: es6
var x = /\u{}/g;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInStrings01_ES5.ts | TypeScript | // @target: es5
var x = "\u{0}";
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInStrings01_ES6.ts | TypeScript | // @target: es6
var x = "\u{0}";
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInStrings02_ES5.ts | TypeScript | // @target: es5
var x = "\u{00}";
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInStrings02_ES6.ts | TypeScript | // @target: es6
var x = "\u{00}";
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInStrings03_ES5.ts | TypeScript | // @target: es5
var x = "\u{0000}";
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInStrings03_ES6.ts | TypeScript | // @target: es6
var x = "\u{0000}";
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInStrings04_ES5.ts | TypeScript | // @target: es5
var x = "\u{00000000}";
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInStrings04_ES6.ts | TypeScript | // @target: es6
var x = "\u{00000000}";
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInStrings05_ES5.ts | TypeScript | // @target: es5
var x = "\u{48}\u{65}\u{6c}\u{6c}\u{6f}\u{20}\u{77}\u{6f}\u{72}\u{6c}\u{64}";
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInStrings05_ES6.ts | TypeScript | // @target: es6
var x = "\u{48}\u{65}\u{6c}\u{6c}\u{6f}\u{20}\u{77}\u{6f}\u{72}\u{6c}\u{64}";
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInStrings06_ES5.ts | TypeScript | // @target: es5
// ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp)
// 1. Assert: 0 ≤ cp ≤ 0x10FFFF.
var x = "\u{10FFFF}";
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInStrings06_ES6.ts | TypeScript | // @target: es6
// ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp)
// 1. Assert: 0 ≤ cp ≤ 0x10FFFF.
var x = "\u{10FFFF}";
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInStrings08_ES5.ts | TypeScript | // @target: es5
// ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp)
// 2. If cp ≤ 65535, return cp.
// (FFFF == 65535)
var x = "\u{FFFF}";
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInStrings08_ES6.ts | TypeScript | // @target: es6
// ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp)
// 2. If cp ≤ 65535, return cp.
// (FFFF == 65535)
var x = "\u{FFFF}";
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInStrings09_ES5.ts | TypeScript | // @target: es5
// ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp)
// 2. If cp ≤ 65535, return cp.
// (10000 == 65536)
var x = "\u{10000}";
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInStrings09_ES6.ts | TypeScript | // @target: es6
// ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp)
// 2. If cp ≤ 65535, return cp.
// (10000 == 65536)
var x = "\u{10000}";
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInStrings10_ES5.ts | TypeScript | // @target: es5
// ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp)
// 2. Let cu1 be floor((cp – 65536) / 1024) + 0xD800.
// Although we should just get back a single code point value of 0xD800,
// this is a useful edge-case test.
var x = "\u{D800}";
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInStrings10_ES6.ts | TypeScript | // @target: es6
// ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp)
// 2. Let cu1 be floor((cp – 65536) / 1024) + 0xD800.
// Although we should just get back a single code point value of 0xD800,
// this is a useful edge-case test.
var x = "\u{D800}";
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInStrings11_ES5.ts | TypeScript | // @target: es5
// ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp)
// 2. Let cu2 be ((cp – 65536) modulo 1024) + 0xDC00.
// Although we should just get back a single code point value of 0xDC00,
// this is a useful edge-case test.
var x = "\u{DC00}";
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInStrings11_ES6.ts | TypeScript | // @target: es6
// ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp)
// 2. Let cu2 be ((cp – 65536) modulo 1024) + 0xDC00.
// Although we should just get back a single code point value of 0xDC00,
// this is a useful edge-case test.
var x = "\u{DC00}";
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInStrings13_ES5.ts | TypeScript | // @target: es5
var x = "\u{DDDDD}";
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInStrings13_ES6.ts | TypeScript | // @target: es6
var x = "\u{DDDDD}";
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInStrings15_ES5.ts | TypeScript | // @target: es5
var x = "\u{abcd}\u{ef12}\u{3456}\u{7890}";
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInStrings15_ES6.ts | TypeScript | // @target: es6
var x = "\u{abcd}\u{ef12}\u{3456}\u{7890}";
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInStrings16_ES5.ts | TypeScript | // @target: es5
var x = "\u{ABCD}\u{EF12}\u{3456}\u{7890}";
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInStrings16_ES6.ts | TypeScript | // @target: es6
var x = "\u{ABCD}\u{EF12}\u{3456}\u{7890}";
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInStrings18_ES5.ts | TypeScript | // @target: es5
var x = "\u{65}\u{65}";
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInStrings18_ES6.ts | TypeScript | // @target: es6
var x = "\u{65}\u{65}";
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInStrings23_ES5.ts | TypeScript | // @target: es5
var x = "\u{00000000000067}";
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInStrings23_ES6.ts | TypeScript | // @target: es6
var x = "\u{00000000000067}";
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInTemplates01_ES5.ts | TypeScript | // @target: es5
var x = `\u{0}`;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInTemplates01_ES6.ts | TypeScript | // @target: es6
var x = `\u{0}`;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInTemplates02_ES5.ts | TypeScript | // @target: es5
var x = `\u{00}`;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInTemplates02_ES6.ts | TypeScript | // @target: es6
var x = `\u{00}`;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInTemplates03_ES5.ts | TypeScript | // @target: es5
var x = `\u{0000}`;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInTemplates03_ES6.ts | TypeScript | // @target: es6
var x = `\u{0000}`;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInTemplates04_ES5.ts | TypeScript | // @target: es5
var x = `\u{00000000}`;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInTemplates04_ES6.ts | TypeScript | // @target: es6
var x = `\u{00000000}`;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInTemplates05_ES5.ts | TypeScript | // @target: es5
var x = `\u{48}\u{65}\u{6c}\u{6c}\u{6f}\u{20}\u{77}\u{6f}\u{72}\u{6c}\u{64}`;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInTemplates05_ES6.ts | TypeScript | // @target: es6
var x = `\u{48}\u{65}\u{6c}\u{6c}\u{6f}\u{20}\u{77}\u{6f}\u{72}\u{6c}\u{64}`;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInTemplates06_ES5.ts | TypeScript | // @target: es5
// ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp)
// 1. Assert: 0 ≤ cp ≤ 0x10FFFF.
var x = `\u{10FFFF}`;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInTemplates06_ES6.ts | TypeScript | // @target: es6
// ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp)
// 1. Assert: 0 ≤ cp ≤ 0x10FFFF.
var x = `\u{10FFFF}`;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInTemplates08_ES5.ts | TypeScript | // @target: es5
// ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp)
// 2. If cp ≤ 65535, return cp.
// (FFFF == 65535)
var x = `\u{FFFF}`;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInTemplates08_ES6.ts | TypeScript | // @target: es6
// ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp)
// 2. If cp ≤ 65535, return cp.
// (FFFF == 65535)
var x = `\u{FFFF}`;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInTemplates09_ES5.ts | TypeScript | // @target: es5
// ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp)
// 2. If cp ≤ 65535, return cp.
// (10000 == 65536)
var x = `\u{10000}`;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInTemplates09_ES6.ts | TypeScript | // @target: es6
// ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp)
// 2. If cp ≤ 65535, return cp.
// (10000 == 65536)
var x = `\u{10000}`;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInTemplates10_ES5.ts | TypeScript | // @target: es5
// ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp)
// 2. Let cu1 be floor((cp – 65536) / 1024) + 0xD800.
// Although we should just get back a single code point value of 0xD800,
// this is a useful edge-case test.
var x = `\u{D800}`;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInTemplates10_ES6.ts | TypeScript | // @target: es6
// ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp)
// 2. Let cu1 be floor((cp – 65536) / 1024) + 0xD800.
// Although we should just get back a single code point value of 0xD800,
// this is a useful edge-case test.
var x = `\u{D800}`;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInTemplates11_ES5.ts | TypeScript | // @target: es5
// ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp)
// 2. Let cu2 be ((cp – 65536) modulo 1024) + 0xDC00.
// Although we should just get back a single code point value of 0xDC00,
// this is a useful edge-case test.
var x = `\u{DC00}`;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInTemplates11_ES6.ts | TypeScript | // @target: es6
// ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp)
// 2. Let cu2 be ((cp – 65536) modulo 1024) + 0xDC00.
// Although we should just get back a single code point value of 0xDC00,
// this is a useful edge-case test.
var x = `\u{DC00}`;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInTemplates13_ES5.ts | TypeScript | // @target: es5
var x = `\u{DDDDD}`;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInTemplates13_ES6.ts | TypeScript | // @target: es6
var x = `\u{DDDDD}`;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInTemplates15_ES5.ts | TypeScript | // @target: es5
var x = `\u{abcd}\u{ef12}\u{3456}\u{7890}`;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInTemplates15_ES6.ts | TypeScript | // @target: es6
var x = `\u{abcd}\u{ef12}\u{3456}\u{7890}`;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInTemplates16_ES5.ts | TypeScript | // @target: es5
var x = `\u{ABCD}\u{EF12}\u{3456}\u{7890}`;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInTemplates16_ES6.ts | TypeScript | // @target: es6
var x = `\u{ABCD}\u{EF12}\u{3456}\u{7890}`;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInTemplates18_ES5.ts | TypeScript | // @target: es5
var x = `\u{65}\u{65}`;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInTemplates18_ES6.ts | TypeScript | // @target: es6
var x = `\u{65}\u{65}`;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInTemplates20_ES5.ts | TypeScript | // @target: es5
var x = `\u{48}\u{65}\u{6c}\u{6c}\u{6f}${`\u{20}\u{020}\u{0020}\u{000020}`}\u{77}\u{6f}\u{72}\u{6c}\u{64}`;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInTemplates20_ES6.ts | TypeScript | // @target: es6
var x = `\u{48}\u{65}\u{6c}\u{6c}\u{6f}${`\u{20}\u{020}\u{0020}\u{000020}`}\u{77}\u{6f}\u{72}\u{6c}\u{64}`;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unionAndIntersectionInference1.ts | TypeScript | // @target: es2015
// Repro from #2264
interface Y { 'i am a very certain type': Y }
var y: Y = <Y>undefined;
function destructure<a, r>(
something: a | Y,
haveValue: (value: a) => r,
haveY: (value: Y) => r
): r {
return something === y ? haveY(y) : haveValue(<a>something);
}
var value = Math.random() > 0.5 ? 'hey!' : <Y>undefined;
var result = destructure(value, text => 'string', y => 'other one'); // text: string, y: Y
// Repro from #4212
function isVoid<a>(value: void | a): value is void {
return undefined;
}
function isNonVoid<a>(value: void | a) : value is a {
return undefined;
}
function foo1<a>(value: void|a): void {
if (isVoid(value)) {
value; // value is void
} else {
value; // value is a
}
}
function baz1<a>(value: void|a): void {
if (isNonVoid(value)) {
value; // value is a
} else {
value; // value is void
}
}
// Repro from #5417
type Maybe<T> = T | void;
function get<U>(x: U | void): U {
return null; // just an example
}
let foo: Maybe<string>;
get(foo).toUpperCase(); // Ok
// Repro from #5456
interface Man {
walks: boolean;
}
interface Bear {
roars: boolean;
}
interface Pig {
oinks: boolean;
}
declare function pigify<T>(y: T & Bear): T & Pig;
declare var mbp: Man & Bear;
pigify(mbp).oinks; // OK, mbp is treated as Pig
pigify(mbp).walks; // Ok, mbp is treated as Man
// Repros from #29815
interface ITest {
name: 'test'
}
const createTestAsync = (): Promise<ITest> => Promise.resolve().then(() => ({ name: 'test' }))
const createTest = (): ITest => {
return { name: 'test' }
}
declare function f1<T, U>(x: T | U): T | U;
declare function f2<T, U>(x: T, y: U): T | U;
let x1: string = f1('a');
let x2: string = f2('a', 'b');
// Repro from #30442
const func = <T>() => {};
const assign = <T, U>(a: T, b: U) => Object.assign(a, b);
const res: (() => void) & { func: any } = assign(() => {}, { func });
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unionAndIntersectionInference2.ts | TypeScript | declare function f1<T>(x: T | string): T;
var a1: string;
var b1: string | string[];
var c1: string[] | string;
var d1: string | { name: string };
var e1: number | string | boolean;
f1(a1); // string
f1(b1); // string[]
f1(c1); // string[]
f1(d1); // { name: string }
f1(e1); // number | boolean
declare function f2<T>(x: T & { name: string }): T;
var a2: string & { name: string };
var b2: { name: string } & string[];
var c2: string & { name: string } & number;
var d2: string & { name: string } & number & { name: string };
f2(a2); // string
f2(b2); // string[]
f2(c2); // never
f2(d2); // never
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unionAndIntersectionInference3.ts | TypeScript | // @strict: true
// @target: esnext
// Repro from #30720
type Maybe<T> = T | undefined;
declare function concatMaybe<T>(...args: (Maybe<T> | Maybe<T>[])[]): T[];
concatMaybe([1, 2, 3], 4);
// Repros from #32247
const g: <U, R, S>(com: () => Iterator<S, U, R> | AsyncIterator<S, U, R>) => Promise<U> = async <U, R, S>(com: () => Iterator<S, U, R> | AsyncIterator<S, U, R>): Promise<U> => {
throw com;
};
interface Foo1<T> {
test(value: T): void;
}
interface Bar1<T> {
test(value: T | PromiseLike<T>): void;
}
declare let f1: <T>(x: Foo1<T> | Bar1<T>) => Promise<T>;
declare let f2: <U>(x: Foo1<U> | Bar1<U>) => Promise<U>;
f1 = f2;
f2 = f1;
type Foo2<T> = {
test(value: T): void;
}
type Bar2<T> = {
test(value: T | PromiseLike<T>): void;
}
declare let g1: <T>(x: Foo2<T> | Bar2<T>) => Promise<T>;
declare let g2: <U>(x: Foo2<U> | Bar2<U>) => Promise<U>;
g1 = g2;
g2 = g1;
// Repro from #32572
declare function foo1<T>(obj: string[] & Iterable<T>): T;
declare function foo2<T>(obj: string[] & T): T;
declare let sa: string[];
declare let sx: string[] & { extra: number };
let x1 = foo1(sa); // string
let y1 = foo1(sx); // string
let x2 = foo2(sa); // unknown
let y2 = foo2(sx); // { extra: number }
// Repro from #33490
declare class Component<P> { props: P }
export type ComponentClass<P> = new (props: P) => Component<P>;
export type FunctionComponent<P> = (props: P) => null;
export type ComponentType<P> = FunctionComponent<P> | ComponentClass<P>;
export interface RouteComponentProps { route: string }
declare function withRouter<
P extends RouteComponentProps,
C extends ComponentType<P>
>(
component: C & ComponentType<P>
): ComponentClass<Omit<P, keyof RouteComponentProps>>;
interface Props extends RouteComponentProps { username: string }
declare const MyComponent: ComponentType<Props>;
withRouter(MyComponent);
// Repro from #33490
type AB<T> = { a: T } | { b: T };
// T & AB<U> normalizes to T & { a: U } | T & { b: U } below
declare function foo<T, U>(obj: T & AB<U>): [T, U];
declare let ab: AB<string>;
let z = foo(ab); // [AB<string>, string]
// Repro from #51399
declare let a: <T>() => (T extends true ? true : false) & boolean;
declare let b: <T>() => (T extends true ? true : false) & boolean;
a = b;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unionSubtypeIfEveryConstituentTypeIsSubtype.ts | TypeScript | enum e {
e1,
e2
}
// A union type U is a subtype of a type T if each type in U is a subtype of T
interface I {
[x: string]: any;
foo: string | number; // ok
foo2: e | number; // ok
}
interface I2 {
[x: string]: number;
// S is union type and each constituent type of S is a subtype of T
foo: string | number; // error string is not subtype of number
foo2: e | number; // ok e and number both subtype of number
}
interface I3 {
[x: string]: string;
foo: string | number; // error numer is not subtype of string
foo2: e | number; // error e and number both not subtype of string
}
// error cases
interface I4 {
[x: string]: boolean;
foo: string | number;
foo2: e | number;
}
interface I5 {
[x: string]: Date;
foo: string | number;
foo2: e | number;
}
interface I6 {
[x: string]: RegExp;
foo: string | number;
foo2: e | number;
}
interface I7 {
[x: string]: { bar: number };
foo: string | number;
foo2: e | number;
}
interface I8 {
[x: string]: number[];
foo: string | number;
foo2: e | number;
}
interface I9 {
[x: string]: I8;
foo: string | number;
foo2: e | number;
}
class A { foo: number; }
interface I10 {
[x: string]: A;
foo: string | number;
foo2: e | number;
}
class A2<T> { foo: T; }
interface I11 {
[x: string]: A2<number>;
foo: string | number;
foo2: e | number;
}
interface I12 {
[x: string]: (x) => number;
foo: string | number;
foo2: e | number;
}
interface I13 {
[x: string]: <T>(x: T) => T;
foo: string | number;
foo2: e | number;
}
enum E2 { A }
interface I14 {
[x: string]: E2;
foo: string | number;
foo2: e | number;
}
function f() { }
module f {
export var bar = 1;
}
interface I15 {
[x: string]: typeof f;
foo: string | number;
foo2: e | number;
}
class c { baz: string }
module c {
export var bar = 1;
}
interface I16 {
[x: string]: typeof c;
foo: string | number;
foo2: e | number;
}
interface I17<T> {
[x: string]: T;
foo: string | number;
foo2: e | number;
}
interface I19 {
[x: string]: Object;
foo: string | number;
foo2: e | number;
}
interface I20 {
[x: string]: {};
foo: string | number;
foo2: e | number;
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unionThisTypeInFunctions.ts | TypeScript | interface Real {
method(this: this, n: number): void;
data: string;
}
interface Fake {
method(this: this, n: number): void;
data: number;
}
function test(r: Real | Fake) {
r.method(12); // error
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unionTypeCallSignatures.ts | TypeScript | var numOrDate: number | Date;
var strOrBoolean: string | boolean;
var strOrNum: string | number;
// If each type in U has call signatures and the sets of call signatures are identical ignoring return types,
// U has the same set of call signatures, but with return types that are unions of the return types of the respective call signatures from each type in U.
var unionOfDifferentReturnType: { (a: number): number; } | { (a: number): Date; };
numOrDate = unionOfDifferentReturnType(10);
strOrBoolean = unionOfDifferentReturnType("hello"); // error
unionOfDifferentReturnType1(true); // error in type of parameter
var unionOfDifferentReturnType1: { (a: number): number; (a: string): string; } | { (a: number): Date; (a: string): boolean; };
numOrDate = unionOfDifferentReturnType1(10);
strOrBoolean = unionOfDifferentReturnType1("hello");
unionOfDifferentReturnType1(true); // error in type of parameter
unionOfDifferentReturnType1(); // error missing parameter
var unionOfDifferentParameterTypes: { (a: number): number; } | { (a: string): Date; };
unionOfDifferentParameterTypes(10);// error - no call signatures
unionOfDifferentParameterTypes("hello");// error - no call signatures
unionOfDifferentParameterTypes();// error - no call signatures
var unionOfDifferentNumberOfSignatures: { (a: number): number; } | { (a: number): Date; (a: string): boolean; };
unionOfDifferentNumberOfSignatures(); // error - no call signatures
unionOfDifferentNumberOfSignatures(10); // error - no call signatures
unionOfDifferentNumberOfSignatures("hello"); // error - no call signatures
var unionWithDifferentParameterCount: { (a: string): string; } | { (a: string, b: number): number; } ;
unionWithDifferentParameterCount();// needs more args
unionWithDifferentParameterCount("hello");// needs more args
unionWithDifferentParameterCount("hello", 10);// OK
var unionWithOptionalParameter1: { (a: string, b?: number): string; } | { (a: string, b?: number): number; };
strOrNum = unionWithOptionalParameter1('hello');
strOrNum = unionWithOptionalParameter1('hello', 10);
strOrNum = unionWithOptionalParameter1('hello', "hello"); // error in parameter type
strOrNum = unionWithOptionalParameter1(); // error
var unionWithOptionalParameter2: { (a: string, b?: number): string; } | { (a: string, b: number): number };
strOrNum = unionWithOptionalParameter2('hello'); // error no call signature
strOrNum = unionWithOptionalParameter2('hello', 10); // error no call signature
strOrNum = unionWithOptionalParameter2('hello', "hello"); // error no call signature
strOrNum = unionWithOptionalParameter2(); // error no call signature
var unionWithOptionalParameter3: { (a: string, b?: number): string; } | { (a: string): number; };
strOrNum = unionWithOptionalParameter3('hello');
strOrNum = unionWithOptionalParameter3('hello', 10); // ok
strOrNum = unionWithOptionalParameter3('hello', "hello"); // wrong argument type
strOrNum = unionWithOptionalParameter3(); // needs more args
var unionWithRestParameter1: { (a: string, ...b: number[]): string; } | { (a: string, ...b: number[]): number };
strOrNum = unionWithRestParameter1('hello');
strOrNum = unionWithRestParameter1('hello', 10);
strOrNum = unionWithRestParameter1('hello', 10, 11);
strOrNum = unionWithRestParameter1('hello', "hello"); // error in parameter type
strOrNum = unionWithRestParameter1(); // error
var unionWithRestParameter2: { (a: string, ...b: number[]): string; } | { (a: string, b: number): number };
strOrNum = unionWithRestParameter2('hello'); // error no call signature
strOrNum = unionWithRestParameter2('hello', 10); // error no call signature
strOrNum = unionWithRestParameter2('hello', 10, 11); // error no call signature
strOrNum = unionWithRestParameter2('hello', "hello"); // error no call signature
strOrNum = unionWithRestParameter2(); // error no call signature
var unionWithRestParameter3: { (a: string, ...b: number[]): string; } | { (a: string): number };
strOrNum = unionWithRestParameter3('hello');
strOrNum = unionWithRestParameter3('hello', 10); // error no call signature
strOrNum = unionWithRestParameter3('hello', 10, 11); // error no call signature
strOrNum = unionWithRestParameter3('hello', "hello"); // wrong argument type
strOrNum = unionWithRestParameter3(); // error no call signature
var unionWithRestParameter4: { (...a: string[]): string; } | { (a: string, b: string): number; };
strOrNum = unionWithRestParameter4("hello"); // error supplied parameters do not match any call signature
strOrNum = unionWithRestParameter4("hello", "world");
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unionTypeCallSignatures2.ts | TypeScript | interface A {
(x: number): number;
(x: string, y?: string): boolean;
(x: Date): void;
<T>(x: T[]): T[];
}
interface B {
(x: number): number;
(x: string): string;
(x: Date): void;
<T>(x: T[]): T[];
}
interface C {
(x: string, ...y: string[]): number;
(x: number, s?: string): number;
<T>(x: T[]): T[];
}
var f1: A | B | C;
var n1 = f1(42); // number
var s1 = f1("abc"); // boolean | string | number
var a1 = f1([true, false]); // boolean[]
var f2: C | B | A;
var n2 = f2(42); // number
var s2 = f2("abc"); // number | string | boolean
var a2 = f2([true, false]); // boolean[]
var f3: B | A | C;
var n3 = f3(42); // number
var s3 = f3("abc"); // string | boolean | number
var a3 = f3([true, false]); // boolean[]
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unionTypeCallSignatures3.ts | TypeScript | function f1(s: string) { }
function f2(s?: string) { }
function f3(...s: string[]) { }
function f4(s: string, s2?: string) { }
function f5(s?: string, n?: number) { }
function f6(s?: string, ...n: number[]) { }
function f7(s: string, ...sRest: string[]) { }
var fUnion: typeof f1 | typeof f2 | typeof f3 | typeof f4 | typeof f5 | typeof f6 | typeof f7;
fUnion(""); // All constituents can be called by passing a single string.
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unionTypeCallSignatures4.ts | TypeScript | type F1 = (a: string, b?: string) => void;
type F2 = (a: string, b?: string, c?: string) => void;
type F3 = (a: string, ...rest: string[]) => void;
type F4 = (a: string, b?: string, ...rest: string[]) => void;
type F5 = (a: string, b: string) => void;
var f12: F1 | F2;
f12("a");
f12("a", "b");
f12("a", "b", "c"); // ok
var f34: F3 | F4;
f34("a");
f34("a", "b");
f34("a", "b", "c");
var f1234: F1 | F2 | F3 | F4;
f1234("a");
f1234("a", "b");
f1234("a", "b", "c"); // ok
var f12345: F1 | F2 | F3 | F4 | F5;
f12345("a"); // error
f12345("a", "b");
f12345("a", "b", "c"); // error
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unionTypeCallSignatures5.ts | TypeScript | // #31485
interface A {
(this: void, b?: number): void;
}
interface B {
(this: number, b?: number): void;
}
interface C {
(i: number): void;
}
declare const fn: A | B | C;
fn(0);
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unionTypeCallSignatures6.ts | TypeScript | type A = { a: string };
type B = { b: number };
type C = { c: string };
type D = { d: number };
type F0 = () => void;
// #31547
type F1 = (this: A) => void;
type F2 = (this: B) => void;
declare var f1: F1 | F2;
f1(); // error
declare var f2: F0 | F1;
f2(); // error
interface F3 {
(this: A): void;
(this: B): void;
}
interface F4 {
(this: C): void;
(this: D): void;
}
interface F5 {
(this: C): void;
(this: B): void;
}
declare var x1: A & C & {
f0: F0 | F3;
f1: F1 | F3;
f2: F1 | F4;
f3: F3 | F4;
f4: F3 | F5;
}
x1.f0();
x1.f1();
x1.f2();
x1.f3(); // error
x1.f4(); // error
declare var x2: A & B & {
f4: F3 | F5;
}
x2.f4();
type F6 = (this: A & B) => void;
declare var f3: F1 | F6;
f3(); // error
interface F7 {
(this: A & B & C): void;
(this: A & B): void;
}
declare var f4: F6 | F7;
f4(); // error
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unionTypeCallSignatures7.ts | TypeScript | // @strict: true
// @noEmit: true
// https://github.com/microsoft/TypeScript/issues/55203
interface Callable<Name extends string> {
(): `${Name} without id`;
(id: number): `${Name} with id`;
}
declare const f: Callable<"A"> | Callable<"B">;
const result = f(123);
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unionTypeConstructSignatures.ts | TypeScript | var numOrDate: number | Date;
var strOrBoolean: string | boolean;
var strOrNum: string | number;
// If each type in U has construct signatures and the sets of construct signatures are identical ignoring return types,
// U has the same set of construct signatures, but with return types that are unions of the return types of the respective construct signatures from each type in U.
var unionOfDifferentReturnType: { new (a: number): number; } | { new (a: number): Date; };
numOrDate = new unionOfDifferentReturnType(10);
strOrBoolean = new unionOfDifferentReturnType("hello"); // error
new unionOfDifferentReturnType1(true); // error in type of parameter
var unionOfDifferentReturnType1: { new (a: number): number; new (a: string): string; } | { new (a: number): Date; new (a: string): boolean; };
numOrDate = new unionOfDifferentReturnType1(10);
strOrBoolean = new unionOfDifferentReturnType1("hello");
new unionOfDifferentReturnType1(true); // error in type of parameter
new unionOfDifferentReturnType1(); // error missing parameter
var unionOfDifferentParameterTypes: { new (a: number): number; } | { new (a: string): Date; };
new unionOfDifferentParameterTypes(10);// error - no call signatures
new unionOfDifferentParameterTypes("hello");// error - no call signatures
new unionOfDifferentParameterTypes();// error - no call signatures
var unionOfDifferentNumberOfSignatures: { new (a: number): number; } | { new (a: number): Date; new (a: string): boolean; };
new unionOfDifferentNumberOfSignatures(); // error - no call signatures
new unionOfDifferentNumberOfSignatures(10); // error - no call signatures
new unionOfDifferentNumberOfSignatures("hello"); // error - no call signatures
var unionWithDifferentParameterCount: { new (a: string): string; } | { new (a: string, b: number): number; };
new unionWithDifferentParameterCount();// needs more args
new unionWithDifferentParameterCount("hello");// needs more args
new unionWithDifferentParameterCount("hello", 10);// ok
var unionWithOptionalParameter1: { new (a: string, b?: number): string; } | { new (a: string, b?: number): number; };
strOrNum = new unionWithOptionalParameter1('hello');
strOrNum = new unionWithOptionalParameter1('hello', 10);
strOrNum = new unionWithOptionalParameter1('hello', "hello"); // error in parameter type
strOrNum = new unionWithOptionalParameter1(); // error
var unionWithOptionalParameter2: { new (a: string, b?: number): string; } | { new (a: string, b: number): number };
strOrNum = new unionWithOptionalParameter2('hello'); // error no call signature
strOrNum = new unionWithOptionalParameter2('hello', 10); // error no call signature
strOrNum = new unionWithOptionalParameter2('hello', "hello"); // error no call signature
strOrNum = new unionWithOptionalParameter2(); // error no call signature
var unionWithOptionalParameter3: { new (a: string, b?: number): string; } | { new (a: string): number; };
strOrNum = new unionWithOptionalParameter3('hello'); // error no call signature
strOrNum = new unionWithOptionalParameter3('hello', 10); // ok
strOrNum = new unionWithOptionalParameter3('hello', "hello"); // wrong type
strOrNum = new unionWithOptionalParameter3(); // error no call signature
var unionWithRestParameter1: { new (a: string, ...b: number[]): string; } | { new (a: string, ...b: number[]): number };
strOrNum = new unionWithRestParameter1('hello');
strOrNum = new unionWithRestParameter1('hello', 10);
strOrNum = new unionWithRestParameter1('hello', 10, 11);
strOrNum = new unionWithRestParameter1('hello', "hello"); // error in parameter type
strOrNum = new unionWithRestParameter1(); // error
var unionWithRestParameter2: { new (a: string, ...b: number[]): string; } | { new (a: string, b: number): number };
strOrNum = new unionWithRestParameter2('hello'); // error no call signature
strOrNum = new unionWithRestParameter2('hello', 10); // error no call signature
strOrNum = new unionWithRestParameter2('hello', 10, 11); // error no call signature
strOrNum = new unionWithRestParameter2('hello', "hello"); // error no call signature
strOrNum = new unionWithRestParameter2(); // error no call signature
var unionWithRestParameter3: { new (a: string, ...b: number[]): string; } | { new (a: string): number };
strOrNum = new unionWithRestParameter3('hello'); // error no call signature
strOrNum = new unionWithRestParameter3('hello', 10); // ok
strOrNum = new unionWithRestParameter3('hello', 10, 11); // ok
strOrNum = new unionWithRestParameter3('hello', "hello"); // wrong type
strOrNum = new unionWithRestParameter3(); // error no call signature
var unionWithAbstractSignature: (abstract new (a: string) => string) | (new (a: string) => string);
new unionWithAbstractSignature('hello');
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unionTypeEquivalence.ts | TypeScript | // A | B is equivalent to A if B is a subtype of A
class C { }
class D extends C { foo() { } }
var x: C;
var x : C | D;
// A | B is equivalent to B | A.
var y: string | number;
var y : number | string;
// AB | C is equivalent to A | BC, where AB is A | B and BC is B | C.
var z : string | number | boolean;
var z : (string | number) | boolean;
var z : string | (number | boolean);
var AB : string | number;
var BC : number | boolean;
var z1: typeof AB | boolean;
var z1: string | typeof BC;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unionTypeFromArrayLiteral.ts | TypeScript | // The resulting type an array literal expression is determined as follows:
// If the array literal is empty, the resulting type is an array type with the element type Undefined.
// Otherwise, if the array literal is contextually typed by a type that has a property with the numeric name ‘0’, the resulting type is a tuple type constructed from the types of the element expressions.
// Otherwise, the resulting type is an array type with an element type that is the union of the types of the element expressions.
var arr1 = [1, 2]; // number[]
var arr2 = ["hello", true]; // (string | number)[]
var arr3Tuple: [number, string] = [3, "three"]; // [number, string]
var arr4Tuple: [number, string] = [3, "three", "hello"]; // [number, string, string]
var arrEmpty = [];
var arr5Tuple: {
0: string;
5: number;
} = ["hello", true, false, " hello", true, 10, "any"]; // Tuple
class C { foo() { } }
class D { foo2() { } }
class E extends C { foo3() { } }
class F extends C { foo4() { } }
var c: C, d: D, e: E, f: F;
var arr6 = [c, d]; // (C | D)[]
var arr7 = [c, d, e]; // (C | D)[]
var arr8 = [c, e]; // C[]
var arr9 = [e, f]; // (E|F)[] | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unionTypeIdentity.ts | TypeScript | // Two types are considered identical when
// they are union types with identical sets of constituent types, or
var strOrNum: string | boolean;
var strOrNum: boolean | string;
var strOrNum: boolean | string | boolean;
var strOrNum: string; // error
var strOrNum: boolean; // error
var strOrNum: number; // error | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unionTypeIndexSignature.ts | TypeScript | var numOrDate: number | Date;
var anyVar: number;
// If each type in U has a string index signature,
// U has a string index signature of a union type of the types of the string index signatures from each type in U.
var unionOfDifferentReturnType: { [a: string]: number; } | { [a: string]: Date; };
numOrDate = unionOfDifferentReturnType["hello"]; // number | Date
numOrDate = unionOfDifferentReturnType[10]; // number | Date
var unionOfTypesWithAndWithoutStringSignature: { [a: string]: number; } | boolean;
anyVar = unionOfTypesWithAndWithoutStringSignature["hello"]; // any
anyVar = unionOfTypesWithAndWithoutStringSignature[10]; // any
// If each type in U has a numeric index signature,
// U has a numeric index signature of a union type of the types of the numeric index signatures from each type in U.
var unionOfDifferentReturnType1: { [a: number]: number; } | { [a: number]: Date; };
numOrDate = unionOfDifferentReturnType1["hello"]; // any
numOrDate = unionOfDifferentReturnType1[10]; // number | Date
var unionOfTypesWithAndWithoutStringSignature1: { [a: number]: number; } | boolean;
anyVar = unionOfTypesWithAndWithoutStringSignature1["hello"]; // any
anyVar = unionOfTypesWithAndWithoutStringSignature1[10]; // any | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unionTypeInference.ts | TypeScript | // @strict: true
// @target: esnext
declare const b: boolean;
declare const s: string;
declare const sn: string | number;
declare function f1<T>(x: T, y: string | T): T;
const a1 = f1(1, 2); // 1 | 2
const a2 = f1(1, "hello"); // 1
const a3 = f1(1, sn); // number
const a4 = f1(undefined, "abc"); // undefined
const a5 = f1("foo", "bar"); // "foo"
const a6 = f1(true, false); // boolean
const a7 = f1("hello", 1); // Error
declare function f2<T>(value: [string, T]): T;
var b1 = f2(["string", true]); // boolean
declare function f3<T>(x: string | false | T): T;
const c1 = f3(5); // 5
const c2 = f3(sn); // number
const c3 = f3(true); // true
const c4 = f3(b); // true
const c5 = f3("abc"); // never
declare function f4<T>(x: string & T): T;
const d1 = f4("abc");
const d2 = f4(s);
const d3 = f4(42); // Error
export interface Foo<T> {
then<U>(f: (x: T) => U | Foo<U>, g: U): Foo<U>;
}
export interface Bar<T> {
then<S>(f: (x: T) => S | Bar<S>, g: S): Bar<S>;
}
function qux(p1: Foo<void>, p2: Bar<void>) {
p1 = p2;
}
// Repros from #32434
declare function foo<T>(x: T | Promise<T>): void;
declare let x: false | Promise<true>;
foo(x);
declare function bar<T>(x: T, y: string | T): T;
const y = bar(1, 2);
// Repro from #32752
const containsPromises: unique symbol = Symbol();
type DeepPromised<T> =
{ [containsPromises]?: true } &
{ [TKey in keyof T]: T[TKey] | DeepPromised<T[TKey]> | Promise<DeepPromised<T[TKey]>> };
async function fun<T>(deepPromised: DeepPromised<T>) {
const deepPromisedWithIndexer: DeepPromised<{ [name: string]: {} | null | undefined }> = deepPromised;
for (const value of Object.values(deepPromisedWithIndexer)) {
const awaitedValue = await value;
if (awaitedValue)
await fun(awaitedValue);
}
}
// Repro from #32752
type Deep<T> = { [K in keyof T]: T[K] | Deep<T[K]> };
declare function baz<T>(dp: Deep<T>): T;
declare let xx: { a: string | undefined };
baz(xx);
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unionTypeLiterals.ts | TypeScript | // basic valid forms of union literals
var simpleUnion: string | number;
var unionOfUnion: string | number | boolean;
var arrayOfUnions: (string | number)[];
var arrayOfUnions: Array<string | number>;
var unionOfFunctionType: (() => string) | (() => number);
var unionOfFunctionType: { (): string } | { (): number };
var unionOfFunctionType: () => string | number;
var unionOfConstructorType: (new () => string) | (new () => number);
var unionOfConstructorType: { new (): string } | { new (): number };
var unionOfConstructorType: new () => string | number; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unionTypeMembers.ts | TypeScript | interface I1<T> {
commonMethodType(a: string): string;
commonPropertyType: string;
commonMethodDifferentParameterType(a: string): string;
commonMethodDifferentReturnType(a: string): string;
commonPropertyDifferenType: string;
commonMethodWithTypeParameter(a: T): T;
commonMethodWithOwnTypeParameter<U>(a: U): U;
methodOnlyInI1(a: string): string;
propertyOnlyInI1: string;
}
interface I2<T> {
commonMethodType(a: string): string;
commonPropertyType: string;
commonMethodDifferentParameterType(a: number): number;
commonMethodDifferentReturnType(a: string): number;
commonPropertyDifferenType: number;
commonMethodWithTypeParameter(a: T): T;
commonMethodWithOwnTypeParameter<U>(a: U): U;
methodOnlyInI2(a: string): string;
propertyOnlyInI2: string;
}
// a union type U has those members that are present in every one of its constituent types,
// with types that are unions of the respective members in the constituent types
var x : I1<number> | I2<number>;
var str: string;
var num: number;
var strOrNum: string | number;
// If each type in U has a property P, U has a property P of a union type of the types of P from each type in U.
str = x.commonPropertyType; // string
str = x.commonMethodType(str); // (a: string) => string so result should be string
strOrNum = x.commonPropertyDifferenType;
strOrNum = x.commonMethodDifferentReturnType(str); // string | union
x.commonMethodDifferentParameterType; // No error - property exists
x.commonMethodDifferentParameterType(strOrNum); // error - no call signatures because the type of this property is ((a: string) => string) | (a: number) => number
// and the call signatures arent identical
num = x.commonMethodWithTypeParameter(num);
num = x.commonMethodWithOwnTypeParameter(num);
str = x.commonMethodWithOwnTypeParameter(str);
strOrNum = x.commonMethodWithOwnTypeParameter(strOrNum);
x.propertyOnlyInI1; // error
x.propertyOnlyInI2; // error
x.methodOnlyInI1("hello"); // error
x.methodOnlyInI2(10); // error | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unionTypePropertyAccessibility.ts | TypeScript | class Default {
member: string;
}
class Public {
public member: string;
}
class Protected {
protected member: string;
}
class Private {
private member: number;
}
var v1: Default;
var v2: Public;
var v3: Protected;
var v4: Private;
var v5: Default | Public;
var v6: Default | Protected;
var v7: Default | Private;
var v8: Public | Protected;
var v9: Public | Private;
var v10: Protected | Private;
var v11: Default | Public | Protected;
var v12: Default | Public | Private;
var v13: Default | Protected | Private;
var v14: Public | Private | Protected;
var v15: Default | Public | Private | Protected;
v1.member;
v2.member;
v3.member;
v4.member;
v5.member;
v6.member;
v7.member;
v8.member;
v9.member;
v10.member;
v11.member;
v12.member;
v13.member;
v14.member;
v15.member;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/unionTypeReadonly.ts | TypeScript | interface Base {
readonly value: number;
}
interface Identical {
readonly value: number;
}
interface Mutable {
value: number;
}
interface DifferentType {
readonly value: string;
}
interface DifferentName {
readonly other: number;
}
let base: Base;
base.value = 12 // error, lhs can't be a readonly property
let identical: Base | Identical;
identical.value = 12; // error, lhs can't be a readonly property
let mutable: Base | Mutable;
mutable.value = 12; // error, lhs can't be a readonly property
let differentType: Base | DifferentType;
differentType.value = 12; // error, lhs can't be a readonly property
let differentName: Base | DifferentName;
differentName.value = 12; // error, property 'value' doesn't exist
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.