_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/errorOnUnionVsObjectShouldDeeplyDisambiguate2.ts_0_620
interface Stuff { a?: () => Promise<number[]>; b: () => Promise<string>; c: () => Promise<string>; d: () => Promise<string>; e: () => Promise<string>; f: () => Promise<string>; g: () => Promise<string>; h: () => Promise<string>; i: () => Promise<string>; j: () => Promise<string>; k: () => Promise<...
{ "end_byte": 620, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/errorOnUnionVsObjectShouldDeeplyDisambiguate2.ts" }
TypeScript/tests/cases/compiler/declFileModuleWithPropertyOfTypeModule.ts_0_85
// @declaration: true module m { export class c { } export var a = m; }
{ "end_byte": 85, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileModuleWithPropertyOfTypeModule.ts" }
TypeScript/tests/cases/compiler/excessPropertyCheckWithSpread.ts_0_244
declare function f({ a: number }): void interface I { readonly n: number; } declare let i: I; f({ a: 1, ...i }); interface R { opt?: number } interface L { opt: string } declare let l: L; declare let r: R; f({ a: 1, ...l, ...r });
{ "end_byte": 244, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/excessPropertyCheckWithSpread.ts" }
TypeScript/tests/cases/compiler/underscoreMapFirst.ts_0_1021
declare module _ { interface Collection<T> { } interface List<T> extends Collection<T> { [index: number]: T; length: number; } interface ListIterator<T, TResult> { (value: T, index: number, list: T[]): TResult; } interface Dictionary<T> extends Collection<T> { [...
{ "end_byte": 1021, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/underscoreMapFirst.ts" }
TypeScript/tests/cases/compiler/inheritedModuleMembersForClodule.ts_0_240
class C { static foo(): string { return "123"; } } class D extends C { } module D { export function foo(): number { return 0; }; } class E extends D { static bar() { return this.foo(); } }
{ "end_byte": 240, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inheritedModuleMembersForClodule.ts" }
TypeScript/tests/cases/compiler/staticInstanceResolution3.ts_0_346
// @module: commonjs // @Filename: staticInstanceResolution3_0.ts export class Promise { static timeout(delay: number): Promise { return null; } } // @Filename: staticInstanceResolution3_1.ts ///<reference path='staticInstanceResolution3_0.ts'/> import WinJS = require('./staticInstanceResolution3_0'); ...
{ "end_byte": 346, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/staticInstanceResolution3.ts" }
TypeScript/tests/cases/compiler/collisionSuperAndLocalVarInMethod.ts_0_320
var _super = 10; // No Error class Foo { x() { var _super = 10; // No error } } class b extends Foo { public foo() { var _super = 10; // Should be error } } class c extends Foo { public foo() { var x = () => { var _super = 10; // Should be error } } }
{ "end_byte": 320, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionSuperAndLocalVarInMethod.ts" }
TypeScript/tests/cases/compiler/reassignStaticProp.ts_0_93
class foo { static bar = 1; static bar:string; // errror - duplicate id }
{ "end_byte": 93, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reassignStaticProp.ts" }
TypeScript/tests/cases/compiler/assignmentIndexedToPrimitives.ts_0_333
const n1: number = [0]; const n2: number = ["0"]; const n3: number = [0, "1"]; const n4: 0 = [0]; const s1: string = [0]; const s2: string = ["0"]; const s3: string = [0, "1"]; const s4: "01" = ["0", "1"]; const no1: number = { 0: 1 }; const so1: string = { 0: 1 }; const so2: string = { "0": 1 }; const so3: string =...
{ "end_byte": 333, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentIndexedToPrimitives.ts" }
TypeScript/tests/cases/compiler/unusedImports15.ts_0_395
//@noUnusedLocals:true //@module: commonjs //@reactNamespace: Element //@jsx: preserve // @filename: foo.tsx import Element = require("react"); export const FooComponent = <div></div> // @filename: node_modules/@types/react/index.d.ts export = React; export as namespace React; declare namespace React { function...
{ "end_byte": 395, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedImports15.ts" }
TypeScript/tests/cases/compiler/typePredicateFreshLiteralWidening.ts_0_847
// @strictNullChecks: true type Narrowable = string | number | bigint | boolean; type Narrow<A> = (A extends Narrowable ? A : never) | ({ [K in keyof A]: Narrow<A[K]>; }); const satisfies = <TWide,>() => <TNarrow extends TWide>(narrow: Narrow<TNarrow>) => narrow; /* =====================================...
{ "end_byte": 847, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typePredicateFreshLiteralWidening.ts" }
TypeScript/tests/cases/compiler/noImplicitAnyLoopCrash.ts_0_91
// @noImplicitAny: true let foo = () => {}; let bar; while (1) { bar = ~foo(...bar); }
{ "end_byte": 91, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noImplicitAnyLoopCrash.ts" }
TypeScript/tests/cases/compiler/unusedTypeParameters10.ts_0_99
//@noUnusedLocals:true //@noUnusedParameters:true type Alias<T> = { }; type Alias2<T> = { x: T };
{ "end_byte": 99, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedTypeParameters10.ts" }
TypeScript/tests/cases/compiler/recursiveGenericUnionType2.ts_0_437
declare module Test1 { export type Container<T> = T | { [i: string]: Container<T>[]; }; export type IStringContainer = Container<string>; } declare module Test2 { export type Container<T> = T | { [i: string]: Container<T>[]; }; export type IStringContainer = Container<string>; }...
{ "end_byte": 437, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveGenericUnionType2.ts" }
TypeScript/tests/cases/compiler/thisInStaticMethod1.ts_0_85
class foo { static x = 3; static bar() { return this.x; } } var x = foo.bar();
{ "end_byte": 85, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/thisInStaticMethod1.ts" }
TypeScript/tests/cases/compiler/nonstrictTemplateWithNotOctalPrintsAsIs.ts_0_77
// https://github.com/Microsoft/TypeScript/issues/21828 const d2 = `\\0041`;
{ "end_byte": 77, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nonstrictTemplateWithNotOctalPrintsAsIs.ts" }
TypeScript/tests/cases/compiler/jsdocTypeNongenericInstantiationAttempt.ts_0_1198
// @allowJs: true // @noEmit: true // @checkJs: true // @filename: index.js /** * @param {<T>(m: Boolean<T>) => string} somebody */ function sayHello(somebody) { return 'Hello ' + somebody; } // @filename: index2.js /** * @param {<T>(m: Void<T>) => string} somebody */ function sayHello2(somebody) { return ...
{ "end_byte": 1198, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsdocTypeNongenericInstantiationAttempt.ts" }
TypeScript/tests/cases/compiler/jsonFileImportChecksCallCorrectlyTwice.ts_0_364
// @esModuleInterop: true // @resolveJsonModule: true // @strict: true // @outDir: dist // @filename: index.ts import data from "./data.json"; interface Foo { str: string; } fn(data.foo); fn(data.foo); // <-- shouldn't error! function fn(arg: Foo[]) { } // @filename: data.json { "foo": [ { "bool"...
{ "end_byte": 364, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsonFileImportChecksCallCorrectlyTwice.ts" }
TypeScript/tests/cases/compiler/promisePermutations2.ts_0_6475
// same as promisePermutations but without the same overloads in Promise<T> interface Promise<T> { then<U>(success?: (value: T) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; done<U>(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void)...
{ "end_byte": 6475, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/promisePermutations2.ts" }
TypeScript/tests/cases/compiler/promisePermutations2.ts_6476_10021
var s7: Promise<string>; var s7a = r7.then(testFunction7, testFunction7, testFunction7); // error var s7b = r7.then(testFunction7P, testFunction7P, testFunction7P); // error var s7c = r7.then(testFunction7P, testFunction7, testFunction7); // error var s7d = r7.then(sPromise, sPromise, sPromise).then(sPromise, sPromise,...
{ "end_byte": 10021, "start_byte": 6476, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/promisePermutations2.ts" }
TypeScript/tests/cases/compiler/classExtendingAny.ts_0_585
// @noEmit: true // @allowJs: true // @checkJs: true // @noImplicitAny: true // @target: es6 // @Filename: a.ts declare var Err: any class A extends Err { payload: string constructor() { super(1,2,3,3,4,56) super.unknown super['unknown'] } process() { return this.payload ...
{ "end_byte": 585, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classExtendingAny.ts" }
TypeScript/tests/cases/compiler/objectLiteralReferencingInternalProperties.ts_0_76
var a = { b: 10, c: b }; // Should give error for attempting to reference b.
{ "end_byte": 76, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectLiteralReferencingInternalProperties.ts" }
TypeScript/tests/cases/compiler/numericUnderscoredSeparator.ts_0_132
// @target: es5,es2015,es2016,es2017,es2018,es2019,esnext 1_000_000_000_000 0b1010_0001_1000_0101 0b1010_0001_1000_0101 0xA0_B0_C0
{ "end_byte": 132, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/numericUnderscoredSeparator.ts" }
TypeScript/tests/cases/compiler/commentsAfterCaseClauses3.ts_3_353
nction getSecurity(level) { switch(level){ case 0: /*Zero*/ case 1: /*One*/ case 2: /*two*/ // Leading comments return "Hi"; case 3: /*three*/ case 4: /*four*/ return "hello"; case 5: /*five*/ default: /*six*/ ...
{ "end_byte": 353, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentsAfterCaseClauses3.ts" }
TypeScript/tests/cases/compiler/noImplicitUseStrict_umd.ts_0_64
// @module: umd // @noImplicitUseStrict: true export var x = 0;
{ "end_byte": 64, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noImplicitUseStrict_umd.ts" }
TypeScript/tests/cases/compiler/esDecoratorsClassFieldsCrash.ts_0_759
// @target: esnext // @useDefineForClassFields: false // @noTypesAndSymbols: true // https://github.com/microsoft/TypeScript/issues/58436 const dec = (x: number, y: number, z: number, t: number) => (_: any, ctx: DecoratorContext): any => { }; const Foo = class { @dec(1, 3, 3, 1) field: undefined @dec(2, 2, 0, ...
{ "end_byte": 759, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/esDecoratorsClassFieldsCrash.ts" }
TypeScript/tests/cases/compiler/breakInIterationOrSwitchStatement1.ts_0_25
while (true) { break; }
{ "end_byte": 25, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/breakInIterationOrSwitchStatement1.ts" }
TypeScript/tests/cases/compiler/declarationEmitTypeofDefaultExport.ts_0_142
// @declaration: true // @filename: /a.ts export default class C {}; // @filename: /b.ts import * as a from "./a"; export default a.default;
{ "end_byte": 142, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitTypeofDefaultExport.ts" }
TypeScript/tests/cases/compiler/optionalFunctionArgAssignability.ts_0_409
interface Promise<T> { then<U>(onFulfill?: (value: T) => U, onReject?: (reason: any) => U): Promise<U>; } var a = function then<U>(onFulfill?: (value: string) => U, onReject?: (reason: any) => U): Promise<U> { return null }; var b = function then<U>(onFulFill?: (value: number) => U, onReject?: (reason: any) => U)...
{ "end_byte": 409, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/optionalFunctionArgAssignability.ts" }
TypeScript/tests/cases/compiler/declarationEmitInferredUndefinedPropFromFunctionInArray.ts_0_139
// @declaration: true // repro from https://github.com/microsoft/TypeScript/issues/53914 export let b = [{ foo: 0, m() {} }, { bar: 1 }];
{ "end_byte": 139, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitInferredUndefinedPropFromFunctionInArray.ts" }
TypeScript/tests/cases/compiler/nodeResolution6.ts_0_229
// @module: commonjs // @moduleResolution: node // @filename: node_modules/ref.ts var x = 1; // @filename: node_modules/a.d.ts /// <reference path="ref.ts"/> export declare var y; // @filename: b.ts import y = require("a");
{ "end_byte": 229, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nodeResolution6.ts" }
TypeScript/tests/cases/compiler/declarationEmitTupleRestSignatureLeadingVariadic.ts_0_117
// @declaration: true const f = <TFirstArgs extends any[], TLastArg>(...args: [...TFirstArgs, TLastArg]): void => {};
{ "end_byte": 117, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitTupleRestSignatureLeadingVariadic.ts" }
TypeScript/tests/cases/compiler/implementArrayInterface.ts_0_1668
declare class MyArray<T> implements Array<T> { toString(): string; toLocaleString(): string; concat<U extends T[]>(...items: U[]): T[]; concat(...items: T[]): T[]; join(separator?: string): string; pop(): T; push(...items: T[]): number; reverse(): T[]; shift(): T; slice(start?: n...
{ "end_byte": 1668, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/implementArrayInterface.ts" }
TypeScript/tests/cases/compiler/moduleElementsInWrongContext2.ts_0_560
function blah () { module M { } export namespace N { export interface I { } } namespace Q.K { } declare module "ambient" { } export = M; var v; function foo() { } export * from "ambient"; export { foo }; export { baz as b } from "ambient"; export default ...
{ "end_byte": 560, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleElementsInWrongContext2.ts" }
TypeScript/tests/cases/compiler/genericWithIndexerOfTypeParameterType2.ts_0_285
//@module: amd export class Collection<TItem extends CollectionItem> { _itemsByKey: { [key: string]: TItem; }; } export class List extends Collection<ListItem>{ Bar() {} } export class CollectionItem {} export class ListItem extends CollectionItem { __isNew: boolean; }
{ "end_byte": 285, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericWithIndexerOfTypeParameterType2.ts" }
TypeScript/tests/cases/compiler/indexedAccessCanBeHighOrder.ts_0_293
declare function get<U, Y extends keyof U>(x: U, y: Y): U[Y]; declare function find<T, K extends keyof T>(o: T[K]): [T, K]; function impl<A, B extends keyof A>(a: A, b: B) { const item = get(a, b); return find(item); } const o = {x: 42}; const r = impl(o, "x"); r[0][r[1]] = o[r[1]];
{ "end_byte": 293, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/indexedAccessCanBeHighOrder.ts" }
TypeScript/tests/cases/compiler/unusedTypeParameters4.ts_0_89
//@noUnusedLocals:true //@noUnusedParameters:true var x: { new <T, U>(a: T): void; }
{ "end_byte": 89, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedTypeParameters4.ts" }
TypeScript/tests/cases/compiler/requireAsFunctionInExternalModule.ts_0_330
// @allowjs: true // @outDir: dist // @Filename: c.js export default function require(a) { } export function has(a) { return true } // @Filename: m.js import require, { has } from "./c" export function hello() { } if (has('ember-debug')) { require('ember-debug'); } // @Filename: m2.ts import { hello } from "./m";...
{ "end_byte": 330, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/requireAsFunctionInExternalModule.ts" }
TypeScript/tests/cases/compiler/discriminatedUnionJsxElement.tsx_0_666
// @strict: true // @declaration: true // @jsx: preserve // Repro from #46021 interface IData<MenuItemVariant extends ListItemVariant = ListItemVariant.OneLine> { menuItemsVariant?: MenuItemVariant; } function Menu<MenuItemVariant extends ListItemVariant = ListItemVariant.OneLine>(data: IData<MenuItemVariant>) {...
{ "end_byte": 666, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/discriminatedUnionJsxElement.tsx" }
TypeScript/tests/cases/compiler/intersectionsOfLargeUnions.ts_0_796
// @strict: true // Repro from #23977 export function assertIsElement(node: Node | null): node is Element { let nodeType = node === null ? null : node.nodeType; return nodeType === 1; } export function assertNodeTagName< T extends keyof ElementTagNameMap, U extends ElementTagNameMap[T]>(node: Node ...
{ "end_byte": 796, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/intersectionsOfLargeUnions.ts" }
TypeScript/tests/cases/compiler/metadataReferencedWithinFilteredUnion.ts_0_352
// @experimentalDecorators: true // @emitDecoratorMetadata: true // @target: es5 // @filename: Class1.ts export class Class1 { } // @filename: Class2.ts import { Class1 } from './Class1'; function decorate(target: any, propertyKey: string) { } export class Class2 { @decorate get prop(): Class1 | undefined { ...
{ "end_byte": 352, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/metadataReferencedWithinFilteredUnion.ts" }
TypeScript/tests/cases/compiler/inferringAnyFunctionType5.ts_0_105
function f<T extends { q: (p1: number) => number }>(p: T): T { return p; } var v = f({ q: x => x });
{ "end_byte": 105, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inferringAnyFunctionType5.ts" }
TypeScript/tests/cases/compiler/callOverloads2.ts_2_424
class Foo { // error bar1() { /*WScript.Echo("bar1");*/ } constructor(x: any) { // WScript.Echo("Constructor function has executed"); } } function Foo(); // error function F1(s:string) {return s;} // error function F1(a:any) { return a;} // error function Goo(s:string); // error - no implementat...
{ "end_byte": 424, "start_byte": 2, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/callOverloads2.ts" }
TypeScript/tests/cases/compiler/importDeclWithExportModifierAndExportAssignmentInAmbientContext.ts_0_118
declare module "m" { module x { interface c { } } export import a = x.c; export = x; }
{ "end_byte": 118, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importDeclWithExportModifierAndExportAssignmentInAmbientContext.ts" }
TypeScript/tests/cases/compiler/typeArgumentsInFunctionExpressions.ts_0_173
var obj = function f<T>(a: T) { // should not error var x: T; return a; }; var obj2 = function f<T>(a: T): T { // should not error var x: T; return a; };
{ "end_byte": 173, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeArgumentsInFunctionExpressions.ts" }
TypeScript/tests/cases/compiler/aliasUsageInVarAssignment.ts_0_655
// @module: commonjs // @Filename: aliasUsageInVarAssignment_backbone.ts export class Model { public someData: string; } // @Filename: aliasUsageInVarAssignment_moduleA.ts import Backbone = require("./aliasUsageInVarAssignment_backbone"); export class VisualizationModel extends Backbone.Model { // interesting ...
{ "end_byte": 655, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/aliasUsageInVarAssignment.ts" }
TypeScript/tests/cases/compiler/instantiatedBaseTypeConstraints2.ts_0_94
interface A<T extends A<T, S>, S extends A<T, S>> { } interface B<U> extends A<B<U>, B<U>> { }
{ "end_byte": 94, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/instantiatedBaseTypeConstraints2.ts" }
TypeScript/tests/cases/compiler/duplicateErrorNameNotFound.ts_0_76
// @strict: true type RoomInterfae = {}; export type { RoomInterface }
{ "end_byte": 76, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateErrorNameNotFound.ts" }
TypeScript/tests/cases/compiler/innerAliases.ts_0_304
module A { export module B { export module C { export class Class1 {} } } } module D { import inner = A.B.C; var c1 = new inner.Class1(); export module E { export class Class2 {} } } var c: D.inner.Class1; c = new D.inner.Class1();
{ "end_byte": 304, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/innerAliases.ts" }
TypeScript/tests/cases/compiler/constEnumNamespaceReferenceCausesNoImport2.ts_0_447
// @preserveConstEnums: true // @noTypesAndSymbols: true // @filename: foo.ts export module ConstEnumOnlyModule { export const enum ConstFooEnum { Some, Values, Here } } // @filename: reexport.ts import * as Foo from "./foo"; export = Foo.ConstEnumOnlyModule; // @filename: index.ts import Foo = requi...
{ "end_byte": 447, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constEnumNamespaceReferenceCausesNoImport2.ts" }
TypeScript/tests/cases/compiler/unusedParameterInCatchClause.ts_0_91
//@noUnusedLocals:true //@noUnusedParameters:true function f1() { try {} catch(ex){} }
{ "end_byte": 91, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedParameterInCatchClause.ts" }
TypeScript/tests/cases/compiler/returnValueInSetter.ts_0_81
class f { set x(value) { return null; // Should be an error } }
{ "end_byte": 81, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/returnValueInSetter.ts" }
TypeScript/tests/cases/compiler/importHelpersInIsolatedModules.ts_0_1012
// @importHelpers: true // @isolatedModules: true // @target: es5 // @module: commonjs // @moduleResolution: classic // @experimentalDecorators: true // @emitDecoratorMetadata: true // @filename: external.ts export class A { } export class B extends A { } declare var dec: any; @dec class C { method(@dec x: number...
{ "end_byte": 1012, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importHelpersInIsolatedModules.ts" }
TypeScript/tests/cases/compiler/typePartameterConstraintInstantiatedWithDefaultWhenCheckingDefault.ts_0_588
// tricky interface interface Settable<T, V> { set(value: V): T; } // implement class Identity<V> implements Settable<Identity<V>, V> { readonly item: V; constructor(value: V) { this.item = value; } public set(value: V): Identity<V> { return new Identity<V>(value); } } // gener...
{ "end_byte": 588, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typePartameterConstraintInstantiatedWithDefaultWhenCheckingDefault.ts" }
TypeScript/tests/cases/compiler/checkIndexConstraintOfJavascriptClassExpression.ts_0_430
// @Filename: weird.js // @allowJs: true // @checkJs: true // @strict: true // @noEmit: true // @outFile: foo.js someFunction(function(BaseClass) { 'use strict'; const DEFAULT_MESSAGE = "nop!"; class Hello extends BaseClass { constructor() { super(); this.foo = "bar"; ...
{ "end_byte": 430, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/checkIndexConstraintOfJavascriptClassExpression.ts" }
TypeScript/tests/cases/compiler/unusedParameterUsedInTypeOf.ts_0_120
//@target: ES5 //@noUnusedLocals:true //@noUnusedParameters:true function f1 (a: number, b: typeof a) { return b; }
{ "end_byte": 120, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedParameterUsedInTypeOf.ts" }
TypeScript/tests/cases/compiler/narrowUnknownByTypeofObject.ts_0_105
// @strictNullChecks: true function foo(x: unknown) { if (typeof x === "object") { x } }
{ "end_byte": 105, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowUnknownByTypeofObject.ts" }
TypeScript/tests/cases/compiler/recursiveIdenticalOverloadResolution.ts_1_136
module M { interface I { (i: I): I; } function f(p: I) { return f }; var i: I; f(i); f(f(i)); f((f(f(i)))); }
{ "end_byte": 136, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveIdenticalOverloadResolution.ts" }
TypeScript/tests/cases/compiler/extBaseClass1.ts_0_202
module M { export class B { public x=10; } export class C extends B { } } module M { export class C2 extends B { } } module N { export class C3 extends M.B { } }
{ "end_byte": 202, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/extBaseClass1.ts" }
TypeScript/tests/cases/compiler/overloadsWithConstraints.ts_3_119
clare function f<T extends Number>(x: T): T; declare function f<T extends String>(x: T): T var v = f<string>("");
{ "end_byte": 119, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overloadsWithConstraints.ts" }
TypeScript/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.ts_0_215
// @module: commonjs // @declaration: true // @filename: server.ts export class a { } // @filename: client.ts import defaultBinding, * as nameSpaceBinding from "./server"; export var x = new nameSpaceBinding.a();
{ "end_byte": 215, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.ts" }
TypeScript/tests/cases/compiler/assignmentCompatWithOverloads.ts_0_474
function f1(x: string): number { return null; } function f2(x: string): string { return null; } function f3(x: number): number { return null; } function f4(x: string): string; function f4(x: number): number; function f4(x: any): any { return undefined; } var g: (s1: string) => number; g = f1; // OK g = f2; // ...
{ "end_byte": 474, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatWithOverloads.ts" }
TypeScript/tests/cases/compiler/invalidStaticField.ts_0_75
class A { foo() { return B.NULL; } } class B { static NOT_NULL = new B(); }
{ "end_byte": 75, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/invalidStaticField.ts" }
TypeScript/tests/cases/compiler/moduleResolutionWithSuffixes_one_externalModule_withPaths.ts_0_1106
// moduleSuffixes has one entry and there's a matching package. use the 'paths' option to map the package. // @fullEmitPaths: true // @filename: /tsconfig.json { "compilerOptions": { "allowJs": true, "checkJs": false, "outDir": "bin", "moduleResolution": "node", "traceResolution": true, "moduleSuffixes": [...
{ "end_byte": 1106, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolutionWithSuffixes_one_externalModule_withPaths.ts" }
TypeScript/tests/cases/compiler/moduleAugmentationImportsAndExports3.ts_0_580
// @module: commonjs // @declaration: true // @filename: f1.ts export class A {} // @filename: f2.ts export class B { n: number; } // @filename: f3.ts import {A} from "./f1"; A.prototype.foo = function () { return undefined; } namespace N { export interface Ifc { a } export interface Cls { a } } decla...
{ "end_byte": 580, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleAugmentationImportsAndExports3.ts" }
TypeScript/tests/cases/compiler/emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES6.ts_3_156
@target: es6 (x) => ({ "1": "one", "2": "two" } as { [key: string]: string })[x]; (x) => ({ "1": "one", "2": "two" } as { [key: string]: string }).x;
{ "end_byte": 156, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES6.ts" }
TypeScript/tests/cases/compiler/unusedLocalsAndParametersDeferred.ts_0_2160
//@noUnusedLocals:true //@noUnusedParameters:true export { }; function defered<T>(a: () => T): T { return a(); } // function declaration paramter function f(a) { defered(() => { a; }); } f(0); // function expression paramter var fexp = function (a) { defered(() => { a; }); }; fex...
{ "end_byte": 2160, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedLocalsAndParametersDeferred.ts" }
TypeScript/tests/cases/compiler/discriminantsAndTypePredicates.ts_0_560
// Repro from #10145 interface A { type: 'A' } interface B { type: 'B' } function isA(x: A | B): x is A { return x.type === 'A'; } function isB(x: A | B): x is B { return x.type === 'B'; } function foo1(x: A | B): any { x; // A | B if (isA(x)) { return x; // A } x; // B if (isB(x)) { ...
{ "end_byte": 560, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/discriminantsAndTypePredicates.ts" }
TypeScript/tests/cases/compiler/commentOnExportEnumDeclaration.ts_3_55
* * comment */ export enum Color { r, g, b }
{ "end_byte": 55, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentOnExportEnumDeclaration.ts" }
TypeScript/tests/cases/compiler/reservedWords2.ts_3_341
port while = require("dfdf"); import * as while from "foo" var typeof = 10; function throw() {} module void {} var {while, return} = { while: 1, return: 2 }; var {this, switch: { continue} } = { this: 1, switch: { continue: 2 }}; var [debugger, if] = [1, 2]; enum void {} function f(default: number) {} class C { m(nul...
{ "end_byte": 341, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reservedWords2.ts" }
TypeScript/tests/cases/compiler/declarationEmitInferredDefaultExportType.ts_0_114
// @declaration: true // @module: commonjs // test.ts export default { foo: [], bar: undefined, baz: null }
{ "end_byte": 114, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitInferredDefaultExportType.ts" }
TypeScript/tests/cases/compiler/emitHelpersWithLocalCollisions.ts_0_244
// @target: es6 // @module: * // @moduleResolution: classic // @experimentalDecorators: true // @filename: a.ts // @noTypesAndSymbols: true declare var dec: any, __decorate: any; @dec export class A { } const o = { a: 1 }; const y = { ...o };
{ "end_byte": 244, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emitHelpersWithLocalCollisions.ts" }
TypeScript/tests/cases/compiler/nestedBlockScopedBindings2.ts_0_1530
function a0() { { let x = 1; () => x; } { let x = 1; } } function a1() { { let x; } { let x = 1; () => x; } } function a2() { { let x = 1; () => x; } { let x; () => x; } } function a3() { ...
{ "end_byte": 1530, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nestedBlockScopedBindings2.ts" }
TypeScript/tests/cases/compiler/functionWithDefaultParameterWithNoStatements1.ts_0_23
function foo(x = 0) { }
{ "end_byte": 23, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionWithDefaultParameterWithNoStatements1.ts" }
TypeScript/tests/cases/compiler/noCheckDoesNotReportError.ts_0_123
// @noCheck: true // @emitDeclarationOnly: true // @declaration: true // @strict: true export const a: number = "not ok";
{ "end_byte": 123, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noCheckDoesNotReportError.ts" }
TypeScript/tests/cases/compiler/typeParameterConstrainedToOuterTypeParameter.ts_0_208
interface A<T> { <U extends T>(x: U[]) } interface B<T> { <U extends T>(x: U) } var a: A<string> var b: B<string> = a; // assignment should be legal (both U's get instantiated to any for comparison)
{ "end_byte": 208, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeParameterConstrainedToOuterTypeParameter.ts" }
TypeScript/tests/cases/compiler/classFieldSuperNotAccessible.ts_0_136
// @target: esnext class T { field = () => {} } class T2 extends T { f() { super.field() // error } } new T2().f()
{ "end_byte": 136, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classFieldSuperNotAccessible.ts" }
TypeScript/tests/cases/compiler/excessivelyLargeTupleSpread.ts_0_1130
// #41771 type BuildTuple<L extends number, T extends any[] = [any]> = T['length'] extends L ? T : BuildTuple<L, [...T, ...T]>; type A = BuildTuple<3> type T0 = [any]; type T1 = [...T0, ...T0]; type T2 = [...T1, ...T1]; type T3 = [...T2, ...T2]; type T4 = [...T3, ...T3]; type T5 = [...T4, ...T4]; type T6 = [......
{ "end_byte": 1130, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/excessivelyLargeTupleSpread.ts" }
TypeScript/tests/cases/compiler/errorElaborationDivesIntoApparentlyPresentPropsOnly.ts_0_226
function foo<T extends { a: string }>(x: T) { x = { a: "abc", b: 20, c: 30 }; } function bar<T extends { a: string }>(x: T) { x = { a: 20 }; } function baz<T extends { a: string }>(x: T) { x = { a: "not ok" }; }
{ "end_byte": 226, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/errorElaborationDivesIntoApparentlyPresentPropsOnly.ts" }
TypeScript/tests/cases/compiler/capturedLetConstInLoop12.ts_0_230
(function() { "use strict"; for (let i = 0; i < 4; i++) { (() => [i] = [i + 1])(); } })(); (function() { "use strict"; for (let i = 0; i < 4; i++) { (() => ({a:i} = {a:i + 1}))(); } })();
{ "end_byte": 230, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/capturedLetConstInLoop12.ts" }
TypeScript/tests/cases/compiler/contextualTyping18.ts_0_59
var foo: {id:number;} = <{id:number;}>({ }); foo = {id: 5};
{ "end_byte": 59, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTyping18.ts" }
TypeScript/tests/cases/compiler/spellingSuggestionGlobal2.ts_0_118
export {} declare global { const x: any } const globals = { x: true } global.x // should suggest `globals` (GH#42209)
{ "end_byte": 118, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/spellingSuggestionGlobal2.ts" }
TypeScript/tests/cases/compiler/jsFileImportPreservedWhenUsed.ts_0_840
// @target: esnext // @allowJs: true // @strict: true // @outDir: ./out // @filename: dash.d.ts type ObjectIterator<TObject, TResult> = (value: TObject[keyof TObject], key: string, collection: TObject) => TResult; interface LoDashStatic { mapValues<T extends object, TResult>(obj: T | null | undefined, callback: Ob...
{ "end_byte": 840, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileImportPreservedWhenUsed.ts" }
TypeScript/tests/cases/compiler/capturedLetConstInLoop7.ts_0_5248
//===let l0: for (let x of []) { (function() { return x}); (() => x); if (x == 1) { break; } if (x == 1) { break l0; } if (x == 2) { continue; } if (x == 2) { continue l0; } } l00: for (let x in []) { (function() { return x}); (() => x); ...
{ "end_byte": 5248, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/capturedLetConstInLoop7.ts" }
TypeScript/tests/cases/compiler/typeParameterDiamond4.ts_0_323
function diamondTop<Top>() { function diamondMiddle<T, U>() { function diamondBottom<Bottom extends Top | T | U>() { var top: Top; var middle: Top | T | U; var bottom: Bottom; top = middle; middle = bottom; top = bottom; } ...
{ "end_byte": 323, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeParameterDiamond4.ts" }
TypeScript/tests/cases/compiler/emitClassMergedWithConstNamespaceNotElided.ts_0_319
// @esModuleInterop: true // @filename: enum.d.ts export namespace Clone { const enum LOCAL { AUTO = 0, LOCAL = 1, NO_LOCAL = 2, NO_LINKS = 3 } } export class Clone { static clone(url: string): void; } // @filename: usage.ts import {Clone} from "./enum"; Clone.clone("ok");
{ "end_byte": 319, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emitClassMergedWithConstNamespaceNotElided.ts" }
TypeScript/tests/cases/compiler/thisInSuperCall.ts_0_372
class Base { constructor(x: any) {} } class Foo extends Base { constructor() { super(this); // error: "super" has to be called before "this" accessing } } class Foo2 extends Base { public p = 0; constructor() { super(this); // error } } class Foo3 extends Base { construct...
{ "end_byte": 372, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/thisInSuperCall.ts" }
TypeScript/tests/cases/compiler/genericMemberFunction.ts_0_609
//@module: amd export class BuildError<A, B, C>{ public parent<A, B extends A, C>(): FileWithErrors<A, B, C> { return undefined; } } export class FileWithErrors<A, B, C>{ public errors<A, B extends A, C>(): BuildError<A, B, C>[] { return undefined; } public parent<A, B extends A, C>(): BuildResult<A, ...
{ "end_byte": 609, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericMemberFunction.ts" }
TypeScript/tests/cases/compiler/declFileEmitDeclarationOnly.ts_0_244
// @declaration: true // @emitDeclarationOnly: true // @filename: helloworld.ts const Log = { info(msg: string) {} } class HelloWorld { constructor(private name: string) { } public hello() { Log.info(`Hello ${this.name}`); } }
{ "end_byte": 244, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileEmitDeclarationOnly.ts" }
TypeScript/tests/cases/compiler/letShadowedByNameInNestedScope.ts_0_113
var x; function foo() { let x = 0; (function () { var _x = 1; console.log(x); })(); }
{ "end_byte": 113, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/letShadowedByNameInNestedScope.ts" }
TypeScript/tests/cases/compiler/commentsDottedModuleName.ts_0_208
// @module: amd // @target: ES5 // @declaration: true // @removeComments: false /** this is multi declare module*/ export module outerModule.InnerModule { /// class b comment export class b { } }
{ "end_byte": 208, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentsDottedModuleName.ts" }
TypeScript/tests/cases/compiler/quotedPropertyName3.ts_0_119
class Test { "prop1": number; foo() { var x = () => this["prop1"]; var y: number = x(); } }
{ "end_byte": 119, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/quotedPropertyName3.ts" }
TypeScript/tests/cases/compiler/module_augmentUninstantiatedModule.ts_0_113
declare module "foo" { namespace M {} var M; export = M; } declare module "bar" { module "foo" {} }
{ "end_byte": 113, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/module_augmentUninstantiatedModule.ts" }
TypeScript/tests/cases/compiler/generics1NoError.ts_0_308
// @declaration: true interface A { a: string; } interface B extends A { b: string; } interface C extends B { c: string; } interface G<T, U extends B> { x: T; y: U; } var v1: G<A, C>; // Ok var v2: G<{ a: string }, C>; // Ok, equivalent to G<A, C> var v4: G<G<A, B>, C>; // Ok
{ "end_byte": 308, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/generics1NoError.ts" }
TypeScript/tests/cases/compiler/controlFlowLoopAnalysis.ts_0_975
// @strictNullChecks: true // @noImplicitAny: true // Repro from #8418 let cond: boolean; function foo(x: number): number { return 1; } function test1() { let x: number | undefined; while (cond) { while (cond) { while (cond) { x = foo(x); } } x...
{ "end_byte": 975, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/controlFlowLoopAnalysis.ts" }
TypeScript/tests/cases/compiler/declFileForFunctionTypeAsTypeParameter.ts_0_115
// @declaration: true class X<T> { } class C extends X<() => number> { } interface I extends X<() => number> { }
{ "end_byte": 115, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileForFunctionTypeAsTypeParameter.ts" }
TypeScript/tests/cases/compiler/enumWithNegativeInfinityProperty.ts_0_31
enum A { "-Infinity" = 1 }
{ "end_byte": 31, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumWithNegativeInfinityProperty.ts" }
TypeScript/tests/cases/compiler/enumsWithMultipleDeclarations3.ts_0_28
module E { } enum E { A }
{ "end_byte": 28, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumsWithMultipleDeclarations3.ts" }
TypeScript/tests/cases/compiler/es2015modulekind.ts_0_188
// @target: es2015 // @sourcemap: false // @declaration: false // @module: es2015 export default class A { constructor () { } public B() { return 42; } }
{ "end_byte": 188, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es2015modulekind.ts" }
TypeScript/tests/cases/compiler/declarationEmitComputedPropertyNameEnum1.ts_0_280
// @strict: true // @declaration: true // @emitDeclarationOnly: true // @filename: type.ts export enum Enum { A = "a", B = "b" } export type Type = { x?: { [Enum.A]: 0 } }; // @filename: index.ts import { type Type } from "./type"; export const foo = { ...({} as Type) };
{ "end_byte": 280, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitComputedPropertyNameEnum1.ts" }