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/templateStringWithEmbeddedTypeOfOperator.ts
TypeScript
var x = `abc${ typeof "hi" }def`;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateStringWithEmbeddedTypeOfOperatorES6.ts
TypeScript
// @target: ES6 var x = `abc${ typeof "hi" }def`;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateStringWithEmbeddedUnaryPlus.ts
TypeScript
var x = `abc${ +Infinity }def`;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateStringWithEmbeddedUnaryPlusES6.ts
TypeScript
// @target: ES6 var x = `abc${ +Infinity }def`;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateStringWithEmbeddedYieldKeywordES6.ts
TypeScript
// @target: ES6 function* gen() { // Once this is supported, yield *must* be parenthesized. var x = `abc${ yield 10 }def`; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateStringWithEmptyLiteralPortions.ts
TypeScript
var a = ``; var b = `${ 0 }`; var c = `1${ 0 }`; var d = `${ 0 }2`; var e = `1${ 0 }2`; var f = `${ 0 }${ 0 }`; var g = `1${ 0 }${ 0 }`; var h = `${ 0 }2${ 0 }`; var i = `1${ 0 }2${ 0 }`; var j = `${ 0 }${ 0 }3`; var k = `1${ 0 }${ 0 }3`; var l = `${ 0 }2${ 0 }3`; var m = `1${ 0 }2${ 0 }3`;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateStringWithEmptyLiteralPortionsES6.ts
TypeScript
// @target: ES6 var a = ``; var b = `${ 0 }`; var c = `1${ 0 }`; var d = `${ 0 }2`; var e = `1${ 0 }2`; var f = `${ 0 }${ 0 }`; var g = `1${ 0 }${ 0 }`; var h = `${ 0 }2${ 0 }`; var i = `1${ 0 }2${ 0 }`; var j = `${ 0 }${ 0 }3`; var k = `1${ 0 }${ 0 }3`; var l = `${ 0 }2${ 0 }3`; var m = `1${ 0 }2${ 0 }3`;...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateStringWithOpenCommentInStringPortion.ts
TypeScript
` /**head ${ 10 } // still middle ${ 20 } /* still tail `
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateStringWithOpenCommentInStringPortionES6.ts
TypeScript
// @target: ES6 ` /**head ${ 10 } // still middle ${ 20 } /* still tail `
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateStringWithPropertyAccess.ts
TypeScript
`abc${0}abc`.indexOf(`abc`);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateStringWithPropertyAccessES6.ts
TypeScript
// @target: ES6 `abc${0}abc`.indexOf(`abc`);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts
TypeScript
 `${function (x: number) { x = "bad"; } }`;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts
