_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/typeGuardNarrowByUntypedField.ts_0_305
// @lib: es6 declare function hasOwnProperty<P extends PropertyKey>(target: {}, property: P): target is { readonly [K in P]: unknown }; declare const arrayLikeOrIterable: ArrayLike<any> | Iterable<any>; if (hasOwnProperty(arrayLikeOrIterable, 'length')) { let x: number = arrayLikeOrIterable.length; }
{ "end_byte": 305, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeGuardNarrowByUntypedField.ts" }
TypeScript/tests/cases/compiler/declarationFunctionTypeNonlocalShouldNotBeAnError.ts_0_112
// @declaration: true namespace foo { function bar(): void {} export const obj = { bar } }
{ "end_byte": 112, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationFunctionTypeNonlocalShouldNotBeAnError.ts" }
TypeScript/tests/cases/compiler/taggedTemplateStringsWithUnicodeEscapesES6.ts_0_108
//@target: es6 function f(...args: any[]) { } f `'\u{1f4a9}'${ " should be converted to " }'\uD83D\uDCA9'`;
{ "end_byte": 108, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/taggedTemplateStringsWithUnicodeEscapesES6.ts" }
TypeScript/tests/cases/compiler/unusedParametersInLambda1.ts_0_120
//@noUnusedLocals:true //@noUnusedParameters:true class A { public f1() { return (X) => { } } }
{ "end_byte": 120, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedParametersInLambda1.ts" }
TypeScript/tests/cases/compiler/contextualTypeFunctionObjectPropertyIntersection.ts_0_2867
// @strict: true // @noEmit: true // repro from #48812 type Action<TEvent extends { type: string }> = (ev: TEvent) => void; interface MachineConfig<TEvent extends { type: string }> { schema: { events: TEvent; }; on?: { [K in TEvent["type"]]?: Action<TEvent extends { type: K } ? TEvent : never>; } & {...
{ "end_byte": 2867, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTypeFunctionObjectPropertyIntersection.ts" }
TypeScript/tests/cases/compiler/genericClasses3.ts_0_213
// @declaration: true class B<T> { a: T; b: T; } class C<T> extends B<T> { public x: T; } var v2: C <string>; var y = v2.x; // should be 'string' var u = v2.a; // should be 'string' var z = v2.b;
{ "end_byte": 213, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericClasses3.ts" }
TypeScript/tests/cases/compiler/privacyClass.ts_0_3002
//@module: commonjs export module m1 { export interface m1_i_public { } interface m1_i_private { } export class m1_c_public { private f1() { } } class m1_c_private { } class m1_C1_private extends m1_c_public { } class m1_C2_private extends m1_c_private { ...
{ "end_byte": 3002, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyClass.ts" }
TypeScript/tests/cases/compiler/promiseIdentityWithConstraints.ts_0_355
export interface IPromise<T, V> { then<U extends T, W extends V>(callback: (x: T) => IPromise<U, W>): IPromise<U, W>; } export interface Promise<T, V> { then<U extends T, W extends V>(callback: (x: T) => Promise<U, W>): Promise<U, W>; } // Error because constraint V doesn't match var x: IPromise<string, number...
{ "end_byte": 355, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/promiseIdentityWithConstraints.ts" }
TypeScript/tests/cases/compiler/contextualTyping20.ts_0_70
var foo:{id:number;}[] = [{id:1}]; foo = [{id:1}, {id:2, name:"foo"}];
{ "end_byte": 70, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTyping20.ts" }
TypeScript/tests/cases/compiler/exportStarForValuesInSystem.ts_0_126
// @module: system // @filename: file1.ts export interface Foo { x } // @filename: file2.ts export * from "file1" var x = 1;
{ "end_byte": 126, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportStarForValuesInSystem.ts" }
TypeScript/tests/cases/compiler/parenthesizedJSDocCastDoesNotNarrow.ts_0_276
// @strict: true // @noEmit: true // @checkJs: true // @allowJs: true // @filename: index.js let value = ""; switch (/** @type {"foo" | "bar"} */ (value)) { case "bar": value; break; case "foo": value; break; case "invalid": value; break; }
{ "end_byte": 276, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parenthesizedJSDocCastDoesNotNarrow.ts" }
TypeScript/tests/cases/compiler/capturedShorthandPropertyAssignmentNoCheck.ts_0_157
// @target: es5 const fns = []; for (const value of [1, 2, 3]) { fns.push(() => ({ value })); } const result = fns.map(fn => fn()); console.log(result)
{ "end_byte": 157, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/capturedShorthandPropertyAssignmentNoCheck.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementNestedObjectBindingPatternWithDefaultValues.ts_0_1116
// @lib: es5 // @sourcemap: true declare var console: { log(msg: string): void; } interface Robot { name: string; skills: { primary?: string; secondary?: string; }; } var robotA: Robot = { name: "mower", skills: { primary: "mowing", secondary: "none" } }; var robotB: Robot = { name: "tri...
{ "end_byte": 1116, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementNestedObjectBindingPatternWithDefaultValues.ts" }
TypeScript/tests/cases/compiler/functionWithNoBestCommonType2.ts_0_115
// @allowUnreachableCode: true var v = function () { return true; return bar(); }; function bar(): void { }
{ "end_byte": 115, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionWithNoBestCommonType2.ts" }
TypeScript/tests/cases/compiler/extendGenericArray.ts_0_88
interface Array<T> { foo(): T; } var arr: string[] = []; var x: number = arr.foo();
{ "end_byte": 88, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/extendGenericArray.ts" }
TypeScript/tests/cases/compiler/identityAndDivergentNormalizedTypes.ts_0_668
// @strict: true // @noEmit: true // Repros from #53998 type ApiPost = | { path: "/login"; body: {}; } | { path: "/user"; body: { name: string; }; } type PostPath = ApiPost["path"]; type PostBody<PATH extends PostPath> = Extract<ApiPost, { path: PATH }>["body"]; cons...
{ "end_byte": 668, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/identityAndDivergentNormalizedTypes.ts" }
TypeScript/tests/cases/compiler/typeInferenceCacheInvalidation.ts_0_422
// @strict: true // Repro from #32230 type Callback<TFoo, TBar> = (foo: TFoo, bar: TBar) => any declare function example<TFoo, TBar, TCallback extends Callback<TFoo, TBar>>( foo: TFoo, callback: TCallback, bar: TBar, ): TCallback example(42, (foo, bar) => ({ t: () => { let s: string = bar; ...
{ "end_byte": 422, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeInferenceCacheInvalidation.ts" }
TypeScript/tests/cases/compiler/aliasErrors.ts_0_475
module foo { export class Provide { } export module bar { export module baz {export class boo {}}} } import provide = foo; import booz = foo.bar.baz; import beez = foo.bar; import m = no; import m2 = no.mod; import n = 5; import o = "s"; import q = null; import r = undefined; var p = new provide.Pro...
{ "end_byte": 475, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/aliasErrors.ts" }
TypeScript/tests/cases/compiler/toStringOnPrimitives.ts_0_67
true.toString() var aBool = false; aBool.toString(); 1..toString();
{ "end_byte": 67, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/toStringOnPrimitives.ts" }
TypeScript/tests/cases/compiler/cyclicModuleImport.ts_0_476
// @declaration: true declare module "SubModule" { import MainModule = require('MainModule'); class SubModule { public static StaticVar: number; public InstanceVar: number; public main: MainModule; constructor(); } export = SubModule; } declare module "MainModule" { i...
{ "end_byte": 476, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/cyclicModuleImport.ts" }
TypeScript/tests/cases/compiler/functionExpressionNames.ts_0_486
// @allowJs: true // @noEmit: true // @checkJs: true // @Filename: b.js exports.E = function() { this.e = 'exported' } var e = new exports.E(); var o = { C: function () { this.c = 'nested object' } } var og = new o.C(); var V = function () { this.v = 'simple' } var v = new V(); var A; A = fun...
{ "end_byte": 486, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionExpressionNames.ts" }
TypeScript/tests/cases/compiler/abstractClassInLocalScope.ts_0_91
(() => { abstract class A {} class B extends A {} new B(); return A; })();
{ "end_byte": 91, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/abstractClassInLocalScope.ts" }
TypeScript/tests/cases/compiler/es6-amd.ts_0_167
// @target: ES6 // @sourcemap: false // @declaration: false // @module: amd class A { constructor () { } public B() { return 42; } }
{ "end_byte": 167, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6-amd.ts" }
TypeScript/tests/cases/compiler/assignmentCompatBug3.ts_0_455
function makePoint(x: number, y: number) { return { get x() { return x;}, // shouldn't be "void" get y() { return y;}, // shouldn't be "void" //x: "yo", //y: "boo", dist: function () { return Math.sqrt(x*x+y*y); // shouldn't be picking up "x" and "y" from the object lit ...
{ "end_byte": 455, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatBug3.ts" }
TypeScript/tests/cases/compiler/declarationEmitClassPrivateConstructor2.ts_0_270
// @target: es5 // @module: commonjs // @declaration: true interface PrivateInterface { } export class ExportedClass1 { private constructor(public data: PrivateInterface) { } } export class ExportedClass2 { protected constructor(data: PrivateInterface) { } }
{ "end_byte": 270, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitClassPrivateConstructor2.ts" }
TypeScript/tests/cases/compiler/moduleNodeDefaultImports.ts_0_606
// @module: node16,nodenext // @filename: mod.cts declare function fun(): void; export default fun; // @filename: b.mts import a from "./mod.cjs"; import { default as b } from "./mod.cjs"; import c, { default as d } from "./mod.cjs"; import * as self from "./b.mjs"; export { default } from "./mod.cjs"; export { default...
{ "end_byte": 606, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleNodeDefaultImports.ts" }
TypeScript/tests/cases/compiler/callOnInstance.ts_0_254
declare function D(): string; // error declare class D { constructor (value: number); } // error var s1: string = D(); // OK var s2: string = (new D(1))(); declare class C { constructor(value: number); } (new C(1))(); // Error for calling an instance
{ "end_byte": 254, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/callOnInstance.ts" }
TypeScript/tests/cases/compiler/defaultArgsInFunctionExpressions.ts_0_864
var f = function (a = 3) { return a; }; // Type should be (a?: number) => number var n: number = f(4); n = f(); var s: string = f(''); s = f(); // Type check the default argument with the type annotation var f2 = function (a: string = 3) { return a; }; // Should error, but be of type (a: string) => string; s = f2('');...
{ "end_byte": 864, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/defaultArgsInFunctionExpressions.ts" }
TypeScript/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts_0_303
//@noUnusedLocals:true //@noUnusedParameters:true var greeter = function (person: string, person2: string) { var unused = 20; function maker(child: string): void { var unused2 = 22; } function maker2(child2: string): void { var unused3 = 23; } maker2(person2); }
{ "end_byte": 303, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts" }
TypeScript/tests/cases/compiler/parseJsxElementInUnaryExpressionNoCrash3.ts_0_63
// @allowJs: true // @outDir: ./out // @filename: a.js !< {:>
{ "end_byte": 63, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parseJsxElementInUnaryExpressionNoCrash3.ts" }
TypeScript/tests/cases/compiler/declarationEmitComputedPropertyName1.ts_0_483
// @strict: true // @declaration: true // @emitDeclarationOnly: true // https://github.com/microsoft/TypeScript/issues/59107 declare function create<T extends {}>(): T; export const c = create<{ data: { ["a_b_c"]: string; ["sss"]: string; s_d: string; queryData?: string; ["foo bar"]: string; ...
{ "end_byte": 483, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitComputedPropertyName1.ts" }
TypeScript/tests/cases/compiler/truthinessPromiseCoercion.ts_0_932
// @strictNullChecks:true // @target:esnext declare const p: Promise<number> declare const p2: null | Promise<number> declare const obj: { p: Promise<unknown> } declare function pf(): Promise<boolean> async function f() { if (p) {} // err if (!!p) {} // no err if (p2) {} // no err p ? f.arguments : f...
{ "end_byte": 932, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/truthinessPromiseCoercion.ts" }
TypeScript/tests/cases/compiler/caseInsensitiveFileSystemWithCapsImportTypeDeclarations.ts_0_533
// @declaration: true // @useCaseSensitiveFileNames: false // @filename: Uppercased_Dir/src/index.ts import { TypeB } from './type-b'; export class Broken { method () { return { } as TypeB; } } // @filename: Uppercased_Dir/src/type-b.ts import { Merge } from './types'; import { TypeA } from './type-a';...
{ "end_byte": 533, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/caseInsensitiveFileSystemWithCapsImportTypeDeclarations.ts" }
TypeScript/tests/cases/compiler/conditionalTypeRelaxingConstraintAssignability.ts_0_799
// @strict: true export type ElChildren = | ElChildren.Void | ElChildren.Text; export namespace ElChildren { export type Void = undefined; export type Text = string; } type Relax<C extends ElChildren> = C extends ElChildren.Text ? ElChildren.Text : C; export class Elem< C extends ElChildren, > { constru...
{ "end_byte": 799, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/conditionalTypeRelaxingConstraintAssignability.ts" }
TypeScript/tests/cases/compiler/contextualTyping14.ts_0_68
class foo { public bar:(a:number)=>number = function(a){return a}; }
{ "end_byte": 68, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTyping14.ts" }
TypeScript/tests/cases/compiler/bestCommonTypeReturnStatement.ts_0_316
// @allowUnreachableCode: true interface IPromise<T> { then(successCallback: (promiseValue: T) => any, errorCallback?: (reason: any) => any): IPromise<any>; } function f() { if (true) return b(); return d(); } function b(): IPromise<void> { return null; } function d(): IPromise<any> { return null; }
{ "end_byte": 316, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/bestCommonTypeReturnStatement.ts" }
TypeScript/tests/cases/compiler/recursiveSpecializationOfExtendedTypeWithError.ts_0_102
// @lib: es5 interface HTMLSelectElement { options: HTMLSelectElement; <A>(name: A): any; }
{ "end_byte": 102, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveSpecializationOfExtendedTypeWithError.ts" }
TypeScript/tests/cases/compiler/narrowingTypeofDiscriminant.ts_0_1086
// @strict: true function f1(obj: { kind: 'a', data: string } | { kind: 1, data: number }) { if (typeof obj.kind === "string") { obj; // { kind: 'a', data: string } } else { obj; // { kind: 1, data: number } } } function f2(obj: { kind: 'a', data: string } | { kind: 1, data: number }...
{ "end_byte": 1086, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowingTypeofDiscriminant.ts" }
TypeScript/tests/cases/compiler/objectLiteralMemberWithModifiers1.ts_0_28
var v = { public foo() { } }
{ "end_byte": 28, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectLiteralMemberWithModifiers1.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationDestructuringParameterNestedObjectBindingPattern.ts_0_895
// @lib: es5 // @sourcemap: true declare var console: { log(msg: string): void; } interface Robot { name: string; skills: { primary: string; secondary: string; }; } var robotA: Robot = { name: "mower", skills: { primary: "mowing", secondary: "none" } }; function foo1({ skills: { primary...
{ "end_byte": 895, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationDestructuringParameterNestedObjectBindingPattern.ts" }
TypeScript/tests/cases/compiler/circularContextualMappedType.ts_0_338
// @strict: true type Func<T> = () => T; type Mapped<T> = { [K in keyof T]: Func<T[K]> }; declare function reproduce(options: number): void; declare function reproduce<T>(options: Mapped<T>): T reproduce({ name: () => { return 123 } }); reproduce({ name() { return 123 } }); reproduce({ name: function () {...
{ "end_byte": 338, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/circularContextualMappedType.ts" }
TypeScript/tests/cases/compiler/mixinOverMappedTypeNoCrash.ts_0_489
// @noEmit: true export type ClassInterface<C> = { [key in keyof C]: C[key]; } type InstanceInterface<I> = { new(...args: any[]): I prototype: I } type Constructor<I extends Object, C = any> = ClassInterface<C> & InstanceInterface<I> function cloneClass<T extends Constructor<{}>>(OriginalClass: T): T { ...
{ "end_byte": 489, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mixinOverMappedTypeNoCrash.ts" }
TypeScript/tests/cases/compiler/aliasUsageInAccessorsOfClass.ts_0_658
// @module: commonjs // @target: ES5 // @Filename: aliasUsage1_backbone.ts export class Model { public someData: string; } // @Filename: aliasUsage1_moduleA.ts import Backbone = require("./aliasUsage1_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } // @Filename...
{ "end_byte": 658, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/aliasUsageInAccessorsOfClass.ts" }
TypeScript/tests/cases/compiler/enumLiteralsSubtypeReduction.ts_0_6
enum E
{ "end_byte": 6, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumLiteralsSubtypeReduction.ts" }
TypeScript/tests/cases/compiler/enumLiteralsSubtypeReduction.ts_7_4797
{ E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13, E14, E15, E16, E17, E18, E19, E20, E21, E22, E23, E24, E25, E26, E27, E28, E29, E30, E31, E32, E33, E34, E35, ...
{ "end_byte": 4797, "start_byte": 7, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumLiteralsSubtypeReduction.ts" }
TypeScript/tests/cases/compiler/enumLiteralsSubtypeReduction.ts_4797_9697
, E490, E491, E492, E493, E494, E495, E496, E497, E498, E499, E500, E501, E502, E503, E504, E505, E506, E507, E508, E509, E510, E511, E512, E513, E514, E515, E516, E517, E518, E519, E520, E521...
{ "end_byte": 9697, "start_byte": 4797, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumLiteralsSubtypeReduction.ts" }
TypeScript/tests/cases/compiler/enumLiteralsSubtypeReduction.ts_9697_10188
, E980, E981, E982, E983, E984, E985, E986, E987, E988, E989, E990, E991, E992, E993, E994, E995, E996, E997, E998, E999, E1000, E1001, E1002, E1003, E1004, E1005, E1006, E1007, E1008, E1009, E101...
{ "end_byte": 10188, "start_byte": 9697, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumLiteralsSubtypeReduction.ts" }
TypeScript/tests/cases/compiler/enumLiteralsSubtypeReduction.ts_10189_16752
{ switch (a) { case 0: return [ E.E0, E.E1] case 2: return [ E.E2, E.E3] case 4: return [ E.E4, E.E5] case 6: return [ E.E6, E.E7] case 8: return [ E.E8, E.E9] case 10: return [ E.E10, E.E11] ...
{ "end_byte": 16752, "start_byte": 10189, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumLiteralsSubtypeReduction.ts" }
TypeScript/tests/cases/compiler/enumLiteralsSubtypeReduction.ts_16761_23462
case 244: return [ E.E244, E.E245] case 246: return [ E.E246, E.E247] case 248: return [ E.E248, E.E249] case 250: return [ E.E250, E.E251] case 252: return [ E.E252, E.E253] case 254: return [ E.E254, E.E255...
{ "end_byte": 23462, "start_byte": 16761, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumLiteralsSubtypeReduction.ts" }
TypeScript/tests/cases/compiler/enumLiteralsSubtypeReduction.ts_23471_30172
case 488: return [ E.E488, E.E489] case 490: return [ E.E490, E.E491] case 492: return [ E.E492, E.E493] case 494: return [ E.E494, E.E495] case 496: return [ E.E496, E.E497] case 498: return [ E.E498, E.E499...
{ "end_byte": 30172, "start_byte": 23471, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumLiteralsSubtypeReduction.ts" }
TypeScript/tests/cases/compiler/enumLiteralsSubtypeReduction.ts_30181_36882
case 732: return [ E.E732, E.E733] case 734: return [ E.E734, E.E735] case 736: return [ E.E736, E.E737] case 738: return [ E.E738, E.E739] case 740: return [ E.E740, E.E741] case 742: return [ E.E742, E.E743...
{ "end_byte": 36882, "start_byte": 30181, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumLiteralsSubtypeReduction.ts" }
TypeScript/tests/cases/compiler/enumLiteralsSubtypeReduction.ts_36891_38246
case 976: return [ E.E976, E.E977] case 978: return [ E.E978, E.E979] case 980: return [ E.E980, E.E981] case 982: return [ E.E982, E.E983] case 984: return [ E.E984, E.E985] case 986: return [ E.E986, E.E987...
{ "end_byte": 38246, "start_byte": 36891, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumLiteralsSubtypeReduction.ts" }
TypeScript/tests/cases/compiler/jsPropertyAssignedAfterMethodDeclaration.ts_0_221
// @allowJs: true // @checkJs: true // @noEmit: true // @noImplicitThis: true // @Filename: /a.js const o = { a() { // Should not be treated as a declaration. Should be an error. this.a = 0; } };
{ "end_byte": 221, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsPropertyAssignedAfterMethodDeclaration.ts" }
TypeScript/tests/cases/compiler/overloadOnConstInBaseWithBadImplementationInDerived.ts_0_157
interface I { x1(a: number, callback: (x: 'hi') => number); } class C implements I { x1(a: number, callback: (x: 'hi') => number) { // error } }
{ "end_byte": 157, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overloadOnConstInBaseWithBadImplementationInDerived.ts" }
TypeScript/tests/cases/compiler/computedPropertiesNarrowed.ts_0_913
// @target: es2015 // @isolatedDeclarations: true // @declaration: true const x: 0 | 1 = Math.random()? 0: 1; declare function assert(n: number): asserts n is 1; assert(x); export let o = { [x]: 1 // error narrow type !== declared type } const y: 0 = 0 export let o2 = { [y]: 1 // ok literal computed type } ...
{ "end_byte": 913, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/computedPropertiesNarrowed.ts" }
TypeScript/tests/cases/compiler/pinnedComments1.ts_0_164
// @removeComments: true /*!========= Keep this pinned comment ========= */ /* unpinned comment */ /*! pinned comment that need to be removed */ class C { }
{ "end_byte": 164, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/pinnedComments1.ts" }
TypeScript/tests/cases/compiler/classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts_0_656
// @strict: true // @lib: esnext // @noEmit: true interface IObserver { handleChange<T, TChange>(observable: IObservable<T, TChange>, change: TChange): void; } interface IObservable<T, TChange = unknown> { get(): T; readonly TChange: TChange; } export interface IReader { readObservable<T>(observable: IObservable...
{ "end_byte": 656, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts" }
TypeScript/tests/cases/compiler/isolatedModulesNoExternalModule.ts_0_72
// @isolatedModules: true // @target: es6 // @filename: file1.ts var x;
{ "end_byte": 72, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/isolatedModulesNoExternalModule.ts" }
TypeScript/tests/cases/compiler/quotedFunctionName2.ts_0_38
class Test1 { static "prop1"() { } }
{ "end_byte": 38, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/quotedFunctionName2.ts" }
TypeScript/tests/cases/compiler/fillInMissingTypeArgsOnJSConstructCalls.ts_0_592
// @allowJs: true // @checkJs: true // @noEmit: true // regression test for #18254 // @Filename: BaseA.js export default class BaseA { } // @Filename: SubA.js import BaseA from './BaseA'; export default class SubA extends BaseA { } // @Filename: BaseB.js import BaseA from './BaseA'; export default class B<T: BaseA> { ...
{ "end_byte": 592, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/fillInMissingTypeArgsOnJSConstructCalls.ts" }
TypeScript/tests/cases/compiler/exportDefaultQualifiedNameNoError.ts_0_127
// @filename: code.ts class C { static x = 0; }; export default C.x; // @filename: usage.ts import def from "./code"; void def;
{ "end_byte": 127, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportDefaultQualifiedNameNoError.ts" }
TypeScript/tests/cases/compiler/importDeclarationNotCheckedAsValueWhenTargetNonValue.ts_0_494
// @filename: file.d.ts declare namespace dojox { namespace charting { namespace axis2d { export class Val { } interface common { createText: object; } namespace common { interface createText { gfx(): string ...
{ "end_byte": 494, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importDeclarationNotCheckedAsValueWhenTargetNonValue.ts" }
TypeScript/tests/cases/compiler/arrayConcat2.ts_0_119
var a: string[] = []; a.concat("hello", 'world'); a.concat('Hello'); var b = new Array<string>(); b.concat('hello');
{ "end_byte": 119, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arrayConcat2.ts" }
TypeScript/tests/cases/compiler/tsxInvokeComponentType.tsx_0_356
// @jsx: react // @strict: true // @esModuleInterop: true /// <reference path="/.lib/react16.d.ts" /> import React, { ComponentType } from "react"; declare const Elem: ComponentType<{ someKey: string }>; const bad = <Elem />; const good = <Elem someKey="ok" />; declare const Elem2: ComponentType<{ opt?: number }>; ...
{ "end_byte": 356, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/tsxInvokeComponentType.tsx" }
TypeScript/tests/cases/compiler/functionExpressionInWithBlock.ts_0_67
function x() { with({}) { function f() { () => this; } } }
{ "end_byte": 67, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionExpressionInWithBlock.ts" }
TypeScript/tests/cases/compiler/declarationEmitInferredTypeAlias9.ts_0_136
// @declaration: true type Foo<T> = T | { x: Foo<T> }; var x: Foo<number[]>; export function returnSomeGlobalValue() { return x; }
{ "end_byte": 136, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitInferredTypeAlias9.ts" }
TypeScript/tests/cases/compiler/moduleCodegenTest4.ts_0_93
//@module: commonjs export module Baz { export var x = "hello"; } Baz.x = "goodbye"; void 0;
{ "end_byte": 93, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleCodegenTest4.ts" }
TypeScript/tests/cases/compiler/resolveTypeAliasWithSameLetDeclarationName1.ts_3_43
ass C { } type baz = C; let baz: baz;
{ "end_byte": 43, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/resolveTypeAliasWithSameLetDeclarationName1.ts" }
TypeScript/tests/cases/compiler/commentsVarDecl.ts_0_1154
// @target: ES5 // @declaration: true // @removeComments: false /** Variable comments*/ var myVariable = 10; // This trailing Comment1 /** This is another variable comment*/ var anotherVariable = 30; // shouldn't appear var aVar = ""; /** this is multiline comment * All these variables are of number type */ var a...
{ "end_byte": 1154, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentsVarDecl.ts" }
TypeScript/tests/cases/compiler/externalModuleReferenceOfImportDeclarationWithExportModifier.ts_0_313
//@module: amd // @Filename: externalModuleReferenceOfImportDeclarationWithExportModifier_0.ts export function foo() { }; // @Filename: externalModuleReferenceOfImportDeclarationWithExportModifier_1.ts export import file1 = require('externalModuleReferenceOfImportDeclarationWithExportModifier_0'); file1.foo();
{ "end_byte": 313, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/externalModuleReferenceOfImportDeclarationWithExportModifier.ts" }
TypeScript/tests/cases/compiler/enumFromExternalModule.ts_0_255
// @module: commonjs // @Filename: enumFromExternalModule_0.ts export enum Mode { Open } // @Filename: enumFromExternalModule_1.ts ///<reference path='enumFromExternalModule_0.ts'/> import f = require('./enumFromExternalModule_0'); var x = f.Mode.Open;
{ "end_byte": 255, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumFromExternalModule.ts" }
TypeScript/tests/cases/compiler/enumWithInfinityProperty.ts_0_28
enum A { Infinity = 1 }
{ "end_byte": 28, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumWithInfinityProperty.ts" }
TypeScript/tests/cases/compiler/pathMappingBasedModuleResolution1_node.ts_0_279
// @module: commonjs // @traceResolution: true // @filename: c:/root/tsconfig.json { "compilerOptions": { "paths": { "*": [ "*", "generated/*" ] } } } // @filename: c:/root/f1.ts export var x = 1;
{ "end_byte": 279, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/pathMappingBasedModuleResolution1_node.ts" }
TypeScript/tests/cases/compiler/moduleAugmentationEnumClassMergeOfReexportIsError.ts_0_328
// @filename: file.ts export class Foo { member: string; } // @filename: reexport.ts export * from "./file"; // @filename: augment.ts import * as ns from "./reexport"; declare module "./reexport" { export enum Foo { A, B, C } } declare const f: ns.Foo; //is this the enum or the class? should be an...
{ "end_byte": 328, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleAugmentationEnumClassMergeOfReexportIsError.ts" }
TypeScript/tests/cases/compiler/extendingClassFromAliasAndUsageInIndexer.ts_0_1265
// @module: commonjs // @Filename: extendingClassFromAliasAndUsageInIndexer_backbone.ts export class Model { public someData: string; } // @Filename: extendingClassFromAliasAndUsageInIndexer_moduleA.ts import Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); export class VisualizationModel...
{ "end_byte": 1265, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/extendingClassFromAliasAndUsageInIndexer.ts" }
TypeScript/tests/cases/compiler/typeComparisonCaching.ts_0_304
// Check that we only cache results of type comparisons that are free of assumptions interface A { p: C; s: string; } interface B { p: D; s: number; } interface C { q: A; } interface D { q: B; } var a: A; var b: B; var c: C; var d: D; a = b; c = d; // Should not be allowed
{ "end_byte": 304, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeComparisonCaching.ts" }
TypeScript/tests/cases/compiler/noBundledEmitFromNodeModules.ts_0_207
// @outFile: out.js // @module: system // @moduleResolution: node // @noImplicitReferences: true // @fileName: /node_modules/projB/index.ts export class C {} // @fileName: /a.ts import { C } from "projB";
{ "end_byte": 207, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noBundledEmitFromNodeModules.ts" }
TypeScript/tests/cases/compiler/jsxElementType.tsx_0_3010
// @strict: true // @jsx: react /// <reference path="/.lib/react16.d.ts" /> import * as React from "react"; type React18ReactFragment = ReadonlyArray<React18ReactNode>; type React18ReactNode = | React.ReactElement<any> | string | number | React18ReactFragment | React.ReactPortal | boolean | null | unde...
{ "end_byte": 3010, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsxElementType.tsx" }
TypeScript/tests/cases/compiler/interface0.ts_0_71
interface Generic<T> { x: T; } var y: Generic<number> = { x: 3 };
{ "end_byte": 71, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/interface0.ts" }
TypeScript/tests/cases/compiler/unusedPrivateVariableInClass2.ts_0_114
//@noUnusedLocals:true //@noUnusedParameters:true class greeter { private x: string; private y: string; }
{ "end_byte": 114, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedPrivateVariableInClass2.ts" }
TypeScript/tests/cases/compiler/declarationEmitExpressionInExtends2.ts_0_162
// @declaration: true class C<T, U> { x: T; y: U; } function getClass<T>(c: T) { return C; } class MyClass extends getClass(2) <string, number> { }
{ "end_byte": 162, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitExpressionInExtends2.ts" }
TypeScript/tests/cases/compiler/contextualTypeBasedOnIntersectionWithAnyInTheMix3.ts_0_684
// @strict: true // @noEmit: true type TypeMap = { str: "a" | "b" | "c"; num: 1 | 2 | 3; }; declare function test1< T extends { [K in keyof TypeMap]: TypeMap[K][] } & { [k: string]: any[] }, >(arg: T): T; const result = test1({ num: [1, 2], str: ["a", "b"], bool: [true, false], }); declare function test...
{ "end_byte": 684, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTypeBasedOnIntersectionWithAnyInTheMix3.ts" }
TypeScript/tests/cases/compiler/contextualTyping34.ts_0_36
var foo = <{ id: number;}> ({id:4});
{ "end_byte": 36, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTyping34.ts" }
TypeScript/tests/cases/compiler/destructuringInVariableDeclarations3.ts_0_90
// @target: es6 // @module: amd export let { toString } = 1; { let { toFixed } = 1; }
{ "end_byte": 90, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/destructuringInVariableDeclarations3.ts" }
TypeScript/tests/cases/compiler/cachedModuleResolution9.ts_0_165
// @moduleResolution: classic // @traceResolution: true // @filename: /a/b/c/lib.ts import {x} from "foo"; // @filename: /a/b/c/d/e/app.ts import {x} from "foo";
{ "end_byte": 165, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/cachedModuleResolution9.ts" }
TypeScript/tests/cases/compiler/topLevelExports.ts_0_98
//@module: amd export var foo = 3; function log(n:number) { return n;} void log(foo).toString();
{ "end_byte": 98, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/topLevelExports.ts" }
TypeScript/tests/cases/compiler/jsxFragmentFactoryNoUnusedLocals.tsx_0_467
// @jsx: react // @jsxFactory: createElement // @jsxFragmentFactory: Fragment // @noUnusedLocals: true /// <reference path="/.lib/react16.d.ts" /> import { Fragment, createElement } from "react" type CounterProps = { count?: number } export function Counter({ count = 0 }: CounterProps) { const [cnt, setCnt] =...
{ "end_byte": 467, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsxFragmentFactoryNoUnusedLocals.tsx" }
TypeScript/tests/cases/compiler/thisKeyword.ts_0_32
module foo { this.bar = 4; }
{ "end_byte": 32, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/thisKeyword.ts" }
TypeScript/tests/cases/compiler/regularExpressionAnnexB.ts_0_638
// @target: esnext const regexes: RegExp[] = [ /\q\u\i\c\k\_\f\o\x\-\j\u\m\p\s/, /[\q\u\i\c\k\_\f\o\x\-\j\u\m\p\s]/, /\P[\P\w-_]/, // Compare to /\q\u\i\c\k\_\f\o\x\-\j\u\m\p\s/u, /[\q\u\i\c\k\_\f\o\x\-\j\u\m\p\s]/u, /\P[\P\w-_]/u, ]; const regexesWithBraces: RegExp[] = [ /{??/, /{,??/, /{,1??/, ...
{ "end_byte": 638, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/regularExpressionAnnexB.ts" }
TypeScript/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision6.ts_0_493
// @noemithelpers: true // @experimentaldecorators: true // @emitdecoratormetadata: true // @target: es5 // @module: commonjs // @filename: db.ts export default class db { public doSomething() { } } // @filename: service.ts import database from './db'; function someDecorator(target) { return target; } @som...
{ "end_byte": 493, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision6.ts" }
TypeScript/tests/cases/compiler/jsxFactoryButNoJsxFragmentFactory.tsx_0_117
//@jsx: react //@jsxfactory: h declare var h: any; <></>; <><span>1</span><><span>2.1</span><span>2.2</span></></>;
{ "end_byte": 117, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsxFactoryButNoJsxFragmentFactory.tsx" }
TypeScript/tests/cases/compiler/classMemberInitializerWithLamdaScoping4.ts_0_384
// @Filename: classMemberInitializerWithLamdaScoping3_0.ts export var field1: string; // @Filename: classMemberInitializerWithLamdaScoping3_1.ts declare var console: { log(msg?: any): void; }; export class Test1 { constructor(private field1: string) { } messageHandler = () => { console.log(fiel...
{ "end_byte": 384, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classMemberInitializerWithLamdaScoping4.ts" }
TypeScript/tests/cases/compiler/classMethodWithKeywordName1.ts_0_28
class C { static try() {} }
{ "end_byte": 28, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classMethodWithKeywordName1.ts" }
TypeScript/tests/cases/compiler/isolatedDeclarationErrorsReturnTypes.ts_0_6458
// @declaration: true // @isolatedDeclarations: true // @declarationMap: false // @target: ESNext // Function Variables export const fnExpressionConstVariable = function foo() { return 0;} export const fnArrowConstVariable = () => "S"; export let fnExpressionLetVariable = function foo() { return 0;} export let fnArro...
{ "end_byte": 6458, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/isolatedDeclarationErrorsReturnTypes.ts" }
TypeScript/tests/cases/compiler/isolatedDeclarationErrorsReturnTypes.ts_6459_9814
export class FnParamsExportedClass { // Should Error fnExpression = function foo(cb = function(){ }) { return 0; } fnArrow = (cb = function(){ }) => "S"; protected fnExpressionProtected = function foo(cb = function(){ }) { return 0; } protected fnArrowProtected = (cb = function(){ }) => "S"; s...
{ "end_byte": 9814, "start_byte": 6459, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/isolatedDeclarationErrorsReturnTypes.ts" }
TypeScript/tests/cases/compiler/declarationEmitUnknownImport2.ts_0_119
// @target: es5 // @module: commonjs // @declaration: true import Foo From './Foo'; // Syntax error export default Foo
{ "end_byte": 119, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitUnknownImport2.ts" }
TypeScript/tests/cases/compiler/es5-commonjs8.ts_0_149
// @target: ES5 // @sourcemap: false // @declaration: false // @module: commonjs // @noEmit: true export default "test"; export var __esModule = 1;
{ "end_byte": 149, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es5-commonjs8.ts" }
TypeScript/tests/cases/compiler/interfaceImplementation8.ts_3_468
1 */ interface i1 { name: string; } class C1 implements i1 { public name:string; } class C2 implements i1 { private name:string; } class C3 { private name:any; } class C4 extends C1 implements i1{ } class C5 extends C2 implements i1{ } class C6 extends C3 implements i1{ } /* 2 */ interfac...
{ "end_byte": 468, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/interfaceImplementation8.ts" }
TypeScript/tests/cases/compiler/asiPublicPrivateProtected.ts_0_487
public class NonPublicClass { public s() { } } class NonPublicClass2 { public private nonPublicFunction() { } } private class NonPrivateClass { private s() { } } class NonPrivateClass2 { private public nonPrivateFunction() { } } protected class NonProtectedClass { protected s...
{ "end_byte": 487, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/asiPublicPrivateProtected.ts" }
TypeScript/tests/cases/compiler/defaultNamedExportWithType3.ts_0_80
// @target: esnext interface Foo {} export const Foo = {}; export default Foo;
{ "end_byte": 80, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/defaultNamedExportWithType3.ts" }