_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/mergedDeclarations3.ts_0_448
module M { export enum Color { Red, Green } } module M { export module Color { export var Blue = 4; } } var p = M.Color.Blue; // ok module M { export function foo() { } } module M { module foo { export var x = 1; } } module M { export module foo { export var y = 2 }...
{ "end_byte": 448, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mergedDeclarations3.ts" }
TypeScript/tests/cases/compiler/widenToAny2.ts_0_134
function foo3<T>(x: T[]): T { return undefined; } var z3:number = foo3([undefined, "def"]); // Type is any, but should be string
{ "end_byte": 134, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/widenToAny2.ts" }
TypeScript/tests/cases/compiler/topLevelLambda.ts_0_43
module M { var f = () => {this.window;} }
{ "end_byte": 43, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/topLevelLambda.ts" }
TypeScript/tests/cases/compiler/declFileTypeAnnotationVisibilityErrorParameterOfFunction.ts_0_866
// @target: ES5 // @module: commonjs // @declaration: true module m { class private1 { } export class public1 { } // Directly using names from this module function foo1(param: private1) { } function foo2(param = new private1()) { } export function foo3(param : private1) { ...
{ "end_byte": 866, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileTypeAnnotationVisibilityErrorParameterOfFunction.ts" }
TypeScript/tests/cases/compiler/parseUnaryExpressionNoTypeAssertionInJsx3.ts_0_117
// @allowJs: true // @noEmit: true // @checkJs: true // @filename: index.js const x = "oops"; const y = + <1234> x;
{ "end_byte": 117, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parseUnaryExpressionNoTypeAssertionInJsx3.ts" }
TypeScript/tests/cases/compiler/ipromise2.ts_0_941
declare module Windows.Foundation { export interface IPromise<T> { then<U>(success?: (value: T) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void ): Windows.Foundation.IPromise<U>; then<U>(success?: (value: T) => IPromise<U>, error?: (error: any) => U, progress?...
{ "end_byte": 941, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ipromise2.ts" }
TypeScript/tests/cases/compiler/classFieldSuperAccessibleJs2.ts_0_426
// @strict: true // @checkJs: true // @target: esnext // @noEmit: true // @filename: index.js class C { constructor() { this.foo = () => { console.log("called arrow"); }; } foo() { console.log("called method"); } } class D extends C { foo() { console.log("SUPER:"); super.foo(); ...
{ "end_byte": 426, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classFieldSuperAccessibleJs2.ts" }
TypeScript/tests/cases/compiler/circularConstructorWithReturn.ts_0_555
// @strictNullChecks: true // This should not be a circularity error. See // https://github.com/microsoft/TypeScript/pull/57465#issuecomment-1960271216 export type Client = ReturnType<typeof getPrismaClient> extends new () => infer T ? T : never export function getPrismaClient(options?: any) { class PrismaClient { ...
{ "end_byte": 555, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/circularConstructorWithReturn.ts" }
TypeScript/tests/cases/compiler/typeIdentityConsidersBrands.ts_0_356
class X{ name: string; } class Y{ name: string; } class X_1 { private name: string; } class Y_1 { private name: string; } function foo(arg: X){} var a = new Y(); var b = new X(); a = b; // ok foo(a); // ok var a2 = new Y_1(); var b2 = new X_1(); function foo2(arg: X_1) { } a2 = b2; // sho...
{ "end_byte": 356, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeIdentityConsidersBrands.ts" }
TypeScript/tests/cases/compiler/chainedSpecializationToObjectTypeLiteral.ts_0_392
interface Sequence<T> { each(iterator: (value: T) => void): void; map<U>(iterator: (value: T) => U): Sequence<U>; filter(iterator: (value: T) => boolean): Sequence<T>; groupBy<K>(keySelector: (value: T) => K): Sequence<{ key: K; items: T[]; }>; } var s: Sequence<string>; var s2 = s.groupBy(s => s.lengt...
{ "end_byte": 392, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/chainedSpecializationToObjectTypeLiteral.ts" }
TypeScript/tests/cases/compiler/functionOverloads13.ts_0_110
function foo(bar:number):string; function foo(bar:number):number; function foo(bar?:number):any { return "" }
{ "end_byte": 110, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloads13.ts" }
TypeScript/tests/cases/compiler/decoratorReferenceOnOtherProperty.ts_0_494
// https://github.com/Microsoft/TypeScript/issues/19799 // @experimentalDecorators: true // @emitDecoratorMetadata: true // @filename: yoha.ts export class Yoha {} // @filename: index.ts import {Yoha} from './yoha'; function foo(...args: any[]) {} class Bar { yoha(@foo yoha, bar: Yoha) {} // ^^...
{ "end_byte": 494, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/decoratorReferenceOnOtherProperty.ts" }
TypeScript/tests/cases/compiler/selfReferencesInFunctionParameters.ts_0_180
function foo(x: number = x) { } function bar(x0 = "", x: number = x) { } class C { constructor(x = 1, y = y) { } bar(a = "", b: string = b.toString()) { } }
{ "end_byte": 180, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/selfReferencesInFunctionParameters.ts" }
TypeScript/tests/cases/compiler/impliedNodeFormatEmit3.ts_0_700
// @allowJs: true // @checkJs: true // @outDir: dist // @module: esnext, commonjs, preserve // @moduleResolution: bundler // @noTypesAndSymbols: true // @Filename: /package.json { "type": "module" } // @Filename: /a.ts export const _ = 0; // @Filename: /b.mts export const _ = 0; // @Filename: /c.cts export const ...
{ "end_byte": 700, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/impliedNodeFormatEmit3.ts" }
TypeScript/tests/cases/compiler/jsdocParameterParsingInfiniteLoop.ts_0_131
// @filename: example.js // @checkJs: true // @allowJs: true // @noEmit: true // @ts-check /** * @type {function(@foo)} */ let x;
{ "end_byte": 131, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsdocParameterParsingInfiniteLoop.ts" }
TypeScript/tests/cases/compiler/findLast.ts_0_1548
// @target: esnext, es2022 const itemNumber: number | undefined = [0].findLast((item) => item === 0); const itemString: string | undefined = ["string"].findLast((item) => item === "string"); new Int8Array().findLast((item) => item === 0); new Uint8Array().findLast((item) => item === 0); new Uint8ClampedArray().findLas...
{ "end_byte": 1548, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/findLast.ts" }
TypeScript/tests/cases/compiler/recursiveInheritance.ts_1_130
interface I5 extends I5 { // error foo():void; } interface i8 extends i9 { } // error interface i9 extends i8 { } // error
{ "end_byte": 130, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveInheritance.ts" }
TypeScript/tests/cases/compiler/declarationEmitCrossFileImportTypeOfAmbientModule.ts_0_370
// @declaration: true // @filename: types/component.d.ts declare module '@namespace/component' { export class Foo {} } // @filename: packages/somepackage/index.d.ts import { Foo } from "@namespace/component"; export declare const item: typeof Foo; // @filename: packages/secondpackage/index.ts import { item } from "...
{ "end_byte": 370, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitCrossFileImportTypeOfAmbientModule.ts" }
TypeScript/tests/cases/compiler/shadowingViaLocalValue.ts_0_105
{ let x; { var x = 1; } } { let x1; { for (var x1 = 0; ;); } }
{ "end_byte": 105, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/shadowingViaLocalValue.ts" }
TypeScript/tests/cases/compiler/isolatedModulesGlobalNamespacesAndEnums.ts_0_555
// @isolatedModules: true // @Filename: script-namespaces.ts namespace Instantiated { export const x = 1; } namespace Uninstantiated { export type T = number; } declare namespace Ambient { export const x: number; } // @Filename: module-namespaces.ts export namespace Instantiated { export const x = 1; ...
{ "end_byte": 555, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/isolatedModulesGlobalNamespacesAndEnums.ts" }
TypeScript/tests/cases/compiler/declFileEnums.ts_0_293
// @declaration: true enum e1 { a, b, c } enum e2 { a = 10, b = a + 2, c = 10, } enum e3 { a = 10, b = Math.PI, c = a + 3 } enum e4 { a, b, c, d = 10, e } enum e5 { "Friday", "Saturday", "Sunday", "Weekend days" }
{ "end_byte": 293, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileEnums.ts" }
TypeScript/tests/cases/compiler/constEnumToStringNoComments.ts_0_463
// @removeComments: true const enum Foo { X = 100, Y = 0.5, Z = 2., A = -1, B = -1.5, C = -1. } let x0 = Foo.X.toString(); let x1 = Foo["X"].toString(); let y0 = Foo.Y.toString(); let y1 = Foo["Y"].toString(); let z0 = Foo.Z.toString(); let z1 = Foo["Z"].toString(); let a0 = Foo.A.toString(); l...
{ "end_byte": 463, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constEnumToStringNoComments.ts" }
TypeScript/tests/cases/compiler/contextuallyTypingOrOperator2.ts_0_137
var v: { a: (_: string) => number } = { a: s => s.length } || { a: s => 1 }; var v2 = (s: string) => s.length || function (s) { s.aaa };
{ "end_byte": 137, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextuallyTypingOrOperator2.ts" }
TypeScript/tests/cases/compiler/instanceofWithPrimitiveUnion.ts_0_186
function test1(x: number | string) { if (x instanceof Object) { x; } } function test2(x: (number | string) | number) { if (x instanceof Object) { x; } }
{ "end_byte": 186, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/instanceofWithPrimitiveUnion.ts" }
TypeScript/tests/cases/compiler/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts_0_2000
// @strict: true type Either<L, A> = Left<L, A> | Right<L, A>; class Left<L, A> { readonly _tag: 'Left' = 'Left' readonly _A!: A readonly _L!: L constructor(readonly value: L) {} /** The given function is applied if this is a `Right` */ map<B>(f: (a: A) => B): Either<L, B> { return this a...
{ "end_byte": 2000, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts" }
TypeScript/tests/cases/compiler/functionOverloads42.ts_0_148
function foo(bar:{a:number;}[]):string; function foo(bar:{a:any;}[]):number; function foo(bar:{a:any;}[]):any{ return bar } var x = foo([{a:'s'}]);
{ "end_byte": 148, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloads42.ts" }
TypeScript/tests/cases/compiler/objectLiteralWithSemicolons1.ts_0_19
var v = { a; b; c }
{ "end_byte": 19, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectLiteralWithSemicolons1.ts" }
TypeScript/tests/cases/compiler/predicateSemantics.ts_0_941
declare let cond: any; // OK: One or other operand is possibly nullish const test1 = (cond ? undefined : 32) ?? "possibly reached"; // Not OK: Both operands nullish const test2 = (cond ? undefined : null) ?? "always reached"; // Not OK: Both operands non-nullish const test3 = (cond ? 132 : 17) ?? "unreachable"; // ...
{ "end_byte": 941, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/predicateSemantics.ts" }
TypeScript/tests/cases/compiler/noParameterReassignmentJSIIFE.ts_0_229
// @allowJs: true // @checkJs: true // @noEmit: true // @filename: index.js self.importScripts = (function (importScripts) { return function () { return importScripts.apply(this, arguments); }; })(importScripts);
{ "end_byte": 229, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noParameterReassignmentJSIIFE.ts" }
TypeScript/tests/cases/compiler/optionalConstructorArgInSuper.ts_0_197
class Base { constructor(opt?) { } foo(other?) { } } class Derived extends Base { } var d = new Derived(); // bug caused an error here, couldn't select overload var d2: Derived; d2.foo();
{ "end_byte": 197, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/optionalConstructorArgInSuper.ts" }
TypeScript/tests/cases/compiler/contextualTypingOfObjectLiterals2.ts_0_154
interface Foo { foo: (t: string) => string; } function f2(args: Foo) { } f2({ foo: s => s.hmm }) // 's' should be 'string', so this should be an error
{ "end_byte": 154, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTypingOfObjectLiterals2.ts" }
TypeScript/tests/cases/compiler/assignmentCompatOnNew.ts_0_90
class Foo{}; function bar(x: {new(): Foo;}){} bar(Foo); // Error, but should be allowed
{ "end_byte": 90, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatOnNew.ts" }
TypeScript/tests/cases/compiler/overloadOnGenericArity.ts_0_135
interface Test { then<U>(p: string): string; then(p: string): Date; // Error: Overloads cannot differ only by return type }
{ "end_byte": 135, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overloadOnGenericArity.ts" }
TypeScript/tests/cases/compiler/deferredConditionalTypes.ts_0_1655
// @strict: true type A<T> = { x: T } extends { x: 0 } ? 1 : 0; type T0<T> = A<T> extends 0 ? 1 : 0; // Deferred type T1<T> = [A<T>] extends [0] ? 1 : 0; // Deferred type T2<T> = [A<T>, A<T>] extends [0, 0] ? 1 : 0; // Deferred type T3<T> = [A<T>, A<T>, A<T>] extends [0, 0, 0] ? 1 : 0; // Deferred type T4<T> = [...
{ "end_byte": 1655, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/deferredConditionalTypes.ts" }
TypeScript/tests/cases/compiler/moduleReopenedTypeOtherBlock.ts_0_136
module M { export class C1 { } export interface I { n: number; } } module M { export class C2 { f(): I { return null; } } }
{ "end_byte": 136, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleReopenedTypeOtherBlock.ts" }
TypeScript/tests/cases/compiler/knockout.ts_2_447
declare module ko { export interface Observable<T> { (): T; (value: T): any; N: number; g: boolean; r: T; } export function observable<T>(value: T): Observable<T>; } var o = { name: ko.observable("Bob"), age: ko.observable(37) } var x_v = o.name().length var age_v = o.ag...
{ "end_byte": 447, "start_byte": 2, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/knockout.ts" }
TypeScript/tests/cases/compiler/sourceMap-Comment1.ts_0_46
// @target: ES5 // @sourcemap: true // Comment
{ "end_byte": 46, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMap-Comment1.ts" }
TypeScript/tests/cases/compiler/es6ExportAssignment.ts_0_40
// @target: es6 var a = 10; export = a;
{ "end_byte": 40, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ExportAssignment.ts" }
TypeScript/tests/cases/compiler/declarationEmitNameConflicts2.ts_0_391
// @declaration: true module X.Y.base { export function f() { } export class C { } export module M { export var v; } export enum E { } } module X.Y.base.Z { export var f = X.Y.base.f; // Should be base.f export var C = X.Y.base.C; // Should be base.C export var M = X.Y.base.M; /...
{ "end_byte": 391, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitNameConflicts2.ts" }
TypeScript/tests/cases/compiler/infiniteConstraints.ts_0_1597
// @strict: true // Both of the following types trigger the recursion limiter in getImmediateBaseConstraint type T1<B extends { [K in keyof B]: Extract<B[Exclude<keyof B, K>], { val: string }>["val"] }> = B; type T2<B extends { [K in keyof B]: B[Exclude<keyof B, K>]["val"] }> = B; // Repros from #22950 type AProp<T...
{ "end_byte": 1597, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/infiniteConstraints.ts" }
TypeScript/tests/cases/compiler/functionOverloadsOnGenericArity1.ts_0_184
// overloading on arity not allowed interface C { f<T>(): string; f<T, U>(): string; <T>(): string; <T, U>(): string; new <T>(): string; new <T, U>(): string; }
{ "end_byte": 184, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloadsOnGenericArity1.ts" }
TypeScript/tests/cases/compiler/jsdocParameterParsingInvalidName.ts_0_81
class c { /** * @param {string} [`foo] */ method(foo) { } }
{ "end_byte": 81, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsdocParameterParsingInvalidName.ts" }
TypeScript/tests/cases/compiler/asyncIIFE.ts_0_124
// @target: ES6 function f1() { (async () => { await 10 throw new Error(); })(); var x = 1; }
{ "end_byte": 124, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/asyncIIFE.ts" }
TypeScript/tests/cases/compiler/typecheckCommaExpression.ts_0_6
(a, b)
{ "end_byte": 6, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typecheckCommaExpression.ts" }
TypeScript/tests/cases/compiler/moduleResolutionWithSymlinks_withOutDir.ts_0_564
// Same as moduleResolutionWithSymlinks.ts, but with outDir // @noImplicitReferences: true // @traceResolution: true // @fullEmitPaths: true // @outDir: /src/bin // @filename: /src/library-a/index.ts // @symlink: /src/library-b/node_modules/library-a/index.ts export class MyClass { private x: number; } // @filename: ...
{ "end_byte": 564, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolutionWithSymlinks_withOutDir.ts" }
TypeScript/tests/cases/compiler/varBlock.ts_0_591
module m2 { export var a, b2: number = 10, b; } declare module m3 { var a, b, c; var a1, b1 = 10; class C { constructor (public c = 10); } } declare var b = 10; declare var a2, b2, c2; declare var da = 10; declare var d3, d4 = 10; module m3 { declare var d = 10; declare var ...
{ "end_byte": 591, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/varBlock.ts" }
TypeScript/tests/cases/compiler/reexportDefaultIsCallable.ts_0_247
// @esModuleInterop: true // @filename: schema.d.ts export default class Schema {} // @filename: reexporter.d.ts export { default } from "./schema"; // @filename: usage.ts import Base from "./reexporter"; export default class Mine extends Base {}
{ "end_byte": 247, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reexportDefaultIsCallable.ts" }
TypeScript/tests/cases/compiler/superPropertyAccess_ES6.ts_0_539
// @target: ES6 class MyBase { getValue(): number { return 1; } get value(): number { return 1; } } class MyDerived extends MyBase { constructor() { super(); const f1 = super.getValue(); const f2 = super.value; } } var d = new MyDerived(); var f3 = d.value; class A { private _property: stri...
{ "end_byte": 539, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/superPropertyAccess_ES6.ts" }
TypeScript/tests/cases/compiler/collisionThisExpressionAndLocalVarWithSuperExperssion.ts_0_283
class a { public foo() { } } class b extends a { public foo() { var _this = 10; var f = () => super.foo(); } } class b2 extends a { public foo() { var f = () => { var _this = 10; return super.foo() } } }
{ "end_byte": 283, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionThisExpressionAndLocalVarWithSuperExperssion.ts" }
TypeScript/tests/cases/compiler/circularTypeofWithFunctionModule.ts_0_167
// Repro from #6072 class Foo {} function maker (value: string): typeof maker.Bar { return maker.Bar; } namespace maker { export class Bar extends Foo {} }
{ "end_byte": 167, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/circularTypeofWithFunctionModule.ts" }
TypeScript/tests/cases/compiler/forLoopWithDestructuringDoesNotElideFollowingStatement.ts_0_71
let array = [{a: 0, b: 1}] for (let { a, ...rest } of array) void a
{ "end_byte": 71, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/forLoopWithDestructuringDoesNotElideFollowingStatement.ts" }
TypeScript/tests/cases/compiler/comparabilityTypeParametersRelatedByUnion.ts_0_175
class C<T> { constructor(readonly x: T) {} good<U extends T>(y: U) { if (y === this.x) {} } bad<U extends T | string>(y: U) { if (y === this.x) {} } }
{ "end_byte": 175, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/comparabilityTypeParametersRelatedByUnion.ts" }
TypeScript/tests/cases/compiler/jsFileCompilationEmitDeclarations.ts_0_130
// @allowJs: true // @outFile: out.js // @declaration: true // @filename: a.ts class c { } // @filename: b.js function foo() { }
{ "end_byte": 130, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationEmitDeclarations.ts" }
TypeScript/tests/cases/compiler/callOnClass.ts_0_27
class C { } var c = C();
{ "end_byte": 27, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/callOnClass.ts" }
TypeScript/tests/cases/compiler/errorForUsingPropertyOfTypeAsType02.ts_0_107
namespace Test1 { function foo<T extends { abc: number }>(x: T) { let a: T.abc = x.abc; } }
{ "end_byte": 107, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/errorForUsingPropertyOfTypeAsType02.ts" }
TypeScript/tests/cases/compiler/jsxIntrinsicDeclaredUsingTemplateLiteralTypeSignatures.tsx_0_350
// @jsx: preserve // @noEmit: true // https://github.com/microsoft/TypeScript/issues/55240 declare namespace JSX { interface IntrinsicElements { [k: `foo${string}`]: { prop: string }; [k: `foobar${string}`]: { prop: 'literal' }; } } <foobaz prop="smth" />; <foobaz prop={10} />; <foobarbaz prop="literal"...
{ "end_byte": 350, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsxIntrinsicDeclaredUsingTemplateLiteralTypeSignatures.tsx" }
TypeScript/tests/cases/compiler/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOutDir.ts_0_196
// @allowJs: true // @declaration: true // @outDir: outDir // @filename: a.ts class c { } // @filename: b.ts /// <reference path="c.js"/> function foo() { } // @filename: c.js function bar() { }
{ "end_byte": 196, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOutDir.ts" }
TypeScript/tests/cases/compiler/baseTypeOrderChecking.ts_0_212
var someVariable: Class4<Class2>; class Class1 { } class Class2 extends Class1 { } class Class3<T> { public memberVariable: Class2; } class Class4<T> extends Class3<T> { }
{ "end_byte": 212, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/baseTypeOrderChecking.ts" }
TypeScript/tests/cases/compiler/breakTarget4.ts_0_80
// @allowUnusedLabels: true target1: target2: while (true) { break target2; }
{ "end_byte": 80, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/breakTarget4.ts" }
TypeScript/tests/cases/compiler/infinitelyExpandingTypes4.ts_0_443
interface Query<T> { // ... groupBy<K>(keySelector: (item: T) => K): Query<Grouping<K, T>>; // ... } interface QueryEnumerator<T> { // ... groupBy<K>(keySelector: (item: T) => K): QueryEnumerator<Grouping<K, T>>; // ... } interface Grouping<K, T> extends Query<T> { key(): K; } var q1: Que...
{ "end_byte": 443, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/infinitelyExpandingTypes4.ts" }
TypeScript/tests/cases/compiler/maximum10SpellingSuggestions.ts_0_183
// @lib: es5 // 10 bobs on the first line // the last two bobs should not have did-you-mean spelling suggestions var blob; bob; bob; bob; bob; bob; bob; bob; bob; bob; bob; bob; bob;
{ "end_byte": 183, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/maximum10SpellingSuggestions.ts" }
TypeScript/tests/cases/compiler/javascriptCommonjsModule.ts_0_190
// @allowJS: true // @outDir: ./out // @module: commonjs // @noEmitHelpers: true // @importHelpers: true // @filename: index.js class Foo {} class Bar extends Foo {} module.exports = Bar;
{ "end_byte": 190, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/javascriptCommonjsModule.ts" }
TypeScript/tests/cases/compiler/javascriptImportDefaultBadExport.ts_0_215
// https://github.com/microsoft/TypeScript/issues/34481 // @allowJs: true // @checkJs: true // @noEmit: true // @Filename: /a.js const alias = {}; module.exports = alias; // @Filename: /b.js import a from "./a";
{ "end_byte": 215, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/javascriptImportDefaultBadExport.ts" }
TypeScript/tests/cases/compiler/pathMappingBasedModuleResolution4_node.ts_0_632
// @moduleResolution: node // @module: commonjs // @traceResolution: true // baseUrl set via command line // @filename: c:/root/tsconfig.json { "compilerOptions": { "baseUrl": "." } } // @filename: c:/root/folder1/file1.ts import {x} from "folder2/file2" declare function use(a: any): void; use(x.toEx...
{ "end_byte": 632, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/pathMappingBasedModuleResolution4_node.ts" }
TypeScript/tests/cases/compiler/typeParametersShouldNotBeEqual.ts_0_131
function ff<T, U>(x: T, y: U) { var z: Object; x = x; // Ok x = y; // Error x = z; // Error z = x; // Ok }
{ "end_byte": 131, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeParametersShouldNotBeEqual.ts" }
TypeScript/tests/cases/compiler/arrayFilter.ts_0_156
var foo = [ { name: 'bar' }, { name: null }, { name: 'baz' } ] foo.filter(x => x.name); //should accepted all possible types not only boolean!
{ "end_byte": 156, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arrayFilter.ts" }
TypeScript/tests/cases/compiler/parserIsClassMemberStart.ts_0_31
class C { type!: number; }
{ "end_byte": 31, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parserIsClassMemberStart.ts" }
TypeScript/tests/cases/compiler/typedArrays-es5.ts_0_607
// @target: ES5 const float32Array = new Float32Array(1); [...float32Array]; const float64Array = new Float64Array(1); [...float64Array]; const int16Array = new Int16Array(1); [...int16Array]; const int32Array = new Int32Array(1); [...int32Array]; const int8Array = new Int8Array(1); [...int8Array]; const nodeList...
{ "end_byte": 607, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typedArrays-es5.ts" }
TypeScript/tests/cases/compiler/typeGuardNarrowsIndexedAccessOfKnownProperty3.ts_0_211
// @strict: true type Foo = (number | undefined)[] | undefined; const foo: Foo = [1, 2, 3]; const index = 1; if (foo !== undefined && foo[index] !== undefined && foo[index] >= 0) { foo[index] // number }
{ "end_byte": 211, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeGuardNarrowsIndexedAccessOfKnownProperty3.ts" }
TypeScript/tests/cases/compiler/bestChoiceType.ts_0_336
// @strictNullChecks: true // Repro from #10041 (''.match(/ /) || []).map(s => s.toLowerCase()); // Similar cases function f1() { let x = ''.match(/ /); let y = x || []; let z = y.map(s => s.toLowerCase()); } function f2() { let x = ''.match(/ /); let y = x ? x : []; let z = y.map(s => s.to...
{ "end_byte": 336, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/bestChoiceType.ts" }
TypeScript/tests/cases/compiler/flowControlTypeGuardThenSwitch.ts_0_514
enum Kind { A, B, } interface Base { kind: Kind; } interface A extends Base { kind: Kind.A; yar: any; } interface B extends Base { kind: Kind.B; gar: any; } type Both = A | B; function isBoth(x: Base): x is Both { return true; } let foo: Base = undefined; if (isBoth(foo)) { swit...
{ "end_byte": 514, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/flowControlTypeGuardThenSwitch.ts" }
TypeScript/tests/cases/compiler/jsdocTypedefBeforeParenthesizedExpression.ts_0_325
// @allowJs: true // @noEmit: true // @filename: test.js // @ts-check /** @typedef {number} NotADuplicateIdentifier */ (2 * 2); /** @typedef {number} AlsoNotADuplicate */ (2 * 2) + 1; /** * * @param a {NotADuplicateIdentifier} * @param b {AlsoNotADuplicate} */ function makeSureTypedefsAreStillRecognized(a, b...
{ "end_byte": 325, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsdocTypedefBeforeParenthesizedExpression.ts" }
TypeScript/tests/cases/compiler/discriminateWithOptionalProperty2.ts_0_1810
// @strict: true // @exactOptionalPropertyTypes: true, false // @lib: esnext // @noEmit: true // https://github.com/microsoft/TypeScript/issues/55532#issuecomment-1694744665 type PromiseOrValue<T> = Promise<T> | T; function mapAsyncIterable<T, U, R = undefined>( iterable: AsyncGenerator<T, R, undefined> | AsyncIte...
{ "end_byte": 1810, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/discriminateWithOptionalProperty2.ts" }
TypeScript/tests/cases/compiler/declarationEmitForModuleImportingModuleAugmentationRetainsImport.ts_0_538
// @declaration: true // @filename: child1.ts import { ParentThing } from './parent'; declare module './parent' { interface ParentThing { add: (a: number, b: number) => number; } } export function child1(prototype: ParentThing) { prototype.add = (a: number, b: number) => a + b; } // @filename: pa...
{ "end_byte": 538, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitForModuleImportingModuleAugmentationRetainsImport.ts" }
TypeScript/tests/cases/compiler/objectInstantiationFromUnionSpread.ts_0_315
// @strictFunctionTypes: true // #40995 interface Success { isSuccess: true; } interface Fail { isSuccess: false; } type Item = Success | Fail; function f1(a: Item[]) { a.map(item => ({ ...item })).filter(value => {}); } function f2<T>(a: Item[]) { a.map(item => ({ ...item })).filter(value => {}); }
{ "end_byte": 315, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectInstantiationFromUnionSpread.ts" }
TypeScript/tests/cases/compiler/genericAndNonGenericOverload1.ts_0_101
interface callable2<T> { (a: T): T; <Z>(a: T): Z; } var c2: callable2<number>; c2<string>(1);
{ "end_byte": 101, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericAndNonGenericOverload1.ts" }
TypeScript/tests/cases/compiler/downlevelLetConst18.ts_0_382
// @target:es5 // @allowUnreachableCode: true 'use strict' for (let x; ;) { function foo() { x }; } for (let x; ;) { function foo1() { x }; } for (let x; ;) { (() => { x })(); } for (const x = 1; ;) { (() => { x })(); } for (let x; ;) { ({ foo() { x }}) } for (let x; ;) { ({ get foo() { r...
{ "end_byte": 382, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/downlevelLetConst18.ts" }
TypeScript/tests/cases/compiler/instantiateTypeParameter.ts_0_36
interface Foo<T> { var x: T<>; }
{ "end_byte": 36, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/instantiateTypeParameter.ts" }
TypeScript/tests/cases/compiler/systemModule15.ts_0_542
// @module: system // @isolatedModules: true // @filename: file1.ts import * as moduleB from "./file2" declare function use(v: any): void; use(moduleB.value); use(moduleB.moduleC); use(moduleB.moduleCStar); // @filename: file2.ts import * as moduleCStar from "./file3" import {value2} from "./file4" import moduleC...
{ "end_byte": 542, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/systemModule15.ts" }
TypeScript/tests/cases/compiler/functionOverloads37.ts_0_143
function foo(bar:{a:number;}[]):string; function foo(bar:{a:boolean;}[]):number; function foo(bar:{a:any;}[]):any{ return bar } var x = foo();
{ "end_byte": 143, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloads37.ts" }
TypeScript/tests/cases/compiler/genericInterfaceFunctionTypeParameter.ts_0_155
//@module: amd export interface IFoo<A> { } export function foo<A>(fn: (ifoo: IFoo<A>) => void) { foo(fn); // Invocation is necessary to repro (!) }
{ "end_byte": 155, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericInterfaceFunctionTypeParameter.ts" }
TypeScript/tests/cases/compiler/getterControlFlowStrictNull.ts_0_565
//@strictNullChecks: true //@target: ES5 class A { a(): string | null { if (Math.random() > 0.5) { return ''; } // it does error here as expected } } class B { get a(): string | null { if (Math.random() > 0.5) { return ''; } // it shou...
{ "end_byte": 565, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/getterControlFlowStrictNull.ts" }
TypeScript/tests/cases/compiler/incompatibleGenericTypes.ts_1_111
interface I1<T> { m1<U>(callback: (p: T) => U): I1<U>; } var v1: I1<boolean>; var v2: I1<number> = v1;
{ "end_byte": 111, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/incompatibleGenericTypes.ts" }
TypeScript/tests/cases/compiler/circularObjectLiteralAccessors.ts_0_215
// @target: es5 // Repro from #6000 const a = { b: { get foo(): string { return a.foo; }, set foo(value: string) { a.foo = value; } }, foo: '' };
{ "end_byte": 215, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/circularObjectLiteralAccessors.ts" }
TypeScript/tests/cases/compiler/memberScope.ts_0_92
module Salt { export class Pepper {} export module Basil { } var z = Basil.Pepper; }
{ "end_byte": 92, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/memberScope.ts" }
TypeScript/tests/cases/compiler/javascriptThisAssignmentInStaticBlock.ts_0_448
// @allowJs: true // @checkJs: true // @declaration: true // @outDir: /out/ // @filename: /src/a.js class Thing { static { this.doSomething = () => {}; } } Thing.doSomething(); // GH#46468 class ElementsArray extends Array { static { const superisArray = super.isArray; const custo...
{ "end_byte": 448, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/javascriptThisAssignmentInStaticBlock.ts" }
TypeScript/tests/cases/compiler/declFileTypeAnnotationTypeAlias.ts_0_498
// @target: ES5 // @module: commonjs // @declaration: true module M { export type Value = string | number | boolean; export var x: Value; export class c { } export type C = c; export module m { export class c { } } export type MC = m.c; export type fc = () => c;...
{ "end_byte": 498, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileTypeAnnotationTypeAlias.ts" }
TypeScript/tests/cases/compiler/interfaceDeclaration5.ts_0_72
//@module: amd export interface I1 { item:string; } export class C1 { }
{ "end_byte": 72, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/interfaceDeclaration5.ts" }
TypeScript/tests/cases/compiler/umdDependencyCommentName2.ts_0_164
//@module: umd ///<amd-dependency path='bar' name='b'/> ///<amd-dependency path='foo'/> ///<amd-dependency path='goo' name='c'/> import m1 = require("m2") m1.f();
{ "end_byte": 164, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/umdDependencyCommentName2.ts" }
TypeScript/tests/cases/compiler/recursiveExportAssignmentAndFindAliasedType3.ts_0_783
//@module: amd // @Filename: recursiveExportAssignmentAndFindAliasedType3_moduleDef.d.ts declare module "moduleC" { import self = require("moduleD"); export = self; } declare module "moduleD" { import self = require("moduleE"); export = self; } declare module "moduleE" { import self = require("modul...
{ "end_byte": 783, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveExportAssignmentAndFindAliasedType3.ts" }
TypeScript/tests/cases/compiler/assignmentCompatability19.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/assignmentCompatability19.ts" }
TypeScript/tests/cases/compiler/recursiveTypes1.ts_0_194
interface Entity<T extends Entity<T>> { X: T; Y: T; } interface Person<U extends Person<U>> extends Entity<U> { n: number; } interface Customer extends Person<Customer> { s: string; }
{ "end_byte": 194, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveTypes1.ts" }
TypeScript/tests/cases/compiler/scopeCheckClassProperty.ts_0_129
class C { constructor() { new A().p; // ok } public x = new A().p; // should also be ok } class A { public p = ''; }
{ "end_byte": 129, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/scopeCheckClassProperty.ts" }
TypeScript/tests/cases/compiler/enumWithQuotedElementName1.ts_0_21
enum E { 'fo"o', }
{ "end_byte": 21, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumWithQuotedElementName1.ts" }
TypeScript/tests/cases/compiler/newArrays.ts_0_165
module M { class Foo {} class Gar { public fa: Foo[]; public x = 10; public y = 10; public m () { this.fa = new Array<Foo>(this.x * this.y); } } }
{ "end_byte": 165, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/newArrays.ts" }
TypeScript/tests/cases/compiler/symbolLinkDeclarationEmitModuleNamesRootDir.ts_0_1094
// @currentDirectory: /monorepo/core // @filename: /monorepo/context/src/value-promise.d.ts export type Constructor<T> = (...args: any[]) => T; // @filename: /monorepo/context/src/bindingkey.d.ts import { Constructor } from "./value-promise" export declare class BindingKey<T> { readonly __type: T; static create<T e...
{ "end_byte": 1094, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/symbolLinkDeclarationEmitModuleNamesRootDir.ts" }
TypeScript/tests/cases/compiler/extractInferenceImprovement.ts_0_617
// @target: es6 // repro mostly from https://github.com/Microsoft/TypeScript/issues/25065 function getProperty2<T, K extends keyof T>(obj: T, key: Extract<K, string>): T[K] { return obj[key]; } function getProperty3<T, K extends Extract<keyof T, string>>(obj: T, key: K): T[K] { return obj[key]; } const s = Sy...
{ "end_byte": 617, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/extractInferenceImprovement.ts" }
TypeScript/tests/cases/compiler/interfaceExtendsClassWithPrivate1.ts_0_341
class C { public foo(x: any) { return x; } private x = 1; } interface I extends C { other(x: any): any; } class D extends C implements I { public foo(x: any) { return x; } other(x: any) { return x; } bar() { } } var c: C; var i: I; var d: D; c = i; i = c; // error i = d; d = i; // error c...
{ "end_byte": 341, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/interfaceExtendsClassWithPrivate1.ts" }
TypeScript/tests/cases/compiler/jsFileMethodOverloads3.ts_0_338
// @noImplicitAny: true // @allowJs: true // @checkJs: true // @noEmit: true // @filename: /a.js /** * @overload * @param {number} x */ /** * @overload * @param {string} x */ /** * @param {string | number} x * @returns {string | number} */ function id(x) { return x; } export let a = id(123); export let...
{ "end_byte": 338, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileMethodOverloads3.ts" }
TypeScript/tests/cases/compiler/controlFlowAliasedDiscriminants.ts_0_2899
// @strict: true type UseQueryResult<T> = { isSuccess: false; data: undefined; } | { isSuccess: true; data: T }; function useQuery(): UseQueryResult<number> { return { isSuccess: false, data: undefined, }; } const { data: data1, isSuccess: isSuccess1 } = useQuery(); const { da...
{ "end_byte": 2899, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/controlFlowAliasedDiscriminants.ts" }