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/newWithSpreadES5.ts | TypeScript | //@target: ES5
function f(x: number, y: number, ...z: string[]) {
}
function f2(...x: string[]) {}
interface A {
f: {
new (x: number, y: number, ...z: string[]);
}
}
class B {
constructor(x: number, y: number, ...z: string[]) {}
}
interface C {
"a-b": typeof B;
}
interface D {
1: typeo... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/newWithSpreadES6.ts | TypeScript | //@target: ES6
function f(x: number, y: number, ...z: string[]) {
}
function f2(...x: string[]) {
}
interface A {
f: {
new (x: number, y: number, ...z: string[]);
}
}
class B {
constructor(x: number, y: number, ...z: string[]) {}
}
interface C {
"a-b": typeof B;
}
interface D {
1: type... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/noAssertForUnparseableTypedefs.ts | TypeScript | // @noEmit: true
// @allowJs: true
// @checkJs: true
// @Filename: bug26693.js
/** @typedef {module:locale} hi */
import { nope } from 'nope';
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/noDuplicateJsdoc1.ts | TypeScript | // @allowJs: true
// @checkJs: true
// @noEmit: true
// @Filename: a.js
/** doc */
const a = b = () => 0;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/noInfer.ts | TypeScript | // @strict: true
// @declaration: true
// NoInfer<T> is erased for primitives
type T00 = NoInfer<string>;
type T01 = NoInfer<string | number | boolean>;
type T02 = NoInfer<undefined>;
type T03 = NoInfer<"foo">;
type T04 = NoInfer<`foo${string}`>;
type T05 = NoInfer<`foo${string}` & `${string}bar`>;
type T06 = NoInfer... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/noInferRedeclaration.ts | TypeScript | // @strict: true
// @declaration: true
// @target: esnext
// @filename: a.ts
export const f = <T>(x: T, y: NoInfer<T>) => x;
// @filename: b.ts
import { f } from "./a";
type NoInfer<T> = T & number;
export const g = f;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/noPropertyAccessFromIndexSignature1.ts | TypeScript | // @noPropertyAccessFromIndexSignature: true
interface A {
foo: string
}
interface B {
[k: string]: string
}
interface C {
foo: string
[k: string]: string
}
declare const a: A;
declare const b: B;
declare const c: C;
declare const d: C | undefined;
// access property
a.foo;
a["foo"]
// access inde... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/noUncheckedIndexedAccess.ts | TypeScript | // @strict: true
// @noUncheckedIndexedAccess: true
type CheckBooleanOnly<T extends boolean> = any;
// Validate CheckBooleanOnly works - should error
type T_ERR1 = CheckBooleanOnly<boolean | undefined>;
enum NumericEnum1 { A, B, C }
enum NumericEnum2 { A = 0, B = 1 , C = 2 }
enum StringEnum1 { A = "Alpha", B = "Beta"... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/noUncheckedIndexedAccessDestructuring.ts | TypeScript | // @strict: true
// @noUncheckedIndexedAccess: true
declare const strArray: string[];
declare const strStrTuple: [string, string];
// Declaration forms for array destructuring
// Destructuring from a simple array -> include undefined
const [s1] = strArray;
s1.toString(); // Should error, s1 possibly undefined
// De... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nodeModulesAllowJsCjsFromJs.ts | TypeScript | // @module: node16,nodenext
// @allowJs: true
// @noEmit: true
// @filename: foo.cjs
exports.foo = "foo"
// @filename: bar.ts
import foo from "./foo.cjs"
foo.foo; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nodeModulesAllowJsExportlessJsModuleDetectionAuto.ts | TypeScript | // @module: node16,nodenext
// @allowJs: true
// @outDir: ./out
// @moduleDetection: auto
// @filename: foo.cjs
// this file is a module despite having no imports
// @filename: bar.js
// however this file is _not_ a module | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nodeModulesAtTypesPriority.ts | TypeScript | // @module: node16
// @strict: true
// @noEmit: true
// @traceResolution: true
// @Filename: /node_modules/@types/react/index.d.ts
declare const React: any;
export = React;
// @Filename: /node_modules/@types/redux/index.d.ts
export declare function createStore(): void;
// @Filename: /packages/a/node_modules/react/in... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nodeModulesCJSResolvingToESM1_emptyPackageJson.ts | TypeScript | // @noEmit: true
// @noTypesAndSymbols: true
// @module: node16
// @allowJs: true
// @checkJs: true
// @jsx: preserve
// @Filename: /package.json
{}
// @Filename: /module.mts
export {};
// @Filename: /tsExtension.ts
import {} from "./module.mjs";
// @Filename: /jsExtension.js
import {} from "./module.mjs";
// @Fil... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nodeModulesCJSResolvingToESM4_noPackageJson.ts | TypeScript | // @noEmit: true
// @noTypesAndSymbols: true
// @module: node16
// @allowJs: true
// @checkJs: true
// @jsx: preserve
// @Filename: /module.mts
export {};
// @Filename: /tsExtension.ts
import {} from "./module.mjs";
// @Filename: /jsExtension.js
import {} from "./module.mjs";
// @Filename: /ctsExtension.cts
import ... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nominalSubtypeCheckOfTypeParameter.ts | TypeScript | interface BinaryTuple<T, S> {
first: T
second: S
}
interface Sequence<T> {
hasNext(): boolean
pop(): T
zip<S>(seq: Sequence<S>): Sequence<BinaryTuple<T, S>>
}
// error, despite the fact that the code explicitly says List<T> extends Sequence<T>, the current rules for infinitely expanding type refer... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nominalSubtypeCheckOfTypeParameter2.ts | TypeScript | interface B<T> {
bar: T;
}
// ok
interface A<T> extends B<T> {
foo: T;
}
// ok
interface A2<T> extends B<B<string>> {
baz: T;
}
interface C<T> {
bam: T;
}
// ok
interface A3<T> extends B<C<T>> {
bing: T;
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nonGenericTypeReferenceWithTypeArguments.ts | TypeScript | // Check that errors are reported for non-generic types with type arguments
class C { }
interface I { }
enum E { }
type T = { };
var v1: C<string>;
var v2: I<string>;
var v3: E<string>;
var v4: T<string>;
function f<U>() {
class C { }
interface I { }
enum E { }
type T = {};
var v1: C<string>;
... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nonInstantiatedModule.ts | TypeScript | module M {
export interface Point { x: number; y: number }
export var a = 1;
}
// primary expression
var m : typeof M;
var m = M;
var a1: number;
var a1 = M.a;
var a2: number;
var a2 = m.a;
module M2 {
export module Point {
export function Origin(): Point {
return { x: 0, y: 0 };
... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nonIterableRestElement1.ts | TypeScript | var c = {};
[...c] = ["", 0]; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nonIterableRestElement2.ts | TypeScript | //@target: ES6
var c = {};
[...c] = ["", 0]; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nonIterableRestElement3.ts | TypeScript | var c = { bogus: 0 };
[...c] = ["", 0]; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nonPrimitiveAccessProperty.ts | TypeScript | var a: object;
a.toString();
a.nonExist(); // error
var { destructuring } = a; // error
var { ...rest } = a; // ok
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nonPrimitiveAndEmptyObject.ts | TypeScript | // @strict: true
// @declaration: true
// Repro from #49480
export interface BarProps {
barProp?: string;
}
export interface FooProps {
fooProps?: BarProps & object;
}
declare const foo: FooProps;
const { fooProps = {} } = foo;
fooProps.barProp;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nonPrimitiveAndTypeVariables.ts | TypeScript | // @strict: true
// Repros from #23800
type A<T, V> = { [P in keyof T]: T[P] extends V ? 1 : 0; };
type B<T, V> = { [P in keyof T]: T[P] extends V | object ? 1 : 0; };
let a: A<{ a: 0 | 1 }, 0> = { a: 0 };
let b: B<{ a: 0 | 1 }, 0> = { a: 0 };
function foo<T, U>(x: T) {
let a: object = x; // Error
let b: U... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nonPrimitiveAsProperty.ts | TypeScript | // @declaration: true
interface WithNonPrimitive {
foo: object
}
var a: WithNonPrimitive = { foo: {bar: "bar"} };
var b: WithNonPrimitive = {foo: "bar"}; // expect error
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nonPrimitiveAssignError.ts | TypeScript | var x = {};
var y = {foo: "bar"};
var a: object;
x = a;
y = a; // expect error
a = x;
a = y;
var n = 123;
var b = true;
var s = "fooo";
a = n; // expect error
a = b; // expect error
a = s; // expect error
n = a; // expect error
b = a; // expect error
s = a; // expect error
var numObj: Number = 123;
var boolObj: Boo... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nonPrimitiveConstraintOfIndexAccessType.ts | TypeScript | // @strict: true
// test for #15371
function f<T extends object, P extends keyof T>(s: string, tp: T[P]): void {
tp = s;
}
function g<T extends null, P extends keyof T>(s: string, tp: T[P]): void {
tp = s;
}
function h<T extends undefined, P extends keyof T>(s: string, tp: T[P]): void {
tp = s;
}
function i... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nonPrimitiveInFunction.ts | TypeScript | // @declaration: true
function takeObject(o: object) {}
function returnObject(): object {
return {};
}
var nonPrimitive: object;
var primitive: boolean;
takeObject(nonPrimitive);
nonPrimitive = returnObject();
takeObject(primitive); // expect error
primitive = returnObject(); // expect error
function returnErro... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nonPrimitiveInGeneric.ts | TypeScript | // @declaration: true
function generic<T>(t: T) {
var o: object = t; // expect error
}
var a = {};
var b = "42";
generic<object>({});
generic<object>(a);
generic<object>(123); // expect error
generic<object>(b); // expect error
function bound<T extends object>(t: T) {
var o: object = t; // ok
}
bound({});
bo... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nonPrimitiveIndexingWithForIn.ts | TypeScript | var a: object;
for (var key in a) {
var value = a[key];
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nonPrimitiveIndexingWithForInNoImplicitAny.ts | TypeScript | // @noImplicitAny: true
var a: object;
for (var key in a) {
var value = a[key]; // error
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nonPrimitiveIndexingWithForInSupressError.ts | TypeScript | // @noImplicitAny: true
// @suppressImplicitAnyIndexErrors: true
var a: object;
for (var key in a) {
var value = a[key];
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nonPrimitiveNarrow.ts | TypeScript | class Narrow {
narrowed: boolean
}
var a: object
if (a instanceof Narrow) {
a.narrowed; // ok
a = 123; // error
}
if (typeof a === 'number') {
a.toFixed(); // error, never
}
var b: object | null
if (typeof b === 'object') {
b.toString(); // ok, object | null
} else {
b.toString(); // error, n... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nonPrimitiveRhsSideOfInExpression.ts | TypeScript | let o: object = {};
function f(): object {
return {};
}
const b1 = "foo" in o;
const b2 = "bar" in f(); | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nonPrimitiveUnionIntersection.ts | TypeScript | // @declaration: true
var a: object & string = ""; // error
var b: object | string = ""; // ok
var c: object & {} = 123; // error
a = b; // error
b = a; // ok
const foo: object & {} = {bar: 'bar'}; // ok
const bar: object & {err: string} = {bar: 'bar'}; // error
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nullAssignableToEveryType.ts | TypeScript | class C {
foo: string;
}
var ac: C;
interface I {
foo: string;
}
var ai: I;
enum E { A }
var ae: E;
var b: number = null;
var c: string = null;
var d: boolean = null;
var e: Date = null;
var f: any = null;
var g: void = null;
var h: Object = null;
var i: {} = null;
var j: () => {} = null;
var k: Function = nu... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nullAssignedToUndefined.ts | TypeScript | var x = undefined = null; // error
var y: typeof undefined = null; // ok, widened | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nullIsSubtypeOfEverythingButUndefined.ts | TypeScript | // null is a subtype of any other types except undefined
var r0 = true ? null : null;
var r0 = true ? null : null;
var u: typeof undefined;
var r0b = true ? u : null;
var r0b = true ? null : u;
var r1 = true ? 1 : null;
var r1 = true ? null : 1;
var r2 = true ? '' : null;
var r2 = true ? null : '';
var r3 = true ?... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nullOrUndefinedTypeGuardIsOrderIndependent.ts | TypeScript | // @strictNullChecks: true
function test(strOrNull: string | null, strOrUndefined: string | undefined) {
var str: string = "original";
var nil: null;
if (null === strOrNull) {
nil = strOrNull;
}
else {
str = strOrNull;
}
if (undefined !== strOrUndefined) {
str = strOr... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nullPropertyName.ts | TypeScript | // @declaration: true
function foo() {}
// properties
foo.x = 1;
foo.y = 1;
// keywords
foo.break = 1;
foo.case = 1;
foo.catch = 1;
foo.class = 1;
foo.const = 1;
foo.continue = 1;
foo.debugger = 1;
foo.default = 1;
foo.delete = 1;
foo.do = 1;
foo.else = 1;
foo.enum = 1;
foo.export = 1;
foo.extends = 1;
foo.false = 1;... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nullishCoalescingOperator1.ts | TypeScript | // @strict: true
// @allowUnreachableCode: false
declare const a1: string | undefined | null
declare const a2: string | undefined | null
declare const a3: string | undefined | null
declare const a4: string | undefined | null
declare const b1: number | undefined | null
declare const b2: number | undefined | null
decla... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nullishCoalescingOperator10.ts | TypeScript | // @strict: true
declare function f(): string | undefined;
let gg = f() ?? 'foo'
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nullishCoalescingOperator11.ts | TypeScript | // @strict: true
declare const f11: 1 | 0 | '' | null | undefined;
let g11 = f11 ?? f11.toFixed()
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nullishCoalescingOperator12.ts | TypeScript | // @strict: true
// @target: ES2015
const obj: { arr: any[] } = { arr: [] };
for (const i of obj?.arr ?? []) { }
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nullishCoalescingOperator2.ts | TypeScript | // @strict: true
declare const a1: 'literal' | undefined | null
declare const a2: '' | undefined | null
declare const a3: 1 | undefined | null
declare const a4: 0 | undefined | null
declare const a5: true | undefined | null
declare const a6: false | undefined | null
declare const a7: unknown | null
declare const a8: n... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nullishCoalescingOperator3.ts | TypeScript | // @strict: true
declare const a1: 'literal' | undefined | null
declare const a2: '' | undefined | null
declare const a3: 1 | undefined | null
declare const a4: 0 | undefined | null
declare const a5: true | undefined | null
declare const a6: false | undefined | null
const aa1 = a1 ?? a2 ?? a3 ?? a4 ?? a5 ?? a6 ?? 'w... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nullishCoalescingOperator4.ts | TypeScript | // @strict: true
declare const a1: 'literal' | undefined | null
const aa1 = a1 ?? a1.toLowerCase()
const aa2 = a1 || a1.toLocaleUpperCase()
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nullishCoalescingOperator5.ts | TypeScript | // @strict: true
declare const a: string | undefined
declare const b: string | undefined
declare const c: string | undefined
// should be a syntax error
a ?? b || c;
// should be a syntax error
a || b ?? c;
// should be a syntax error
a ?? b && c;
// should be a syntax error
a && b ?? c;
// Valid according to spe... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nullishCoalescingOperator6.ts | TypeScript | // @strict: true
function foo(foo: string, bar = foo ?? "bar") { }
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nullishCoalescingOperator7.ts | TypeScript | // @strict: true
declare const a: string | undefined;
declare const b: string | undefined;
declare const c: string | undefined;
const foo1 = a ? 1 : 2;
const foo2 = a ?? 'foo' ? 1 : 2;
const foo3 = a ?? 'foo' ? (b ?? 'bar') : (c ?? 'baz');
function f () {
const foo4 = a ?? 'foo' ? b ?? 'bar' : c ?? 'baz';
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nullishCoalescingOperator8.ts | TypeScript | // @strict: true
declare const a: { p: string | undefined, m(): string | undefined };
declare const b: { p: string | undefined, m(): string | undefined };
const n1 = a.p ?? "default";
const n2 = a.m() ?? "default";
const n3 = a.m() ?? b.p ?? b.m() ?? "default";;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nullishCoalescingOperator9.ts | TypeScript | // @strict: true
declare let f: null | ((x: string) => void);
let g = f || (abc => { void abc.toLowerCase() })
let gg = f ?? (abc => { void abc.toLowerCase() })
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nullishCoalescingOperatorInAsyncGenerator.ts | TypeScript | // @target: esnext,es2015,es5
// @lib: esnext
// @noEmitHelpers: true
// @noTypesAndSymbols: true
// https://github.com/microsoft/TypeScript/issues/37686
async function* f(a: { b?: number }) {
let c = a.b ?? 10;
while (c) {
yield c--;
}
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nullishCoalescingOperatorInParameterBindingPattern.2.ts | TypeScript | // @target: esnext,es2015,es5
// @noTypesAndSymbols: true
// @noEmit: true
// https://github.com/microsoft/TypeScript/issues/36295
const a = (): string | undefined => undefined;
(({ [a() ?? "d"]: c = "" }) => { var a; })();
const x = "";
(({ [a() ?? "d"]: c = "", d = x }) => { var x; })(); | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nullishCoalescingOperatorInParameterBindingPattern.ts | TypeScript | // @target: esnext,es2015,es5
// @noTypesAndSymbols: true
// https://github.com/microsoft/TypeScript/issues/36295
const a = (): string | undefined => undefined;
(({ [a() ?? "d"]: c = "" }) => {})(); | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nullishCoalescingOperatorInParameterInitializer.2.ts | TypeScript | // @target: esnext,es2015,es5
// @noTypesAndSymbols: true
// @noEmit: true
// https://github.com/microsoft/TypeScript/issues/36295
const a = (): string | undefined => undefined;
((b = a() ?? "d") => { var a; })();
const x = "";
((b = a() ?? "d", d = x) => { var x; })(); | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nullishCoalescingOperatorInParameterInitializer.ts | TypeScript | // @target: esnext,es2015,es5
// @noTypesAndSymbols: true
// https://github.com/microsoft/TypeScript/issues/36295
const a = (): string | undefined => undefined;
((b = a() ?? "d") => {})(); | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nullishCoalescingOperator_es2020.ts | TypeScript | // @strict: true
// @target: es2020
declare const a1: 'literal' | undefined | null
declare const a2: '' | undefined | null
declare const a3: 1 | undefined | null
declare const a4: 0 | undefined | null
declare const a5: true | undefined | null
declare const a6: false | undefined | null
declare const a7: unknown | null
... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/nullishCoalescingOperator_not_strict.ts | TypeScript | // @strict: false
declare const a1: 'literal' | undefined | null
declare const a2: '' | undefined | null
declare const a3: 1 | undefined | null
declare const a4: 0 | undefined | null
declare const a5: true | undefined | null
declare const a6: false | undefined | null
declare const a7: unknown | null
declare const a8: ... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/numberAssignableToEnum.ts | TypeScript | enum E { A }
var n: number;
var e: E;
e = n;
n = e; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/numberPropertyAccess.ts | TypeScript | var x = 1;
var a = x.toExponential();
var b = x.hasOwnProperty('toFixed');
var c = x['toExponential']();
var d = x['hasOwnProperty']('toFixed'); | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/numericIndexerConstrainsPropertyDeclarations.ts | TypeScript | // String indexer types constrain the types of named properties in their containing type
interface MyNumber extends Number {
foo: number;
}
class C {
[x: number]: string;
constructor() { } // ok
a: string; // ok
b: number; // ok
c: () => {} // ok
"d": string; // ok
"e": number; // ok... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/numericIndexerConstrainsPropertyDeclarations2.ts | TypeScript | // String indexer providing a constraint of a user defined type
class A {
foo(): string { return ''; }
}
class B extends A {
bar(): string { return ''; }
}
class Foo {
[x: number]: A;
1.0: A; // ok
2.0: B; // ok
"2.5": B // ok
3.0: number; // error
"4.0": string; // error
}
interface... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/numericIndexingResults.ts | TypeScript | class C {
[x: number]: string;
1 = '';
"2" = ''
}
var c: C;
var r1 = c['1'];
var r2 = c['2'];
var r3 = c['3'];
var r4 = c[1];
var r5 = c[2];
var r6 = c[3];
interface I {
[x: number]: string;
1: string;
"2": string;
}
var i: I
var r1 = i['1'];
var r2 = i['2'];
var r3 = i['3'];
var r4 = i[1];
v... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/numericLiteralTypes1.ts | TypeScript | type A1 = 1;
type A2 = 1.0;
type A3 = 1e0;
type A4 = 10e-1;
type A5 = 1 | 1.0 | 1e0 | 10e-1;
function f1() {
var a: A1 = 1;
var a: A2 = 1;
var a: A3 = 1;
var a: A4 = 1;
var a: A5 = 1;
}
type B1 = -1 | 0 | 1;
type B2 = 1 | 0 | -1;
type B3 = 0 | -1 | 1;
function f2() {
var b: B1 = -1;
var b... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/numericLiteralTypes2.ts | TypeScript | // @strictNullChecks: true
type A1 = 1;
type A2 = 1.0;
type A3 = 1e0;
type A4 = 10e-1;
type A5 = 1 | 1.0 | 1e0 | 10e-1;
function f1() {
var a: A1 = 1;
var a: A2 = 1;
var a: A3 = 1;
var a: A4 = 1;
var a: A5 = 1;
}
type B1 = -1 | 0 | 1;
type B2 = 1 | 0 | -1;
type B3 = 0 | -1 | 1;
function f2() {
... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/numericLiteralTypes3.ts | TypeScript | type A = 1;
type B = 2 | 3;
type C = 1 | 2 | 3;
type D = 0 | 1 | 2;
function f1(a: A, b: B, c: C, d: D) {
a = a;
a = b;
a = c;
a = d;
}
function f2(a: A, b: B, c: C, d: D) {
b = a;
b = b;
b = c;
b = d;
}
function f3(a: A, b: B, c: C, d: D) {
c = a;
c = b;
c = c;
c = d;... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/numericStringLiteralTypes.ts | TypeScript | // @strict: true
// @declaration: true
type T0 = string & `${string}`; // string
type T1 = string & `${number}`; // `${number}
type T2 = string & `${bigint}`; // `${bigint}
type T3<T extends string> = string & `${T}`; // `${T}
type T4<T extends string> = string & `${Capitalize<`${T}`>}`; // `${Capitalize<T>}`
fu... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectBindingPatternKeywordIdentifiers05.ts | TypeScript |
var { as } = { as: 1 } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectBindingPatternKeywordIdentifiers06.ts | TypeScript |
var { as: as } = { as: 1 } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectLiteralContextualTyping.ts | TypeScript | // In a contextually typed object literal, each property value expression is contextually typed by
// the type of the property with a matching name in the contextual type, if any, or otherwise
// for a numerically named property, the numeric index type of the contextual type, if any, or otherwise
// the ... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectLiteralGettersAndSetters.ts | TypeScript | // Get and set accessor with the same name
var sameName1a = { get 'a'() { return ''; }, set a(n) { var p = n; var p: string; } };
var sameName2a = { get 0.0() { return ''; }, set 0(n) { var p = n; var p: string; } };
var sameName3a = { get 0x20() { return ''; }, set 3.2e1(n) { var p = n; var p: string; } };
var sameNam... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectLiteralNormalization.ts | TypeScript | // @strict: true
// @declaration: true
// Object literals in unions are normalized upon widening
let a1 = [{ a: 0 }, { a: 1, b: "x" }, { a: 2, b: "y", c: true }][0];
a1.a; // number
a1.b; // string | undefined
a1.c; // boolean | undefined
a1 = { a: 1 };
a1 = { a: 0, b: 0 }; // Error
a1 = { b: "y" }; // Error
a1 =... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectLiteralShorthandProperties.ts | TypeScript | // @target: es5
var a, b, c;
var x1 = {
a
};
var x2 = {
a,
}
var x3 = {
a: 0,
b,
c,
d() { },
x3,
parent: x3
};
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectLiteralShorthandPropertiesAssignment.ts | TypeScript | // @lib: es5
var id: number = 10000;
var name: string = "my name";
var person: { name: string; id: number } = { name, id };
function foo( obj:{ name: string }): void { };
function bar(name: string, id: number) { return { name, id }; }
function bar1(name: string, id: number) { return { name }; }
function baz(name: str... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectLiteralShorthandPropertiesAssignmentES6.ts | TypeScript | // @lib: es5
// @target: es6
var id: number = 10000;
var name: string = "my name";
var person: { name: string; id: number } = { name, id };
function foo(obj: { name: string }): void { };
function bar(name: string, id: number) { return { name, id }; }
function bar1(name: string, id: number) { return { name }; }
functi... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectLiteralShorthandPropertiesAssignmentError.ts | TypeScript | // @lib: es5
var id: number = 10000;
var name: string = "my name";
var person: { b: string; id: number } = { name, id }; // error
var person1: { name, id }; // ok
function foo(name: string, id: number): { id: string, name: number } { return { name, id }; } // error
function bar(obj: { name: string; id: boolean }) ... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts | TypeScript | // @lib: es5
var id: number = 10000;
var name: string = "my name";
var person: { b: string; id: number } = { name, id }; // error
function bar(name: string, id: number): { name: number, id: string } { return { name, id }; } // error
function foo(name: string, id: number): { name: string, id: number } { return { nam... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectLiteralShorthandPropertiesES6.ts | TypeScript | // @target: es6
var a, b, c;
var x1 = {
a
};
var x2 = {
a,
}
var x3 = {
a: 0,
b,
c,
d() { },
x3,
parent: x3
};
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectLiteralShorthandPropertiesFunctionArgument.ts | TypeScript | // @lib: es5
var id: number = 10000;
var name: string = "my name";
var person = { name, id };
function foo(p: { name: string; id: number }) { }
foo(person);
var obj = { name: name, id: id }; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectLiteralShorthandPropertiesFunctionArgument2.ts | TypeScript | // @lib: es5
var id: number = 10000;
var name: string = "my name";
var person = { name, id };
function foo(p: { a: string; id: number }) { }
foo(person); // error
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectLiteralShorthandPropertiesWithModule.ts | TypeScript | // module export
module m {
export var x;
}
module m {
var z = x;
var y = {
a: x,
x
};
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectLiteralShorthandPropertiesWithModuleES6.ts | TypeScript | // @target: es6
module m {
export var x;
}
module m {
var z = x;
var y = {
a: x,
x
};
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectLiteralWidened.ts | TypeScript | // object literal properties are widened to any
var x1 = {
foo: null,
bar: undefined
}
var y1 = {
foo: null,
bar: {
baz: null,
boo: undefined
}
}
// these are not widened
var u: undefined = undefined;
var n: null = null;
var x2 = {
foo: n,
bar: u
}
var y2 = {
foo: n... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectRest.ts | TypeScript | // @target: es2015
var o = { a: 1, b: 'no' }
var { ...clone } = o;
var { a, ...justB } = o;
var { a, b: renamed, ...empty } = o;
var { ['b']: renamed, ...justA } = o;
var { 'b': renamed, ...justA } = o;
var { b: { '0': n, '1': oooo }, ...justA } = o;
let o2 = { c: 'terrible idea?', d: 'yes' };
var { d: renamed, ...d }... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectRest2.ts | TypeScript | // @lib: es2015
// @target: es2015
// test for #12203
declare function connectionFromArray(objects: number, args: any): {};
function rootConnection(name: string) {
return {
resolve: async (context, args) => {
const { objects } = await { objects: 12 };
return {
...connectionFromArray(objects,... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectRestAssignment.ts | TypeScript | // @target: es2015
let ka: any;
let nested: { ki };
let other: number;
let rest: { };
let complex: { x: { ka, ki }, y: number };
({x: { ka, ...nested }, y: other, ...rest} = complex);
// should be:
let overEmit: { a: { ka: string, x: string }[], b: { z: string, ki: string, ku: string }, ke: string, ko: string };
// v... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectRestCatchES5.ts | TypeScript | let a = 1, b = 2;
try {} catch ({ a, ...b }) {} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectRestForOf.ts | TypeScript | // @target: es2015
let array: { x: number, y: string }[];
for (let { x, ...restOf } of array) {
[x, restOf];
}
let xx: number;
let rrestOff: { y: string };
for ({ x: xx, ...rrestOff } of array ) {
[xx, rrestOff];
}
for (const norest of array.map(a => ({ ...a, x: 'a string' }))) {
[norest.x, norest.y];
/... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectRestNegative.ts | TypeScript | // @noImplicitAny: true
let o = { a: 1, b: 'no' };
var { ...mustBeLast, a } = o;
var b: string;
let notAssignable: { a: string };
({ b, ...notAssignable } = o);
function stillMustBeLast({ ...mustBeLast, a }: { a: number, b: string }): void {
}
function generic<T extends { x, y }>(t: T) {
let { x, ...rest } = t;
... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectRestParameter.ts | TypeScript | // @target: es2015
function cloneAgain({ a, ...clone }: { a: number, b: string }): void {
}
declare function suddenly(f: (a: { x: { z, ka }, y: string }) => void);
suddenly(({ x: a, ...rest }) => rest.y);
suddenly(({ x: { z = 12, ...nested }, ...rest } = { x: { z: 1, ka: 1 }, y: 'noo' }) => rest.y + nested.ka);
class... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectRestParameterES5.ts | TypeScript | // @target: es5
function cloneAgain({ a, ...clone }: { a: number, b: string }): void {
}
declare function suddenly(f: (a: { x: { z, ka }, y: string }) => void);
suddenly(({ x: a, ...rest }) => rest.y);
suddenly(({ x: { z = 12, ...nested }, ...rest } = { x: { z: 1, ka: 1 }, y: 'noo' }) => rest.y + nested.ka);
class C ... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectRestPropertyMustBeLast.ts | TypeScript | var {...a, x } = { x: 1 }; // Error, rest must be last property
({...a, x } = { x: 1 }); // Error, rest must be last property
var {...a, x, ...b } = { x: 1 }; // Error, rest must be last property
({...a, x, ...b } = { x: 1 }); // Error, rest must be last property
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectRestReadonly.ts | TypeScript | // #23734
type ObjType = {
foo: string
baz: string
quux: string
}
const obj: Readonly<ObjType> = {
foo: 'bar',
baz: 'qux',
quux: 'quuz',
}
const { foo, ...rest } = obj
delete rest.baz
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectSpread.ts | TypeScript | // @strictNullChecks: true
// @target: es5
let o = { a: 1, b: 'no' }
let o2 = { b: 'yes', c: true }
let swap = { a: 'yes', b: -1 };
let addAfter: { a: number, b: string, c: boolean } =
{ ...o, c: false }
let addBefore: { a: number, b: string, c: boolean } =
{ c: false, ...o }
let override: { a: number, b: stri... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectSpreadComputedProperty.ts | TypeScript | // fixes #12200
function f() {
let n: number = 12;
let m: number = 13;
let a: any = null;
const o1 = { ...{}, [n]: n };
const o2 = { ...{}, [a]: n };
const o3 = { [a]: n, ...{}, [n]: n, ...{}, [m]: m };
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectSpreadIndexSignature.ts | TypeScript | // @strict: true
declare let indexed1: { [n: string]: number; a: number; };
declare let indexed2: { [n: string]: boolean; c: boolean; };
declare let indexed3: { [n: string]: number };
let i = { ...indexed1, b: 11 };
// only indexed has indexer, so i[101]: any
i[101];
let ii = { ...indexed1, ...indexed2 };
// both have ... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectSpreadNoTransform.ts | TypeScript | // @target: esnext
const y = { a: 'yes', b: 'no' };
const o = { x: 1, ...y };
var b;
var rest: any;
({ b, ...rest } = o);
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectSpreadRepeatedComplexity.ts | TypeScript | // @strict: true
function f(cnd: Record<number, boolean>){
// Type is a union of 2^(n-1) members, where n is the number of spread objects
return {
// Without this one, it collapses to {} ?
...(cnd[1] &&
cnd[2] && {
prop0: 0,
}),
// With one prop each, it ... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/objectSpreadRepeatedNullCheckPerf.ts | TypeScript | // @strict: true
interface Props {
readonly a?: string
readonly b?: string
readonly c?: string
readonly d?: string
readonly e?: string
readonly f?: string
readonly g?: string
readonly h?: string
readonly i?: string
readonly j?: string
readonly k?: string
readonly l?: stri... | 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.