_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/typeGuardConstructorNarrowAny.ts_0_409
// @target: esnext // Narrowing any to primitives let var1: any; if (var1.constructor === String) { var1; // String } if (var1.constructor === Number) { var1; // Number } if (var1.constructor === Boolean) { var1; // Boolean } if (var1.constructor === Array) { var1; // any[] } if (var1.constructor === ...
{ "end_byte": 409, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeGuardConstructorNarrowAny.ts" }
TypeScript/tests/cases/compiler/genericGetter2.ts_0_95
class A<T> { } class C<T> { data: A<T>; get x(): A { return this.data; } }
{ "end_byte": 95, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericGetter2.ts" }
TypeScript/tests/cases/compiler/numberToString.ts_0_191
function f1(n:number):string { return n; // error return type mismatch } function f2(s:string):void { } f1(3); f2(3); // error no coercion to string f2(3+""); // ok + operator promotes
{ "end_byte": 191, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/numberToString.ts" }
TypeScript/tests/cases/compiler/fakeInfinity3.ts_0_268
// @strict: true // @declaration: true export enum Foo { A = 1e999, B = -1e999, } namespace X { type A = 1e999; type B = 2e999; export function f(): A { throw new Error() } } export const m = X.f(); export const Infinity = "oops";
{ "end_byte": 268, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/fakeInfinity3.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.ts_3_67
@sourcemap: true var {x = 500, y} = { x: 20, y: "hi" };
{ "end_byte": 67, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.ts" }
TypeScript/tests/cases/compiler/initializersInAmbientEnums.ts_0_62
declare enum E { a = 10, b = a, e = 10 << 2 * 8, }
{ "end_byte": 62, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/initializersInAmbientEnums.ts" }
TypeScript/tests/cases/compiler/mergedDeclarations5.ts_0_134
// @filename: a.ts class A { protected foo() {} } // @filename: b.ts interface A { } class B extends A { protected foo() {} }
{ "end_byte": 134, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mergedDeclarations5.ts" }
TypeScript/tests/cases/compiler/exportEqualMemberMissing.ts_0_595
// @module: commonjs // @Filename: exportEqualMemberMissing_0.ts module server { export interface connectModule { (res, req, next): void; } export interface connectExport { use: (mod: connectModule) => connectExport; } } var server: { (): server.connectExport; foo: Date; }; expor...
{ "end_byte": 595, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportEqualMemberMissing.ts" }
TypeScript/tests/cases/compiler/varInFunctionInVarInitializer.ts_0_64
var a = function () { var c = 1; return c; }, b = 1;
{ "end_byte": 64, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/varInFunctionInVarInitializer.ts" }
TypeScript/tests/cases/compiler/jsFileESModuleWithEnumTag.ts_0_478
// @allowJs: true // @checkJs: true // @noEmit: true // @filename: jsFileESModuleWithEnumTag.js export {}; // mark as module /** @enum {number} */ const ChangeDetectionStrategy = { OnPush: 0, Default: 1, }; ChangeDetectionStrategy[ChangeDetectionStrategy.OnPush] = 'OnPush'; ChangeDetectionStrategy[ChangeDetectionSt...
{ "end_byte": 478, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileESModuleWithEnumTag.ts" }
TypeScript/tests/cases/compiler/typeNamedUndefined1.ts_0_347
// @strict: true // @target: esnext // @lib: esnext export namespace ns { const s = Symbol(); export type undefined = typeof s; export function x(p: undefined): undefined { // global undefined return p; } } export function x(p: ns.undefined) { // undefined from the namespace return p; } e...
{ "end_byte": 347, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeNamedUndefined1.ts" }
TypeScript/tests/cases/compiler/unionReductionWithStringMappingAndIdenticalBaseTypeExistsNoCrash.tsx_0_2545
// @strict: true // @noEmit: true // @target: esnext // @lib: dom, esnext // @jsx: react // @esModuleInterop: true // @moduleResolution: node // https://github.com/microsoft/TypeScript/issues/56688 // @filename: node_modules/@types/react/index.d.ts export = React; export as namespace React; declare namespace React ...
{ "end_byte": 2545, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unionReductionWithStringMappingAndIdenticalBaseTypeExistsNoCrash.tsx" }
TypeScript/tests/cases/compiler/bitwiseCompoundAssignmentOperators.ts_0_265
var a = true; var b = 1; a ^= a; a = true; b ^= b; b = 1; a ^= b; a = true; b ^= a; b = 1; var c = false; var d = 2; c &= c; c = false; d &= d; d = 2; c &= d; c = false; d &= c; var e = true; var f = 0; e |= e; e = true; f |= f; f = 0; e |= f; e = true; f |= f;
{ "end_byte": 265, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/bitwiseCompoundAssignmentOperators.ts" }
TypeScript/tests/cases/compiler/jsFileCompilationWithoutJsExtensions.ts_0_33
// @filename: a.js declare var v;
{ "end_byte": 33, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationWithoutJsExtensions.ts" }
TypeScript/tests/cases/compiler/coAndContraVariantInferences3.ts_0_5842
// @strict: true interface DeprecationOptions { message?: string; error?: boolean; name?: string; } type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never; type OverloadDefinitions = { readonly [P in number]: (...args: any[]) => any; }; type Ove...
{ "end_byte": 5842, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/coAndContraVariantInferences3.ts" }
TypeScript/tests/cases/compiler/baseCheck.ts_0_601
class C { constructor(x: number, y: number) { } } class ELoc extends C { constructor(x: number) { super(0, x); } } class ELocVar extends C { constructor(x: number) { super(0, loc); } m() { var loc=10; } } class D extends C { constructor(public z: number) { super(this....
{ "end_byte": 601, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/baseCheck.ts" }
TypeScript/tests/cases/compiler/funduleSplitAcrossFiles.ts_0_158
// @Filename: funduleSplitAcrossFiles_function.ts function D() { } // @Filename: funduleSplitAcrossFiles_module.ts module D { export var y = "hi"; } D.y;
{ "end_byte": 158, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/funduleSplitAcrossFiles.ts" }
TypeScript/tests/cases/compiler/concatError.ts_1_407
var n1: number[]; /* interface Array<T> { concat(...items: T[][]): T[]; // Note: This overload needs to be picked for arrays of arrays, even though both are applicable concat(...items: T[]): T[]; } */ var fa: number[]; fa = fa.concat([0]); fa = fa.concat(0); /* declare class C<T> { public m(p1: C<C<T...
{ "end_byte": 407, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/concatError.ts" }
TypeScript/tests/cases/compiler/mappedTypeGenericIndexedAccess.ts_0_894
// @strict: true // @declaration: true // Repro from #49242 type Types = { first: { a1: true }; second: { a2: true }; third: { a3: true }; } class Test { entries: { [T in keyof Types]?: Types[T][] }; constructor() { this.entries = {}; } addEntry<T extends keyof Types>(name: T, e...
{ "end_byte": 894, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mappedTypeGenericIndexedAccess.ts" }
TypeScript/tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts_0_201
//@noUnusedLocals:true //@noUnusedParameters:true class Dummy { public greeter(person: string, person2: string, person3: string) { var unused = 20; person2 = "dummy value"; } }
{ "end_byte": 201, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts" }
TypeScript/tests/cases/compiler/recursiveResolveTypeMembers.ts_0_221
// Repro from #25291 type PromisedTuple<L extends any[], U = (...args: L) => void> = U extends (h: infer H, ...args: infer R) => [Promise<H>, ...PromisedTuple<R>] ? [] : [] type Promised = PromisedTuple<[1, 2, 3]>
{ "end_byte": 221, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveResolveTypeMembers.ts" }
TypeScript/tests/cases/compiler/typeReferenceDirectives9.ts_0_661
// @noImplicitReferences: true // @declaration: true // @typeRoots: /types // @traceResolution: true // @currentDirectory: / // @filename: /types/lib/index.d.ts interface Lib { x } // @filename: /main.ts export class Cls { x } // @filename: /mod1.ts /// <reference types="lib" /> import {Cls} from "./main"; Cls...
{ "end_byte": 661, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeReferenceDirectives9.ts" }
TypeScript/tests/cases/compiler/divideAndConquerIntersections.ts_0_3494
// @strict: true // @noEmit: true type QQ<T extends string[]> = & ("a" | T[0]) & ("b" | T[1]) & ("c" | T[2]) & ("d" | T[3]) & ("e" | T[4]) & ("f" | T[5]) & ("g" | T[6]) & ("h" | T[7]) & ("i" | T[8]) & ("j" | T[9]) & ("k" | T[10]) & ("l" | T[11]) & ("m" | T[12]) &...
{ "end_byte": 3494, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/divideAndConquerIntersections.ts" }
TypeScript/tests/cases/compiler/inKeywordTypeguard.ts_0_6080
// @strict: true, false // @target: es2015 class A { a: string; } class B { b: string; } function negativeClassesTest(x: A | B) { if ("a" in x) { x.b = "1"; } else { x.a = "1"; } } function positiveClassesTest(x: A | B) { if ("a" in x) { x.b = "1"; } else { x.a = "...
{ "end_byte": 6080, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inKeywordTypeguard.ts" }
TypeScript/tests/cases/compiler/inKeywordTypeguard.ts_6082_6566
function test1<T extends any[] | Record<string, any>>(obj: T) { if (Array.isArray(obj) || 'length' in obj) { obj; // T } else { obj; // T } } function test2<T extends any[] | Record<string, any>>(obj: T) { if (Array.isArray(obj)) { obj; // T & any[] } else { obj; ...
{ "end_byte": 6566, "start_byte": 6082, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inKeywordTypeguard.ts" }
TypeScript/tests/cases/compiler/protoInIndexer.ts_0_92
class X { constructor() { this['__proto__'] = null; // used to cause ICE } }
{ "end_byte": 92, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/protoInIndexer.ts" }
TypeScript/tests/cases/compiler/missingFunctionImplementation2.ts_0_227
// @Filename: missingFunctionImplementation2_a.ts export {}; declare module "./missingFunctionImplementation2_b" { export function f(a, b): void; } // @Filename: missingFunctionImplementation2_b.ts export function f(a?, b?);
{ "end_byte": 227, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/missingFunctionImplementation2.ts" }
TypeScript/tests/cases/compiler/initializePropertiesWithRenamedLet.ts_0_245
// @target: es5 var x0; if (true) { let x0; var obj1 = { x0: x0 }; var obj2 = { x0 }; } var x, y, z; if (true) { let { x: x } = { x: 0 }; let { y } = { y: 0 }; let z; ({ z: z } = { z: 0 }); ({ z } = { z: 0 }); }
{ "end_byte": 245, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/initializePropertiesWithRenamedLet.ts" }
TypeScript/tests/cases/compiler/libTypeScriptSubfileResolvingConfig.ts_0_462
// @traceResolution: true // @Filename: /somepath/node_modules/@typescript/lib-dom/index.d.ts // NOOP // @Filename: /somepath/node_modules/@typescript/lib-dom/iterable.d.ts interface DOMIterable { abc: string } // @Filename: /somepath/tsconfig.json { } // @Filename: /somepath/index.ts /// <reference lib="dom.iterable"...
{ "end_byte": 462, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/libTypeScriptSubfileResolvingConfig.ts" }
TypeScript/tests/cases/compiler/es5ExportDefaultFunctionDeclaration.ts_0_92
// @target: es5 // @module: commonjs // @declaration: true export default function f() { }
{ "end_byte": 92, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es5ExportDefaultFunctionDeclaration.ts" }
TypeScript/tests/cases/compiler/extendNonClassSymbol2.ts_0_155
function Foo() { this.x = 1; } var x = new Foo(); // legal, considered a constructor function class C extends Foo {} // error, could not find symbol Foo
{ "end_byte": 155, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/extendNonClassSymbol2.ts" }
TypeScript/tests/cases/compiler/keepImportsInDts1.ts_0_120
// @module: amd // @declaration: true // @filename: c:/test.d.ts export {}; // @filename: c:/app/main.ts import "test"
{ "end_byte": 120, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/keepImportsInDts1.ts" }
TypeScript/tests/cases/compiler/declarationEmitInvalidReferenceAllowJs.ts_0_85
// @allowJs: true // @declaration: true /// <reference path="invalid" /> var x = 0;
{ "end_byte": 85, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitInvalidReferenceAllowJs.ts" }
TypeScript/tests/cases/compiler/multiExtendsSplitInterfaces2.ts_0_204
interface A { a: number; } interface I extends A { i1: number; } interface B { b: number; } interface I extends B { i2: number; } var i: I; var a = i.a; var i1 = i.i1; var b = i.b; var i2 = i.i2;
{ "end_byte": 204, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/multiExtendsSplitInterfaces2.ts" }
TypeScript/tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts_3_181
ass A { blub = 6; } class B extends A { blah = 2; constructor(public x: number) { "use strict"; 'someStringForEgngInject'; super() } }
{ "end_byte": 181, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts" }
TypeScript/tests/cases/compiler/regularExpressionCharacterClassRangeOrder.ts_0_769
// @target: esnext // The characters in the following regular expressions are ASCII-lookalike characters found in Unicode, including: // - 𝘈 (U+1D608 Mathematical Sans-Serif Italic Capital A) // - 𝘡 (U+1D621 Mathematical Sans-Serif Italic Capital Z) // // See https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_S...
{ "end_byte": 769, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/regularExpressionCharacterClassRangeOrder.ts" }
TypeScript/tests/cases/compiler/isolatedModulesOut.ts_0_124
// @isolatedModules: true // @out:all.js // @target: es6 // @filename: file1.ts export var x; // @filename: file2.ts var y;
{ "end_byte": 124, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/isolatedModulesOut.ts" }
TypeScript/tests/cases/compiler/exportStarForValues9.ts_0_267
// @module: amd // @filename: file1.ts export interface Foo { x } // @filename: file2.ts export interface A { x } export * from "file1" export * from "file3" export var x = 1; // @filename: file3.ts export interface B { x } export * from "file2" export var x = 1;
{ "end_byte": 267, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportStarForValues9.ts" }
TypeScript/tests/cases/compiler/functionOverloads21.ts_0_129
function foo(bar:{a:number;}[]); function foo(bar:{a:number; b:string;}[]); function foo(bar:{a:any; b?:string;}[]) { return 0 }
{ "end_byte": 129, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloads21.ts" }
TypeScript/tests/cases/compiler/noEmitOnError.ts_0_87
// @noemitonerror: true // @sourcemap: true // @declaration: true var x: number = "";
{ "end_byte": 87, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noEmitOnError.ts" }
TypeScript/tests/cases/compiler/recursiveBaseCheck2.ts_0_370
declare module Box2D.Collision.Shapes { export class b2CircleShape extends b2Shape { } export class b2Shape extends Box2D.Collision.Shapes.b2CircleShape { } } declare module Box2D.Dynamics { export class b2ContactListener extends Box2D.Collision.Shapes.b2Shape { } export class b2FixtureDef e...
{ "end_byte": 370, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveBaseCheck2.ts" }
TypeScript/tests/cases/compiler/genericAndNonGenericInheritedSignature2.ts_0_112
interface Foo { f(x: any): any; } interface Bar { f<T>(x: T): T; } interface Hello extends Bar, Foo { }
{ "end_byte": 112, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericAndNonGenericInheritedSignature2.ts" }
TypeScript/tests/cases/compiler/augmentedTypesExternalModule1.ts_0_103
//@module: amd export var a = 1; class c5 { public foo() { } } module c5 { } // should be ok everywhere
{ "end_byte": 103, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/augmentedTypesExternalModule1.ts" }
TypeScript/tests/cases/compiler/promiseEmptyTupleNoException.ts_0_100
// @target: es2017 export async function get(): Promise<[]> { let emails = []; return emails; }
{ "end_byte": 100, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/promiseEmptyTupleNoException.ts" }
TypeScript/tests/cases/compiler/moduleVariables.ts_0_207
// @lib: es5 declare var console: any; var x = 1; module M { export var x = 2; console.log(x); // 2 } module M { console.log(x); // 2 } module M { var x = 3; console.log(x); // 3 }
{ "end_byte": 207, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleVariables.ts" }
TypeScript/tests/cases/compiler/excessPropertyCheckingIntersectionWithConditional.ts_0_188
type Foo<K> = K extends unknown ? { a: number } : unknown const createDefaultExample = <K,>(x: K): Foo<K> & { x: K; } => { return { a: 1, x: x }; // okay in TS 4.7.4, error in TS 4.8.2 }
{ "end_byte": 188, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/excessPropertyCheckingIntersectionWithConditional.ts" }
TypeScript/tests/cases/compiler/recursiveNamedLambdaCall.ts_0_313
// @lib: es5 var promise = function( obj ) { if ( top && top.doScroll ) { (function doScrollCheck() { if ( false ) { try { top.doScroll("left"); } catch(e) { return setTimeout( doScrollCheck, 50 ); } // detach all dom ready events detach(); } })(); } };
{ "end_byte": 313, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveNamedLambdaCall.ts" }
TypeScript/tests/cases/compiler/optionalParamterAndVariableDeclaration2.ts_0_120
// @strictNullChecks: true class C { constructor(options?: number) { var options = (options || 0); } }
{ "end_byte": 120, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/optionalParamterAndVariableDeclaration2.ts" }
TypeScript/tests/cases/compiler/dynamicRequire.ts_0_132
// @allowJs: true // @module: amd // @outFile: a_out.js // @filename: a.js function foo(name) { var s = require("t/" + name) }
{ "end_byte": 132, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/dynamicRequire.ts" }
TypeScript/tests/cases/compiler/jsFileCompilationShortHandProperty.ts_0_155
// @allowJs: true // @outFile: out.js // @FileName: a.js function foo() { var a = 10; var b = "Hello"; return { a, b }; }
{ "end_byte": 155, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationShortHandProperty.ts" }
TypeScript/tests/cases/compiler/controlFlowOuterVariable.ts_0_215
// @strictNullChecks: true // Repros from #10641 const CONFIG = { foo: '', setFoo: function(foo: string) { CONFIG.foo = foo; } }; const helper = function<T>(t: T[]) { helper(t.slice(1)); }
{ "end_byte": 215, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/controlFlowOuterVariable.ts" }
TypeScript/tests/cases/compiler/constraintsThatReferenceOtherContstraints1.ts_0_368
interface Object { } class Foo<T, U extends T> { } class Bar<T extends Object, U extends T> { data: Foo<Object, Object>; // Error 1 Type 'Object' does not satisfy the constraint 'T' for type parameter 'U extends T'. } var x: Foo< { a: string }, { a: string; b: number }>; // Error 2 Type '{ a: string; b: number; }...
{ "end_byte": 368, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constraintsThatReferenceOtherContstraints1.ts" }
TypeScript/tests/cases/compiler/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.ts_0_211
// @module: commonjs // @declaration: true // @Filename: file1.ts export function foo() { var classes = undefined; return new classes(null); } // @Filename: file2.ts import f = require('./file1'); f.foo();
{ "end_byte": 211, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.ts" }
TypeScript/tests/cases/compiler/exhaustiveSwitchCheckCircularity.ts_0_706
// @strict: true // Repro from #47539 declare function isNever(n: never): boolean; function f() { let foo: "aaa" | "bbb" = "aaa"; while (true) { switch (foo) { case "aaa": } if (foo === "aaa") { foo = "bbb"; } else if (isNever(foo)) { // Error ...
{ "end_byte": 706, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exhaustiveSwitchCheckCircularity.ts" }
TypeScript/tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithoutExport.ts_0_1994
//@module: amd //@declaration: true // @Filename: privacyTopLevelAmbientExternalModuleImportWithoutExport_require.ts // Public elements export class c_public { foo: string; } // @Filename: privacyTopLevelAmbientExternalModuleImportWithoutExport_require1.ts export class c_public { bar: string; } // @Filename:...
{ "end_byte": 1994, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithoutExport.ts" }
TypeScript/tests/cases/compiler/genericFunctions3.ts_0_239
interface Query<T> { foo(x: string): Query<T[]>; } function from<T>(arg: boolean): Query<T>; // was Error: Overload signature is not compatible with function definition. function from<T>(arg: any): Query<T> { return undefined; }
{ "end_byte": 239, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericFunctions3.ts" }
TypeScript/tests/cases/compiler/augmentedTypesModules4.ts_0_429
// module then enum // should be errors module m4 { } enum m4 { } module m4a { var y = 2; } enum m4a { One } module m4b { export var y = 2; } enum m4b { One } module m4c { interface I { foo(): void } } enum m4c { One } module m4d { class C { foo() { } } } enum m4d { One } //// module then module module m5 { expor...
{ "end_byte": 429, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/augmentedTypesModules4.ts" }
TypeScript/tests/cases/compiler/newAbstractInstance2.ts_0_104
// @Filename: /a.ts export default abstract class {} // @Filename: /b.ts import A from "./a"; new A();
{ "end_byte": 104, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/newAbstractInstance2.ts" }
TypeScript/tests/cases/compiler/cyclicGenericTypeInstantiation.ts_0_268
function foo<T>() { var z = foo<typeof y>(); var y: { y2: typeof z }; return y; } function bar<T>() { var z = bar<typeof y>(); var y: { y2: typeof z; } return y; } var a = foo<number>(); var b = bar<number>(); a = b;
{ "end_byte": 268, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/cyclicGenericTypeInstantiation.ts" }
TypeScript/tests/cases/compiler/wrappedIncovations2.ts_0_40
var v = this. foo(). bar(). baz();
{ "end_byte": 40, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/wrappedIncovations2.ts" }
TypeScript/tests/cases/compiler/bigintPropertyName.ts_0_1065
// @target: esnext // @fileName: a.ts // BigInt cannot be used as an object literal property { ({1n: 123}); }; const bigNum: bigint = 0n; const a = { 1n: 123 }; const b = { [1n]: 456 }; const c = { [bigNum]: 789 }; const arr = [1, 2, 3] as const; const { 0: d } = arr; const { "0": e } = arr; const { 0n: f } = arr; /...
{ "end_byte": 1065, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/bigintPropertyName.ts" }
TypeScript/tests/cases/compiler/classMergedWithInterfaceMultipleBasesNoError.ts_0_231
interface Bar { } interface Baz { } interface Q { } interface Foo extends Bar, Baz { } class Foo { } export default class extends Foo { readonly observer = this.handleIntersection; readonly handleIntersection = () => { } }
{ "end_byte": 231, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classMergedWithInterfaceMultipleBasesNoError.ts" }
TypeScript/tests/cases/compiler/declarationEmitProtectedMembers.ts_0_1006
// @declaration: true // @target: es5 // Class with protected members class C1 { protected x: number; protected f() { return this.x; } protected set accessor(a: number) { } protected get accessor() { return 0; } protected static sx: number; protected static sf() { return...
{ "end_byte": 1006, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitProtectedMembers.ts" }
TypeScript/tests/cases/compiler/jsFileMethodOverloads5.ts_0_336
// @declaration: true // @emitDeclarationOnly: true // @allowJs: true // @filename: /a.js /** * @overload * @param {string} a * @return {void} */ /** * @overload * @param {number} a * @param {number} [b] * @return {void} */ /** * @param {string | number} a * @param {number} [b] */ export const foo = func...
{ "end_byte": 336, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileMethodOverloads5.ts" }
TypeScript/tests/cases/compiler/collisionThisExpressionAndAmbientVarInGlobal.ts_0_94
declare var _this: number; // no error as no code gen var f = () => this; _this = 10; // Error
{ "end_byte": 94, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionThisExpressionAndAmbientVarInGlobal.ts" }
TypeScript/tests/cases/compiler/typeArgumentInferenceOrdering.ts_0_214
class C { y: I; } interface I { x(): Goo; } interface Goo { p: string; } function foo<T>(f: { y: T }): T { return null } var x = foo(new C()).x; // was Error that property x does not exist on type {}
{ "end_byte": 214, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeArgumentInferenceOrdering.ts" }
TypeScript/tests/cases/compiler/optionalParameterRetainsNull.ts_0_232
// @strictNullChecks: true interface Bar { bar: number; foo: object | null; } let a = { test<K extends keyof Bar> (a: K, b?: Bar[K] | null) { } }; a.test("bar", null); // ok, null is assignable to number | null | undefined
{ "end_byte": 232, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/optionalParameterRetainsNull.ts" }
TypeScript/tests/cases/compiler/typeArgumentsShouldDisallowNonGenericOverloads.ts_0_336
function foo(a: string): string; function foo<T>(a: T): number; function foo(a: any): any { return "hi"; } var x: number = foo<string>("hi"); // return type should be 'number' var y: string = foo("hi"); // return type should be 'string' var w: string = foo<string>("hi"); // should error var z: number = foo("hi");...
{ "end_byte": 336, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeArgumentsShouldDisallowNonGenericOverloads.ts" }
TypeScript/tests/cases/compiler/importedAliasesInTypePositions.ts_0_424
// @module:amd // @Filename: file1.ts export module elaborate.nested.mod.name { export class ReferredTo { doSomething(): void { } } } // @Filename: file2.ts // @module: amd import RT_ALIAS = require("file1"); import ReferredTo = RT_ALIAS.elaborate.nested.mod.name.ReferredTo; export module Impo...
{ "end_byte": 424, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importedAliasesInTypePositions.ts" }
TypeScript/tests/cases/compiler/isolatedModulesDontElideReExportStar.ts_0_129
// @isolatedModules: true // @target: es6 // @filename: /a.ts export type T = number; // @filename: /b.ts export * from "./a";
{ "end_byte": 129, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/isolatedModulesDontElideReExportStar.ts" }
TypeScript/tests/cases/compiler/functionOverloads9.ts_0_86
function foo(foo:string); function foo(foo?:string){ return '' }; var x = foo('foo');
{ "end_byte": 86, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloads9.ts" }
TypeScript/tests/cases/compiler/binaryArithmatic4.ts_0_20
var v = null | null;
{ "end_byte": 20, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/binaryArithmatic4.ts" }
TypeScript/tests/cases/compiler/globalThisDeclarationEmit2.ts_0_181
// @declaration: true // @filename: index.ts import { variable } from "./variable"; export { variable as globalThis }; // @filename: variable.ts export const variable = globalThis;
{ "end_byte": 181, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/globalThisDeclarationEmit2.ts" }
TypeScript/tests/cases/compiler/commentOnArrayElement5.ts_3_100
nst array = [ /* element 1 */ 1, /* end of element 1 */ /* extra comment */ ];
{ "end_byte": 100, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentOnArrayElement5.ts" }
TypeScript/tests/cases/compiler/compositeGenericFunction.ts_3_157
nction f<T>(value: T) { return value; }; function h<R>(func: (x: number) => R): R { return null; } var z: number = h<number>(f); var z: number = h(f);
{ "end_byte": 157, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/compositeGenericFunction.ts" }
TypeScript/tests/cases/compiler/augmentExportEquals1.ts_0_368
// @module: amd // @filename: file1.ts var x = 1; export = x; // @filename: file2.ts import x = require("./file1"); // augmentation for './file1' // should error since './file1' does not have namespace meaning declare module "./file1" { interface A { a } } // @filename: file3.ts import x = require("./file1"); ...
{ "end_byte": 368, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/augmentExportEquals1.ts" }
TypeScript/tests/cases/compiler/declarationEmitExportAssignedNamespaceNoTripleSlashTypesReference.ts_0_967
// @declaration: true // @filename: node_modules/@types/react/index.d.ts export = React; declare namespace React { export type Component<T = any, U = {}, V = {}> = { x: T, y: U, z: V }; export interface DOMAttributes<T> { } } // @filename: node_modules/@emotion/core/index.d.ts import { Component } from 're...
{ "end_byte": 967, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitExportAssignedNamespaceNoTripleSlashTypesReference.ts" }
TypeScript/tests/cases/compiler/declFileAliasUseBeforeDeclaration2.ts_0_166
//@module: commonjs //@declaration: true declare module "test" { module A { class C { } } class B extends E { } import E = A.C; }
{ "end_byte": 166, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileAliasUseBeforeDeclaration2.ts" }
TypeScript/tests/cases/compiler/isolatedDeclarationsLiterals.ts_0_1301
// @isolatedDeclarations: true // @declaration: true // @strict: true // @target: esnext // @filename: file1.ts export const constObject = { /** Value Of 1 */ one: 1, /** Value Of 0o1 */ oneOctal: 0o1, /** Value Of 0x1 */ oneHex: 0x1, /** Value Of +1 */ pOne: +1, /** Value Of -1 ...
{ "end_byte": 1301, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/isolatedDeclarationsLiterals.ts" }
TypeScript/tests/cases/compiler/substitutionTypeNoMergeOfAssignableType.ts_0_502
interface Entry { comment?: string; } interface Entity { fields: {[key: string]: Entry}; } type Fields<E extends Entity> = { [P in keyof E["fields"]]: E["fields"][P] }; type Nodes<T = any> = { [P in keyof T]: T[P] extends Entity ? Fields<T[P]> : T[P] }; function make...
{ "end_byte": 502, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/substitutionTypeNoMergeOfAssignableType.ts" }
TypeScript/tests/cases/compiler/collisionCodeGenModuleWithPrivateMember.ts_0_107
module m1 { class m1 { } var x = new m1(); export class c1 { } } var foo = new m1.c1();
{ "end_byte": 107, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionCodeGenModuleWithPrivateMember.ts" }
TypeScript/tests/cases/compiler/mapOnTupleTypes02.ts_0_188
// @declaration: true // @noImplicitAny: true // @strictNullChecks: true export type Point = [number, number]; export function increment(point: Point) { return point.map(d => d + 1); }
{ "end_byte": 188, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mapOnTupleTypes02.ts" }
TypeScript/tests/cases/compiler/internalAliasVarInsideTopLevelModuleWithoutExport.ts_0_124
//@module: commonjs // @declaration: true export module a { export var x = 10; } import b = a.x; export var bVal = b;
{ "end_byte": 124, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/internalAliasVarInsideTopLevelModuleWithoutExport.ts" }
TypeScript/tests/cases/compiler/typeParameterAsElementType.ts_0_58
function fee<T>() { var t: T; var arr = [t, ""]; }
{ "end_byte": 58, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeParameterAsElementType.ts" }
TypeScript/tests/cases/compiler/isolatedModulesReExportType.ts_0_1350
// @isolatedModules: true // @Filename: /exportT.ts export type T = number; // @Filename: /exportValue.ts export class C {} // @Filename: /exportEqualsT.ts declare type T = number; export = T; // @Filename: /node_modules/foo/bar.d.ts export type T = number; // @Filename: /node_modules/foo/index.d.ts export { T } f...
{ "end_byte": 1350, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/isolatedModulesReExportType.ts" }
TypeScript/tests/cases/compiler/noImplicitAnyMissingGetAccessor.ts_3_212
@noImplicitAny : true // @target: es5 abstract class Parent { public abstract set message(str); } class Child extends Parent { _x: any; public set message(str) { this._x = str; } }
{ "end_byte": 212, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noImplicitAnyMissingGetAccessor.ts" }
TypeScript/tests/cases/compiler/systemModule13.ts_0_134
// @module: system export let [x,y,z] = [1, 2, 3]; export const {a: z0, b: {c: z1}} = {a: true, b: {c: "123"}}; for ([x] of [[1]]) {}
{ "end_byte": 134, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/systemModule13.ts" }
TypeScript/tests/cases/compiler/jsdocFunctionClassPropertiesDeclaration.ts_0_320
// @allowJs: true // @checkJs: true // @strict: true // @declaration: true // @outDir: ./out // @filename: /a.js /** * @param {number | undefined} x * @param {number | undefined} y */ export function Foo(x, y) { if (!(this instanceof Foo)) { return new Foo(x, y); } this.x = x; this.y = y; }
{ "end_byte": 320, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsdocFunctionClassPropertiesDeclaration.ts" }
TypeScript/tests/cases/compiler/functionOverloads31.ts_0_122
function foo(bar:string):string; function foo(bar:number):number; function foo(bar:any):any{ return bar } var x = foo(5);
{ "end_byte": 122, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloads31.ts" }
TypeScript/tests/cases/compiler/logicalNotExpression1.ts_0_5
!foo;
{ "end_byte": 5, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/logicalNotExpression1.ts" }
TypeScript/tests/cases/compiler/isolatedDeclarationsAllowJs.ts_0_145
// @isolatedDeclarations: true // @allowJS: true // @declaration: true // @filename: file1.ts export var x; // @filename: file2.js export var y;
{ "end_byte": 145, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/isolatedDeclarationsAllowJs.ts" }
TypeScript/tests/cases/compiler/amdModuleName1.ts_0_140
//@module: amd ///<amd-module name='NamedModule'/> class Foo { x: number; constructor() { this.x = 5; } } export = Foo;
{ "end_byte": 140, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/amdModuleName1.ts" }
TypeScript/tests/cases/compiler/cloduleAcrossModuleDefinitions.ts_0_170
module A { export class B { foo() { } static bar() { } } } module A { export module B { export var x = 1; } } var b: A.B; // ok
{ "end_byte": 170, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/cloduleAcrossModuleDefinitions.ts" }
TypeScript/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.ts_0_1023
// @target: es5 // @module: commonjs // @declaration: true // @filename: es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0.ts var a = 10; export default a; // @filename: es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.ts import defaultBinding1, { } from "./es6ImportDefaultBindingFollowedWithNamedImport1In...
{ "end_byte": 1023, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.ts" }
TypeScript/tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts_0_200
// @target: es6 // This should be an error // More details: http://www.ecma-international.org/ecma-262/6.0/#sec-iteration-statements var let = 10; for (let of [1,2,3]) {} for (let in [1,2,3]) {}
{ "end_byte": 200, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts" }
TypeScript/tests/cases/compiler/propertyAccessExpressionInnerComments.ts_0_567
/*1*/Array/*2*/./*3*/toString/*4*/ /*1*/Array /*2*/./*3*/ // Single-line comment toString/*4*/ /*1*/Array/*2*/./*3*/ // Single-line comment toString/*4*/ /*1*/Array // Single-line comment /*2*/./*3*/toString/*4*/ /* Existing issue: the "2" comments below are duplicated and "3"s are missing *...
{ "end_byte": 567, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/propertyAccessExpressionInnerComments.ts" }
TypeScript/tests/cases/compiler/varNameConflictsWithImportInDifferentPartOfModule.ts_0_132
module M1 { export var q = 5; export var s = ''; } module M1 { export import q = M1.s; // Should be an error but isn't }
{ "end_byte": 132, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/varNameConflictsWithImportInDifferentPartOfModule.ts" }
TypeScript/tests/cases/compiler/jsDeclarationsGlobalFileConstFunctionNamed.ts_0_488
// @checkJs: true // @declaration: true // @emitDeclarationOnly: true // @filename: file.js const SomeConstructor = function Named() { this.x = 1; }; const SomeConstructor2 = function Named() { }; SomeConstructor2.staticMember = "str"; const SomeConstructor3 = function Named() { this.x = 1; }; SomeConstructor3.stat...
{ "end_byte": 488, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsDeclarationsGlobalFileConstFunctionNamed.ts" }
TypeScript/tests/cases/compiler/errorConstructorSubtypes.ts_0_308
// @lib: es5,dom // In Node, ErrorConstructor is augmented with extra properties. Excerpted below. interface ErrorConstructor { captureStackTrace(targetObject: Object, constructorOpt?: Function): void; } declare var x: ErrorConstructor x = Error; // OK x = RangeError; new x().message x.captureStackTrace
{ "end_byte": 308, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/errorConstructorSubtypes.ts" }
TypeScript/tests/cases/compiler/idInProp.ts_0_47
function f() { var t: { (f: any) : any; }; }
{ "end_byte": 47, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/idInProp.ts" }