TypeScript
//@target: es6 `${function (x: number) { x = "bad"; } }`;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisAndSuperInStaticMembers1.ts
TypeScript
// @target: esnext, es2022, es2015 // @useDefineForClassFields: true // @noTypesAndSymbols: true declare class B { static a: any; static f(): number; a: number; f(): number; } class C extends B { static x: any = undefined!; static y1 = this.x; static y2 = this.x(); static y3 = this?.x(...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisAndSuperInStaticMembers2.ts
TypeScript
// @target: esnext, es2022, es2015 // @useDefineForClassFields: false // @noTypesAndSymbols: true declare class B { static a: any; static f(): number; a: number; f(): number; } class C extends B { static x: any = undefined!; static y1 = this.x; static y2 = this.x(); static y3 = this?.x...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisAndSuperInStaticMembers3.ts
TypeScript
// @target: es5 // @useDefineForClassFields: true // @noTypesAndSymbols: true declare class B { static a: any; static f(): number; a: number; f(): number; } class C extends B { static x: any = undefined!; static y1 = this.x; static y2 = this.x(); static y3 = this?.x(); static y4 = ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisAndSuperInStaticMembers4.ts
TypeScript
// @target: es5 // @useDefineForClassFields: false // @noTypesAndSymbols: true declare class B { static a: any; static f(): number; a: number; f(): number; } class C extends B { static x: any = undefined!; static y1 = this.x; static y2 = this.x(); static y3 = this?.x(); static y4 =...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisInInstanceMemberInitializer.ts
TypeScript
class C { x = this; } class D<T> { x = this; y: T; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisInObjectLiterals.ts
TypeScript
// @noImplicitAny: true // @noImplicitThis: true class MyClass { t: number; fn() { type ContainingThis = this; //type of 'this' in an object literal is the containing scope's this var t = { x: this, y: this.t }; var t: { x: ContainingThis; y: number }; } } //type of 'this'...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisMethodCall.ts
TypeScript
// @strict: true // @target: es6 class C { method?() {} other() { this.method?.(); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisPropertyAssignment.ts
TypeScript
// @checkJs: true // @allowJs: true // @strict: true // @emitDeclarationOnly: true // @declaration: true // @Filename: a.js // This test is asserting that a single property/element access // on `this` is a special assignment declaration, but chaining // off that does not create additional declarations. I’m not sure //...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisPropertyAssignmentCircular.ts
TypeScript
// @allowJs: true // @checkJs: true // @declaration: true // @emitDeclarationOnly: true // @filename: thisPropertyAssignmentCircular.js export class Foo { constructor() { this.foo = "Hello"; } slicey() { this.foo = this.foo.slice(); } m() { this.foo } } /** @class */ fun...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisPropertyAssignmentComputed.ts
TypeScript
// @allowjs: true // @checkjs: true // @noemit: true // @strict: true // @filename: thisPropertyAssignmentComputed.js this["a" + "b"] = 0
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisPropertyAssignmentInherited.ts
TypeScript
// @checkJs: true // @strict: true // @emitDeclarationOnly: true // @declaration: true // @Filename: thisPropertyAssignmentInherited.js export class Element { /** * @returns {String} */ get textContent() { return '' } set textContent(x) {} cloneNode() { return this} } export class HTMLElement exten...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisPropertyOverridesAccessors.ts
TypeScript
// @target: esnext // @allowjs: true // @noemit: true // @checkjs: true // @Filename: foo.ts class Foo { get p() { return 1 } set p(value) { } } // @Filename: bar.js class Bar extends Foo { constructor() { super() this.p = 2 } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisPrototypeMethodCompoundAssignment.ts
TypeScript
// @strict: true // @noEmit: true Element.prototype.remove ??= function () { this.parentNode?.removeChild(this); };
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisPrototypeMethodCompoundAssignmentJs.ts
TypeScript
// @strict: true // @noEmit: true // @checkJs: true // @allowJs: true // @filename: index.js Element.prototype.remove ??= function () { this.parentNode?.removeChild(this); }; /** * @this Node */ Element.prototype.remove ??= function () { this.parentNode?.removeChild(this); };
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisTag1.ts
TypeScript
// @noEmit: true // @allowJs: true // @checkJs: true // @strict: true // @Filename: a.js /** @this {{ n: number }} Mount Holyoke Preparatory School * @param {string} s * @return {number} */ function f(s) { return this.n + s.length } const o = { f, n: 1 } o.f('hi')
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisTag2.ts
TypeScript
// @target: esnext // @allowJs: true // @declaration: true // @emitDeclarationOnly: true // @filename: a.js /** @this {string} */ export function f1() {} /** @this */ export function f2() {}
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisTag3.ts
TypeScript
// @allowJs: true // @checkJs: true // @noEmit: true // @filename: /a.js /** * @typedef {{fn(a: string): void}} T */ class C { /** * @this {T} * @param {string} a */ p = (a) => this.fn("" + a); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisTypeAccessibility.ts
TypeScript
class MyClass { private p: number = 123; protected pp: number = 123; public ppp: number = 123; private static sp: number = 123; protected static spp: number = 123; public static sppp: number = 123; } interface MyClass { extension1(p: number): void; extension2(p: number): void; exten...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisTypeAndConstraints.ts
TypeScript
class A { self() { return this; } } function f<T extends A>(x: T) { function g<U extends T>(x: U) { x = x.self(); } x = x.self(); } class B<T extends A> { foo(x: T) { x = x.self(); } bar<U extends T>(x: U) { x = x.self(); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisTypeErrors.ts
TypeScript
var x1: this; var x2: { a: this }; var x3: this[]; function f1(x: this): this { var y: this; return this; } interface I1 { a: { x: this }; b: { (): this }; c: { new (): this }; d: { [x: string]: this }; e: { f(x: this): this }; } class C1 { a: { x: this }; b: { (): this }; c: ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisTypeErrors2.ts
TypeScript
class Base { constructor(a: this) { } } class Generic<T> { } class Derived { n: number; constructor(public host: Generic<this>) { let self: this = this; this.n = 12; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisTypeInAccessors.ts
TypeScript
// @noImplicitAny: true // @noImplicitThis: true // @target: es5 interface Foo { n: number; x: number; } const explicit = { n: 12, get x(this: Foo): number { return this.n; }, set x(this: Foo, n: number) { this.n = n; } } const copiedFromGetter = { n: 14, get x(this: Foo): number { return t...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisTypeInAccessorsNegative.ts
TypeScript
// @noImplicitAny: true // @noImplicitThis: true // @target: es5 interface Foo { n: number; x: number; } interface Bar { wrong: "place" | "time" | "method" | "technique"; } const mismatch = { n: 13, get x(this: Foo) { return this.n; }, set x(this: Bar, n) { this.wrong = "method"; } } const conte...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisTypeInBasePropertyAndDerivedContainerOfBase01.ts
TypeScript
// @declaration: true interface BoxOfFoo<T extends Foo> { item: T } interface Foo { self: this; } interface Bar extends Foo { other: BoxOfFoo<this>; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisTypeInClasses.ts
TypeScript
class C1 { x: this; f(x: this): this { return undefined; } } class C2 { [x: string]: this; } interface Foo<T> { x: T; y: this; } class C3 { a: this[]; b: [this, this]; c: this | Date; d: this & Date; e: (((this))); f: (x: this) => this; g: new (x: this) => this; h:...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisTypeInFunctions.ts
TypeScript
// body checking class B { n: number; } class C { n: number; explicitThis(this: this, m: number): number { return this.n + m; } explicitC(this: C, m: number): number { return this.n + m; } explicitProperty(this: {n: number}, m: number): number { return this.n + m; ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisTypeInFunctions2.ts
TypeScript
// @noImplicitAny: true // @noImplicitThis: true interface IndexedWithThis { // this is a workaround for React init?: (this: this) => void; willDestroy?: (this: any) => void; [propName: string]: number | string | boolean | symbol | undefined | null | {} | ((this: any, ...args:any[]) => any); } interfac...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisTypeInFunctions3.ts
TypeScript
declare class Base { check<TProp extends this>(prop: TProp): boolean; } class Test extends Base { m() { this.check(this); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisTypeInFunctions4.ts
TypeScript
type WrongObject = {value: number}; type CorrectObject = {name: string}; declare function isCorrect(obj: any): obj is CorrectObject declare function callsCallback(cb: (name: string)=>void) function problemFunction(this: CorrectObject | WrongObject): void { //check type if (!isCorrect(this)) return; call...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisTypeInInterfaces.ts
TypeScript
interface I1 { x: this; f(x: this): this; } interface I2 { (x: this): this; new (x: this): this; [x: string]: this; } interface Foo<T> { x: T; y: this; } interface I3 { a: this[]; b: [this, this]; c: this | Date; d: this & Date; e: (((this))); f: (x: this) => this;...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisTypeInObjectLiterals.ts
TypeScript
// @noImplicitAny: true // @noImplicitThis: true let o = { d: "bar", m() { return this.d.length; }, f: function() { return this.d.length; } } let mutuallyRecursive = { a: 100, start() { return this.passthrough(this.a); }, passthrough(n: number) { ret...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisTypeInObjectLiterals2.ts
TypeScript
// @declaration: true // @strict: true // @target: es5 // In methods of an object literal with no contextual type, 'this' has the type // of the object literal. let obj1 = { a: 1, f() { return this.a; }, b: "hello", c: { g() { this.g(); } }, get d() { ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisTypeInTaggedTemplateCall.ts
TypeScript
// @target: esnext class Foo { static m<T>(this: new () => T, strings: TemplateStringsArray | string) { return new this() } } Foo.m`test`; (Foo.m)`test`;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisTypeInTuples.ts
TypeScript
interface Array<T> { slice(): this; } let t: [number, string] = [42, "hello"]; let a = t.slice(); let b = t.slice(1); let c = t.slice(0, 1);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisTypeInTypePredicate.ts
TypeScript
declare function filter<S>(f: (this: void, x: any) => x is S): S[]; const numbers = filter<number>((x): x is number => 'number' == typeof x)
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisTypeOfConstructorFunctions.ts
TypeScript
// @Filename: thisTypeOfConstructorFunctions.js // @allowJs: true // @checkJs: true // @noEmit: true /** * @class * @template T * @param {T} t */ function Cp(t) { /** @type {this} */ this.dit = this this.y = t /** @return {this} */ this.m3 = () => this } Cp.prototype = { /** @return {this}...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisTypeOptionalCall.ts
TypeScript
// @strictNullChecks: true // @noImplicitAny: true // @noImplicitThis: true // @strictBindCallApply: false function maybeBind<T, A extends any[], R>(obj: T, fn: ((this: T, ...args: A) => R) | undefined): ((...args: A) => R) | undefined { return fn?.bind(obj); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/thisTypeSyntacticContext.ts
TypeScript
function f(this: { n: number }) { } const o: { n: number, test?: (this: { n: number }) => void } = { n: 1 } o.test = f o.test(); o!.test(); o.test!(); o.test!!!(); (o.test!)(); (o.test)();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/throwInEnclosingStatements.ts
TypeScript
// @allowUnreachableCode: true function fn(x) { throw x; } <T>(x: T) => { throw x; } var y: string; switch (y) { case 'a': throw y; default: throw y; } var z = 0; while (z < 10) { throw z; } for (var i = 0; ;) { throw i; } for (var idx in {}) { throw idx; } do { throw null; }while...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/throwStatements.ts
TypeScript
// @allowUnreachableCode: true // all legal interface I { id: number; } class C implements I { id: number; } class D<T>{ source: T; recurse: D<T>; wrapped: D<D<T>> } function F(x: string): number { return 42; } module M { export class A { name: string; } export function F2...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/topLevelAmbientModule.ts
TypeScript
// @module: commonjs // @Filename: foo_0.ts declare module "foo" { export var x: number; } // @Filename: foo_1.ts /// <reference path="foo_0.ts"/> import foo = require("foo"); var z = foo.x + 10;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/topLevelAwait.2.ts
TypeScript
// @target: esnext // @module: es2022,esnext declare namespace foo { const await: any; } // await allowed in import=namespace when not a module import await = foo.await;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/topLevelAwait.3.ts
TypeScript
// @target: esnext // @module: es2022,esnext // @filename: index.d.ts // await keyword allowed as identifier in a declaration file export {}; declare const await: any; declare class C extends await {}
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/topLevelFileModule.ts
TypeScript
// @module: commonjs // @Filename: vs/foo_0.ts export var x: number; // @Filename: vs/fum.d.ts export declare var y: number; // @Filename: foo_1.ts import foo = require("./vs/foo_0"); import fum = require("./vs/fum"); var z = foo.x + fum.y;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/topLevelFileModuleMissing.ts
TypeScript
// @module: commonjs // @Filename: vs/foo_0.ts export var x: number; // @Filename: foo_1.ts import foo = require("vs/foo"); var z = foo.x + 10;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/topLevelModuleDeclarationAndFile.ts
TypeScript
// @module: commonjs // @Filename: vs/foo_0/index.ts export var x: number = 42; // @Filename: foo_1.ts declare module "vs/foo_0" { export var y: () => number; } // @Filename: foo_2.ts /// <reference path="foo_1.ts"/> import foo = require("vs/foo_0"); var z1 = foo.x + 10; // Should error, as declaration should win...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/topLevelThisAssignment.ts
TypeScript
// @outFile: output.js // @allowJs: true // @checkJs: true // @Filename: a.js this.a = 10; this.a; a; // @Filename: b.js this.a; a;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/topLevelVarHoistingCommonJS.ts
TypeScript
// @target: esnext // @module: commonjs // @noTypesAndSymbols: true declare var _: any; { var a = _; } if (_) { var b = _; } else { var c = _; } switch (_) { case _: var d = _; default: var e = _; } while (_) { var f = _; } do { var g = _; } while (_); for (var h = _; ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/topLevelVarHoistingSystem.ts
TypeScript
// @target: esnext // @module: system // @noTypesAndSymbols: true if (false) { var y = 1; } function f() { console.log(y); } export { y };
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/tryStatements.ts
TypeScript
function fn() { try { } catch { } try { } catch { try { } catch { try { } catch { } } try { } catch { } } try { } catch (x) { var x: any; } try { } finally { } try { } catch { } finally { } try { } catch (z) { } finally { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/ts-expect-error-js.ts
TypeScript
// @allowJs: true // @checkJs: true // @noEmit: true // @fileName: a.js // there should be a "Unused @ts-expect-error" error since js files are being checked // @ts-expect-error const a = 1;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/ts-expect-error-nocheck-js.ts
TypeScript
// @allowJs: true // @checkJs: false // @noEmit: true // @fileName: a.js // there should not be a "Unused @ts-expect-error" error since js files are not being checked // @ts-expect-error const a = 1;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/ts-expect-error-nocheck.ts
TypeScript
// @ts-nocheck // there should not be a "Unused @ts-expect-error" error due to the // @ts-nocheck // @ts-expect-error const a = 1;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/ts-expect-error.ts
TypeScript
// @ts-expect-error additional commenting var invalidCommentedFancySingle: number = 'nope'; /* @ts-expect-error additional commenting */ var invalidCommentedFancyMulti: number = 'nope'; // @ts-expect-error additional commenting var validCommentedFancySingle: string = 'nope'; /* @ts-expect-error additional commentin...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/ts-ignore.ts
TypeScript
// @ts-ignore with additional commenting var invalidCommentedFancy: number = 'nope'; // @ts-ignore with additional commenting var validCommentedFancy: string = 'nope'; // @ts-ignore var invalidCommentedPlain: number = 'nope'; // @ts-ignore var validCommentedPlain: string = 'nope'; var invalidPlain: number = 'nope';...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/tsNoCheckForTypescript.ts
TypeScript
// @declaration: true // @filename: file.ts // @ts-nocheck export const a = 1 + {}; // This is an error, ofc, `Operator '+' cannot be applied to types '1' and '{}'`, which will be suppressed by the `nocheck` comment export interface Aleph { q: number; } export class Bet implements Aleph { q: string = "lol" ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/tsNoCheckForTypescriptComments1.ts
TypeScript
// @declaration: true // @filename: file.ts // @ts-nocheck additional comments export const a = 1 + {}; // This is an error, ofc, `Operator '+' cannot be applied to types '1' and '{}'`, which will be suppressed by the `nocheck` comment export interface Aleph { q: number; } export class Bet implements Aleph { q:...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/tsNoCheckForTypescriptComments2.ts
TypeScript
// @declaration: true // @filename: file.ts // @ts-nocheck: additional comments export const a = 1 + {}; // This is an error, ofc, `Operator '+' cannot be applied to types '1' and '{}'`, which will be suppressed by the `nocheck` comment export interface Aleph { q: number; } export class Bet implements Aleph { ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/tsxAttributeErrors.tsx
TypeScript (TSX)
// @jsx: preserve declare namespace JSX { interface Element { } interface IntrinsicElements { div: { text?: string; width?: number; } span: any; } } // Error, number is not assignable to string <div text={42} />; // Error, string is not assignable to number <div width={'foo'} />; // Error, number is...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/tsxAttributeResolution.tsx
TypeScript (TSX)
//@jsx: preserve declare namespace JSX { interface IntrinsicElements { x: { y: number; z: string; }; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/tsxAttributeResolution1.tsx
TypeScript (TSX)
//@filename: file.tsx //@jsx: preserve declare module JSX { interface Element { } interface IntrinsicElements { test1: Attribs1; test2: { reqd: string }; var: { var: string }; } } interface Attribs1 { x?: number; s?: string; } // OK <test1 x={0} />; // OK <test1 />; // OK <test1 data-x={true} />; // OK <te...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/tsxAttributeResolution10.tsx
TypeScript (TSX)
//@jsx: preserve //@module: amd //@filename: react.d.ts declare module JSX { interface Element { } interface IntrinsicElements { } interface ElementAttributesProperty { props; } } //@filename: file.tsx export class MyComponent { render() { } props: { [s: string]: boolean; } } // Should be an err...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/tsxAttributeResolution11.tsx
TypeScript (TSX)
//@jsx: preserve //@module: amd //@filename: react.d.ts declare module JSX { interface Element { } interface IntrinsicElements { } interface ElementAttributesProperty { props; } interface IntrinsicAttributes { ref?: string; } } //@filename: file.tsx class MyComponent { render() { } props: { ref...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/tsxAttributeResolution12.tsx
TypeScript (TSX)
//@jsx: preserve //@filename: react.d.ts declare module JSX { interface Element { } interface IntrinsicElements { } interface ElementAttributesProperty { props; } interface IntrinsicAttributes { ref?: string; } } //@filename: file.tsx declare class Component<P, S> { constructor(props?: P, context?: any)...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/tsxAttributeResolution13.tsx
TypeScript (TSX)
//@jsx: preserve //@filename: test.tsx function Test() { } <Test></Test>
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/tsxAttributeResolution14.tsx
TypeScript (TSX)
//@jsx: preserve //@module: amd //@filename: react.d.ts declare module JSX { interface Element { } interface IntrinsicElements { div: any; } interface ElementAttributesProperty { prop: any } } //@filename: file.tsx interface IProps { primaryText: string, [propName: string]: string | number } fun...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/tsxAttributeResolution15.tsx
TypeScript (TSX)
// @filename: file.tsx // @jsx: preserve // @noLib: true // @skipLibCheck: true // @noImplicitAny: true // @libFiles: react.d.ts,lib.d.ts import React = require('react'); class BigGreeter extends React.Component<{ }, {}> { render() { return <div>Default hi</div>; } greeting: string; } // Error l...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/tsxAttributeResolution16.tsx
TypeScript (TSX)
// @filename: file.tsx // @jsx: preserve // @noLib: true // @skipLibCheck: true // @libFiles: react.d.ts,lib.d.ts import React = require('react'); interface Address { street: string; country: string; } interface CanadianAddress extends Address { postalCode: string; } interface AmericanAddress extends Addre...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/tsxAttributeResolution2.tsx
TypeScript (TSX)
//@filename: file.tsx //@jsx: preserve declare module JSX { interface Element { } interface IntrinsicElements { test1: Attribs1; } } interface Attribs1 { c1?: (x: string) => void; } // OK <test1 c1={(x) => x.length} />; // OK <test1 data-c1={(x) => x.leng} />; // OK // Errors <test1 c1={(x) => x.leng} />; // E...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/tsxAttributeResolution3.tsx
TypeScript (TSX)
//@filename: file.tsx //@jsx: preserve declare module JSX { interface Element { } interface IntrinsicElements { test1: Attribs1; } } interface Attribs1 { x: string; y?: number; z?: string; } // OK var obj1 = { x: 'foo' }; <test1 {...obj1} /> // Error, x is not string var obj2 = { x: 32 }; <test1 {...obj2} /> ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/tsxAttributeResolution4.tsx
TypeScript (TSX)
//@filename: file.tsx //@jsx: preserve declare module JSX { interface Element { } interface IntrinsicElements { test1: Attribs1; } } interface Attribs1 { x(n: string): void; } // OK <test1 {... {x: (n) => 0} } />; // Error, no member 'len' on 'string' <test1 {... {x: (n) => n.len} } />;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/tsxAttributeResolution5.tsx
TypeScript (TSX)
//@filename: file.tsx //@jsx: preserve declare module JSX { interface Element { } interface IntrinsicElements { test1: Attribs1; test2: Attribs2; } } interface Attribs1 { x: string; } interface Attribs2 { toString(): string; } function make1<T extends {x: string}> (obj: T) { return <test1 {...obj} />; // OK...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/tsxAttributeResolution6.tsx
TypeScript (TSX)
//@filename: file.tsx //@jsx: preserve declare module JSX { interface Element { } interface IntrinsicElements { test1: { n?: boolean; s?: string}; test2: { n: boolean; }; } } // Error <test1 s />; <test1 n='true' />; <test2 />; // OK <test1 n />; <test1 n={false} />; <test2 n />;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/tsxAttributeResolution7.tsx
TypeScript (TSX)
//@filename: file.tsx //@jsx: preserve declare module JSX { interface Element { } interface IntrinsicElements { test1: { "data-foo"?: string }; } } // Error <test1 data-foo={32} />; // OK <test1 data-foo={'32'} />; <test1 data-bar={'32'} />; <test1 data-bar={32} />;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/tsxAttributeResolution8.tsx
TypeScript (TSX)
//@filename: file.tsx //@jsx: preserve declare module JSX { interface Element { } interface IntrinsicElements { test1: {x: string}; } } var x: any; // Should be OK <test1 {...x} />
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/tsxAttributeResolution9.tsx
TypeScript (TSX)
//@jsx: preserve //@module: amd //@filename: react.d.ts declare module JSX { interface Element { } interface IntrinsicElements { } interface ElementAttributesProperty { props; } } interface Props { foo: string; } //@filename: file.tsx export class MyComponent { render() { } props: { foo: string; ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/tsxCorrectlyParseLessThanComparison1.tsx
TypeScript (TSX)
// @jsx: react declare module JSX { interface Element { div: string; } } declare namespace React { class Component<P, S> { constructor(props?: P, context?: any); props: P; } } export class ShortDetails extends React.Component<{ id: number }, {}> { public render(): JSX.Eleme...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/tsxDefaultAttributesResolution1.tsx
TypeScript (TSX)
// @filename: file.tsx // @jsx: preserve // @noLib: true // @skipLibCheck: true // @libFiles: react.d.ts,lib.d.ts import React = require('react'); interface Prop { x: boolean; } class Poisoned extends React.Component<Prop, {}> { render() { return <div>Hello</div>; } } // OK let p = <Poisoned x/>;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/tsxDefaultAttributesResolution2.tsx
TypeScript (TSX)
// @filename: file.tsx // @jsx: preserve // @noLib: true // @skipLibCheck: true // @libFiles: react.d.ts,lib.d.ts import React = require('react'); interface Prop { x: true; } class Poisoned extends React.Component<Prop, {}> { render() { return <div>Hello</div>; } } // OK let p = <Poisoned x/>;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/tsxDefaultAttributesResolution3.tsx
TypeScript (TSX)
// @filename: file.tsx // @jsx: preserve // @noLib: true // @skipLibCheck: true // @libFiles: react.d.ts,lib.d.ts import React = require('react'); interface Prop { x: false; } class Poisoned extends React.Component<Prop, {}> { render() { return <div>Hello</div>; } } // Error let p = <Poisoned x/>...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/tsxDynamicTagName1.tsx
TypeScript (TSX)
// @jsx: preserve var CustomTag = "h1"; <CustomTag> Hello World </CustomTag> // No error
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/tsxDynamicTagName2.tsx
TypeScript (TSX)
// @jsx: preserve declare module JSX { interface Element { } interface IntrinsicElements { div: any } } var customTag = "h1"; <customTag> Hello World </customTag> // This should be an error. The lower-case is look up as an intrinsic element name
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/tsxDynamicTagName3.tsx
TypeScript (TSX)
// @jsx: preserve declare module JSX { interface Element { } interface IntrinsicElements { div: any } } var CustomTag: "h1" = "h1"; <CustomTag> Hello World </CustomTag> // This should be an error. we will try look up string literal type in JSX.IntrinsicElements
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/tsxDynamicTagName4.tsx
TypeScript (TSX)
// @jsx: preserve declare module JSX { interface Element { } interface IntrinsicElements { div: any h1: any } } var CustomTag: "h1" = "h1"; <CustomTag> Hello World </CustomTag>
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/tsxDynamicTagName5.tsx
TypeScript (TSX)
// @jsx: preserve //@filename: react.d.ts declare module 'react' { class Component<T, U> { } } //@filename: app.tsx import * as React from 'react'; export class Text extends React.Component<{}, {}> { _tagName: string = 'div'; render() { return ( <this._tagName /> ); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/tsxDynamicTagName6.tsx
TypeScript (TSX)
// @jsx: preserve declare module JSX { interface Element { } interface IntrinsicElements { div: any } } const t = {tag:'h1'} const foo = <t.tag/> // No error
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/tsxDynamicTagName7.tsx
TypeScript (TSX)
// @jsx: preserve //@filename: react.d.ts declare module 'react' { class Component<T, U> { } } //@filename: app.tsx import * as React from 'react'; export class Text extends React.Component<{}, {}> { _tagName: string = 'div'; render() { return ( <this/> // this should be an error ); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University