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/typescript-errors/type-lit/optional-getter/input.ts
TypeScript
export type A = { get m?(): string; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript-errors/type-lit/optional-setter/input.ts
TypeScript
export type A = { set m?(val: string); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript-errors/type-lit/readonly-getter/input.ts
TypeScript
export type A = { readonly get m(): string; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript-errors/type-lit/readonly-method/input.ts
TypeScript
export type A = { readonly m(): string; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript-errors/type-lit/readonly-setter/input.ts
TypeScript
export type A = { readonly set m(val: string); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript-errors/type-only-export-specifier/duplicated-type-only/input.ts
TypeScript
export type { type something }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript-errors/type-only-export-specifier/missing-as/input.ts
TypeScript
export { type foo bar }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript-errors/type-only-export-specifier/missing-local/input.ts
TypeScript
export { type foo as }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript-errors/type-only-export-specifier/redundant-tokens/input.ts
TypeScript
export { type foo as bar baz }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript-errors/type-only-export-specifier/too-many-as/input.ts
TypeScript
export { type as as as as }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript-errors/type-only-import-equals-decl/named/input.ts
TypeScript
import type { MyType } = require('commonjs-package')
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript-errors/type-only-import-equals-decl/namespace/input.ts
TypeScript
import type * as MyType = require('commonjs-package')
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript-errors/type-only-import-specifier/duplicated-type-only/input.ts
TypeScript
import type { type something } from 'mod'
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript-errors/type-only-import-specifier/invalid-local/input.ts
TypeScript
import { type as export } from 'mod'
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript-errors/type-only-import-specifier/invalid-type-only-local-with-imported/input.ts
TypeScript
import { type as as export } from 'mod'
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript-errors/type-only-import-specifier/invalid-type-only/input.ts
TypeScript
import { type import } from 'mod'
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript-errors/type-only-import-specifier/missing-as/input.ts
TypeScript
import { type foo bar } from 'mod'
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript-errors/type-only-import-specifier/missing-local/input.ts
TypeScript
import { type foo as } from 'mod'
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript-errors/type-only-import-specifier/redundant-tokens/input.ts
TypeScript
import { type foo as bar baz } from 'mod'
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript-errors/type-only-import-specifier/too-many-as/input.ts
TypeScript
import { type as as as as } from 'mod'
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript-errors/type-parameter-lists/typeParameterConstModifiers.ts
TypeScript
// @strict: true declare function f1<const T>(x: T): T; const x11 = f1('a'); const x12 = f1(['a', ['b', 'c']]); const x13 = f1({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }); declare function f2<const T, U>(x: T | undefined): T; const x21 = f2('a'); const x22 = f2(['a', ['b', 'c']]); const x23 = f2({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }); declare function f3<const T>(x: T): T[]; const x31 = f3("hello"); const x32 = f3("hello"); declare function f4<const T>(obj: [T, T]): T; const x41 = f4([[1, 'x'], [2, 'y']]); const x42 = f4([{ a: 1, b: 'x' }, { a: 2, b: 'y' }]); declare function f5<const T>(obj: { x: T, y: T }): T; const x51 = f5({ x: [1, 'x'], y: [2, 'y'] }); const x52 = f5({ x: { a: 1, b: 'x' }, y: { a: 2, b: 'y' } }); declare function f6<const T extends readonly unknown[]>(...args: T): T; const x61 = f6(1, 'b', { a: 1, b: 'x' }); class C1<const T> { constructor(x: T) {} foo<const U>(x: U) { return x; } } const c71 = new C1({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }); const c72 = c71.foo(['a', ['b', 'c']]); const fx1 = <const T>(x: T) => x; const fx2 = <const T,>(x: T) => x; interface I1<const T> { x: T } // Error interface I2 { f<const T>(x: T): T; } type T1<const T> = T; // Error type T2 = <const T>(x: T) => T; type T3 = { <const T>(x: T): T }; type T4 = new <const T>(x: T) => T; type T5 = { new <const T>(x: T): T }; // Corrected repro from #51745 type Obj = { a: { b: { c: "123" } } }; type GetPath<T, P> = P extends readonly [] ? T : P extends readonly [infer A extends keyof T, ...infer Rest] ? GetPath<T[A], Rest> : never; function set<T, const P extends readonly string[]>(obj: T, path: P, value: GetPath<T, P>) {} declare let obj: Obj; declare let value: "123"; set(obj, ['a', 'b', 'c'], value);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript-errors/types/tuple-optional-invalid/input.ts
TypeScript
let x: [string?, number]
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript-errors/use-strict/arrow-fn-expr/input.ts
TypeScript
const f = ([x]: string) => { 'use strict' }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript-errors/use-strict/fn-block/input.ts
TypeScript
function f([x]: string) { 'use strict' }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript-errors/variable-declarator/definite-assignment-not-allowed/input.ts
TypeScript
let {}! = {};
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript-errors/variance-annotations/1/input.ts
TypeScript
type Covariant<out T> = { x: T; } declare let super_covariant: Covariant<unknown>; declare let sub_covariant: Covariant<string>; super_covariant = sub_covariant; sub_covariant = super_covariant; // Error type Contravariant<in T> = { f: (x: T) => void; } declare let super_contravariant: Contravariant<unknown>; declare let sub_contravariant: Contravariant<string>; super_contravariant = sub_contravariant; // Error sub_contravariant = super_contravariant; type Invariant<in out T> = { f: (x: T) => T; } declare let super_invariant: Invariant<unknown>; declare let sub_invariant: Invariant<string>; super_invariant = sub_invariant; // Error sub_invariant = super_invariant; // Error // Variance of various type constructors type T10<out T> = T; type T11<in T> = keyof T; type T12<out T, out K extends keyof T> = T[K]; type T13<in out T> = T[keyof T]; // Variance annotation errors type Covariant1<in T> = { // Error x: T; } type Contravariant1<out T> = keyof T; // Error type Contravariant2<out T> = { // Error f: (x: T) => void; } type Invariant1<in T> = { // Error f: (x: T) => T; } type Invariant2<out T> = { // Error f: (x: T) => T; } // Variance in circular types type Foo1<in T> = { // Error x: T; f: FooFn1<T>; } type FooFn1<T> = (foo: Bar1<T[]>) => void; type Bar1<T> = { value: Foo1<T[]>; } type Foo2<out T> = { // Error x: T; f: FooFn2<T>; } type FooFn2<T> = (foo: Bar2<T[]>) => void; type Bar2<T> = { value: Foo2<T[]>; } type Foo3<in out T> = { x: T; f: FooFn3<T>; } type FooFn3<T> = (foo: Bar3<T[]>) => void; type Bar3<T> = { value: Foo3<T[]>; } // Wrong modifier usage type T20<public T> = T; // Error type T21<in out in T> = T; // Error type T22<in out out T> = T; // Error type T23<out in T> = T; // Error declare function f1<in T>(x: T): void; // Error declare function f2<out T>(): T; // Error class C { in a = 0; // Error out b = 0; // Error } // Interface merging interface Baz<out T> {} interface Baz<in T> {} declare let baz1: Baz<unknown>; declare let baz2: Baz<string>; baz1 = baz2; // Error baz2 = baz1; // Error // Repro from #44572 interface Parent<out A> { child: Child<A> | null; parent: Parent<A> | null; } interface Child<A, B = unknown> extends Parent<A> { readonly a: A; readonly b: B; } function fn<A>(inp: Child<A>) { const a: Child<unknown> = inp; } const pu: Parent<unknown> = { child: { a: 0, b: 0, child: null, parent: null }, parent: null }; const notString: Parent<string> = pu; // Error // Repro from comment in #44572 declare class StateNode<TContext, in out TEvent extends { type: string }> { _storedEvent: TEvent; _action: ActionObject<TEvent>; _state: StateNode<TContext, any>; } interface ActionObject<TEvent extends { type: string }> { exec: (meta: StateNode<any, TEvent>) => void; } declare function createMachine<TEvent extends { type: string }>(action: ActionObject<TEvent>): StateNode<any, any>; declare function interpret<TContext>(machine: StateNode<TContext, any>): void; const machine = createMachine({} as any); interpret(machine); declare const qq: ActionObject<{ type: "PLAY"; value: number }>; createMachine<{ type: "PLAY"; value: number } | { type: "RESET" }>(qq); // Error
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript.rs
Rust
#![allow(clippy::needless_update)] use std::{ fs::File, io::Read, path::{Path, PathBuf}, }; use pretty_assertions::assert_eq; use swc_common::{comments::SingleThreadedComments, FileName}; use swc_ecma_ast::*; use swc_ecma_parser::{lexer::Lexer, PResult, Parser, Syntax, TsSyntax}; use swc_ecma_visit::FoldWith; use testing::StdErr; use crate::common::Normalizer; #[path = "common/mod.rs"] mod common; #[testing::fixture("tests/shifted/**/*.ts")] fn shifted(file: PathBuf) { { // Drop to reduce memory usage. // // Because the test suite contains lots of test cases, it results in oom in // github actions. let input = { let mut buf = String::new(); File::open(&file).unwrap().read_to_string(&mut buf).unwrap(); buf }; eprintln!( "\n\n========== Running reference test {}\nSource:\n{}\n", file.display(), input ); } with_parser(false, &file, true, true, |p, comments| { let program = p.parse_program()?.fold_with(&mut Normalizer { drop_span: false, is_test262: false, }); let json = serde_json::to_string_pretty(&program).expect("failed to serialize module as json"); if StdErr::from(json) .compare_to_file(format!("{}.json", file.display())) .is_err() { panic!() } if StdErr::from(format!("{:#?}", comments)) .compare_to_file(format!("{}.comments", file.display())) .is_err() { panic!() } Ok(()) }) .map_err(|_| ()) .unwrap(); } #[testing::fixture("tests/typescript/**/*.ts")] #[testing::fixture("tests/typescript/**/*.mts")] #[testing::fixture("tests/typescript/**/*.cts")] #[testing::fixture("tests/typescript/**/*.tsx")] fn spec(file: PathBuf) { let output = file.parent().unwrap().join(format!( "{}.json", file.file_name().unwrap().to_string_lossy() )); run_spec(&file, &output); } #[testing::fixture( "tests/tsc/**/*.ts", exclude( "for-of51.ts", "parserArrowFunctionExpression11", "esDecorators-decoratorExpression.1" ) )] fn tsc_spec(file: PathBuf) { let output = file.with_extension("json"); run_spec(&file, &output); } fn run_spec(file: &Path, output_json: &Path) { let file_name = file .display() .to_string() .replace("\\\\", "/") .replace('\\', "/"); // Ignore some useless tests let ignore = file_name.contains("tsc/FunctionDeclaration7_es6") || file_name.contains("unicodeExtendedEscapesInStrings11_ES5") || file_name.contains("tsc/unicodeExtendedEscapesInStrings10_ES5") || file_name.contains("tsc/unicodeExtendedEscapesInStrings11_ES6") || file_name.contains("tsc/unicodeExtendedEscapesInStrings10_ES6") || file_name.contains("tsc/propertyNamesOfReservedWords") || file_name.contains("unicodeExtendedEscapesInTemplates10_ES5") || file_name.contains("unicodeExtendedEscapesInTemplates10_ES6") || file_name.contains("tsc/unicodeExtendedEscapesInTemplates11_ES5") || file_name.contains("tsc/unicodeExtendedEscapesInTemplates11_ES6") || file_name.contains("tsc/parser.numericSeparators.decimal"); // Useful only for error reporting let ignore = ignore || file_name.contains("tsc/callSignaturesWithParameterInitializers") || file_name.contains("tsc/jsdocDisallowedInTypescript") || file_name.contains("tsc/errorSuperCalls") || file_name.contains("tsc/restElementMustBeLast") || file_name.contains("tsc/parserRegularExpressionDivideAmbiguity3"); // Postponed let ignore = ignore || file_name.contains("tsc/inlineJsxFactoryDeclarationsx") || file_name.contains("tsc/importDefaultNamedType") || file_name.contains("tsc/tsxAttributeResolution5x") || file_name.contains("tsc/tsxErrorRecovery2x") || file_name.contains("tsc/tsxErrorRecovery3x") || file_name.contains("tsc/tsxErrorRecovery5x") || file_name.contains("tsc/tsxReactEmitEntitiesx") || file_name.contains("tsc/tsxTypeArgumentsJsxPreserveOutputx") || file_name.contains("tsc/emitCompoundExponentiationAssignmentWithIndexingOnLHS3") || file_name.contains("tsc/objectLiteralGettersAndSetters") || file_name.contains("tsc/restElementMustBeLast") || file_name.contains("tsc/unicodeEscapesInJsxtagsx") || file_name.contains("tsc/FunctionDeclaration6_es6") || file_name.contains("tsc/checkJsxNamespaceNamesQuestionableForms") || file_name.contains("tsc/classExtendingOptionalChain") || file_name.contains("tsc/inlineJsxFactoryDeclarations") || file_name.contains("tsc/interfaceExtendingOptionalChain") || file_name.contains("tsc/interfacesWithPredefinedTypesAsNames") || file_name.contains("tsc/namedTupleMembersErrors") || file_name.contains("tsc/parserForOfStatement23") || file_name.contains("tsc/topLevelAwait.2") || file_name.contains("tsc/tsxAttributeResolution5") || file_name.contains("tsc/tsxErrorRecovery2") || file_name.contains("tsc/tsxErrorRecovery3") || file_name.contains("tsc/tsxTypeArgumentsJsxPreserveOutput") || file_name.contains("tsc/unicodeEscapesInJsxtags") || file_name.contains("tsc/propertyAccessNumericLiterals") || file_name.contains("tsc/parserAssignmentExpression1") || file_name.contains("tsc/parserGreaterThanTokenAmbiguity11") || file_name.contains("tsc/parserGreaterThanTokenAmbiguity15") || file_name.contains("tsc/parserGreaterThanTokenAmbiguity16") || file_name.contains("tsc/parserGreaterThanTokenAmbiguity20") || file_name.contains("tsc/awaitUsingDeclarationsInFor") || file_name.ends_with("tsc/usingDeclarationsInFor.ts") || file_name.ends_with("tsc/decoratorOnClassMethod12.ts") || file_name.ends_with("tsc/esDecorators-preservesThis.ts") || file_name.ends_with("tsc/topLevelVarHoistingCommonJS.ts"); if ignore { return; } { // Drop to reduce memory usage. // // Because the test suite contains lots of test cases, it results in oom in // github actions. let input = { let mut buf = String::new(); File::open(file).unwrap().read_to_string(&mut buf).unwrap(); buf }; eprintln!( "\n\n========== Running reference test {}\nSource:\n{}\n", file_name, input ); } with_parser(false, file, true, false, |p, _| { let program = p.parse_program()?.fold_with(&mut Normalizer { drop_span: false, is_test262: false, }); let json = serde_json::to_string_pretty(&program).expect("failed to serialize module as json"); if StdErr::from(json.clone()) .compare_to_file(output_json) .is_err() { panic!() } let program = program.fold_with(&mut Normalizer { drop_span: true, is_test262: false, }); let deser = match serde_json::from_str::<Program>(&json) { Ok(v) => v.fold_with(&mut Normalizer { drop_span: true, is_test262: false, }), Err(err) => { if err.to_string().contains("invalid type: null, expected f64") { return Ok(()); } panic!( "failed to deserialize json back to module: {}\n{}", err, json ) } }; // We are not debugging f64 parsing of serde. if file_name.contains("issue-1803") || file_name.contains("stc") { return Ok(()); } assert_eq!(program, deser, "JSON:\n{}", json); Ok(()) }) .map_err(|_| ()) .unwrap(); } fn with_parser<F, Ret>( treat_error_as_bug: bool, file_name: &Path, no_early_errors: bool, shift: bool, f: F, ) -> Result<Ret, StdErr> where F: FnOnce(&mut Parser<Lexer>, &SingleThreadedComments) -> PResult<Ret>, { let fname = file_name.display().to_string(); ::testing::run_test(treat_error_as_bug, |cm, handler| { if shift { cm.new_source_file(FileName::Anon.into(), "".into()); } let comments = SingleThreadedComments::default(); let fm = cm .load_file(file_name) .unwrap_or_else(|e| panic!("failed to load {}: {}", file_name.display(), e)); let lexer = Lexer::new( Syntax::Typescript(TsSyntax { dts: fname.ends_with(".d.ts"), tsx: fname.contains("tsx"), decorators: true, no_early_errors, disallow_ambiguous_jsx_like: fname.contains("cts") || fname.contains("mts"), ..Default::default() }), EsVersion::Es2015, (&*fm).into(), Some(&comments), ); let mut p = Parser::new_from(lexer); let res = f(&mut p, &comments).map_err(|e| e.into_diagnostic(handler).emit()); for err in p.take_errors() { err.into_diagnostic(handler).emit(); } if handler.has_errors() { return Err(()); } res }) } #[testing::fixture("tests/typescript-errors/**/*.ts")] #[testing::fixture("tests/typescript-errors/**/*.mts")] #[testing::fixture("tests/typescript-errors/**/*.cts")] #[testing::fixture("tests/typescript-errors/**/*.tsx")] fn errors(file: PathBuf) { let file_name = file.display().to_string(); { let input = { let mut buf = String::new(); File::open(&file).unwrap().read_to_string(&mut buf).unwrap(); buf }; eprintln!( "\n\n========== Running reference test {}\nSource:\n{}\n", file_name, input ); } let module = with_parser(false, &file, false, false, |p, _| { p.parse_typescript_module() }); let err = module.expect_err("should fail, but parsed as"); if err .compare_to_file(format!("{}.swc-stderr", file.display())) .is_err() { panic!() } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/amaro-194/input.ts
TypeScript
class Wrapper<Fn extends (...args: any[]) => any> { #inner: Fn; constructor(inner: Fn) { this.#inner = inner; } wrap(x: unknown): ReturnType<Fn> { return this.#inner(x); } } async function main(): Promise<void> { // The error happens here: const promiseWrapper = new Wrapper<<T>(x: T) => Promise<T>>(Promise.resolve.bind(Promise)); const strPromise: Promise<string> = promiseWrapper.wrap("Hello, World!") as any; const str = await strPromise; console.log(str); } main();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/arrow-function/annotated/input.ts
TypeScript
(x: number): number => x;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/arrow-function/async-await-null/input.ts
TypeScript
async <T>() => await null;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/arrow-function/async-generic-false-positive/input.ts
TypeScript
async < 1; async<T>() == 0;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/arrow-function/async-generic/input.ts
TypeScript
async <T>(a: T): T => a;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/arrow-function/async-param/input.ts
TypeScript
let fn1 = (async, x) => {}; let fn2 = (async = 1, x) => {}; let fn3 = (async?, x?) => {}; let fn4 = (async: any, x: any) => {};
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/arrow-function/async-rest/input.ts
TypeScript
async (...args: any[]) : any => {}
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/arrow-function/async/input.ts
TypeScript
async (x?: number): any => x;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/arrow-function/const-type-param/input.ts
TypeScript
export const fn = <const Data extends Type>(payload: Data) => payload;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/arrow-function/default-parameter-values/input.ts
TypeScript
(x: number = 0) => 0;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/arrow-function/destructuring/input.ts
TypeScript
({ a = 0 }) => 0;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/arrow-function/generic-tsx/input.ts
TypeScript
// Same as `generic`. Verify that JSX doesn't change things. <T>(a: T): T => a;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/arrow-function/generic/input.ts
TypeScript
<T>(a: T): T => a;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/arrow-function/inside-conditional-expr/input.ts
TypeScript
referrer ? false : ([, specifier]): string => specifier;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/arrow-function/optional-parameter/input.ts
TypeScript
(x?: number): any => x;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/arrow-function/predicate-types/input.ts
TypeScript
(x: any): x is string => true;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/case1/input.ts
TypeScript
class Foo { declare a: string }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/cast/as/input.ts
TypeScript
x as T; x < y as boolean; // (x < y) as boolean; x === 1 as number; // x === (1 as number); x as any as T;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/cast/assert-and-assign/input.ts
TypeScript
(a as number) = 42;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/cast/false-positive/input.ts
TypeScript
f(x < 0, /a/);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/cast/multiple-assert-and-assign/input.ts
TypeScript
(a as number as any) = 42;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/cast/need-parentheses/input.ts
TypeScript
(<T> x).y; (x as T).y; x!.y;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/cast/null-assertion-2/input.ts
TypeScript
x! / 2
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/cast/null-assertion-3/input.ts
TypeScript
const x = foo()!;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/cast/null-assertion-and-assign-2/input.ts
TypeScript
x! *= 1
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/cast/null-assertion-and-assign/input.ts
TypeScript
x! += 1;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/cast/null-assertion-false-positive/input.ts
TypeScript
a !b
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/cast/null-assertion-then-property-access/input.ts
TypeScript
x!.y;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/cast/null-assertion/input.ts
TypeScript
x!;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/cast/type-assertion-after-operator/input.ts
TypeScript
1 + <number> 1;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/cast/type-assertion-and-assign/input.ts
TypeScript
(<number> x) += 1;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/cast/type-assertion-before-operator/input.ts
TypeScript
<number> 1 + 1;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/cast/type-assertion/input.ts
TypeScript
<number> 1;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/abstract-false-positive/input.ts
TypeScript
// Exports an identifier, doesn't try parsing `abstract class` export default abstract;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/abstract/input.ts
TypeScript
abstract class C {} declare abstract class C {} export abstract class C {} // `export abstract class {}` is not valid TypeScript. export default abstract class { } export default abstract class C { } // `abstract class` is not valid as an expression. export abstract class C { abstract prop: number; abstract method(): void; } export class C { // should still have as abstract even though parent is not abstract prop: number; abstract method(): void; // should be abstract in spite of override in wrong place override abstract method(): string; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/auto-accessor/input.ts
TypeScript
abstract class B { abstract accessor i: number; } class C1 extends B { accessor a: any; accessor b = 1; static accessor c: any; static accessor d = 2; public static accessor e = 4; protected static accessor f: number; private accessor g!: string; public accessor h = 1; public override accessor i = 10; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/constructor-with-modifier-names/input.ts
TypeScript
class Foo { constructor(set, readonly) {} constructor(set: any, readonly: boolean) {} }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/constructor/input.ts
TypeScript
class C { constructor(x: number, y: number); constructor(x: string, y: string); constructor(x: any, y: any) {} }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/declare/input.ts
TypeScript
declare class C { [x: string]: any; x; x: number; f(); f(): void; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/decorators/input.ts
TypeScript
@dec class C { constructor(@dec public param: string) { } @dec @dec2 method() {} @dec prop; @dec get prop2() { return 5; } @dec static method() {} }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/expression-extends-implements/input.ts
TypeScript
(class extends f()<T> implements X.Y<T> {}); (class C extends f()<T> implements X.Y<T> {});
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/expression-extends/input.ts
TypeScript
(class extends f()<T> {}); (class C extends f()<T> {});
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/expression-generic/input.ts
TypeScript
(class<T> {}); (class C<T> {});
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/expression-implements/input.ts
TypeScript
(class implements X.Y<T> {}); (class C implements X.Y<T> {});
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/extends-implements/input.ts
TypeScript
class C extends f()<T> implements X.Y<T> {}
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/extends/input.ts
TypeScript
class C extends f()<T> {}
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/generic/input.ts
TypeScript
class C<T extends object = { x: number }> {}
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/get-generic/input.ts
TypeScript
declare class C { get<T>(): void; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/get-set-asi-issue/input.ts
TypeScript
class C { get x() { return 0 } set x(value) {} }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/implements/input.ts
TypeScript
class C implements X.Y<T> {}
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/index-signature/input.ts
TypeScript
class C { [x: string]: any; readonly [x: string]: any; static [x: string]: any; static readonly [x: string]: any; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/members-with-modifier-names/input.ts
TypeScript
class C { public(): void; public static(): void; readonly = 0; async<T>(): void; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/members-with-reserved-names/input.ts
TypeScript
class C { public delete(): void; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/method-computed/input.ts
TypeScript
class C { [Symbol.iterator](): void; [Symbol.iterator]?(): void; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/method-generic/input.ts
TypeScript
class C { f<T>(a: T, b?: T, ...c: T[]): T {} [Symbol.iterator]<T>(): T {} }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/method-no-body/input.ts
TypeScript
class C { f(); f(): void; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/method-optional/input.ts
TypeScript
class C { m?(): void {} }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/method-return-type/input.ts
TypeScript
class C { f(): void {} g(): this is {} { return true; } h(): asserts this is {} { throw ""; } i(): asserts this { throw ""; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/method-with-newline-with-body/input.ts
TypeScript
class C { m() { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/method-with-newline-without-body/input.ts
TypeScript
class C { m() n() }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/modifier-override/input.ts
TypeScript
class MyClass1 extends BaseClass { override() {} override show() {} public override show() {} override size = 5; override readonly size = 5; abstract override readonly size = 5; private abstract override readonly size = 5; static override show() {} }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/modifiers-accessors/input.ts
TypeScript
// Copy of modifiers-methods with 'get' abstract class C { abstract get a(); static get s() { return 0; } public abstract get pua(); public static get pus() { return 0; } public get pu() { return 0; } protected get po() { return 0; } private get pi() { return 0; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/modifiers-methods-async/input.ts
TypeScript
// Copy of modifiers-methods with 'async' abstract class C { abstract async a(); static async s() {} public abstract async pua(); public static async pus() {} public async pu() {} protected async po() {} private async pi() {} }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/modifiers-properties/input.ts
TypeScript
abstract class C { readonly r; readonly r2?: number; abstract a; static s; public pu; protected po; private pi; readonly abstract ra; abstract readonly ar; static readonly sr; public readonly pur; public abstract pua; public static pus; public readonly abstract pura; public abstract readonly puar; public static readonly pusr; declare public readonly dpur; declare private static readonly dpisr; declare d; declare declare; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/override-parameter-property/input.ts
TypeScript
class C extends B { constructor(override: Date) constructor(override v: number) constructor(public override v: string) constructor(override readonly v: boolean) constructor(arg: any) { super() } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/override/input.ts
TypeScript
class C extends B { override prop = 5; override method() { } } // even without an extends it should set is_override class C { override prop = 5; override method() { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/properties/input.ts
TypeScript
class C { x; x?; x: number; x: number = 1; x!; x!: number; async: boolean; static async: boolean; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/property-computed/input.ts
TypeScript
class C { [Symbol.iterator]: number; [Symbol.iterator]?: number; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/property-declare/input.ts
TypeScript
class MyClass { declare hoge: string; declare foo: number; constructor() { this.hoge = "test"; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/property-private/input.ts
TypeScript
class MyClass { #a = 0; #b: string; constructor() { this.#b = "test"; } method() { return #a in this; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/class/static/input.ts
TypeScript
class C { static f(); public static f(); protected static f(); private static f(); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/const/no-initializer/input.ts
TypeScript
const x: number;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/typescript/custom/arrow/complex-tsc/input.ts
TypeScript
export const assertEachNode = shouldAssert(AssertionLevel.Normal) ? (nodes: Node[], test: (node: Node) => boolean, message?: string): void => assert( test === undefined || every(nodes, test), message || "Unexpected node.", () => `Node array did not pass test '${getFunctionName(test)}'.`, assertEachNode) : noop;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University