_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/overloadedStaticMethodSpecialization.ts_0_135
class A<T> { static B<S>(v: A<S>): A<S>; static B<S>(v: S): A<S>; static B<S>(v: any): A<S> { return null; } }
{ "end_byte": 135, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overloadedStaticMethodSpecialization.ts" }
TypeScript/tests/cases/compiler/resolveInterfaceNameWithSameLetDeclarationName2.ts_3_78
terface foo { } interface bar { } let bar: bar | foo; let foo: bar | foo;
{ "end_byte": 78, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/resolveInterfaceNameWithSameLetDeclarationName2.ts" }
TypeScript/tests/cases/compiler/conditionalAnyCheckTypePicksBothBranches.ts_0_151
type T = any extends number ? 1 : 0; let x: T; x = 1; x = 0; // not an error type U = [any] extends [number] ? 1 : 0; let y: U; y = 1; y = 0; // error
{ "end_byte": 151, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/conditionalAnyCheckTypePicksBothBranches.ts" }
TypeScript/tests/cases/compiler/literalsInComputedProperties1.ts_0_733
// @noImplicitAny: true let x = { 1:1, [2]:1, "3":1, ["4"]:1 } x[1].toExponential(); x[2].toExponential(); x[3].toExponential(); x[4].toExponential(); interface A { 1:number; [2]:number; "3":number; ["4"]:number; } let y:A; y[1].toExponential(); y[2].toExponential(); y[3].toExponentia...
{ "end_byte": 733, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/literalsInComputedProperties1.ts" }
TypeScript/tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts_0_687
interface A { x } interface B { x; y } interface C { z } interface D { q } class G<T extends A> { constructor(x: T) { } } declare function foo(arg: (x: D) => number): string; declare function foo(arg: (x: C) => any): string; declare function foo(arg: (x: B) => any): number; var result: number = foo(x => new G(x)...
{ "end_byte": 687, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts" }
TypeScript/tests/cases/compiler/tsxUnionSpread.tsx_0_645
// @jsx: preserve // @filename: index.tsx namespace JSX { export interface Element {} } export type CatInfo = { type: 'Cat'; subType: string; }; export type DogInfo = { type: 'Dog'; }; export type AnimalInfo = CatInfo | DogInfo; function AnimalComponent(info: AnimalInfo): JSX.Element { return undefined as any...
{ "end_byte": 645, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/tsxUnionSpread.tsx" }
TypeScript/tests/cases/compiler/mergedDeclarations7.ts_0_457
// @filename: passport.d.ts declare module 'passport' { namespace passport { interface Passport { use(): this; } interface PassportStatic extends Passport { Passport: {new(): Passport}; } } const passport: passport.PassportStatic; export = passpo...
{ "end_byte": 457, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mergedDeclarations7.ts" }
TypeScript/tests/cases/compiler/templateExpressionNoInlininingOfConstantBindingWithInitializer.ts_0_273
type Params = { value?: string | number } function example(parameters: Params) { const { value = '123' } = parameters return `${value}` === '345' } function example2(parameters: Params) { const { value = '123' } = parameters const b = `${value}`; return b; }
{ "end_byte": 273, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/templateExpressionNoInlininingOfConstantBindingWithInitializer.ts" }
TypeScript/tests/cases/compiler/missingSelf.ts_0_241
class CalcButton { public a() { this.onClick(); } public onClick() { } } class CalcButton2 { public b() { () => this.onClick(); } public onClick() { } } var c = new CalcButton(); c.a(); var c2 = new CalcButton2(); c2.b();
{ "end_byte": 241, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/missingSelf.ts" }
TypeScript/tests/cases/compiler/voidAsNonAmbiguousReturnType.ts_0_450
// @module: commonjs // @Filename: voidAsNonAmbiguousReturnType_0.ts export function mkdirSync(path: string, mode?: number): void; export function mkdirSync(path: string, mode?: string): void {} // @Filename: voidAsNonAmbiguousReturnType_1.ts ///<reference path='voidAsNonAmbiguousReturnType_0.ts'/> import fs = require...
{ "end_byte": 450, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/voidAsNonAmbiguousReturnType.ts" }
TypeScript/tests/cases/compiler/es6ImportParseErrors.ts_0_27
// @target: es6 import 10;
{ "end_byte": 27, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ImportParseErrors.ts" }
TypeScript/tests/cases/compiler/typePredicatesOptionalChaining2.ts_0_362
// @strict: true type Person = { name: string; } const getName1 = (person?: Person): string => { return typeof person?.name === 'string' ? person?.name : ''; }; const isString = (value: any): value is string => { return typeof value === 'string'; }; const getName2 = (person?: Person): string => { return isStr...
{ "end_byte": 362, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typePredicatesOptionalChaining2.ts" }
TypeScript/tests/cases/compiler/declarationEmitTypeAliasWithTypeParameters6.ts_3_167
@declaration: true type Foo<T, Y> = { foo<U, J>(): Foo<U, J> }; type SubFoo<R, S> = Foo<S, R>; function foo() { return {} as SubFoo<number, string>; }
{ "end_byte": 167, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitTypeAliasWithTypeParameters6.ts" }
TypeScript/tests/cases/compiler/destructuringAssignment_private.ts_0_263
class C { private x = 0; private o = [{ a: 1 }]; } let x: number; ([{ a: { x } }] = [{ a: new C() }]); ({ o: [{ a: x }]} = new C()); const nameX = "x"; ([{ a: { [nameX]: x } }] = [{ a: new C() }]); const nameO = "o"; ({ [nameO]: [{ a: x }]} = new C());
{ "end_byte": 263, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/destructuringAssignment_private.ts" }
TypeScript/tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments5.ts_0_215
function f<T, U>(t1: T, u1: U, pf1: (u2: U) => T, pf2: (t2: T) => U): [T, U] { return [t1, pf2(t1)]; } interface A { a: A; } interface B extends A { b: any; } var a: A, b: B; var d = f(a, b, u2 => u2.b, t2 => t2);
{ "end_byte": 215, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments5.ts" }
TypeScript/tests/cases/compiler/reducibleIndexedAccessTypes.ts_0_1036
// @strict: true // @noEmit: true // Repro from 53030 enum Type { A, B, C } interface PayloadStructure { dataType: Type; data: unknown; } interface PayloadA extends PayloadStructure { dataType: Type.A; data: string; } interface PayloadB extends PayloadStructure { dataType: Type.B; data: num...
{ "end_byte": 1036, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reducibleIndexedAccessTypes.ts" }
TypeScript/tests/cases/compiler/targetTypeTest3.ts_0_274
// Test target typing for array literals and call expressions var a : string[] = [1,2,"3"]; // should produce an error function func1(stuff:any[]) { return stuff; } function func2(stuff1:string, stuff2:number, stuff3:number) { return func1([stuff1, stuff2, stuff3]); }
{ "end_byte": 274, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/targetTypeTest3.ts" }
TypeScript/tests/cases/compiler/classExtendsInterfaceInModule.ts_0_225
module M { export interface I1 {} export interface I2<T> {} } class C1 extends M.I1 {} class C2<T> extends M.I2<T> {} module Mod { export namespace Nested { export interface I {} } } class D extends Mod.Nested.I {}
{ "end_byte": 225, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classExtendsInterfaceInModule.ts" }
TypeScript/tests/cases/compiler/anonymousClassDeclarationDoesntPrintWithReadonly.ts_0_136
// @declaration: true export class X { constructor(readonly a: number) { } } export function y() { return class extends X { } }
{ "end_byte": 136, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/anonymousClassDeclarationDoesntPrintWithReadonly.ts" }
TypeScript/tests/cases/compiler/forInStatement1.ts_0_38
var expr: any; for (var a in expr) { }
{ "end_byte": 38, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/forInStatement1.ts" }
TypeScript/tests/cases/compiler/collisionSuperAndLocalFunctionInMethod.ts_0_470
function _super() { // No error } class Foo { x() { function _super() { // No error } } _super() { // No error } } class b extends Foo { public foo() { function _super() { // should be error } } _super() { // No Error } } class c extends Foo { publi...
{ "end_byte": 470, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionSuperAndLocalFunctionInMethod.ts" }
TypeScript/tests/cases/compiler/declarationEmitLateBoundJSAssignments.ts_0_567
// @strict: true // @declaration: true // @target: es6 // @checkJs: true // @allowJs: true // @emitDeclarationOnly: true // @filename: file.js export function foo() {} foo.bar = 12; const _private = Symbol(); foo[_private] = "ok"; const strMem = "strMemName"; foo[strMem] = "ok"; const dashStrMem = "dashed-str-mem"; foo...
{ "end_byte": 567, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitLateBoundJSAssignments.ts" }
TypeScript/tests/cases/compiler/objectLiteralWithSemicolons5.ts_0_43
var v = { foo() { }; a: b; get baz() { }; }
{ "end_byte": 43, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectLiteralWithSemicolons5.ts" }
TypeScript/tests/cases/compiler/privateNameJsx.tsx_0_114
// @jsx: preserve class Test { #prop = () => <div />; render() { return <this.#prop />; } }
{ "end_byte": 114, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privateNameJsx.tsx" }
TypeScript/tests/cases/compiler/methodSignatureHandledDeclarationKindForSymbol.ts_0_76
interface Foo { bold(): string; } interface Foo { bold: string; }
{ "end_byte": 76, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/methodSignatureHandledDeclarationKindForSymbol.ts" }
TypeScript/tests/cases/compiler/unusedLocalsinConstructor1.ts_0_119
//@noUnusedLocals:true //@noUnusedParameters:true class greeter { constructor() { var unused = 20; } }
{ "end_byte": 119, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedLocalsinConstructor1.ts" }
TypeScript/tests/cases/compiler/overloadOnConstNoStringImplementation.ts_0_409
function x2(a: number, cb: (x: 'hi') => number); function x2(a: number, cb: (x: 'bye') => number); function x2(a: number, cb: (x: any) => number) { cb('hi'); cb('bye'); var hm = 'hm'; cb(hm); // should this work without a string definition? cb('uh'); cb(1); } var cb: (number) => number = (x: n...
{ "end_byte": 409, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overloadOnConstNoStringImplementation.ts" }
TypeScript/tests/cases/compiler/assignmentCompatability39.ts_0_445
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 classWithTwoPublic<T,U> { constructor(public one: T, public two: U) {...
{ "end_byte": 445, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatability39.ts" }
TypeScript/tests/cases/compiler/assignToExistingClass.ts_0_295
module Test { class Mocked { myProp: string; } class Tester { willThrowError() { Mocked = Mocked || function () { // => Error: Invalid left-hand side of assignment expression. return { myProp: "test" }; }; } } }
{ "end_byte": 295, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignToExistingClass.ts" }
TypeScript/tests/cases/compiler/conflictMarkerDiff3Trivia2.ts_0_144
class C { foo() { <<<<<<< B a(); } ||||||| merged common ancestors c(); } ======= b(); } >>>>>>> A public bar() { } }
{ "end_byte": 144, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/conflictMarkerDiff3Trivia2.ts" }
TypeScript/tests/cases/compiler/pathMappingBasedModuleResolution_withExtension_failedLookup.ts_0_257
// @noImplicitReferences: true // @traceResolution: true // @Filename: /a.ts import { foo } from "foo"; // @Filename: /tsconfig.json { "compilerOptions": { "baseUrl": ".", "paths": { "foo": ["foo/foo.ts"] } } }
{ "end_byte": 257, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/pathMappingBasedModuleResolution_withExtension_failedLookup.ts" }
TypeScript/tests/cases/compiler/newMap.ts_0_32
// @lib: es6 new Map<string>();
{ "end_byte": 32, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/newMap.ts" }
TypeScript/tests/cases/compiler/memberAccessOnConstructorType.ts_0_40
var f: new () => void; f.arguments == 0;
{ "end_byte": 40, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/memberAccessOnConstructorType.ts" }
TypeScript/tests/cases/compiler/exportEqualsClassNoRedeclarationError.ts_0_179
// @target: es6 // @module: commonjs class SomeClass { static get someProp(): number { return 0; } static set someProp(value: number) {} } export = SomeClass;
{ "end_byte": 179, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportEqualsClassNoRedeclarationError.ts" }
TypeScript/tests/cases/compiler/scopeCheckInsideStaticMethod1.ts_0_132
class C { private v; public p; static s; static b() { v = 1; // ERR C.s = 1; this.p = 1; // ERR } }
{ "end_byte": 132, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/scopeCheckInsideStaticMethod1.ts" }
TypeScript/tests/cases/compiler/functionOverloads17.ts_0_72
function foo():{a:number;} function foo():{a:string;} { return {a:""} }
{ "end_byte": 72, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloads17.ts" }
TypeScript/tests/cases/compiler/capturedLetConstInLoop3_ES6.ts_0_3467
// @target: ES6 ///=========let declare function use(a: any); function foo0(x) { for (let x of []) { var v = x; (function() { return x + v }); (() => x + v); } use(v); } function foo0_1(x) { for (let x in []) { var v = x; (function() { return x + v }); ...
{ "end_byte": 3467, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/capturedLetConstInLoop3_ES6.ts" }
TypeScript/tests/cases/compiler/stringIndexerAndConstructor1.ts_0_56
interface I { [s: string]: number; "": string; }
{ "end_byte": 56, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/stringIndexerAndConstructor1.ts" }
TypeScript/tests/cases/compiler/argumentsObjectCreatesRestForJs.ts_0_432
// @checkJs: true // @allowJs: true // @Filename: main.js // @noemit: true function allRest() { arguments; } allRest(); allRest(1, 2, 3); function someRest(x, y) { arguments; } someRest(); // x and y are still optional because they are in a JS file someRest(1, 2, 3); /** * @param {number} x - a thing */ function jsd...
{ "end_byte": 432, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/argumentsObjectCreatesRestForJs.ts" }
TypeScript/tests/cases/compiler/errorLocationForInterfaceExtension.ts_0_44
var n = ''; interface x extends string { }
{ "end_byte": 44, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/errorLocationForInterfaceExtension.ts" }
TypeScript/tests/cases/compiler/contextualTypingOfLambdaWithMultipleSignatures.ts_0_115
interface Foo { getFoo(n: number): void; getFoo(s: string): void; } var foo: Foo; foo.getFoo = bar => { };
{ "end_byte": 115, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTypingOfLambdaWithMultipleSignatures.ts" }
TypeScript/tests/cases/compiler/inferenceOptionalPropertiesToIndexSignatures.ts_0_708
// @strict: true // @target: esnext declare function foo<T>(obj: { [x: string]: T }): T; declare const x1: { a: string, b: number }; declare const x2: { a: string, b: number | undefined }; declare const x3: { a: string, b?: number }; declare const x4: { a: string, b?: number | undefined }; let a1 = foo(x1); // stri...
{ "end_byte": 708, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inferenceOptionalPropertiesToIndexSignatures.ts" }
TypeScript/tests/cases/compiler/undefinedArgumentInference.ts_0_116
function foo1<T>(f1: { x: T; y: T }): T { return undefined; } var z1 = foo1({ x: undefined, y: undefined });
{ "end_byte": 116, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/undefinedArgumentInference.ts" }
TypeScript/tests/cases/compiler/functionExpressionAndLambdaMatchesFunction.ts_0_175
class CDoc { constructor() { function doSomething(a: Function) { } doSomething(() => undefined); doSomething(function () { }); } }
{ "end_byte": 175, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionExpressionAndLambdaMatchesFunction.ts" }
TypeScript/tests/cases/compiler/withStatementInternalComments.ts_0_61
// @ts-ignore /*1*/ with /*2*/ ( /*3*/ false /*4*/ ) /*5*/ {}
{ "end_byte": 61, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/withStatementInternalComments.ts" }
TypeScript/tests/cases/compiler/enumBasics2.ts_0_270
enum Foo { a = 2, b = 3, x = a.b, // should error y = b.a, // should error z = y.x * a.x, // should error } enum Bar { a = (1).valueOf(), // ok b = Foo.a, // ok c = Foo.a.valueOf(), // ok d = Foo.a.a, // should error }
{ "end_byte": 270, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumBasics2.ts" }
TypeScript/tests/cases/compiler/mappedTypeInferenceAliasSubstitution.ts_0_371
// @strict: true // @noEmit: true // repro from #31616 const v = { test: { smth: 5 } }; type Field<A extends string, R> = { [K in A]: R } const f = <A extends string, B extends string, R>(x: { [K in A]: Field<B, R> }): R => ({} as any); const r1 = f(v); const g = <A extends string, B extends string, R>(x: Field<A,...
{ "end_byte": 371, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mappedTypeInferenceAliasSubstitution.ts" }
TypeScript/tests/cases/compiler/unaryOperatorsInStrictMode.ts_0_98
"use strict" ++eval; --eval; ++arguments; --arguments; eval++; eval--; arguments++; arguments--;
{ "end_byte": 98, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unaryOperatorsInStrictMode.ts" }
TypeScript/tests/cases/compiler/declarationEmitDefaultExport2.ts_0_62
// @declaration: true // @target: es6 export default class { }
{ "end_byte": 62, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitDefaultExport2.ts" }
TypeScript/tests/cases/compiler/staticPrototypeProperty.ts_0_73
class C { static prototype() { } } class C2 { static prototype; }
{ "end_byte": 73, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/staticPrototypeProperty.ts" }
TypeScript/tests/cases/compiler/targetTypeArgs.ts_0_355
function foo(callback: (x: string) => void) { callback("hello"); } foo(function(x) { x }); [1].forEach(function(v,i,a) { v }); ["hello"].every(function(v,i,a) {return true;}); [1].every(function(v,i,a) {return true;}); [1].every(function(v,i,a) {return true;}); ["s"].every(function(v,i,a) {return true;}); ["s"...
{ "end_byte": 355, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/targetTypeArgs.ts" }
TypeScript/tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts_0_773
// @noimplicitany: true let [a, b, c] = [1, 2, 3]; // no error let [a1 = 10, b1 = 10, c1 = 10] = [1, 2, 3]; // no error let [a2 = undefined, b2 = undefined, c2 = undefined] = [1, 2, 3]; // no error let [a3 = <any>undefined, b3 = <any>null, c3 = <any>undefined] = [1, 2, 3]; // no error let [a4] = [<any>undefined], [b4] ...
{ "end_byte": 773, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts" }
TypeScript/tests/cases/compiler/jsFileCompilationTypeSyntaxOfVar.ts_0_57
// @allowJs: true // @filename: a.js var v: () => number;
{ "end_byte": 57, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationTypeSyntaxOfVar.ts" }
TypeScript/tests/cases/compiler/genericFunctions1.ts_0_100
// @declaration: true function foo<T > (x: T) { return x; } var x = foo(5); // 'x' should be number
{ "end_byte": 100, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericFunctions1.ts" }
TypeScript/tests/cases/compiler/mutuallyRecursiveGenericBaseTypes2.ts_0_122
class foo<T> { bar(): foo2<T[]> { return null; } } class foo2<T> extends foo<T> { } var test = new foo<string>();
{ "end_byte": 122, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mutuallyRecursiveGenericBaseTypes2.ts" }
TypeScript/tests/cases/compiler/autoLift2.ts_0_261
class A { constructor() { this.foo: any; this.bar: any; } baz() { this.foo = "foo"; this.bar = "bar"; [1, 2].forEach((p) => this.foo); [1, 2].forEach((p) => this.bar); } } var a = new A(); a.baz();
{ "end_byte": 261, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/autoLift2.ts" }
TypeScript/tests/cases/compiler/overloadOnConstNoAnyImplementation.ts_0_362
function x1(a: number, cb: (x: 'hi') => number); function x1(a: number, cb: (x: 'bye') => number); function x1(a: number, cb: (x: string) => number) { cb('hi'); cb('bye'); var hm = 'hm'; cb(hm); cb('uh'); cb(1); // error } var cb: (number) => number = (x: number) => 1; x1(1, cb); x1(1, (x: 'hi'...
{ "end_byte": 362, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overloadOnConstNoAnyImplementation.ts" }
TypeScript/tests/cases/compiler/classExpressionWithResolutionOfNamespaceOfSameName01.ts_3_91
mespace C { export interface type { } } var x = class C { prop: C.type; }
{ "end_byte": 91, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classExpressionWithResolutionOfNamespaceOfSameName01.ts" }
TypeScript/tests/cases/compiler/interfacePropertiesWithSameName2.ts_0_758
interface Mover { move(): void; getStatus(): { speed: number; }; } interface Shaker { shake(): void; getStatus(): { frequency: number; }; } interface MoverShaker extends Mover, Shaker { } // Inside a module declare module MoversAndShakers { export class Mover { move(): void; getSt...
{ "end_byte": 758, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/interfacePropertiesWithSameName2.ts" }
TypeScript/tests/cases/compiler/arrowFunctionParsingDoesNotConfuseParenthesizedObjectForArrowHead.ts_0_564
// regression test for https://github.com/microsoft/TypeScript/issues/32914 declare var value: boolean; declare var a: any; const test = () => ({ // "Identifier expected." error on "!" and two "Duplicate identifier '(Missing)'." errors on space. prop: !value, // remove ! to see that errors will be gone run...
{ "end_byte": 564, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arrowFunctionParsingDoesNotConfuseParenthesizedObjectForArrowHead.ts" }
TypeScript/tests/cases/compiler/reactJsxReactResolvedNodeNext.tsx_0_546
// @jsx: react-jsx // @module: nodenext // @traceResolution: true // @filename: file.tsx export const a = <div></div>; // @filename: node_modules/@types/react/package.json { "name": "@types/react", "version": "0.0.1", "main": "", "types": "index.d.ts", } // @filename: node_modules/@types/react/index.d.t...
{ "end_byte": 546, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reactJsxReactResolvedNodeNext.tsx" }
TypeScript/tests/cases/compiler/ensureNoCrashExportAssignmentDefineProperrtyPotentialMerge.ts_0_445
// @allowJs: true // @noEmit: true // @checkJs: true // @filename: namespacey.js const A = {} A.bar = class Q {} module.exports = A; // @filename: namespacer.js const B = {} B.NS = require("./namespacey"); Object.defineProperty(B, "NS", { value: "why though", writable: true }); module.exports = B; // @filename: index....
{ "end_byte": 445, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ensureNoCrashExportAssignmentDefineProperrtyPotentialMerge.ts" }
TypeScript/tests/cases/compiler/verbatimModuleSyntaxReactReference.ts_0_280
// @module: preserve // @verbatimModuleSyntax: true // @jsx: react // @noEmit: true // @noUnusedLocals: true // @noTypesAndSymbols: true // @Filename: react.d.ts declare module 'react'; // @Filename: index.tsx import React from 'react'; export const build = <div>hello </div>;
{ "end_byte": 280, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/verbatimModuleSyntaxReactReference.ts" }
TypeScript/tests/cases/compiler/undefinedSymbolReferencedInArrayLiteral1.ts_0_147
var tokens = [{ startIndex: deltaOffset }]; var functions = [function() { [1, 2, 3].NonexistantMethod(); anotherNonExistingMethod(); }];
{ "end_byte": 147, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/undefinedSymbolReferencedInArrayLiteral1.ts" }
TypeScript/tests/cases/compiler/abstractIdentifierNameStrict.ts_0_83
var abstract = true; function foo() { "use strict"; var abstract = true; }
{ "end_byte": 83, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/abstractIdentifierNameStrict.ts" }
TypeScript/tests/cases/compiler/commentOnAmbientfunction.ts_0_290
//@filename: a.ts /*!========= Keep this pinned comment ========= */ /*! Don't keep this pinned comment */ declare function foo(); // Don't keep this comment. declare function bar(); //@filename: b.ts ///<reference path="a.ts"/> declare function foobar(a: typeof foo): typeof bar;
{ "end_byte": 290, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentOnAmbientfunction.ts" }
TypeScript/tests/cases/compiler/checkJsFiles.ts_0_97
// @allowJs: true // @checkJs: true // @noEmit: true // @fileName: a.js var x = "string"; x = 0;
{ "end_byte": 97, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/checkJsFiles.ts" }
TypeScript/tests/cases/compiler/es6ModuleWithModuleGenTargetAmd.ts_0_128
// @target: ES6 // @module: amd export class A { constructor () { } public B() { return 42; } }
{ "end_byte": 128, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ModuleWithModuleGenTargetAmd.ts" }
TypeScript/tests/cases/compiler/jsFileClassPropertyType.ts_0_157
// @allowJs: true // @noEmit: true // @filename: foo.js class C { constructor () { this.p = 0; } } // @filename: bar.ts (new C()).p = "string";
{ "end_byte": 157, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileClassPropertyType.ts" }
TypeScript/tests/cases/compiler/blockScopedBindingsReassignedInLoop2.ts_0_606
for (let x = 1, y = 2; x < y; ++x, --y) { let a = () => x++ + y++; if (x == 1) { break; } else { y = 5; } } for (let x = 1, y = 2; x < y; ++x, --y) { let a = () => x++ + y++; if (x == 1) { continue; } else { y = 5; } } loop: for (let x = 1, y = 2...
{ "end_byte": 606, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/blockScopedBindingsReassignedInLoop2.ts" }
TypeScript/tests/cases/compiler/es6ModuleInternalNamedImports.ts_0_646
// @target: ES6 export module M { // variable export var M_V = 0; // interface export interface M_I { } //calss export class M_C { } // instantiated module export module M_M { var x; } // uninstantiated module export module M_MU { } // function export function M_F() { } ...
{ "end_byte": 646, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ModuleInternalNamedImports.ts" }
TypeScript/tests/cases/compiler/inheritedGenericCallSignature.ts_1_191
interface I1<T> { (a: T): T; } interface Object {} interface I2<T> extends I1<T[]> { b: T; } var x: I2<Date>; var y = x(undefined); y.length; // should not error
{ "end_byte": 191, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inheritedGenericCallSignature.ts" }
TypeScript/tests/cases/compiler/contravariantInferenceAndTypeGuard.ts_0_1215
// @strict: true interface ListItem<TData> { prev: ListItem<TData> | null; next: ListItem<TData> | null; data: TData; } type IteratorFn<TData, TResult, TContext = List<TData>> = (this: TContext, item: TData, node: ListItem<TData>, list: List<TData>) => TResult; type FilterFn<TData, TResult extends TData, TC...
{ "end_byte": 1215, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contravariantInferenceAndTypeGuard.ts" }
TypeScript/tests/cases/compiler/functionOverloads23.ts_0_114
function foo(bar:(b:string)=>void); function foo(bar:(a:number)=>void); function foo(bar:(a?)=>void) { return 0 }
{ "end_byte": 114, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloads23.ts" }
TypeScript/tests/cases/compiler/nestedLoopTypeGuards.ts_0_771
// Repros from #10378 function f1() { var a: boolean | number | string; if (typeof a !== 'boolean') { // a is narrowed to "number | string" for (var i = 0; i < 1; i++) { for (var j = 0; j < 1; j++) {} if (typeof a === 'string') { // a is narrowed to "stri...
{ "end_byte": 771, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nestedLoopTypeGuards.ts" }
TypeScript/tests/cases/compiler/collisionSuperAndLocalFunctionInProperty.ts_0_309
function _super() { // No error } class Foo { public prop1 = { doStuff: () => { function _super() { // No error } } } } class b extends Foo { public prop2 = { doStuff: () => { function _super() { // error } } } }
{ "end_byte": 309, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionSuperAndLocalFunctionInProperty.ts" }
TypeScript/tests/cases/compiler/keepImportsInDts3.ts_0_145
// @module: amd // @declaration: true // @outFile: outputfile.js // @filename: c:/test.ts export {}; // @filename: c:/app/main.ts import "test"
{ "end_byte": 145, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/keepImportsInDts3.ts" }
TypeScript/tests/cases/compiler/constDeclarations-es5.ts_0_102
// @target: ES5 const z7 = false; const z8: number = 23; const z9 = 0, z10 :string = "", z11 = null;
{ "end_byte": 102, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constDeclarations-es5.ts" }
TypeScript/tests/cases/compiler/mappedTypeIndexedAccessConstraint.ts_0_2109
// @strict: true // @noEmit: true type Identity<T> = { [K in keyof T]: T[K] }; type M0 = { a: 1, b: 2 }; type M1 = { [K in keyof Partial<M0>]: M0[K] }; type M2 = { [K in keyof Required<M1>]: M1[K] }; type M3 = { [K in keyof Identity<Partial<M0>>]: M0[K] }; function foo<K extends keyof M0>(m1: M1[K], m2: M2[K], m3...
{ "end_byte": 2109, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mappedTypeIndexedAccessConstraint.ts" }
TypeScript/tests/cases/compiler/enumWithExport.ts_0_55
namespace x { export let y = 123 } enum x { z = y }
{ "end_byte": 55, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumWithExport.ts" }
TypeScript/tests/cases/compiler/maxNodeModuleJsDepthDefaultsToZero.ts_0_808
// @module: commonjs // @moduleResolution: node // @allowJs: true // @traceResolution: true // @noEmit: true // @filename: /tsconfig.json { "compileOnSave": true, "compilerOptions": { "module": "commonjs", "moduleResolution": "node", "outDir": "bin" } } // @filename: /node_modules/s...
{ "end_byte": 808, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/maxNodeModuleJsDepthDefaultsToZero.ts" }
TypeScript/tests/cases/compiler/augmentExportEquals4_1.ts_0_453
// @module: amd // @filename: file1.d.ts declare module "file1" { class foo {} namespace foo { export var v: number; } export = foo; } // @filename: file2.ts /// <reference path="file1.d.ts"/> import x = require("file1"); x.b = 1; // OK - './file1' is a namespace declare module "file1" { ...
{ "end_byte": 453, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/augmentExportEquals4_1.ts" }
TypeScript/tests/cases/compiler/parameterReferencesOtherParameter2.ts_0_114
class Model { public name: string; } class UI { constructor(model: Model, foo = model.name) { } }
{ "end_byte": 114, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parameterReferencesOtherParameter2.ts" }
TypeScript/tests/cases/compiler/modularizeLibrary_Worker.asynciterable.ts_3_237
@skipLibCheck: true // @lib: es2018,webworker,webworker.asynciterable // @target: es2018 navigator.storage.getDirectory().then(async directory => { for await (const [key, handle] of directory) { handle.kind; } });
{ "end_byte": 237, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/modularizeLibrary_Worker.asynciterable.ts" }
TypeScript/tests/cases/compiler/internalAliasInterface.ts_0_121
// @declaration: true module a { export interface I { } } module c { import b = a.I; export var x: b; }
{ "end_byte": 121, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/internalAliasInterface.ts" }
TypeScript/tests/cases/compiler/doNotEmitPinnedDetachedComments.ts_3_302
@removeComments: true var x = 10; /*! Single Line comment */ function baz() { } /*! multi-line comment */ //======================== function bar() { /*! Remove this comment */ } function foo() { /*! Remove this */ return 0; } //========================
{ "end_byte": 302, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/doNotEmitPinnedDetachedComments.ts" }
TypeScript/tests/cases/compiler/simplifyingConditionalWithInteriorConditionalIsRelated.ts_0_707
// @strict: true // from https://github.com/microsoft/TypeScript/issues/30706 type ConditionalType<T> = T extends string ? string : number; function ConditionalOrUndefined<T>(): ConditionalType<T> | undefined { return 0 as any; } function JustConditional<T>(): ConditionalType<T> { return ConditionalOrUndefine...
{ "end_byte": 707, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/simplifyingConditionalWithInteriorConditionalIsRelated.ts" }
TypeScript/tests/cases/compiler/contextuallyTypeAsyncFunctionReturnTypeFromUnion.ts_0_932
// @strict: true // @noEmit: true // @target: esnext // repro #47682 declare class StateMachine<T> { onDone: (a: T) => void; } declare function createMachine<T>(implementations: { services: Record<string, () => Promise<T> | StateMachine<T>>; }): void; createMachine<{ count: number }>({ services: { test: a...
{ "end_byte": 932, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextuallyTypeAsyncFunctionReturnTypeFromUnion.ts" }
TypeScript/tests/cases/compiler/letDeclarations-scopes2.ts_0_328
// @target: ES6 let global = 0; { let local = 0; local; // OK global; // OK local2; // Error { let local2 = 0; local; // OK global; // OK local2; // OK } local; // OK global; // OK local2; // Error } local; // Error global; // OK local2; /...
{ "end_byte": 328, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/letDeclarations-scopes2.ts" }
TypeScript/tests/cases/compiler/es5-declaration-amd.ts_0_166
// @target: ES5 // @sourcemap: false // @declaration: true // @module: amd class A { constructor () { } public B() { return 42; } }
{ "end_byte": 166, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es5-declaration-amd.ts" }
TypeScript/tests/cases/compiler/arraySlice.ts_0_48
var arr: string[] | number[]; arr.splice(1, 1);
{ "end_byte": 48, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arraySlice.ts" }
TypeScript/tests/cases/compiler/commentsOnObjectLiteral4.ts_0_121
// @removeComments: false // @target: ES5 var v = { /** * @type {number} */ get bar(): number { return 12; } }
{ "end_byte": 121, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentsOnObjectLiteral4.ts" }
TypeScript/tests/cases/compiler/staticGetter2.ts_0_107
// once caused stack overflow class C { static x() { var r = this; return this; } }
{ "end_byte": 107, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/staticGetter2.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationDestructuringForArrayBindingPatternDefaultValues2.ts_0_3414
// @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": 3414, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationDestructuringForArrayBindingPatternDefaultValues2.ts" }
TypeScript/tests/cases/compiler/promiseWithResolvers.ts_0_98
// @target: esnext type T = {}; const { promise, resolve, reject } = Promise.withResolvers<T>();
{ "end_byte": 98, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/promiseWithResolvers.ts" }
TypeScript/tests/cases/compiler/subtypingTransitivity.ts_0_206
class B { x: Object; } class D extends B { public x: string; } class D2 extends B { public x: number; } var b: B; var d: D; var d2: D2; d.x = ''; b = d; b.x = 1; // assigned number to string
{ "end_byte": 206, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/subtypingTransitivity.ts" }
TypeScript/tests/cases/compiler/noImplicitAnyForMethodParameters.ts_0_377
//@noimplicitany: true declare class A { private foo(a); // OK - ambient class and private method - no error } declare class B { public foo(a); // OK - ambient class and public method - error } class C { private foo(a) { } // OK - non-ambient class and private method - error } class D { public foo(a) ...
{ "end_byte": 377, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noImplicitAnyForMethodParameters.ts" }
TypeScript/tests/cases/compiler/weakType.ts_0_1447
interface Settings { timeout?: number; onError?(): void; } function getDefaultSettings() { return { timeout: 1000 }; } interface CtorOnly { new(s: string): { timeout: 1000 } } function doSomething(settings: Settings) { /* ... */ } // forgot to call `getDefaultSettings` doSomething(getDefaultSettings);...
{ "end_byte": 1447, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/weakType.ts" }
TypeScript/tests/cases/compiler/jsFileCompilationFunctionOverloadSyntax.ts_0_70
// @allowJs: true // @noEmit: true // @filename: a.js function foo();
{ "end_byte": 70, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationFunctionOverloadSyntax.ts" }
TypeScript/tests/cases/compiler/propertyAccess4.ts_0_13
null.toBAZ();
{ "end_byte": 13, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/propertyAccess4.ts" }