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/computedPropertyNamesContextualType1_ES6.ts | TypeScript | // @target: es6
interface I {
[s: string]: (x: string) => number;
[s: number]: (x: any) => number; // Doesn't get hit
}
var o: I = {
["" + 0](y) { return y.length; },
["" + 1]: y => y.length
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/computedPropertyNamesContextualType2_ES5.ts | TypeScript | // @target: es5
interface I {
[s: string]: (x: any) => number; // Doesn't get hit
[s: number]: (x: string) => number;
}
var o: I = {
[+"foo"](y) { return y.length; },
[+"bar"]: y => y.length
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/computedPropertyNamesContextualType2_ES6.ts | TypeScript | // @target: es6
interface I {
[s: string]: (x: any) => number; // Doesn't get hit
[s: number]: (x: string) => number;
}
var o: I = {
[+"foo"](y) { return y.length; },
[+"bar"]: y => y.length
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/computedPropertyNamesContextualType3_ES5.ts | TypeScript | // @target: es5
interface I {
[s: string]: (x: string) => number;
}
var o: I = {
[+"foo"](y) { return y.length; },
[+"bar"]: y => y.length
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/computedPropertyNamesContextualType3_ES6.ts | TypeScript | // @target: es6
interface I {
[s: string]: (x: string) => number;
}
var o: I = {
[+"foo"](y) { return y.length; },
[+"bar"]: y => y.length
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/computedPropertyNamesContextualType4_ES5.ts | TypeScript | // @target: es5
interface I {
[s: string]: any;
[s: number]: any;
}
var o: I = {
[""+"foo"]: "",
[""+"bar"]: 0
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/computedPropertyNamesContextualType4_ES6.ts | TypeScript | // @target: es6
interface I {
[s: string]: any;
[s: number]: any;
}
var o: I = {
[""+"foo"]: "",
[""+"bar"]: 0
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/computedPropertyNamesContextualType5_ES5.ts | TypeScript | // @target: es5
interface I {
[s: string]: any;
[s: number]: any;
}
var o: I = {
[+"foo"]: "",
[+"bar"]: 0
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/computedPropertyNamesContextualType5_ES6.ts | TypeScript | // @target: es6
interface I {
[s: string]: any;
[s: number]: any;
}
var o: I = {
[+"foo"]: "",
[+"bar"]: 0
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/computedPropertyNamesContextualType6_ES5.ts | TypeScript | // @target: es5
interface I<T> {
[s: string]: T;
}
declare function foo<T>(obj: I<T>): T
foo({
p: "",
0: () => { },
["hi" + "bye"]: true,
[0 + 1]: 0,
[+"hi"]: [0]
}); | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/computedPropertyNamesContextualType6_ES6.ts | TypeScript | // @target: es6
interface I<T> {
[s: string]: T;
}
declare function foo<T>(obj: I<T>): T
foo({
p: "",
0: () => { },
["hi" + "bye"]: true,
[0 + 1]: 0,
[+"hi"]: [0]
}); | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/computedPropertyNamesContextualType7_ES5.ts | TypeScript | // @target: es5
interface I<T> {
[n: number]: T;
}
interface J<T> {
[s: string]: T;
}
declare function foo<T>(obj: I<T>): T;
declare function g<T>(obj: J<T>): T;
foo({
0: () => { },
["hi" + "bye"]: true,
[0 + 1]: 0,
[+"hi"]: [0]
});
g({ p: "" });
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/computedPropertyNamesContextualType7_ES6.ts | TypeScript | // @target: es6
interface I<T> {
[n: number]: T;
}
interface J<T> {
[s: string]: T;
}
declare function foo<T>(obj: I<T>): T;
declare function g<T>(obj: J<T>): T;
foo({
0: () => { },
["hi" + "bye"]: true,
[0 + 1]: 0,
[+"hi"]: [0]
});
g({ p: "" });
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/computedPropertyNamesContextualType8_ES5.ts | TypeScript | // @target: es5
interface I {
[s: string]: boolean;
[s: number]: boolean;
}
var o: I = {
[""+"foo"]: "",
[""+"bar"]: 0
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/computedPropertyNamesContextualType8_ES6.ts | TypeScript | // @target: es6
interface I {
[s: string]: boolean;
[s: number]: boolean;
}
var o: I = {
[""+"foo"]: "",
[""+"bar"]: 0
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/computedPropertyNamesContextualType9_ES5.ts | TypeScript | // @target: es5
interface I {
[s: string]: boolean;
[s: number]: boolean;
}
var o: I = {
[+"foo"]: "",
[+"bar"]: 0
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/computedPropertyNamesContextualType9_ES6.ts | TypeScript | // @target: es6
interface I {
[s: string]: boolean;
[s: number]: boolean;
}
var o: I = {
[+"foo"]: "",
[+"bar"]: 0
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/computedPropertyNamesDeclarationEmit1_ES5.ts | TypeScript | // @target: es5
// @declaration: true
class C {
["" + ""]() { }
get ["" + ""]() { return 0; }
set ["" + ""](x) { }
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/computedPropertyNamesDeclarationEmit1_ES6.ts | TypeScript | // @target: es6
// @declaration: true
class C {
["" + ""]() { }
get ["" + ""]() { return 0; }
set ["" + ""](x) { }
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/computedPropertyNamesDeclarationEmit2_ES5.ts | TypeScript | // @target: es5
// @declaration: true
class C {
static ["" + ""]() { }
static get ["" + ""]() { return 0; }
static set ["" + ""](x) { }
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/computedPropertyNamesDeclarationEmit2_ES6.ts | TypeScript | // @target: es6
// @declaration: true
class C {
static ["" + ""]() { }
static get ["" + ""]() { return 0; }
static set ["" + ""](x) { }
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/computedPropertyNamesDeclarationEmit5_ES5.ts | TypeScript | // @target: es5
// @declaration: true
var v = {
["" + ""]: 0,
["" + ""]() { },
get ["" + ""]() { return 0; },
set ["" + ""](x) { }
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/computedPropertyNamesDeclarationEmit5_ES6.ts | TypeScript | // @target: es6
// @declaration: true
var v = {
["" + ""]: 0,
["" + ""]() { },
get ["" + ""]() { return 0; },
set ["" + ""](x) { }
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/computedPropertyNamesDeclarationEmit6_ES5.ts | TypeScript | // @target: es5
// @declaration: true
var v = {
[-1]: {},
[+1]: {},
[~1]: {},
[!1]: {}
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/computedPropertyNamesDeclarationEmit6_ES6.ts | TypeScript | // @target: es6
// @declaration: true
var v = {
[-1]: {},
[+1]: {},
[~1]: {},
[!1]: {}
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/computedPropertyNamesSourceMap1_ES5.ts | TypeScript | // @target: es5
// @sourceMap: true
class C {
["hello"]() {
debugger;
}
get ["goodbye"]() {
return 0;
}
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/computedPropertyNamesSourceMap1_ES6.ts | TypeScript | // @target: es6
// @sourceMap: true
class C {
["hello"]() {
debugger;
}
get ["goodbye"]() {
return 0;
}
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/computedPropertyNamesSourceMap2_ES5.ts | TypeScript | // @target: es5
// @sourceMap: true
var v = {
["hello"]() {
debugger;
},
get ["goodbye"]() {
return 0;
}
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/computedPropertyNamesSourceMap2_ES6.ts | TypeScript | // @target: es6
// @sourceMap: true
var v = {
["hello"]() {
debugger;
},
get ["goodbye"]() {
return 0;
}
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/computedPropertyNamesWithStaticProperty.ts | TypeScript | // @target: es6
class C1 {
static staticProp = 10;
get [C1.staticProp]() {
return "hello";
}
set [C1.staticProp](x: string) {
var y = x;
}
[C1.staticProp]() { }
}
(class C2 {
static staticProp = 10;
get [C2.staticProp]() {
return "hello";
}
set [C2.static... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/conditionalOperatorConditionIsBooleanType.ts | TypeScript | //Cond ? Expr1 : Expr2, Cond is of boolean type, Expr1 and Expr2 have the same type
var condBoolean: boolean;
var exprAny1: any;
var exprBoolean1: boolean;
var exprNumber1: number;
var exprString1: string;
var exprIsObject1: Object;
var exprAny2: any;
var exprBoolean2: boolean;
var exprNumber2: number;
var exprStrin... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/conditionalOperatorConditionIsNumberType.ts | TypeScript | //Cond ? Expr1 : Expr2, Cond is of number type, Expr1 and Expr2 have the same type
var condNumber: number;
var exprAny1: any;
var exprBoolean1: boolean;
var exprNumber1: number;
var exprString1: string;
var exprIsObject1: Object;
var exprAny2: any;
var exprBoolean2: boolean;
var exprNumber2: number;
var exprString2:... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/conditionalOperatorConditoinIsAnyType.ts | TypeScript | //Cond ? Expr1 : Expr2, Cond is of any type, Expr1 and Expr2 have the same type
var condAny: any;
var x: any;
var exprAny1: any;
var exprBoolean1: boolean;
var exprNumber1: number;
var exprString1: string;
var exprIsObject1: Object;
var exprAny2: any;
var exprBoolean2: boolean;
var exprNumber2: number;
var exprStrin... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/conditionalOperatorConditoinIsStringType.ts | TypeScript | //Cond ? Expr1 : Expr2, Cond is of string type, Expr1 and Expr2 have the same type
var condString: string;
var exprAny1: any;
var exprBoolean1: boolean;
var exprNumber1: number;
var exprString1: string;
var exprIsObject1: Object;
var exprAny2: any;
var exprBoolean2: boolean;
var exprNumber2: number;
var exprString2:... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/conditionalOperatorWithIdenticalBCT.ts | TypeScript | //Cond ? Expr1 : Expr2, Expr1 and Expr2 have identical best common type
class X { propertyX: any; propertyX1: number; propertyX2: string };
class A extends X { propertyA: number };
class B extends X { propertyB: string };
var x: X;
var a: A;
var b: B;
//Cond ? Expr1 : Expr2, Expr1 is supertype
//Be Not contextually... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/conditionalOperatorWithoutIdenticalBCT.ts | TypeScript | //Cond ? Expr1 : Expr2, Expr1 and Expr2 have no identical best common type
class X { propertyX: any; propertyX1: number; propertyX2: string };
class A extends X { propertyA: number };
class B extends X { propertyB: string };
var x: X;
var a: A;
var b: B;
// No errors anymore, uses union types
true ? a : b;
var resul... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/conditionalTypes1.ts | TypeScript | // @strict: true
// @declaration: true
type T00 = Exclude<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "b" | "d"
type T01 = Extract<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "a" | "c"
type T02 = Exclude<string | number | (() => void), Function>; // string | number
type T03 = Extract<string | number | (() => void)... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/conditionalTypes2.ts | TypeScript | // @strict: true
// @declaration: true
interface Covariant<T> {
foo: T extends string ? T : number;
}
interface Contravariant<T> {
foo: T extends string ? keyof T : number;
}
interface Invariant<T> {
foo: T extends string ? keyof T : T;
}
function f1<A, B extends A>(a: Covariant<A>, b: Covariant<B>) {
... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/conditionalTypesExcessProperties.ts | TypeScript | type Something<T> = { test: string } & (T extends object ? {
arg: T
} : {
arg?: undefined
});
function testFunc2<A extends object>(a: A, sa: Something<A>) {
sa = { test: 'hi', arg: a }; // not excess (but currently still not assignable)
sa = { test: 'bye', arg: a, arr: a } // excess
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/conflictingCommonJSES2015Exports.ts | TypeScript | // @checkJs: true
// @allowJS: true
// @noEmit: true
// @Filename: bug24934.js
export function abc(a, b, c) { return 5; }
module.exports = { abc };
// @Filename: use.js
import { abc } from './bug24934';
abc(1, 2, 3);
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constEnum1.ts | TypeScript | // @declaration: true
// An enum declaration that specifies a const modifier is a constant enum declaration.
// In a constant enum declaration, all members must have constant values and
// it is an error for a member declaration to specify an expression that isn't classified as a constant enum expression.
const enum... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constEnum2.ts | TypeScript | // @declaration: true
// An enum declaration that specifies a const modifier is a constant enum declaration.
// In a constant enum declaration, all members must have constant values and
// it is an error for a member declaration to specify an expression that isn't classified as a constant enum expression.
// Error :... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constEnum3.ts | TypeScript | const enum TestType { foo, bar }
type TestTypeStr = keyof typeof TestType;
function f1(f: TestType) { }
function f2(f: TestTypeStr) { }
f1(TestType.foo)
f1(TestType.bar)
f2('foo')
f2('bar')
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constEnum4.ts | TypeScript | if (1)
const enum A { }
else if (2)
const enum B { }
else
const enum C { }
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constEnumNoObjectPrototypePropertyAccess.ts | TypeScript | // @strict: true
// @noEmit: true
// https://github.com/microsoft/TypeScript/issues/55421
const enum Bebra {}
console.log(Bebra.constructor)
console.log(Bebra.hasOwnProperty)
console.log(Bebra.isPrototypeOf)
console.log(Bebra.propertyIsEnumerable)
console.log(Bebra.toLocaleString)
console.log(Bebra.toString)
console... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constEnumPropertyAccess1.ts | TypeScript | // @declaration: true
// @target: es6
// constant enum declarations are completely erased in the emitted JavaScript code.
// it is an error to reference a constant enum object in any other context
// than a property access that selects one of the enum's members
const enum G {
A = 1,
B = 2,
C = A + B,
... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constEnumPropertyAccess2.ts | TypeScript | // @declaration: true
// constant enum declarations are completely erased in the emitted JavaScript code.
// it is an error to reference a constant enum object in any other context
// than a property access that selects one of the enum's members
const enum G {
A = 1,
B = 2,
C = A + B,
D = A * 2
}
//... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constEnumPropertyAccess3.ts | TypeScript | const enum E {
A = ~1,
B = -1,
C = ~(1 + 1),
D = -(1 + 2),
E = 1 - 10,
}
E.A.toString();
E.B.toString();
E.C.toString();
E.D.toString();
E["A"].toString();
E["B"].toString();
E["C"].toString();
E["D"].toString();
E["E"].toString();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constLocalsInFunctionExpressions.ts | TypeScript | declare function getStringOrNumber(): string | number;
function f1() {
const x = getStringOrNumber();
if (typeof x === "string") {
const f = () => x.length;
}
}
function f2() {
const x = getStringOrNumber();
if (typeof x !== "string") {
return;
}
const f = () => x.length;
}... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constraintSatisfactionWithAny.ts | TypeScript | // any is not a valid type argument unless there is no constraint, or the constraint is any
function foo<T extends String>(x: T): T { return null; }
function foo2<T extends { x: number }>(x: T): T { return null; }
//function foo3<T extends T[]>(x: T): T { return null; }
function foo4<T extends <T>(x: T) => void>(x: T)... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constraintSatisfactionWithAny2.ts | TypeScript | // errors expected for type parameter cannot be referenced in the constraints of the same list
// any is not a valid type argument unless there is no constraint, or the constraint is any
declare function foo<Z, T extends <U>(x: U) => Z>(y: T): Z;
var a: any;
foo(a);
foo<any, any>(a); | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constraintSatisfactionWithEmptyObject.ts | TypeScript | // valid uses of a basic object constraint, no errors expected
// Object constraint
function foo<T extends Object>(x: T) { }
var r = foo({});
var a = {};
var r = foo({});
class C<T extends Object> {
constructor(public x: T) { }
}
var r2 = new C({});
interface I<T extends Object> {
x: T;
}
var i: I<{}>;
// ... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructBigint.ts | TypeScript | // @target: esnext
// @lib: esnext
// @strict: true
BigInt(1);
BigInt(1n);
BigInt("0");
BigInt(false);
BigInt(Symbol());
BigInt({ e: 1, m: 1 })
BigInt(null);
BigInt(undefined)
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructSignatureAssignabilityInInheritance.ts | TypeScript | // Checking basic subtype relations with construct signatures
module ConstructSignature {
interface Base { // T
// M's
new (x: number): void; // BUG 842221
new (x: number, y: number): number;
}
// S's
interface I extends Base {
// N's
new (x: number): number; //... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructSignatureAssignabilityInInheritance2.ts | TypeScript | // checking subtype relations for function types as it relates to contextual signature instantiation
class Base { foo: string; }
class Derived extends Base { bar: string; }
class Derived2 extends Derived { baz: string; }
class OtherDerived extends Base { bing: string; }
interface A { // T
// M's
a: new (x: nu... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructSignatureAssignabilityInInheritance3.ts | TypeScript | // checking subtype relations for function types as it relates to contextual signature instantiation
// error cases
module Errors {
class Base { foo: string; }
class Derived extends Base { bar: string; }
class Derived2 extends Derived { baz: string; }
class OtherDerived extends Base { bing: string; }
... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructSignatureAssignabilityInInheritance4.ts | TypeScript | // checking subtype relations for function types as it relates to contextual signature instantiation
class Base { foo: string; }
class Derived extends Base { bar: string; }
class Derived2 extends Derived { baz: string; }
class OtherDerived extends Base { bing: string; }
interface A { // T
// M's
a: new <T>(x:... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructSignatureAssignabilityInInheritance5.ts | TypeScript | // checking subtype relations for function types as it relates to contextual signature instantiation
// same as subtypingWithConstructSignatures2 just with an extra level of indirection in the inheritance chain
class Base { foo: string; }
class Derived extends Base { bar: string; }
class Derived2 extends Derived { baz... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructSignatureAssignabilityInInheritance6.ts | TypeScript | // checking subtype relations for function types as it relates to contextual signature instantiation
// same as subtypingWithConstructSignatures4 but using class type parameters instead of generic signatures
// all are errors
class Base { foo: string; }
class Derived extends Base { bar: string; }
class Derived2 extend... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructSignatureWithAccessibilityModifiersOnParameters.ts | TypeScript | // Parameter properties are only valid in constructor definitions, not even in other forms of construct signatures
class C {
constructor(public x, private y) { }
}
class C2 {
constructor(public x) { }
}
class C3 {
constructor(private x) { }
}
interface I {
new (public x);
}
interface I2 {
new (... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructSignatureWithAccessibilityModifiersOnParameters2.ts | TypeScript | // Parameter properties are not valid in overloads of constructors
class C {
constructor(public x, private y);
constructor(public x, private y) { }
}
class C2 {
constructor(private x);
constructor(public x) { }
}
class C3 {
constructor(private x);
constructor(private y) { }
}
interface I {
... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructSignaturesWithIdenticalOverloads.ts | TypeScript | // Duplicate overloads of construct signatures should generate errors
class C {
constructor(x: number, y: string);
constructor(x: number, y: string); // error
constructor(x: number) { }
}
var r1 = new C(1, '');
class C2<T> {
constructor(x: T, y: string);
constructor(x: T, y: string); // error
... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructSignaturesWithOverloads.ts | TypeScript | // No errors expected for basic overloads of construct signatures
class C {
constructor(x: number, y?: string);
constructor(x: number, y: string);
constructor(x: number) { }
}
var r1 = new C(1, '');
class C2<T> {
constructor(x: T, y?: string);
constructor(x: T, y: string);
constructor(x: T) {... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructSignaturesWithOverloads2.ts | TypeScript | // No errors expected for basic overloads of construct signatures with merged declarations
// clodules
class C {
constructor(x: number, y?: string);
constructor(x: number, y: string);
constructor(x: number) { }
}
module C {
export var x = 1;
}
var r1 = new C(1, '');
class C2<T> {
constructor(x: T... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructSignaturesWithOverloadsThatDifferOnlyByReturnType.ts | TypeScript | // Error for construct signature overloads to differ only by return type
class C {
constructor(x: number) { }
}
class C2<T> {
constructor(x: T, y?: string) { }
}
interface I {
new(x: number, y: string): C;
new(x: number, y: string): C2<number>; // error
}
interface I2<T> {
new (x: T, y: string):... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructorFunctionMergeWithClass.ts | TypeScript | // @allowJs: true
// @noEmit: true
// @checkJs: true
// @Filename: file1.js
var SomeClass = function () {
this.otherProp = 0;
};
new SomeClass();
// @Filename: file2.js
class SomeClass { }
SomeClass.prop = 0
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructorFunctionMethodTypeParameters.ts | TypeScript | // @noEmit: true
// @allowJs: true
// @checkJs: true
// @filename: constructorFunctionMethodTypeParameters.js
/**
* @template {string} T
* @param {T} t
*/
function Cls(t) {
this.t = t;
}
/**
* @template {string} V
* @param {T} t
* @param {V} v
* @return {V}
*/
Cls.prototype.topLevelComment = function (t, v... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructorFunctionTypeIsAssignableToBaseType.ts | TypeScript | class Base {
static foo: {
bar: Object;
}
}
class Derived extends Base {
// ok
static foo: {
bar: number;
}
}
class Derived2 extends Base {
// ok, use assignability here
static foo: {
bar: any;
}
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructorFunctionTypeIsAssignableToBaseType2.ts | TypeScript | // the constructor function itself does not need to be a subtype of the base type constructor function
class Base {
static foo: {
bar: Object;
}
constructor(x: Object) {
}
}
class Derived extends Base {
// ok
static foo: {
bar: number;
}
constructor(x: number) {
... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructorFunctions.ts | TypeScript | // @allowJs: true
// @checkJs: true
// @noEmit: true
// @filename: index.js
function C1() {
if (!(this instanceof C1)) return new C1();
this.x = 1;
}
const c1_v1 = C1();
const c1_v2 = new C1();
var C2 = function () {
if (!(this instanceof C2)) return new C2();
this.x = 1;
};
const c2_v1 = C2();
cons... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructorFunctions2.ts | TypeScript | // @allowJs: true
// @checkJs: true
// @noEmit: true
// @module: commonjs
// @filename: node.d.ts
declare function require(id: string): any;
declare var module: any, exports: any;
// @filename: index.js
const A = require("./other");
const a = new A().id;
const B = function() { this.id = 1; }
B.prototype.m = function(... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructorFunctions3.ts | TypeScript | // @noEmit: true
// @allowJs: true
// @checkJs: true
// @noImplicitAny: true
// @Filename: a.js
function Instance() {
this.i = 'simple'
}
var i = new Instance();
Instance;
i;
function StaticToo() {
this.i = 'more complex'
}
StaticToo.property = 'yep'
var s = new StaticToo();
s;
StaticToo;
// Both!
function A ... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructorFunctionsStrict.ts | TypeScript | // @noEmit: true
// @allowJs: true
// @checkJs: true
// @strict: true
// @noImplicitThis: false
// @Filename: a.js
/** @param {number} x */
function C(x) {
this.x = x
}
C.prototype.m = function() {
this.y = 12
}
var c = new C(1)
c.x = undefined // should error
c.y = undefined // ok
/** @param {number} x */
f... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructorHasPrototypeProperty.ts | TypeScript | module NonGeneric {
class C {
foo: string;
}
class D extends C {
bar: string;
}
var r = C.prototype;
r.foo;
var r2 = D.prototype;
r2.bar;
}
module Generic {
class C<T,U> {
foo: T;
bar: U;
}
class D<T,U> extends C<T,U> {
baz: T;
... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructorImplementationWithDefaultValues.ts | TypeScript | class C {
constructor(x);
constructor(x = 1) {
var y = x;
}
}
class D<T> {
constructor(x);
constructor(x:T = null) {
var y = x;
}
}
class E<T extends Date> {
constructor(x);
constructor(x: T = null) {
var y = x;
}
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructorImplementationWithDefaultValues2.ts | TypeScript | class C {
constructor(x);
constructor(public x: string = 1) { // error
var y = x;
}
}
class D<T, U> {
constructor(x: T, y: U);
constructor(x: T = 1, public y: U = x) { // error
var z = x;
}
}
class E<T extends Date> {
constructor(x);
constructor(x: T = new Date()) { // ... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructorNameInObjectLiteralAccessor.ts | TypeScript | // @target: esnext
const c1 = {
get constructor() { return },
set constructor(value) {}
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructorOverloadsWithDefaultValues.ts | TypeScript | class C {
foo: string;
constructor(x = 1); // error
constructor() {
}
}
class D<T> {
foo: string;
constructor(x = 1); // error
constructor() {
}
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructorOverloadsWithOptionalParameters.ts | TypeScript | class C {
foo: string;
constructor(x?, y?: any[]);
constructor() {
}
}
class D<T> {
foo: string;
constructor(x?, y?: any[]);
constructor() {
}
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructorParameterProperties.ts | TypeScript | class C {
y: string;
constructor(private x: string, protected z: string) { }
}
var c: C;
var r = c.y;
var r2 = c.x; // error
var r3 = c.z; // error
class D<T> {
y: T;
constructor(a: T, private x: T, protected z: T) { }
}
var d: D<string>;
var r = d.y;
var r2 = d.x; // error
var r3 = d.a; // error
var... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructorParameterProperties2.ts | TypeScript | class C {
y: number;
constructor(y: number) { } // ok
}
var c: C;
var r = c.y;
class D {
y: number;
constructor(public y: number) { } // error
}
var d: D;
var r2 = d.y;
class E {
y: number;
constructor(private y: number) { } // error
}
var e: E;
var r3 = e.y; // error
class F {
y: numb... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructorParameterShadowsOuterScopes.ts | TypeScript | // Initializer expressions for instance member variables are evaluated in the scope of the class constructor
// body but are not permitted to reference parameters or local variables of the constructor.
// This effectively means that entities from outer scopes by the same name as a constructor parameter or
// local va... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructorParameterShadowsOuterScopes2.ts | TypeScript | // @target: esnext
// @useDefineForClassFields: true
// With useDefineForClassFields: true and ESNext target, initializer
// expressions for property declarations are evaluated in the scope of
// the class body and are permitted to reference parameters or local
// variables of the constructor. This is different from ... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructorTagOnClassConstructor.ts | TypeScript | // @allowJs: true
// @noEmit: true
// @checkJs: true
// @Filename: bug27025.js
export class Alpha { }
export class Beta {
/**
* @constructor
*/
constructor() {
}
}
const arr = [Alpha, Beta];
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructorTagOnNestedBinaryExpression.ts | TypeScript | // @allowjs: true
// @noemit: true
// @Filename: constructorTagOnNestedBinaryExpression.js
// Fixes #35021
/** @constructor */
a = b = function c () {
console.log(this)
};
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructorTagOnObjectLiteralMethod.ts | TypeScript | // @noEmit: true
// @Filename: example.js
// @allowJs: true
// @checkJs: true
// @noImplicitAny: true
const obj = {
/** @constructor */
Foo() { this.bar = "bar" }
};
(new obj.Foo()).bar
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructorTagWithThisTag.ts | TypeScript | // @allowJs: true
// @noEmit: true
// @checkJs: true
// @Filename: classthisboth.js
/**
* @class
* @this {{ e: number, m: number }}
* this-tag should win, both 'e' and 'm' should be defined.
*/
function C() {
this.e = this.m + 1
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructorWithAssignableReturnExpression.ts | TypeScript | // a class constructor may return an expression, it must be assignable to the class instance type to be valid
class C {
constructor() {
return 1;
}
}
class D {
x: number;
constructor() {
return 1; // error
}
}
class E {
x: number;
constructor() {
return { x: 1 };
... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/constructorWithExpressionLessReturn.ts | TypeScript | class C {
constructor() {
return;
}
}
class D {
x: number;
constructor() {
return;
}
}
class E {
constructor(public x: number) {
return;
}
}
class F<T> {
constructor(public x: T) {
return;
}
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/contextualIntersectionType.ts | TypeScript | var x: { a: (s: string) => string } & { b: (n: number) => number };
x = {
a: s => s,
b: n => n
};
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/contextualSignatureInstantiation.ts | TypeScript | // TypeScript Spec, section 4.12.2:
// If e is an expression of a function type that contains exactly one generic call signature and no other members,
// and T is a function type with exactly one non - generic call signature and no other members, then any inferences
// made for type parameters referenced by the paramet... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/contextualThisType.ts | TypeScript | interface X {
a: (p: this) => this;
}
interface Y extends X {
}
var x: Y = {
a(p) {
return p;
}
}
var y = x.a(x);
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/contextualThisTypeInJavascript.ts | TypeScript | // @allowJs: true
// @checkJs: true
// @noEmit: true
// @Filename: context.js
const obj = {
prop: 2,
method() {
this;
this.prop;
this.method;
this.unknown; // ok, obj has a string indexer
}
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/contextualTypeFromJSDoc.ts | TypeScript | // @allowJs: true
// @checkJs: true
// @noEmit: true
// @filename: index.js
// @target: esnext
/** @type {Array<[string, {x?:number, y?:number}]>} */
const arr = [
['a', { x: 1 }],
['b', { y: 2 }]
];
/** @return {Array<[string, {x?:number, y?:number}]>} */
function f() {
return [
['a', { x: 1 }],
... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/contextualTypeTupleEnd.ts | TypeScript | // @strict: true
// @noEmit: true
type Funcs = [...((arg: number) => void)[], (arg: string) => void];
declare function num(x: number): void;
declare function str(x: string): void;
declare function f1(...args: Funcs): void;
f1(); // Error
f1(x => str(x));
f1(x => num(x), x => str(x));
f1(x => num(x), x => num(x), x... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/contextualTypeWithTuple.ts | TypeScript | // no error
var numStrTuple: [number, string] = [5, "hello"];
var numStrTuple2: [number, string] = [5, "foo", true];
var numStrBoolTuple: [number, string, boolean] = [5, "foo", true];
var objNumTuple: [{ a: string }, number] = [{ a: "world" }, 5];
var strTupleTuple: [string, [number, {}]] = ["bar", [5, { x: 1, y: 1 }]... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/contextualTypeWithUnionTypeCallSignatures.ts | TypeScript | //When used as a contextual type, a union type U has those members that are present in any of
// its constituent types, with types that are unions of the respective members in the constituent types.
// Let S be the set of types in U that have call signatures.
// If S is not empty and the sets of call signatures of ... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/contextualTypeWithUnionTypeIndexSignatures.ts | TypeScript | //When used as a contextual type, a union type U has those members that are present in any of
// its constituent types, with types that are unions of the respective members in the constituent types.
interface SomeType {
(a: number): number;
}
interface SomeType2 {
(a: number): string;
}
interface IWithNoStr... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/contextualTypeWithUnionTypeMembers.ts | TypeScript | //When used as a contextual type, a union type U has those members that are present in any of
// its constituent types, with types that are unions of the respective members in the constituent types.
interface I1<T> {
commonMethodType(a: string): string;
commonPropertyType: string;
commonMethodWithTypePar... | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/contextualTypeWithUnionTypeObjectLiteral.ts | TypeScript | var str: string;
var num: number;
var strOrNumber: string | number = str || num;
var objStr: { prop: string };
var objNum: { prop: number };
var objStrOrNum1: { prop: string } | { prop: number } = objStr || objNum;
var objStrOrNum2: { prop: string | number } = objStr || objNum;
// Below is error because :
// Spec says... | 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.