_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/emitCommentsOnlyFile.ts_0_247
// @removeComments: false /** * @name Foo * @class */ /**#@+ * @memberOf Foo# * @field */ /** * @name bar * @type Object[] */ /**#@-*/ /** * @name Foo2 * @class */ /**#@+ * @memberOf Foo2# * @field */ /** * @name bar * @type Object[] */ /**#@-*/
{ "end_byte": 247, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emitCommentsOnlyFile.ts" }
TypeScript/tests/cases/compiler/unionErrorMessageOnMatchingDiscriminant.ts_0_253
// @strict: true type A = { type: 'a', data: { a: string } }; type B = { type: 'b', data: null }; type C = { type: 'c', payload: string }; type Union = A | B | C; // error const foo: Union = { type: 'a', data: null };
{ "end_byte": 253, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unionErrorMessageOnMatchingDiscriminant.ts" }
TypeScript/tests/cases/compiler/thisInStatics.ts_0_134
class C { static f() { var y/*1*/ = this; } static get x() { var y/*2*/ = this; return y; } }
{ "end_byte": 134, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/thisInStatics.ts" }
TypeScript/tests/cases/compiler/coAndContraVariantInferences4.ts_0_649
// @strict: true const enum SyntaxKind { Modifier, Decorator, } interface Node { kind: SyntaxKind; } interface Modifier extends Node { kind: SyntaxKind.Modifier; } interface Decorator extends Node { kind: SyntaxKind.Decorator; } declare function isModifier(node: Node): node is Modifier; declare function...
{ "end_byte": 649, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/coAndContraVariantInferences4.ts" }
TypeScript/tests/cases/compiler/incompatibleTypes.ts_0_1247
interface IFoo1 { p1(): number; } class C1 implements IFoo1 { // incompatible on the return type public p1() { return "s"; } } interface IFoo2 { p1(s:string): number; } class C2 implements IFoo2 { // incompatible on the param type public p1(n:number) { return 0; } } interface...
{ "end_byte": 1247, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/incompatibleTypes.ts" }
TypeScript/tests/cases/compiler/nestedLoops.ts_0_477
// @target: es5 export class Test { constructor() { let outerArray: Array<number> = [1, 2, 3]; let innerArray: Array<number> = [1, 2, 3]; for (let outer of outerArray) for (let inner of innerArray) { this.aFunction((newValue, oldValue) => { ...
{ "end_byte": 477, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nestedLoops.ts" }
TypeScript/tests/cases/compiler/genericClassStaticMethod.ts_0_106
class Foo<T> { static getFoo() { } } class Bar<T> extends Foo<T> { static getFoo() { } }
{ "end_byte": 106, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericClassStaticMethod.ts" }
TypeScript/tests/cases/compiler/implicitAnyInAmbientDeclaration.ts_0_371
//@noimplicitany: true module Test { declare class C { public publicMember; // this should be an error private privateMember; // this should not be an error public publicFunction(x); // this should be an error private privateFunction(privateParam); // this should not be an error...
{ "end_byte": 371, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/implicitAnyInAmbientDeclaration.ts" }
TypeScript/tests/cases/compiler/nonNullableReductionNonStrict.ts_0_508
// Repros from #43425 type Transform1<T> = ((value: string) => T) | (string extends T ? undefined : never); type Transform2<T> = string extends T ? ((value: string) => T) | undefined : (value: string) => T; function test<T>(f1: Transform1<T>, f2: Transform2<T>) { f1?.("hello"); f2?.("hello"); } function f1<T...
{ "end_byte": 508, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nonNullableReductionNonStrict.ts" }
TypeScript/tests/cases/compiler/commentOnElidedModule1.ts_0_272
//@filename: a.ts /*!================= Keep this pinned ================= */ /*! Don't keep this pinned comment */ module ElidedModule { } // Don't keep this comment. module ElidedModule2 { } //@filename: b.ts ///<reference path="a.ts"/> module ElidedModule3 { }
{ "end_byte": 272, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentOnElidedModule1.ts" }
TypeScript/tests/cases/compiler/nodeNextModuleResolution1.ts_0_287
// @moduleResolution: nodenext // @traceResolution: true // @filename: /a/node_modules/foo.d.ts export declare let x: number // @filename: /a/b/c/d/e/package.json { "name": "e", "version": "1.0.0", "type": "module" } // @filename: /a/b/c/d/e/app.ts import {x} from "foo";
{ "end_byte": 287, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nodeNextModuleResolution1.ts" }
TypeScript/tests/cases/compiler/pathMappingBasedModuleResolution3_classic.ts_0_533
// @moduleResolution: classic // @module: amd // @baseUrl: c:/root // @traceResolution: true // baseUrl set via command line // @filename: c:/root/folder1/file1.ts import {x} from "folder2/file2" declare function use(a: any): void; use(x.toExponential()); // @filename: c:/root/folder2/file2.ts import {x as a} from "...
{ "end_byte": 533, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/pathMappingBasedModuleResolution3_classic.ts" }
TypeScript/tests/cases/compiler/reservedWords.ts_0_178
var obj = { if: 0, debugger: 2, break: 3, function: 4 } //This compiles. var obj2 = { if: 0, while: 1, debugger: 2, break: 3, function: 4 }
{ "end_byte": 178, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reservedWords.ts" }
TypeScript/tests/cases/compiler/libTypeScriptOverrideSimpleConfig.ts_0_358
// @traceResolution: true // @Filename: /somepath/node_modules/@typescript/lib-dom/index.d.ts interface ABC { abc: string } // @Filename: /somepath/tsconfig.json { } // @Filename: /somepath/index.ts /// <reference lib="dom" /> const a: ABC = { abc: "Hello" } // This should fail because libdom has been replaced // by ...
{ "end_byte": 358, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/libTypeScriptOverrideSimpleConfig.ts" }
TypeScript/tests/cases/compiler/arrayLiteral1.ts_0_17
var v30 = [1, 2];
{ "end_byte": 17, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arrayLiteral1.ts" }
TypeScript/tests/cases/compiler/identicalTypesNoDifferByCheckOrder.ts_0_1164
// @strictNullChecks: true interface SomeProps { x?: string; y?: number; renderAs?: FunctionComponent1<SomeProps> } type SomePropsX = Required<Pick<SomeProps, "x">> & Omit<SomeProps, "x">; interface SomePropsClone { x?: string; y?: number; renderAs?: FunctionComponent2<SomeProps> } type Some...
{ "end_byte": 1164, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/identicalTypesNoDifferByCheckOrder.ts" }
TypeScript/tests/cases/compiler/typeConstraintsWithConstructSignatures.ts_0_277
interface Constructable { new (): any; } class C<T extends Constructable> { constructor(public data: T, public data2: Constructable) { } create() { var x = new this.data(); // should not error var x2 = new this.data2(); // should not error } }
{ "end_byte": 277, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeConstraintsWithConstructSignatures.ts" }
TypeScript/tests/cases/compiler/voidIsInitialized.ts_0_222
// @strict: true const x: void = undefined; const y: void = undefined; if(typeof x === "undefined") { x // no error: assume x2 is initialised } if(typeof y !== "undefined") { y // no error: do not narrow void }
{ "end_byte": 222, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/voidIsInitialized.ts" }
TypeScript/tests/cases/compiler/functionOverloads26.ts_0_116
function foo():string; function foo(bar:string):number; function foo(bar?:any):any{ return '' } var x = foo('baz');
{ "end_byte": 116, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloads26.ts" }
TypeScript/tests/cases/compiler/spreadTupleAccessedByTypeParameter.ts_0_154
export function test<N extends number>(singletons: ["a"][], i: N) { const singleton = singletons[i]; const [, ...rest] = singleton; return rest; }
{ "end_byte": 154, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/spreadTupleAccessedByTypeParameter.ts" }
TypeScript/tests/cases/compiler/typeofUsedBeforeBlockScoped.ts_0_144
type T = typeof C & typeof C.s & typeof o & typeof o.n; class C { static s = 2; } type W = typeof o.n; let o2: typeof o; let o = { n: 12 };
{ "end_byte": 144, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeofUsedBeforeBlockScoped.ts" }
TypeScript/tests/cases/compiler/taggedTemplateStringsWithCurriedFunction.ts_0_222
//@target: es5 // Originated from #38558 const f = _ => (..._) => ""; f({ ...{ x: 0 } })``; f({ ...{ x: 0 } })`x`; f({ ...{ x: 0 } })`x${f}x`; f({ ...{ x: 0 }, y: (() => 1)() })``; f({ x: (() => 1)(), ...{ y: 1 } })``;
{ "end_byte": 222, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/taggedTemplateStringsWithCurriedFunction.ts" }
TypeScript/tests/cases/compiler/emptyModuleName.ts_0_65
// @module: commonjs import * as A from ""; class B extends A { }
{ "end_byte": 65, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emptyModuleName.ts" }
TypeScript/tests/cases/compiler/restUnion3.ts_0_290
// @strict: true declare const nullAndUndefinedUnion: null | undefined; var rest4: { }; var {...rest4 } = nullAndUndefinedUnion; declare const unionWithIntersection: ({ n: number } & { s: string }) & undefined; var rest5: { n: number, s: string }; var {...rest5 } = unionWithIntersection;
{ "end_byte": 290, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/restUnion3.ts" }
TypeScript/tests/cases/compiler/declarationEmitTypeAliasWithTypeParameters3.ts_3_115
@declaration: true type Foo<T> = { foo<U>(): Foo<U> }; function bar() { return {} as Foo<number>; }
{ "end_byte": 115, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitTypeAliasWithTypeParameters3.ts" }
TypeScript/tests/cases/compiler/explicitAnyAfterSpreadNoImplicitAnyError.ts_0_67
// @noImplicitAny: true ({ a: [], ...(null as any) }); let x: any;
{ "end_byte": 67, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/explicitAnyAfterSpreadNoImplicitAnyError.ts" }
TypeScript/tests/cases/compiler/expressionsForbiddenInParameterInitializers.ts_0_145
// @lib: es6 // @filename: bar.ts export async function foo({ foo = await import("./bar") }) { } export function* foo2({ foo = yield "a" }) { }
{ "end_byte": 145, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/expressionsForbiddenInParameterInitializers.ts" }
TypeScript/tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts_0_7069
// @lib: es5 // @allowUnreachableCode: true declare module "fs" { export class File { constructor(filename: string); public ReadAllText(): string; } export interface IFile { [index: number]: string; } } import fs = module("fs"); module TypeScriptAllInOne { export class Pr...
{ "end_byte": 7069, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts" }
TypeScript/tests/cases/compiler/extendArray.ts_0_421
var a = [1,2]; a.forEach(function (v,i,a) {}); declare module _Core { interface Array { collect(fn:(e:_element) => _element[]) : any[]; } } var arr = (<any>Array).prototype; arr.collect = function (fn) { var res = []; for (var i = 0; i < this.length; ++i) { var tmp = fn(this[i]); for...
{ "end_byte": 421, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/extendArray.ts" }
TypeScript/tests/cases/compiler/aliasInaccessibleModule.ts_0_80
// @declaration: true module M { module N { } export import X = N; }
{ "end_byte": 80, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/aliasInaccessibleModule.ts" }
TypeScript/tests/cases/compiler/getSetEnumerable.ts_0_509
// @target: ES5 class GetSetEnumerableClassGet { get prop() { return true;} } class GetSetEnumerableClassSet { set prop(value: boolean) { } } class GetSetEnumerableClassGetSet { get prop() { return true;} set prop(value: boolean) { } } const GetSetEnumerableObjectGet = { get prop() { return true...
{ "end_byte": 509, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/getSetEnumerable.ts" }
TypeScript/tests/cases/compiler/forInStatement4.ts_0_46
var expr: any; for (var a: number in expr) { }
{ "end_byte": 46, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/forInStatement4.ts" }
TypeScript/tests/cases/compiler/declarationEmitObjectLiteralAccessors1.ts_0_619
// @strict: true // @declaration: true // @emitDeclarationOnly: true // same type accessors export const obj1 = { /** my awesome getter (first in source order) */ get x(): string { return ""; }, /** my awesome setter (second in source order) */ set x(a: string) {}, }; // divergent accessors export const...
{ "end_byte": 619, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitObjectLiteralAccessors1.ts" }
TypeScript/tests/cases/compiler/declareFileExportAssignment.ts_0_380
//@module: commonjs // @declaration: true module m2 { export interface connectModule { (res, req, next): void; } export interface connectExport { use: (mod: connectModule) => connectExport; listen: (port: number) => void; } } var m2: { (): m2.connectExport; test1: m2.co...
{ "end_byte": 380, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declareFileExportAssignment.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.ts_3_50
@sourcemap: true var {x = 500} = { x: 20 };
{ "end_byte": 50, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.ts" }
TypeScript/tests/cases/compiler/classImplementsMethodWIthTupleArgs.ts_0_293
// @strict: true declare class MySettable implements Settable { set(option: Record<string, unknown>): void; set(name: string, value: unknown): void; } interface Settable { set(...args: [option: Record<string, unknown>] | [name: string, value: unknown] | [name: string]): void; }
{ "end_byte": 293, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classImplementsMethodWIthTupleArgs.ts" }
TypeScript/tests/cases/compiler/assertionFunctionWildcardImport2.ts_0_405
// @strict: true // @filename: asserts.ts function isNonNullable<T>(obj: T): asserts obj is NonNullable<T> { if (obj === undefined || obj === null) { throw new Error("Must not be a nullable value"); } } export { isNonNullable }; // @filename: test.ts import * as asserts from "./asserts"; functio...
{ "end_byte": 405, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assertionFunctionWildcardImport2.ts" }
TypeScript/tests/cases/compiler/emitBundleWithPrologueDirectives1.ts_3_174
@outFile: outFile.js // @module: amd // @target: es5 // @Filename: test.ts /* Detached Comment */ // Class Doo Comment export class Doo {} class Scooby extends Doo {}
{ "end_byte": 174, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emitBundleWithPrologueDirectives1.ts" }
TypeScript/tests/cases/compiler/validUseOfThisInSuper.ts_0_298
class Base { constructor(public b: Base) { } } class Super extends Base { constructor() { super((() => this)()); // ok since this is not the case: The constructor declares parameter properties or the containing class declares instance member variables with initializers. } }
{ "end_byte": 298, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/validUseOfThisInSuper.ts" }
TypeScript/tests/cases/compiler/circularAccessorAnnotations.ts_0_387
// @strict: true // @declaration: true declare const c1: { get foo(): typeof c1.foo; } declare const c2: { set foo(value: typeof c2.foo); } declare const c3: { get foo(): string; set foo(value: typeof c3.foo); } type T1 = { get foo(): T1["foo"]; } type T2 = { set foo(value: T2["foo"]); } t...
{ "end_byte": 387, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/circularAccessorAnnotations.ts" }
TypeScript/tests/cases/compiler/parseUnaryExpressionNoTypeAssertionInJsx2.ts_0_113
// @allowJs: true // @noEmit: true // @checkJs: true // @filename: index.js const x = "oops"; const y = + <> x;
{ "end_byte": 113, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parseUnaryExpressionNoTypeAssertionInJsx2.ts" }
TypeScript/tests/cases/compiler/privacyCheckTypeOfInvisibleModuleNoError.ts_0_184
// @declaration: true module Outer { module Inner { export var m: number; } export var f: typeof Inner; // Since we dont unwind inner any more, it is error here }
{ "end_byte": 184, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyCheckTypeOfInvisibleModuleNoError.ts" }
TypeScript/tests/cases/compiler/instanceofNarrowReadonlyArray.ts_0_168
// @strict function narrow(x: readonly number[] | number): readonly number[] { if (x instanceof Array) { return x; } else { return [x]; } }
{ "end_byte": 168, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/instanceofNarrowReadonlyArray.ts" }
TypeScript/tests/cases/compiler/mergedDeclarations2.ts_0_78
enum Foo { b } enum Foo { a = b } module Foo { export var x = b }
{ "end_byte": 78, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mergedDeclarations2.ts" }
TypeScript/tests/cases/compiler/unusedVariablesinForLoop.ts_0_100
//@noUnusedLocals:true //@noUnusedParameters:true function f1 () { for(var i = 0; ;) { } }
{ "end_byte": 100, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedVariablesinForLoop.ts" }
TypeScript/tests/cases/compiler/exportEmptyArrayBindingPattern.ts_0_142
// @module: commonjs,amd,system,es2015,esnext // @target: esnext,es5 // @noEmitHelpers: true // @noTypesAndSymbols: true export const [] = [];
{ "end_byte": 142, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportEmptyArrayBindingPattern.ts" }
TypeScript/tests/cases/compiler/undeclaredModuleError.ts_0_614
//@module: amd import fs = require('fs'); function readdir(path: string, accept: (stat: fs.Stats, name: string) => boolean, callback: (error: Error, results: { name: string; stat: fs.Stats; }[]) => void ) {} function join(...paths: string[]) {} function instrumentFile(covFileDir: string, covFileName: string, original...
{ "end_byte": 614, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/undeclaredModuleError.ts" }
TypeScript/tests/cases/compiler/localAliasExportAssignment.ts_0_291
// @module: commonjs // @Filename: localAliasExportAssignment_0.ts var server: { (): any; }; export = server; // @Filename: localAliasExportAssignment_1.ts ///<reference path='localAliasExportAssignment_0.ts'/> import connect = require('./localAliasExportAssignment_0'); connect();
{ "end_byte": 291, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/localAliasExportAssignment.ts" }
TypeScript/tests/cases/compiler/detachedCommentAtStartOfFunctionBody2.ts_0_243
class TestFile { foo(message: string): () => string { /// <summary>Test summary</summary> /// <param name="message" type="String" /> /// <returns type="Function" /> return () => message + this.name; } }
{ "end_byte": 243, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/detachedCommentAtStartOfFunctionBody2.ts" }
TypeScript/tests/cases/compiler/duplicatePackage_relativeImportWithinPackage_scoped.ts_0_766
// @noImplicitReferences: true // @traceResolution: true // @Filename: /node_modules/a/node_modules/@foo/bar/package.json { "name": "@foo/bar", "version": "1.2.3" } // @Filename: /node_modules/a/node_modules/@foo/bar/index.d.ts export class C { private x: number; } // @Filename: /node_modules/a/index.d.t...
{ "end_byte": 766, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicatePackage_relativeImportWithinPackage_scoped.ts" }
TypeScript/tests/cases/compiler/higherOrderMappedIndexLookupInference.ts_0_503
// @strict function f1(a: <T>() => keyof T, b: <U>() => keyof U) { a = b; b = a; } function f2(a: <T, K extends keyof T>() => T[K], b: <U, L extends keyof U>() => U[L]) { a = b; b = a; } function f3(a: <T>() => { [K in keyof T]: T[K] }, b: <U>() => { [K in keyof U]: U[K] }) { a = b; b = a; } ...
{ "end_byte": 503, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/higherOrderMappedIndexLookupInference.ts" }
TypeScript/tests/cases/compiler/functionOverloads12.ts_0_136
// @allowUnreachableCode: true function foo():string; function foo():number; function foo():any { if (true) return ""; else return 0;}
{ "end_byte": 136, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloads12.ts" }
TypeScript/tests/cases/compiler/staticAndMemberFunctions.ts_0_49
class T { static x() { } public y() { } }
{ "end_byte": 49, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/staticAndMemberFunctions.ts" }
TypeScript/tests/cases/compiler/conflictMarkerTrivia3.tsx_0_29
const x = <div> <<<<<<< HEAD
{ "end_byte": 29, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/conflictMarkerTrivia3.tsx" }
TypeScript/tests/cases/compiler/spaceBeforeQuestionMarkInPropertyAssignment.ts_0_36
var x = {x ?: 1} // should not crash
{ "end_byte": 36, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/spaceBeforeQuestionMarkInPropertyAssignment.ts" }
TypeScript/tests/cases/compiler/ipromise3.ts_0_755
interface IPromise3<T> { then<U>(success?: (value: T) => IPromise3<U>, error?: (error: any) => IPromise3<U>, progress?: (progress: any) => void ): IPromise3<U>; then<U>(success?: (value: T) => IPromise3<U>, error?: (error: any) => U, progress?: (progress: any) => void ): IPromise3<U>; then<U>(success?: (val...
{ "end_byte": 755, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ipromise3.ts" }
TypeScript/tests/cases/compiler/es6ImportNameSpaceImportNoNamedExports.ts_0_267
// @target: es5 // @module: commonjs // @filename: es6ImportNameSpaceImportNoNamedExports_0.ts var a = 10; export = a; // @filename: es6ImportNameSpaceImportNoNamedExports_1.ts import * as nameSpaceBinding from "./es6ImportNameSpaceImportNoNamedExports_0"; // error
{ "end_byte": 267, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ImportNameSpaceImportNoNamedExports.ts" }
TypeScript/tests/cases/compiler/collisionExportsRequireAndAmbientModule.ts_0_1590
//@module: amd //@filename: collisionExportsRequireAndAmbientModule_externalmodule.ts export declare module require { export interface I { } export class C { } } export function foo(): require.I { return null; } export declare module exports { export interface I { } export class C { ...
{ "end_byte": 1590, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionExportsRequireAndAmbientModule.ts" }
TypeScript/tests/cases/compiler/classInConvertedLoopES5.ts_0_227
// @target: es5 const classesByRow: Record<string, object> = {}; for (const row of ['1', '2', '3', '4', '5']) { class RowClass { row = row; static factory = () => new RowClass(); } classesByRow[row] = RowClass; }
{ "end_byte": 227, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classInConvertedLoopES5.ts" }
TypeScript/tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithExport.ts_0_231
//@module: commonjs // @declaration: true export module a { export module b { export interface I { foo(); } } } export module c { export import b = a.b; export var x: b.I; x.foo(); }
{ "end_byte": 231, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithExport.ts" }
TypeScript/tests/cases/compiler/errorRecoveryInClassDeclaration.ts_3_104
ass C { public bar() { var v = foo( public blaz() {} ); } }
{ "end_byte": 104, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/errorRecoveryInClassDeclaration.ts" }
TypeScript/tests/cases/compiler/impliedNodeFormatEmit2.ts_0_680
// @allowJs: true // @checkJs: true // @outDir: dist // @module: esnext, commonjs, preserve // @moduleResolution: bundler // @noTypesAndSymbols: true // @Filename: /package.json {} // @Filename: /a.ts export const _ = 0; // @Filename: /b.mts export const _ = 0; // @Filename: /c.cts export const _ = 0; // @Filename...
{ "end_byte": 680, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/impliedNodeFormatEmit2.ts" }
TypeScript/tests/cases/compiler/restParamsWithNonRestParams.ts_0_189
function foo(...b:number[]){} foo(); // ok function foo2(a:string, ...b:number[]){} foo2(); // should be an error function foo3(a?:string, ...b:number[]){} foo3(); // error but shouldn't be
{ "end_byte": 189, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/restParamsWithNonRestParams.ts" }
TypeScript/tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts_0_724
module M { export interface I { } } module M { export class I { } } module M { export function f() { } } module M { export class f { } // error } module M { function g() { } } module M { export class g { } // no error } module M { export class C { } } module M { function C() { } // no...
{ "end_byte": 724, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts" }
TypeScript/tests/cases/compiler/ambientExternalModuleReopen.ts_0_85
declare module "fs" { var x: string; } declare module 'fs' { var y: number; }
{ "end_byte": 85, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ambientExternalModuleReopen.ts" }
TypeScript/tests/cases/compiler/namespaces1.ts_0_126
module X { export module Y { export interface Z { } } export interface Y { } } var x: X.Y.Z; var x2: X.Y;
{ "end_byte": 126, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/namespaces1.ts" }
TypeScript/tests/cases/compiler/jsFileCompilationWithDeclarationEmitPathSameAsInput.ts_0_107
// @declaration: true // @filename: a.ts class c { } // @filename: a.d.ts declare function isC(): boolean;
{ "end_byte": 107, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationWithDeclarationEmitPathSameAsInput.ts" }
TypeScript/tests/cases/compiler/functionOverloads43.ts_0_268
function foo(bar: { a:number }[]): number; function foo(bar: { a:string }[]): string; function foo([x]: { a:number | string }[]): string | number { if (x) { return x.a; } return undefined; } var x = foo([{a: "str"}]); var y = foo([{a: 100}]);
{ "end_byte": 268, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloads43.ts" }
TypeScript/tests/cases/compiler/jsFileFunctionParametersAsOptional2.ts_0_214
// @allowJs: true // @noEmit: true // @filename: foo.js /** * @param a * @param b * @param c */ function f(a, b, c) { } // @filename: bar.ts f(); // Error f(1); // Error f(1, 2); // Error f(1, 2, 3); // OK
{ "end_byte": 214, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileFunctionParametersAsOptional2.ts" }
TypeScript/tests/cases/compiler/classWithDuplicateIdentifier.ts_0_218
class C { a(): number { return 0; } // error: duplicate identifier a: number; } class K { b: number; // error: duplicate identifier b(): number { return 0; } } class D { c: number; c: string; }
{ "end_byte": 218, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classWithDuplicateIdentifier.ts" }
TypeScript/tests/cases/compiler/contextuallyTypingOrOperator3.ts_0_62
function foo<T, U extends T>(u: U) { var x3: U = u || u; }
{ "end_byte": 62, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextuallyTypingOrOperator3.ts" }
TypeScript/tests/cases/compiler/innerOverloads.ts_1_193
function outer() { function inner(x:number); // should work function inner(x:string); function inner(a:any) { return a; } return inner(0); } var x = outer(); // should work
{ "end_byte": 193, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/innerOverloads.ts" }
TypeScript/tests/cases/compiler/inheritedFunctionAssignmentCompatibility.ts_0_144
interface IResultCallback extends Function { } function fn(cb: IResultCallback) { } fn((a, b) => true); fn(function (a, b) { return true; })
{ "end_byte": 144, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inheritedFunctionAssignmentCompatibility.ts" }
TypeScript/tests/cases/compiler/es6ModuleFunctionDeclaration.ts_0_347
// @target: ES6 export function foo() { } function foo2() { } foo(); foo2(); export module m1 { export function foo3() { } function foo4() { } foo(); foo2(); foo3(); foo4(); } module m2 { export function foo3() { } function foo4() { } foo(); foo2(); foo3(); ...
{ "end_byte": 347, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ModuleFunctionDeclaration.ts" }
TypeScript/tests/cases/compiler/narrowingTypeofUndefined1.ts_0_327
declare const a: { error: { prop: string }, result: undefined } | { error: undefined, result: { prop: number } } if (typeof a.error === 'undefined') { a.result.prop; // number } else { a.error.prop; // string } if (typeof a.error !== 'undefined') { a.error.prop; // string } else { a.result.prop; // nu...
{ "end_byte": 327, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowingTypeofUndefined1.ts" }
TypeScript/tests/cases/compiler/noCheckNoEmit.ts_0_140
// @noCheck: true // @emitDeclarationOnly: true // @declaration: true // @noEmit: true // @strict: true export const a: number = "not ok";
{ "end_byte": 140, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noCheckNoEmit.ts" }
TypeScript/tests/cases/compiler/implicitAnyFunctionOverloadWithImplicitAnyReturnType.ts_0_174
//@noimplicitany: true // this should be an error interface IFace { funcOfIFace(); // error at "f" } // this should not be an error interface IFace1{ f1(): any; }
{ "end_byte": 174, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/implicitAnyFunctionOverloadWithImplicitAnyReturnType.ts" }
TypeScript/tests/cases/compiler/mismatchedGenericArguments1.ts_0_217
interface IFoo<T> { foo<T>(x: T): T; } class C<T> implements IFoo<T> { foo(x: string): number { return null; } } class C2<T> implements IFoo<T> { foo<U>(x: string): number { return null; } }
{ "end_byte": 217, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mismatchedGenericArguments1.ts" }
TypeScript/tests/cases/compiler/evalOrArgumentsInDeclarationFunctions.ts_0_233
// @filename: /a.d.ts declare global { export namespace ns { export function eval(): void; export function arguments(): void; } } declare function eval(): void; declare function arguments(): void; export {}
{ "end_byte": 233, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/evalOrArgumentsInDeclarationFunctions.ts" }
TypeScript/tests/cases/compiler/asiArith.ts_0_97
var x = 1; var y = 1; var z = x + + + y var a = 1; var b = 1; var c = x - - - y
{ "end_byte": 97, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/asiArith.ts" }
TypeScript/tests/cases/compiler/thisPredicateInObjectLiteral.ts_0_219
// @strict: true // Should be OK const foo2 = { isNumber(): this is { b: string } { return true; }, }; // Still an error const foo3 = { isNumber(x: any): x is this { return true; }, };
{ "end_byte": 219, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/thisPredicateInObjectLiteral.ts" }
TypeScript/tests/cases/compiler/forStatementInnerComments.ts_0_362
// @target: es6 declare var a; /*0*/ for /*1*/ ( /*2*/ var /*3*/ x /*4*/ in /*5*/ a /*6*/) /*7*/ {} /*0*/ for /*1*/ ( /*2*/ var /*3*/ y /*4*/ of /*5*/ a /*6*/) /*7*/ {} /*0*/ for /*1*/ ( /*2*/ x /*3*/ in /*4*/ a /*5*/) /*6*/ {} /*0*/ for /*1*/ ( /*2*/ y /*3*/ of /*4*/ a /*5*/) /*6*/ {} /*0*/ for /*1*/ ( /*2*/ a /*3*/ ;...
{ "end_byte": 362, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/forStatementInnerComments.ts" }
TypeScript/tests/cases/compiler/webworkerIterable.ts_0_253
// @skipLibCheck: true // @lib: es2020,webworker,webworker.iterable // @target: es2020 // This API is only in webworker importScripts("") // This should not raise a compiler error const f = new FormData() for (const element of f) { element.length }
{ "end_byte": 253, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/webworkerIterable.ts" }
TypeScript/tests/cases/compiler/duplicateIdentifierInCatchBlock.ts_0_241
var v; try { } catch (e) { function v() { } } function w() { } try { } catch (e) { var w; } try { } catch (e) { var x; function x() { } // error function e() { } // error var p: string; var p: number; // error }
{ "end_byte": 241, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateIdentifierInCatchBlock.ts" }
TypeScript/tests/cases/compiler/inferenceErasedSignatures.ts_0_1594
// @strict: true // @target: es2015 // Repro from #37163 declare class SomeBaseClass { set<K extends keyof this>(key: K, value: this[K]): this[K]; } abstract class SomeAbstractClass<C, M, R> extends SomeBaseClass { foo!: (r?: R) => void; bar!: (r?: any) => void; abstract baz(c: C): Promise<M>; } cla...
{ "end_byte": 1594, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inferenceErasedSignatures.ts" }
TypeScript/tests/cases/compiler/jsxFactoryAndJsxFragmentFactoryErrorNotIdentifier.tsx_0_144
//@jsx: react //@jsxFactory: h //@jsxFragmentFactory: 234 declare var h: any; <></>; <><span>1</span><><span>2.1</span><span>2.2</span></></>;
{ "end_byte": 144, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsxFactoryAndJsxFragmentFactoryErrorNotIdentifier.tsx" }
TypeScript/tests/cases/compiler/functionTypeArgumentArityErrors.ts_0_778
// Overloaded functions with default type arguments declare function f1<A = any>(): void; declare function f1<A, B, C, D = any>(): void; f1<number, number>(); f1<number, number, number, number, number>(); // Overloaded functions with no default type arguments declare function f2<A>(): void; declare function f2<A, B, C...
{ "end_byte": 778, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionTypeArgumentArityErrors.ts" }
TypeScript/tests/cases/compiler/prototypes.ts_0_85
Object.prototype; // ok new Object().prototype; // error function f() {} f.prototype;
{ "end_byte": 85, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/prototypes.ts" }
TypeScript/tests/cases/compiler/duplicateConstructorOverloadSignature2.ts_0_88
class C<T> { constructor(x: T); constructor(x: T); constructor(x: any) { } }
{ "end_byte": 88, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateConstructorOverloadSignature2.ts" }
TypeScript/tests/cases/compiler/APILibCheck.ts_0_960
// @module: commonjs // @noImplicitAny: true // @strictNullChecks: true // @lib: es2018 // @exactOptionalPropertyTypes: true // @noTypesAndSymbols: true // @noEmit: true // @filename: node_modules/typescript/package.json { "name": "typescript", "types": "/.ts/typescript.d.ts" } // @filename: node_modules/type...
{ "end_byte": 960, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/APILibCheck.ts" }
TypeScript/tests/cases/compiler/exportDefaultMissingName.ts_0_21
export default xyzzy;
{ "end_byte": 21, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportDefaultMissingName.ts" }
TypeScript/tests/cases/compiler/specialIntersectionsInMappedTypes.ts_0_370
// @strict: true // @noUncheckedIndexedAccess: true // Repro from #50683 type Alignment = (string & {}) | "left" | "center" | "right"; type Alignments = Record<Alignment, string>; const a: Alignments = { left: "align-left", center: "align-center", right: "align-right", other: "align-other", }; a.lef...
{ "end_byte": 370, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/specialIntersectionsInMappedTypes.ts" }
TypeScript/tests/cases/compiler/experimentalDecoratorMetadataUnresolvedTypeObjectInEmit.ts_0_310
// @experimentalDecorators: true // @emitDecoratorMetadata: true // @filename: types.d.ts declare namespace A { export namespace B { export namespace C { export namespace D { } } } } // @filename: usage.ts class Foo { f(@decorate user: A.B.C.D.E): void {} }
{ "end_byte": 310, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/experimentalDecoratorMetadataUnresolvedTypeObjectInEmit.ts" }
TypeScript/tests/cases/compiler/resolveModuleNameWithSameLetDeclarationName2.ts_3_173
clare module "punycode" { interface ucs2 { decode(string: string): string; encode(codePoints: number[]): string; } export let ucs2: ucs2; }
{ "end_byte": 173, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/resolveModuleNameWithSameLetDeclarationName2.ts" }
TypeScript/tests/cases/compiler/noCollisionThisExpressionAndLocalVarInProperty.ts_0_331
class class1 { public prop1 = { doStuff: (callback) => () => { var _this = 2; return callback(_this); } } } class class2 { constructor() { var _this = 2; } public prop1 = { doStuff: (callback) => () => { return callback(10); ...
{ "end_byte": 331, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noCollisionThisExpressionAndLocalVarInProperty.ts" }
TypeScript/tests/cases/compiler/unaryPlus.ts_0_227
// allowed per spec var a = +1; var b = +(<any>""); enum E { some, thing }; var c = +E.some; // also allowed, used to be errors var x = +"3"; //should be valid var y = -"3"; // should be valid var z = ~"3"; // should be valid
{ "end_byte": 227, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unaryPlus.ts" }
TypeScript/tests/cases/compiler/collisionCodeGenModuleWithModuleChildren.ts_0_526
module M { export var x = 3; module m1 { var M = 10; var p = x; } } module M { module m2 { class M { } var p = x; var p2 = new M(); } } module M { module m3 { function M() { } var p = x; var p2 = M(); } } modu...
{ "end_byte": 526, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionCodeGenModuleWithModuleChildren.ts" }
TypeScript/tests/cases/compiler/declarationEmitDestructuringWithOptionalBindingParameters.ts_3_149
@declaration: true function foo([x,y,z]?: [string, number, boolean]) { } function foo1( { x, y, z }?: { x: string; y: number; z: boolean }) { }
{ "end_byte": 149, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitDestructuringWithOptionalBindingParameters.ts" }
TypeScript/tests/cases/compiler/declarationEmitNameConflicts3.ts_0_603
// @declaration: true // @module: commonjs module M { export interface D { } export module D { export function f() { } } export module C { export function f() { } } export module E { export function f() { } } } module M.P { export class C { static f() { }...
{ "end_byte": 603, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitNameConflicts3.ts" }
TypeScript/tests/cases/compiler/collisionArgumentsClassMethod.ts_0_1755
class c1 { public foo(i: number, ...arguments) { //arguments is error var arguments: any[]; // no error } public foo1(arguments: number, ...rest) { //arguments is error var arguments = 10; // no error } public fooNoError(arguments: number) { // no error var arguments = 10; //...
{ "end_byte": 1755, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionArgumentsClassMethod.ts" }