_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/errorOnInitializerInObjectTypeLiteralProperty.ts_0_71
var Foo: { bar: number = 5; }; let Bar: { bar: number = 5; };
{ "end_byte": 71, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/errorOnInitializerInObjectTypeLiteralProperty.ts" }
TypeScript/tests/cases/compiler/reverseMappedTypeDeepDeclarationEmit.ts_0_690
// @declaration: true export type Validator<T> = NativeTypeValidator<T> | ObjectValidator<T> export type NativeTypeValidator<T> = (n: any) => T | undefined export type ObjectValidator<O> = { [K in keyof O]: Validator<O[K]> } //native validators export declare const SimpleStringValidator: NativeTypeValidator<string...
{ "end_byte": 690, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reverseMappedTypeDeepDeclarationEmit.ts" }
TypeScript/tests/cases/compiler/noImplicitReturnsInAsync1.ts_0_219
// @target: es6 // @noImplicitReturns: true async function test(isError: boolean = false) { if (isError === true) { return; } let x = await Promise.resolve("The test is passed without an error."); }
{ "end_byte": 219, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noImplicitReturnsInAsync1.ts" }
TypeScript/tests/cases/compiler/errorElaboration.ts_0_400
// Repro for #5712 interface Ref<T> { prop: T; } interface Container<T> { m1: Container<Ref<T>>; m2: T; } declare function foo(x: () => Container<Ref<number>>): void; let a: () => Container<Ref<string>>; foo(a); // Repro for #25498 function test(): {[A in "foo"]: A} { return {foo: "bar"}; } // Repro f...
{ "end_byte": 400, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/errorElaboration.ts" }
TypeScript/tests/cases/compiler/prototypeOnConstructorFunctions.ts_0_107
interface I1 { const: new (options?, element?) => any; } var i: I1; i.const.prototype.prop = "yo";
{ "end_byte": 107, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/prototypeOnConstructorFunctions.ts" }
TypeScript/tests/cases/compiler/propertiesAndIndexers2.ts_0_253
interface A { [n: number]: string; [s: string]: number; } // All of these should fail. interface B extends A { c: string; 3: string; Infinity: string; "-Infinity": string; NaN: string; "-NaN": string; 6(): string; }
{ "end_byte": 253, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/propertiesAndIndexers2.ts" }
TypeScript/tests/cases/compiler/jsFileCompilationWithJsEmitPathSameAsInput.ts_0_88
// @allowJs: true // @filename: a.ts class c { } // @filename: a.js function foo() { }
{ "end_byte": 88, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationWithJsEmitPathSameAsInput.ts" }
TypeScript/tests/cases/compiler/typeOfOperator1.ts_0_62
var x = 1; var y: string = typeof x; var z: number = typeof x;
{ "end_byte": 62, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeOfOperator1.ts" }
TypeScript/tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeAlias.ts_0_743
// @target: ES5 // @module: commonjs // @declaration: true interface Window { someMethod(); } module M { type W = Window | string; export module N { export class Window { } export var p: W; // Should report error that W is private } } module M1 { export type W = Window | string; ...
{ "end_byte": 743, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeAlias.ts" }
TypeScript/tests/cases/compiler/unusedLocalsAndParametersTypeAliases.ts_0_544
//@noUnusedLocals:true //@noUnusedParameters:true // used in a declaration type handler1 = () => void; export interface I1 { getHandler: handler1; } // exported export type handler2 = () => void; // used in extends clause type handler3 = () => void; export interface I3<T extends handler3> { getHandler: T; } ...
{ "end_byte": 544, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedLocalsAndParametersTypeAliases.ts" }
TypeScript/tests/cases/compiler/multiModuleFundule1.ts_0_204
function C(x: number) { } module C { export var x = 1; } module C { export function foo() { } } var r = C(2); var r2 = new C(2); // using void returning function as constructor var r3 = C.foo();
{ "end_byte": 204, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/multiModuleFundule1.ts" }
TypeScript/tests/cases/compiler/functionOverloadsRecursiveGenericReturnType.ts_0_228
class B<V>{ private id: V; } class A<U>{ GetEnumerator: () => B<U>; } function Choice<T>(args: T[]): A<T>; function Choice<T>(...v_args: T[]): A<T>; function Choice<T>(...v_args: any[]): A<T>{ return new A<T>(); }
{ "end_byte": 228, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloadsRecursiveGenericReturnType.ts" }
TypeScript/tests/cases/compiler/inferentialTypingWithObjectLiteralProperties.ts_0_185
function f<T>(x: T, y: T): T { return x; } f({ x: [null] }, { x: [1] }).x[0] = "" // ok f({ x: [1] }, { x: [null] }).x[0] = "" // was error TS2011: Cannot convert 'string' to 'number'.
{ "end_byte": 185, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inferentialTypingWithObjectLiteralProperties.ts" }
TypeScript/tests/cases/compiler/assignmentCompatability42.ts_0_449
module __test1__ { export interface interfaceWithPublicAndOptional<T,U> { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional<number,string> = { one: 1 };; export var __val__obj4 = obj4; } module __test2__ { export class classWithPublicPrivate<T,U> { constructor(public one: T, private two: U) ...
{ "end_byte": 449, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatability42.ts" }
TypeScript/tests/cases/compiler/enumAssignmentCompat4.ts_0_284
namespace M { export enum MyEnum { BAR } export var object2 = { foo: MyEnum.BAR }; } namespace N { export enum MyEnum { FOO }; export var object1 = { foo: MyEnum.FOO }; } let broken = [ N.object1, M.object2 ];
{ "end_byte": 284, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumAssignmentCompat4.ts" }
TypeScript/tests/cases/compiler/noUnusedLocals_writeOnly.ts_0_652
// @strict: true // @noUnusedLocals: true // @noUnusedParameters: true function f(x = 0, b = false) { // None of these statements read from 'x', so it will be marked unused. x = 1; ([x] = [1]); ({ x } = { x: 1 }); ({ x: x } = { x: 1 }); ({ a: [{ b: x }] } = { a: [{ b: 1 }] }); ({ x = 2 } = ...
{ "end_byte": 652, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noUnusedLocals_writeOnly.ts" }
TypeScript/tests/cases/compiler/functionParameterArityMismatch.ts_0_431
declare function f1(a: number); declare function f1(a: number, b: number, c: number); f1(); f1(1, 2); f1(1, 2, 3, 4); declare function f2(); declare function f2(a: number, b: number); declare function f2(a: number, b: number, c: number, d: number); declare function f2(a: number, b: number, c: number, d: number, e: num...
{ "end_byte": 431, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionParameterArityMismatch.ts" }
TypeScript/tests/cases/compiler/accessOverriddenBaseClassMember1.ts_0_363
class Point { constructor(public x: number, public y: number) { } public toString() { return "x=" + this.x + " y=" + this.y; } } class ColoredPoint extends Point { constructor(x: number, y: number, public color: string) { super(x, y); } public toString() { return super.to...
{ "end_byte": 363, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/accessOverriddenBaseClassMember1.ts" }
TypeScript/tests/cases/compiler/clinterfaces.ts_0_258
//@module: commonjs module M { class C { } interface C { } interface D { } class D { } } interface Foo<T> { a: string; } class Foo<T>{ b: number; } class Bar<T>{ b: number; } interface Bar<T> { a: string; } export = Foo;
{ "end_byte": 258, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/clinterfaces.ts" }
TypeScript/tests/cases/compiler/topLevel.ts_0_409
interface IPoint { x:number; y:number; } class Point implements IPoint { constructor(public x,public y){} public move(xo:number,yo:number) { this.x+=xo; this.y+=yo; return this; } public toString() { return ("("+this.x+","+this.y+")"); } } var result=""; result+=(new Point(3,4).move(2,...
{ "end_byte": 409, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/topLevel.ts" }
TypeScript/tests/cases/compiler/implicitAnyGenerics.ts_0_369
// @noimplicitany: true class C<T> { x: T; } var c = new C(); var c2 = new C<any>(); var c3 = new C<number>(); var c4: C<any> = new C(); class D<T> { constructor(x: T) { } } var d = new D(null); var d2 = new D(1); var d3 = new D<any>(1); var d4 = new D(<any>1); var d5: D<any> = new D(null); function foo<T>...
{ "end_byte": 369, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/implicitAnyGenerics.ts" }
TypeScript/tests/cases/compiler/declFilePrivateMethodOverloads.ts_0_816
// @declaration: true interface IContext { someMethod(); } class c1 { private _forEachBindingContext(bindingContext: IContext, fn: (bindingContext: IContext) => void); private _forEachBindingContext(bindingContextArray: Array<IContext>, fn: (bindingContext: IContext) => void); private _forEachBindingCo...
{ "end_byte": 816, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFilePrivateMethodOverloads.ts" }
TypeScript/tests/cases/compiler/asyncFunctionReturnType.2.ts_0_128
// @target: esnext // https://github.com/microsoft/TypeScript/issues/47291 class X { f = async (): Promise<this> => this; }
{ "end_byte": 128, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/asyncFunctionReturnType.2.ts" }
TypeScript/tests/cases/compiler/assignmentCompatability13.ts_0_338
module __test1__ { export interface interfaceWithPublicAndOptional<T,U> { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional<number,string> = { one: 1 };; export var __val__obj4 = obj4; } module __test2__ { export var obj = {two: "1"}; export var __val__obj = obj; } __test2__.__val__obj = __t...
{ "end_byte": 338, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatability13.ts" }
TypeScript/tests/cases/compiler/selfReferencingSpreadInLoop.ts_0_135
// @noImplicitAny: true let additional = []; for (const subcomponent of [1, 2, 3]) { additional = [...additional, subcomponent]; }
{ "end_byte": 135, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/selfReferencingSpreadInLoop.ts" }
TypeScript/tests/cases/compiler/declarationEmitPrefersPathKindBasedOnBundling2.ts_0_431
// @declaration: true // @target: es5 // @baseUrl: . // @module: amd // @outFile: ./dist.js // @rootDir: ./src // @filename: src/lib/operators/scalar.ts export interface Scalar { (): string; value: number; } export function scalar(value: string): Scalar { return null as any; } // @filename: src/settings/spacing.ts ...
{ "end_byte": 431, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitPrefersPathKindBasedOnBundling2.ts" }
TypeScript/tests/cases/compiler/declarationEmitOfFuncspace.ts_0_162
// @declaration: true // @Filename: expando.ts // #27032 function ExpandoMerge(n: number) { return n; } namespace ExpandoMerge { export interface I { } }
{ "end_byte": 162, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitOfFuncspace.ts" }
TypeScript/tests/cases/compiler/contextualExpressionTypecheckingDoesntBlowStack.ts_0_854
// @target: es5 // @lib: es6 // @strict: true // repro for: https://github.com/Microsoft/TypeScript/issues/23661 export interface IValidationError { message: string; } export default class Operation { validateParameters(parameterValues: any) : IValidationError[] | null { let result: IValidationError[]...
{ "end_byte": 854, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualExpressionTypecheckingDoesntBlowStack.ts" }
TypeScript/tests/cases/compiler/arrayEvery.ts_0_161
const foo: (number | string)[] = ['aaa']; const isString = (x: unknown): x is string => typeof x === 'string'; if (foo.every(isString)) { foo[0].slice(0); }
{ "end_byte": 161, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arrayEvery.ts" }
TypeScript/tests/cases/compiler/intraBindingPatternReferences.ts_0_665
// @strict: true // @noEmit: true // https://github.com/microsoft/TypeScript/issues/59177 function foo() { return a } const [a, b = a + 1] = [42]; const [c1, c2 = c1] = [123]; const [d1, d2 = d1, d3 = d2] = [123]; const { e1, e2 = e1 } = { e1: 1 }; const { f1, f2 = f1, f3 = f2 } = { f1: 1 }; // Example that requi...
{ "end_byte": 665, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/intraBindingPatternReferences.ts" }
TypeScript/tests/cases/compiler/assignmentCompatability33.ts_0_362
module __test1__ { export interface interfaceWithPublicAndOptional<T,U> { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional<number,string> = { one: 1 };; export var __val__obj4 = obj4; } module __test2__ { export var obj: { <Tstring>(a: Tstring): Tstring; }; export var __val__obj = obj; } __...
{ "end_byte": 362, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatability33.ts" }
TypeScript/tests/cases/compiler/es5-asyncFunctionDoStatements.ts_0_1510
// @lib: es5,es2015.promise // @noEmitHelpers: true // @target: ES5 declare var x, y, z, a, b, c; async function doStatement0() { do { x; } while (y); } async function doStatement1() { do { await x; } while (y); } async function doStatement2() { do { x; } while (await y); } async function doStatement3()...
{ "end_byte": 1510, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es5-asyncFunctionDoStatements.ts" }
TypeScript/tests/cases/compiler/jsdocFunctionTypeFalsePositive.ts_0_111
// @allowJs: true // @checkJs: true // @noEmit: true // @Filename: /a.js /** @param {<} x */ function f(x) {}
{ "end_byte": 111, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsdocFunctionTypeFalsePositive.ts" }
TypeScript/tests/cases/compiler/unusedTypeParameterInMethod1.ts_0_153
//@noUnusedLocals:true //@noUnusedParameters:true class A { public f1<X, Y, Z>() { var a: Y; var b: Z; a; b; } }
{ "end_byte": 153, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedTypeParameterInMethod1.ts" }
TypeScript/tests/cases/compiler/pathsValidation3.ts_0_168
// @filename: tsconfig.json { "compilerOptions": { "baseUrl": ".", "paths": { "foo": [] } } } // @filename: a.ts let x = 1;
{ "end_byte": 168, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/pathsValidation3.ts" }
TypeScript/tests/cases/compiler/structural1.ts_0_151
module M { export interface I { salt:number; pepper:number; } export function f(i:I) { } f({salt:2,pepper:0}); }
{ "end_byte": 151, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/structural1.ts" }
TypeScript/tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts_0_328
// @declaration: true var [x10, [y10, [z10]]] = [1, ["hello", [true]]]; var [x11 = 0, y11 = ""] = [1, "hello"]; var [a11, b11, c11] = []; var [a2, [b2, { x12, y12: c2 }]=["abc", { x12: 10, y12: false }]] = [1, ["hello", { x12: 5, y12: true }]]; var [x13, y13] = [1, "hello"]; var [a3, b3] = [[x13, y13], { x: x13, y: ...
{ "end_byte": 328, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts" }
TypeScript/tests/cases/compiler/collisionRestParameterFunctionExpressions.ts_0_673
function foo() { function f1(_i: number, ...restParameters) { //_i is error var _i = 10; // no error } function f1NoError(_i: number) { // no error var _i = 10; // no error } function f3(...restParameters) { var _i = 10; // no error } function f3NoError() { va...
{ "end_byte": 673, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionRestParameterFunctionExpressions.ts" }
TypeScript/tests/cases/compiler/conditionalTypeAnyUnion.ts_1_151
// repro from #52568 type Spec = any extends object ? any : string; type WithSpec<T extends number> = T type R = WithSpec<Spec> // should not error
{ "end_byte": 151, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/conditionalTypeAnyUnion.ts" }
TypeScript/tests/cases/compiler/objectLitTargetTypeCallSite.ts_0_86
function process( x: {a:number; b:string;}) { return x.a; } process({a:true,b:"y"});
{ "end_byte": 86, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectLitTargetTypeCallSite.ts" }
TypeScript/tests/cases/compiler/fieldAndGetterWithSameName.ts_0_80
//@module: amd export class C { x: number; get x(): number { return 1; } }
{ "end_byte": 80, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/fieldAndGetterWithSameName.ts" }
TypeScript/tests/cases/compiler/varianceCallbacksAndIndexedAccesses.ts_2_1061
type Source = { <K extends keyof WindowEventMap>(type: K, listener: (this: Window, ev: WindowEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; (type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; } interface Action1<T> { (arg:...
{ "end_byte": 1061, "start_byte": 2, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/varianceCallbacksAndIndexedAccesses.ts" }
TypeScript/tests/cases/compiler/newLineInTypeofInstantiation.ts_0_67
interface Example { (a: number): typeof a <T>(): void }
{ "end_byte": 67, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/newLineInTypeofInstantiation.ts" }
TypeScript/tests/cases/compiler/newNonReferenceType.ts_0_51
var a = new any(); var b = new boolean(); // error
{ "end_byte": 51, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/newNonReferenceType.ts" }
TypeScript/tests/cases/compiler/voidReturnLambdaValue.ts_0_113
function foo(arg1, arg2, callback:(v1,v2,v3) => void):void { return callback(arg1, arg2, arg2); }
{ "end_byte": 113, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/voidReturnLambdaValue.ts" }
TypeScript/tests/cases/compiler/classExtendsInterfaceThatExtendsClassWithPrivates1.ts_0_232
class C { public foo(x: any) { return x; } private x = 1; } interface I extends C { other(x: any): any; } class D2 implements I { public foo(x: any) { return x } private x = 3; other(x: any) { return x } }
{ "end_byte": 232, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classExtendsInterfaceThatExtendsClassWithPrivates1.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationDestructuringForArrayBindingPattern.ts_0_2934
// @lib: es5 // @sourcemap: true declare var console: { log(msg: any): void; } type Robot = [number, string, string]; type MultiSkilledRobot = [string, [string, string]]; let robotA: Robot = [1, "mower", "mowing"]; function getRobot() { return robotA; } let multiRobotA: MultiSkilledRobot = ["mower", ["mowing"...
{ "end_byte": 2934, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationDestructuringForArrayBindingPattern.ts" }
TypeScript/tests/cases/compiler/esModuleInteropNamedDefaultImports.ts_0_294
// @module: commonjs // @esModuleInterop: true // @filename: mod.ts export default class Foo {} export class Bar {} // @filename: idx.ts import Foo from "./mod"; import { default as Foo2 } from "./mod"; import { Bar, default as Foo3 } from "./mod"; new Foo(); new Foo2(); new Bar(); new Foo3();
{ "end_byte": 294, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/esModuleInteropNamedDefaultImports.ts" }
TypeScript/tests/cases/compiler/declFileAliasUseBeforeDeclaration.ts_0_277
// @module: commonjs // @declaration: true // @Filename: declFileAliasUseBeforeDeclaration_foo.ts export class Foo { } // @Filename: declFileAliasUseBeforeDeclaration_test.ts export function bar(a: foo.Foo) { } import foo = require("./declFileAliasUseBeforeDeclaration_foo");
{ "end_byte": 277, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileAliasUseBeforeDeclaration.ts" }
TypeScript/tests/cases/compiler/defaultValueInFunctionOverload1.ts_0_54
function foo(x: string = ''); function foo(x = '') { }
{ "end_byte": 54, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/defaultValueInFunctionOverload1.ts" }
TypeScript/tests/cases/compiler/localImportNameVsGlobalName.ts_0_200
module Keyboard { export enum Key { UP, DOWN, LEFT, RIGHT } } module App { import Key = Keyboard.Key; export function foo(key: Key): void {} foo(Key.UP); foo(Key.DOWN); foo(Key.LEFT); }
{ "end_byte": 200, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/localImportNameVsGlobalName.ts" }
TypeScript/tests/cases/compiler/controlFlowManyConsecutiveConditionsNoTimeout.ts_0_3866
// @strict: true export enum Choice { One, Two, } const choice: Choice = Choice.One; const choiceOne = Choice.One; if (choice === choiceOne) {} if (choice === choiceOne) {} if (choice === choiceOne) {} if (choice === choiceOne) {} if (choice === choiceOne) {} if (choice === choiceOne) {} if (choice === choic...
{ "end_byte": 3866, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/controlFlowManyConsecutiveConditionsNoTimeout.ts" }
TypeScript/tests/cases/compiler/moduleUnassignedVariable.ts_0_172
module Bar { export var a = 1; function fooA() { return a; } // Correct: return Bar.a export var b; function fooB() { return b; } // Incorrect: return b }
{ "end_byte": 172, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleUnassignedVariable.ts" }
TypeScript/tests/cases/compiler/jsdocClassMissingTypeArguments.ts_0_166
// @allowJs: true // @checkJs: true // @noEmit: true // @noImplicitAny: true // @Filename: /a.js /** @template T */ class C {} /** @param {C} p */ function f(p) {}
{ "end_byte": 166, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsdocClassMissingTypeArguments.ts" }
TypeScript/tests/cases/compiler/es6ExportDefaultClassDeclaration.ts_0_83
// @target: es6 // @declaration: true export default class C { method() { } }
{ "end_byte": 83, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ExportDefaultClassDeclaration.ts" }
TypeScript/tests/cases/compiler/missingCommaInTemplateStringsArray.ts_0_66
var array = [ `template string 1` `template string 2` ];
{ "end_byte": 66, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/missingCommaInTemplateStringsArray.ts" }
TypeScript/tests/cases/compiler/importHelpersES6.ts_0_1000
// @importHelpers: true // @target: es6 // @experimentalDecorators: true // @filename: a.ts declare var dec: any; @dec export class A { #x: number = 1; async f() { this.#x = await this.#x; } g(u) { return #x in u; } } const o = { a: 1 }; const y = { ...o }; // @filename: tslib.d.ts export declare function...
{ "end_byte": 1000, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importHelpersES6.ts" }
TypeScript/tests/cases/compiler/cloduleWithDuplicateMember2.ts_0_129
class C { set x(y) { } static set y(z) { } } module C { export var x = 1; } module C { export function x() { } }
{ "end_byte": 129, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/cloduleWithDuplicateMember2.ts" }
TypeScript/tests/cases/compiler/instanceOfInExternalModules.ts_0_351
// @module: amd // @Filename: instanceOfInExternalModules_require.ts export class Foo { foo: string; } // @Filename: instanceOfInExternalModules_1.ts ///<reference path='instanceOfInExternalModules_require.ts'/> import Bar = require("instanceOfInExternalModules_require"); function IsFoo(value: any): boolean { retu...
{ "end_byte": 351, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/instanceOfInExternalModules.ts" }
TypeScript/tests/cases/compiler/mutuallyRecursiveCallbacks.ts_0_184
// Repro from #18277 interface Foo<T> { (bar: Bar<T>): void }; type Bar<T> = (foo: Foo<T>) => Foo<T>; declare function foo<T>(bar: Bar<T>): void; declare var bar: Bar<{}>; bar = foo;
{ "end_byte": 184, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mutuallyRecursiveCallbacks.ts" }
TypeScript/tests/cases/compiler/getParameterNameAtPosition.ts_0_336
// @strict: true // Repro from #30171 interface Mock<Y extends any[]> extends Function { (...args: Y): any; } type Tester = (opts: any, done: (...args: any[]) => any) => any; declare function cases(tester: Tester): void; declare function fn<Y extends any[]>(implementation?: (...args: Y) => any): Mock<Y>; cases(fn...
{ "end_byte": 336, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/getParameterNameAtPosition.ts" }
TypeScript/tests/cases/compiler/arrayAssignmentTest4.ts_2_501
class C3 { CM3M1() { return 3;} } /* This behaves unexpectedly with teh following types: Type 1 of any[]: * Type 2 of the following throws an error but shouldn't: () => void[], SomeClass[], and {one: 1}[]. * Type 2 of the following doesn't throw an error but should: {one: 1}, new() => SomeClass, SomeClass. *...
{ "end_byte": 501, "start_byte": 2, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arrayAssignmentTest4.ts" }
TypeScript/tests/cases/compiler/deeplyNestedCheck.ts_0_993
// Repro from #14794 interface DataSnapshot<X = {}> { child(path: string): DataSnapshot; } interface Snapshot<T> extends DataSnapshot { child<U extends Extract<keyof T, string>>(path: U): Snapshot<T[U]>; } // Repro from 34619 interface A { b: B[] } interface B { c: C } interface C { d: D[] } interface D { e: E[...
{ "end_byte": 993, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/deeplyNestedCheck.ts" }
TypeScript/tests/cases/compiler/asyncFunctionNoReturnType.ts_0_76
// @noImplicitReturns: true async () => { if (window) return; }
{ "end_byte": 76, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/asyncFunctionNoReturnType.ts" }
TypeScript/tests/cases/compiler/narrowingMutualSubtypes.ts_0_3313
// @strict: true // Check that `any` is a strict supertype of `unknown` declare const ru1: { [x: string]: unknown }; declare const ra1: { [x: string]: any }; const a1a = [ru1, ra1]; // { [x: string]: any }[] const a1b = [ra1, ru1]; // { [x: string]: any }[] declare const ra2: { [x: string]: any }; declare const r...
{ "end_byte": 3313, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowingMutualSubtypes.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.ts_3_49
@sourcemap: true var [x = 20, j] = [1, 2];
{ "end_byte": 49, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.ts" }
TypeScript/tests/cases/compiler/nestedObjectRest.ts_0_150
// @target: es2017 // https://github.com/microsoft/TypeScript/issues/43400 var x, y; [{ ...x }] = [{ abc: 1 }]; for ([{ ...y }] of [[{ abc: 1 }]]) ;
{ "end_byte": 150, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nestedObjectRest.ts" }
TypeScript/tests/cases/compiler/genericBaseClassLiteralProperty2.ts_0_334
class CollectionItem2 { } class BaseCollection2<TItem extends CollectionItem2> { _itemsByKey: { [key: string]: TItem; }; constructor() { this._itemsByKey = {}; } } class DataView2 extends BaseCollection2<CollectionItem2> { fillItems(item: CollectionItem2) { this._itemsByKey['dummy'] = ...
{ "end_byte": 334, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericBaseClassLiteralProperty2.ts" }
TypeScript/tests/cases/compiler/declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts_0_168
// @declaration: true export interface Foo { item: Bar; } interface Bar { baz(): void; } namespace Bar { export function biz() { return 0; } }
{ "end_byte": 168, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts" }
TypeScript/tests/cases/compiler/arrayConstructors1.ts_0_184
var x: string[]; x = new Array(1); x = new Array('hi', 'bye'); x = new Array<string>('hi', 'bye'); var y: number[]; y = new Array(1); y = new Array(1,2); y = new Array<number>(1, 2);
{ "end_byte": 184, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arrayConstructors1.ts" }
TypeScript/tests/cases/compiler/augmentedTypesFunction.ts_0_863
// function then var function y1() { } // error var y1 = 1; // error // function then function function y2() { } // error function y2() { } // error function y2a() { } // error var y2a = () => { } // error // function then class function y3() { } // error class y3 { } // error function y3a() { } // error class y3a...
{ "end_byte": 863, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/augmentedTypesFunction.ts" }
TypeScript/tests/cases/compiler/classDeclarationShouldBeOutOfScopeInComputedNames.ts_0_309
// @lib: es6 class A { static readonly p1 = Symbol(); static readonly p2 = Symbol(); // All of the below should be out of scope or TDZ - `A` has not finished being constructed as they are executed static readonly [A.p1] = 0; static [A.p2]() { return 0 }; [A.p1]() { } [A.p2] = 0 }
{ "end_byte": 309, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classDeclarationShouldBeOutOfScopeInComputedNames.ts" }
TypeScript/tests/cases/compiler/unparenthesizedFunctionTypeInUnionOrIntersection.ts_0_792
type U1 = string | () => void; type U2 = string | (foo: number) => void type U3 = | () => number type U4 = | (foo?: number) => void; type U5 = string | (number: number, foo?: string) => void | number; type U6 = | string | (...args: any[]) => void | number; type I1 = string & () => void; type I2 = string & (...fo...
{ "end_byte": 792, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unparenthesizedFunctionTypeInUnionOrIntersection.ts" }
TypeScript/tests/cases/compiler/genericFunctionSpecializations1.ts_0_157
function foo3<T>(test: string); // error function foo3<T>(test: T) { } function foo4<T>(test: string); // valid function foo4<T extends String>(test: T) { }
{ "end_byte": 157, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericFunctionSpecializations1.ts" }
TypeScript/tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts_0_157
//@noUnusedLocals:true //@noUnusedParameters:true var func = function(person: string, person2: string) { var unused = 20; person2 = "Dummy value"; }
{ "end_byte": 157, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts" }
TypeScript/tests/cases/compiler/isolatedModulesNoEmitOnError.ts_0_116
// @isolatedModules: true // @noEmitOnError:true // @target: es6 // @filename: file1.ts export const x: string = 3;
{ "end_byte": 116, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/isolatedModulesNoEmitOnError.ts" }
TypeScript/tests/cases/compiler/parameterListAsTupleType.ts_0_590
function foo(a: number, b: string) { return true; } type Foops = Parameters<typeof foo>; const x = (a: number) => 5; type Xps = Parameters<typeof x>; const a: Xps = ['should-not-work']; // works, but shouldn't function t(...args: Xps) {} // should work class C { constructor(a: number, b: string) { } } type...
{ "end_byte": 590, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parameterListAsTupleType.ts" }
TypeScript/tests/cases/compiler/doWhileUnreachableCode.ts_0_191
function test() { let foo = 0; testLoop: do { foo++; continue testLoop; } while (function() { var x = 1; return false; }()); return foo; }
{ "end_byte": 191, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/doWhileUnreachableCode.ts" }
TypeScript/tests/cases/compiler/exportAssignmentError.ts_0_131
//@module: amd // @Filename: exportEqualsModule_A.ts module M { export var x; } import M2 = M; export = M2; // should not error
{ "end_byte": 131, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportAssignmentError.ts" }
TypeScript/tests/cases/compiler/exportAssignmentInterface.ts_0_234
//@module: amd // @Filename: exportAssignmentInterface_A.ts interface A { p1: number; } export = A; // @Filename: exportAssignmentInterface_B.ts import I1 = require("exportAssignmentInterface_A"); var i: I1; var n: number = i.p1;
{ "end_byte": 234, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportAssignmentInterface.ts" }
TypeScript/tests/cases/compiler/typeReferenceDirectives1.ts_0_273
// @noImplicitReferences: true // @traceResolution: true // @declaration: true // @typeRoots: /types // @currentDirectory: / // @filename: /types/lib/index.d.ts interface $ { x } // @filename: /app.ts /// <reference types="lib" preserve="true" /> interface A { x: $ }
{ "end_byte": 273, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeReferenceDirectives1.ts" }
TypeScript/tests/cases/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.ts_0_962
// @noImplicitReferences: true // @filename: tsconfig.json { "compilerOptions": { "module": "nodenext", "outDir": "./dist", "declarationDir": "./types", "declaration": true } } // @filename: package.json { "name": "@this/package", "type": "module", "exports": { ".": { "default": "./d...
{ "end_byte": 962, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.ts" }
TypeScript/tests/cases/compiler/deleteReadonly.ts_0_195
interface A { readonly b } var a: A = { b: 123 }; delete a.b; interface B { readonly [k: string]: string } var b: B = { 'test': 'test' }; delete b['test']; delete ((((b['test']))));
{ "end_byte": 195, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/deleteReadonly.ts" }
TypeScript/tests/cases/compiler/functionOverloads29.ts_0_121
function foo(bar:string):string; function foo(bar:number):number; function foo(bar:any):any{ return bar } var x = foo();
{ "end_byte": 121, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloads29.ts" }
TypeScript/tests/cases/compiler/generics2.ts_0_608
interface A { a: string; } interface B extends A { b: string; } interface C extends B { c: string; } interface G<T, U extends B> { x: T; y: U; } var v1: { x: { a: string; } y: { a: string; b: string; c: string }; }; // Ok var v2: G<{ a: string }, C>; // Ok, equivalent to G<A, C> var v3: G<A, A>; ...
{ "end_byte": 608, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/generics2.ts" }
TypeScript/tests/cases/compiler/checkerInitializationCrash.ts_0_959
// @module: esnext // @moduleResolution: node // @esModuleInterop: true // @Filename: /node_modules/@fullcalendar/react/index.d.ts import * as react from 'react'; declare global { namespace FullCalendarVDom { export import VNode = react.ReactNode; } } export default class FullCalendar { } // @Filename: /node...
{ "end_byte": 959, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/checkerInitializationCrash.ts" }
TypeScript/tests/cases/compiler/commentOnBinaryOperator2.ts_0_181
// @removeComments: true var a = 'some' // comment + 'text'; var b = 'some' /* comment */ + 'text'; var c = 'some' /* comment */ + /*comment1*/ 'text';
{ "end_byte": 181, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentOnBinaryOperator2.ts" }
TypeScript/tests/cases/compiler/genericReversingTypeParameters2.ts_0_270
class BiMap<K, V> { private inverseBiMap: BiMap<V, K>; public get(key: K): V { return null; } public inverse(): BiMap<V, K> { return null; } } var b = new BiMap<string, number>(); var i = b.inverse(); // used to get the type wrong here. var r2b = i.get(1);
{ "end_byte": 270, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericReversingTypeParameters2.ts" }
TypeScript/tests/cases/compiler/narrowByClauseExpressionInSwitchTrue4.ts_0_149
// @strict: true // @noEmit: true declare const f: 'a' | 'b' | 'c'; switch (true) { case f === "a": default: f; case f === "b": f; }
{ "end_byte": 149, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowByClauseExpressionInSwitchTrue4.ts" }
TypeScript/tests/cases/compiler/ClassDeclaration22.ts_0_40
class C { "foo"(); "bar"() { } }
{ "end_byte": 40, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ClassDeclaration22.ts" }
TypeScript/tests/cases/compiler/reexportMissingDefault4.ts_0_133
// @filename: b.d.ts declare var b: number; export { b }; // @filename: a.ts export { b } from "./b"; export { default } from "./b";
{ "end_byte": 133, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reexportMissingDefault4.ts" }
TypeScript/tests/cases/compiler/importNonExportedMember5.ts_0_140
// @esModuleInterop: true // @module: commonjs // @Filename: a.ts class Foo {} export = Foo; // @Filename: b.ts import { Foo } from './a';
{ "end_byte": 140, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importNonExportedMember5.ts" }
TypeScript/tests/cases/compiler/jsSelfReferencingArgumentsFunction.ts_0_127
// @Filename: foo.js // @noEmit: true // @allowJs: true // Test #16139 function Foo() { arguments; return new Foo(); }
{ "end_byte": 127, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsSelfReferencingArgumentsFunction.ts" }
TypeScript/tests/cases/compiler/superWithTypeArgument3.ts_0_168
class C<T> { foo: T; bar<U>(x: U) { } } class D<T> extends C<T> { constructor() { super<T>(); } bar() { super.bar<T>(null); } }
{ "end_byte": 168, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/superWithTypeArgument3.ts" }
TypeScript/tests/cases/compiler/typeInferenceTypePredicate.ts_0_134
declare function f<T>(predicate: (x: {}) => x is T): T; // 'res' should be of type 'number'. const res = f((n): n is number => true);
{ "end_byte": 134, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeInferenceTypePredicate.ts" }
TypeScript/tests/cases/compiler/contextualTypeForInitalizedVariablesFiltersUndefined.ts_0_263
// @strict: true const fInferred = ({ a = 0 } = {}) => a; // const fInferred: ({ a }?: { a?: number; }) => number const fAnnotated: typeof fInferred = ({ a = 0 } = {}) => a; declare var t: { s: string } | undefined; const { s } = t; function fst({ s } = t) { }
{ "end_byte": 263, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTypeForInitalizedVariablesFiltersUndefined.ts" }
TypeScript/tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts_0_1855
// @declaration: true module rionegrensis { export class caniventer extends Lanthanum.nitidus<petrophilus.minutilla, julianae.sumatrana> { salomonseni() : caniventer { var x : caniventer; () => { var y = this; }; return x; } uchidai() : lavali.xanthognathus { var x : lavali.xanthognathus; () => { var y = this...
{ "end_byte": 1855, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts" }
TypeScript/tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts_1856_6705
module julianae { export class steerii { } export class nudicaudus { brandtii() : argurus.germaini { var x : argurus.germaini; () => { var y = this; }; return x; } maxwellii() : ruatanica.Praseodymium<Lanthanum.jugularis, dammermani.melanops> { var x : ruatanica.Praseodymium<Lanthanum.jugularis, dammerman...
{ "end_byte": 6705, "start_byte": 1856, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts" }
TypeScript/tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts_6708_12005
export class sumatrana extends Lanthanum.jugularis { wolffsohni() : Lanthanum.suillus<dammermani.melanops, quasiater.carolinensis> { var x : Lanthanum.suillus<dammermani.melanops, quasiater.carolinensis>; () => { var y = this; }; return x; } geata() : ruatanica.hector<sumatrana, quasiater.bobrinskoi> { var x : ...
{ "end_byte": 12005, "start_byte": 6708, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts" }
TypeScript/tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts_12006_12428
module ruatanica { export class hector<T0, T1> { humulis() : julianae.steerii { var x : julianae.steerii; () => { var y = this; }; return x; } eurycerus() : panamensis.linulus<ruatanica.Praseodymium<Lanthanum.jugularis, dammermani.melanops>, lavali.wilsoni> { var x : panamensis.linulus<ruatanica.Praseodymium<...
{ "end_byte": 12428, "start_byte": 12006, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts" }