_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/fixingTypeParametersRepeatedly2.ts_0_451
interface Base { baseProp; } interface Derived extends Base { toBase(): Base; } var derived: Derived; declare function foo<T>(x: T, func: (p: T) => T): T; var result = foo(derived, d => d.toBase()); // bar should type check just like foo. // The same error should be observed in both cases. declare function b...
{ "end_byte": 451, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/fixingTypeParametersRepeatedly2.ts" }
TypeScript/tests/cases/compiler/functionCall9.ts_0_113
function foo(a?:string, b?:number){}; foo('foo', 1); foo('foo'); foo('foo','bar'); foo('foo', 1, 'bar'); foo();
{ "end_byte": 113, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionCall9.ts" }
TypeScript/tests/cases/compiler/indirectSelfReference.ts_0_41
class a extends b{ } class b extends a{ }
{ "end_byte": 41, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/indirectSelfReference.ts" }
TypeScript/tests/cases/compiler/newExpressionWithCast.ts_0_256
// @noimplicitany: true function Test() { } // valid but error with noImplicitAny var test = new Test(); function Test2() { } // parse error var test2 = new <any>Test2(); function Test3() { } // valid with noImplicitAny var test3 = new (<any>Test3)();
{ "end_byte": 256, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/newExpressionWithCast.ts" }
TypeScript/tests/cases/compiler/intersectionsAndOptionalProperties3.ts_0_874
// @strict: true // @exactOptionalPropertyTypes: true, false // @noEmit: true type A_Primitive = { disabled?: boolean | undefined; }; type B_Primitive = { disabled?: boolean; }; type C_Primitive = { disabled?: boolean | undefined; }; declare const ab_primitive: A_Primitive & B_Primitive; declare const ac_prim...
{ "end_byte": 874, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/intersectionsAndOptionalProperties3.ts" }
TypeScript/tests/cases/compiler/binaryArithmatic2.ts_0_22
var v = 4 | undefined;
{ "end_byte": 22, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/binaryArithmatic2.ts" }
TypeScript/tests/cases/compiler/letInVarDeclOfForIn_ES6.ts_0_105
// @target: es6 // should not be an error for (var let in [1,2,3]) {} { for (var let in [1,2,3]) {} }
{ "end_byte": 105, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/letInVarDeclOfForIn_ES6.ts" }
TypeScript/tests/cases/compiler/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOut.ts_0_198
// @allowJs: true // @outFile: out.js // @declaration: true // @filename: a.ts class c { } // @filename: b.ts /// <reference path="c.js"/> function foo() { } // @filename: c.js function bar() { }
{ "end_byte": 198, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOut.ts" }
TypeScript/tests/cases/compiler/commentOnArrayElement3.ts_3_134
nst array = [ /* element 1*/ 1 /* end of element 1 */, 2 /* end of element 2 */, , /* extra comment */ ];
{ "end_byte": 134, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentOnArrayElement3.ts" }
TypeScript/tests/cases/compiler/augmentExportEquals7.ts_0_256
// @Filename: /node_modules/lib/index.d.ts declare var lib: () => void; declare namespace lib {} export = lib; // @Filename: /node_modules/@types/lib-extender/index.d.ts import * as lib from "lib"; declare module "lib" { export function fn(): void; }
{ "end_byte": 256, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/augmentExportEquals7.ts" }
TypeScript/tests/cases/compiler/convertKeywordsYes.ts_0_4487
// reserved ES5 future in strict mode var constructor = 0; var any = 0; var boolean = 0; var implements = 0; var interface = 0; var let = 0; var module = 0; var number = 0; var package = 0; var private = 0; var protected = 0; var public = 0; var set = 0; var static = 0; var string = 0; var get = 0; var yield = 0; var ...
{ "end_byte": 4487, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/convertKeywordsYes.ts" }
TypeScript/tests/cases/compiler/superAccess2.ts_0_450
class P { x() { } static y() { } } class Q extends P { xx = super; static yy = super; // error for static initializer accessing super // Super is not allowed in constructor args constructor(public z = super, zz = super, zzz = () => super) { super(); } foo(zz = super) { ...
{ "end_byte": 450, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/superAccess2.ts" }
TypeScript/tests/cases/compiler/globalThisDeclarationEmit.ts_0_182
// @declaration: true // @filename: index.ts import { variable } from "./variable"; export const globalThis = variable; // @filename: variable.ts export const variable = globalThis;
{ "end_byte": 182, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/globalThisDeclarationEmit.ts" }
TypeScript/tests/cases/compiler/decoratorInJsFile1.ts_0_117
// @allowjs: true // @noEmit: true // @filename: a.js @SomeDecorator class SomeClass { foo(x: number) { } }
{ "end_byte": 117, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/decoratorInJsFile1.ts" }
TypeScript/tests/cases/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.ts_0_457
// @filename: tsconfig.json { "compilerOptions": { "module": "nodenext", "outDir": "./dist", "declarationDir": "./types", "composite": true } } // @filename: package.json { "name": "@this/package", "type": "module", "exports": { ".": { "default": "./dist/index.js", "types": "./...
{ "end_byte": 457, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.ts" }
TypeScript/tests/cases/compiler/module_augmentExistingAmbientVariable.ts_0_80
// @lib: es5 declare var console: any; module console { export var x = 2; }
{ "end_byte": 80, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/module_augmentExistingAmbientVariable.ts" }
TypeScript/tests/cases/compiler/privateVisibles.ts_0_115
class Foo { private pvar = 0; constructor() { var n = this.pvar; } public meth() { var q = this.pvar;} }
{ "end_byte": 115, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privateVisibles.ts" }
TypeScript/tests/cases/compiler/awaitedTypeStrictNull.ts_0_2736
// @target: esnext // @strictNullChecks: true type T1 = Awaited<number>; type T2 = Awaited<Promise<number>>; type T3 = Awaited<number | Promise<number>>; type T4 = Awaited<number | Promise<string>>; type T5 = Awaited<{ then: number }>; type T6 = Awaited<{ then(): void }>; // never (non-promise "thenable") type T7 = Aw...
{ "end_byte": 2736, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/awaitedTypeStrictNull.ts" }
TypeScript/tests/cases/compiler/commentOnArrayElement11.ts_3_42
nst array = [ , /* comment */ ];
{ "end_byte": 42, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentOnArrayElement11.ts" }
TypeScript/tests/cases/compiler/objectLiteralComputedNameNoDeclarationError.ts_0_116
// @declaration: true const Foo = { BANANA: 'banana' as 'banana', } export const Baa = { [Foo.BANANA]: 1 };
{ "end_byte": 116, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectLiteralComputedNameNoDeclarationError.ts" }
TypeScript/tests/cases/compiler/functionExpressionShadowedByParams.ts_0_234
function b1(b1: number) { b1.toPrecision(2); // should not error b1(12); // should error } var x = { b: function b(b: number) { b.toPrecision(2); // should not error b.apply(null, null); // should error } };
{ "end_byte": 234, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionExpressionShadowedByParams.ts" }
TypeScript/tests/cases/compiler/gettersAndSetters.ts_0_1077
// @target: es2020 // classes class C { public fooBack = ""; static barBack:string = ""; public bazBack = ""; public get Foo() { return this.fooBack;} // ok public set Foo(foo:string) {this.fooBack = foo;} // ok static get Bar() {return C.barBack;} // ok static set Bar(bar:string) {C.b...
{ "end_byte": 1077, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/gettersAndSetters.ts" }
TypeScript/tests/cases/compiler/unusedParametersInLambda2.ts_0_138
//@noUnusedLocals:true //@noUnusedParameters:true class A { public f1() { return (X, Y) => { Y; } } }
{ "end_byte": 138, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedParametersInLambda2.ts" }
TypeScript/tests/cases/compiler/contextualTypingFunctionReturningFunction.ts_0_138
interface I { a(s: string): void; b(): (n: number) => void; } declare function f(i: I): void; f({ a: s => {}, b: () => n => {}, });
{ "end_byte": 138, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTypingFunctionReturningFunction.ts" }
TypeScript/tests/cases/compiler/aliasUsageInTypeArgumentOfExtendsClause.ts_0_800
// @module: commonjs // @Filename: aliasUsageInTypeArgumentOfExtendsClause_backbone.ts export class Model { public someData: string; } // @Filename: aliasUsageInTypeArgumentOfExtendsClause_moduleA.ts import Backbone = require("./aliasUsageInTypeArgumentOfExtendsClause_backbone"); export class VisualizationModel ex...
{ "end_byte": 800, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/aliasUsageInTypeArgumentOfExtendsClause.ts" }
TypeScript/tests/cases/compiler/genericClasses0.ts_0_108
// @declaration: true class C<T> { public x: T; } var v1 : C<string>; var y = v1.x; // should be 'string'
{ "end_byte": 108, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericClasses0.ts" }
TypeScript/tests/cases/compiler/contextualTyping23.ts_0_82
var foo:(a:{():number; (i:number):number; })=>number; foo = function(a){return 5};
{ "end_byte": 82, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTyping23.ts" }
TypeScript/tests/cases/compiler/unreachableSwitchTypeofAny.ts_0_403
// @Filename: unreachable.ts // @allowUnreachableCode: false const unreachable = (x: any): number => { switch (typeof x) { case 'string': return 0 case 'number': return 0 case 'bigint': return 0 case 'boolean': return 0 case 'symbol': return 0 case 'undefined': return...
{ "end_byte": 403, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unreachableSwitchTypeofAny.ts" }
TypeScript/tests/cases/compiler/unreachableSwitchTypeofUnknown.ts_0_407
// @Filename: unreachable.ts // @allowUnreachableCode: false const unreachable = (x: unknown): number => { switch (typeof x) { case 'string': return 0 case 'number': return 0 case 'bigint': return 0 case 'boolean': return 0 case 'symbol': return 0 case 'undefined': re...
{ "end_byte": 407, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unreachableSwitchTypeofUnknown.ts" }
TypeScript/tests/cases/compiler/accessorWithRestParam.ts_0_76
// @target: es5 class C { set X(...v) { } static set X(...v2) { } }
{ "end_byte": 76, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/accessorWithRestParam.ts" }
TypeScript/tests/cases/compiler/ambientWithStatements.ts_0_370
declare module M { break; continue; debugger; do { } while (true); var x; for (x in null) { } if (true) { } else { } 1; L: var y; return; switch (x) { case 1: break; default: break; } throw "nooo"; try { } catch (e) ...
{ "end_byte": 370, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ambientWithStatements.ts" }
TypeScript/tests/cases/compiler/outModuleConcatUnspecifiedModuleKindDeclarationOnly.ts_0_179
// @target: ES5 // @outFile: out.js // @declaration: true, // @emitDeclarationOnly: true // @Filename: a.ts export class A { } // module // @Filename: b.ts var x = 0; // global
{ "end_byte": 179, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/outModuleConcatUnspecifiedModuleKindDeclarationOnly.ts" }
TypeScript/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts_0_296
//@noUnusedLocals:true //@noUnusedParameters:true function greeter(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": 296, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts" }
TypeScript/tests/cases/compiler/modularizeLibrary_NoErrorDuplicateLibOptions2.ts_3_1315
@lib: es5,es2015,es2015.core,es2015.symbol.wellknown // @target: es6 // Using Es6 array function f(x: number, y: number, z: number) { return Array.from(arguments); } f(1, 2, 3); // no error // Using ES6 collection var m = new Map<string, number>(); m.clear(); // Using ES6 iterable m.keys(); // Using ES6 funct...
{ "end_byte": 1315, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/modularizeLibrary_NoErrorDuplicateLibOptions2.ts" }
TypeScript/tests/cases/compiler/genericArray1.ts_0_242
// @declaration: true /* var n: number[]; interface Array<T> { map<U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; } interface String{ length: number; } */ var lengths = ["a", "b", "c"].map(x => x.length);
{ "end_byte": 242, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericArray1.ts" }
TypeScript/tests/cases/compiler/classPropertyErrorOnNameOnly.ts_0_771
// @strict: true type Values = 1 | 2 | 3 | 4 | 5 | 6 type FuncType = (arg: Values) => string // turn on strictNullChecks class Example { insideClass: FuncType = function(val) { // error span goes from here switch (val) { case 1: return "1"; case 2: return "2"; case 3: r...
{ "end_byte": 771, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classPropertyErrorOnNameOnly.ts" }
TypeScript/tests/cases/compiler/moduleElementsInWrongContext.ts_0_543
{ 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 v; export def...
{ "end_byte": 543, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleElementsInWrongContext.ts" }
TypeScript/tests/cases/compiler/downlevelLetConst8.ts_0_9
let a = 1
{ "end_byte": 9, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/downlevelLetConst8.ts" }
TypeScript/tests/cases/compiler/modKeyword.ts_0_58
var module:any; var foo:any; var _ = module.exports = foo
{ "end_byte": 58, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/modKeyword.ts" }
TypeScript/tests/cases/compiler/superHasMethodsFromMergedInterface.ts_0_109
class C { m1() { } } interface C { m2(): void } class Sub extends C { m3() { super.m2(); } }
{ "end_byte": 109, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/superHasMethodsFromMergedInterface.ts" }
TypeScript/tests/cases/compiler/genericConstraintSatisfaction1.ts_0_89
interface I<S> { f: <T extends S>(x: T) => void } var x: I<{s: string}> x.f({s: 1})
{ "end_byte": 89, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericConstraintSatisfaction1.ts" }
TypeScript/tests/cases/compiler/unusedVariablesinBlocks2.ts_0_117
//@noUnusedLocals:true //@noUnusedParameters:true function f1 () { let x = 10; { let x = 11; } }
{ "end_byte": 117, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedVariablesinBlocks2.ts" }
TypeScript/tests/cases/compiler/thisWhenTypeCheckFails.ts_0_111
class c { public n() { var k = () => { var s: string = this.n(); } } }
{ "end_byte": 111, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/thisWhenTypeCheckFails.ts" }
TypeScript/tests/cases/compiler/regexMatchAll-esnext.ts_0_135
// @target: esnext const matches = /\w/g[Symbol.matchAll]("matchAll"); const array = [...matches]; const { index, input } = array[0];
{ "end_byte": 135, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/regexMatchAll-esnext.ts" }
TypeScript/tests/cases/compiler/declareFileExportAssignmentWithVarFromVariableStatement.ts_0_388
//@module: commonjs // @declaration: true module m2 { export interface connectModule { (res, req, next): void; } export interface connectExport { use: (mod: connectModule) => connectExport; listen: (port: number) => void; } } var x = 10, m2: { (): m2.connectExport; test...
{ "end_byte": 388, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declareFileExportAssignmentWithVarFromVariableStatement.ts" }
TypeScript/tests/cases/compiler/crashInGetTextOfComputedPropertyName.ts_0_871
// https://github.com/Microsoft/TypeScript/issues/29006 export interface A { type: 'a' } export interface B { type: 'b' } export type AB = A | B const itemId = 'some-id' // --- test on first level --- const items: { [id: string]: AB } = {} const { [itemId]: itemOk1 } = items typeof itemOk1 // pass // --- test on sec...
{ "end_byte": 871, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/crashInGetTextOfComputedPropertyName.ts" }
TypeScript/tests/cases/compiler/esModuleInteropImportCall.ts_0_201
// @esModuleInterop: true // @lib: es6 // @Filename: foo.d.ts declare function foo(): void; declare namespace foo {} export = foo; // @Filename: index.ts import("./foo").then(f => { f.default; });
{ "end_byte": 201, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/esModuleInteropImportCall.ts" }
TypeScript/tests/cases/compiler/indexSignatureInOtherFile.ts_0_764
// @target: es2015 // @Filename: index.ts class Test extends Array1 { [key: symbol]: string } // @Filename: other.ts interface Array1<T> { length: number; [n: number]: T; } interface ArrayConstructor1 { new(arrayLength?: number): Array1<any>; } declare var Array1: ArrayConstructor1; // iterable.d.ts interfa...
{ "end_byte": 764, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/indexSignatureInOtherFile.ts" }
TypeScript/tests/cases/compiler/controlFlowInitializedDestructuringVariables.ts_0_107
// @strict: true declare const obj: { a?: string, b?: number }; const { a = "0", b = +a, } = obj;
{ "end_byte": 107, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/controlFlowInitializedDestructuringVariables.ts" }
TypeScript/tests/cases/compiler/sourceMapSample.ts_0_820
// @sourcemap: true module Foo.Bar { "use strict"; class Greeter { constructor(public greeting: string) { } greet() { return "<h1>" + this.greeting + "</h1>"; } } function foo(greeting: string): Foo.Bar.Greeter { return new Greeter(greeting); }...
{ "end_byte": 820, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapSample.ts" }
TypeScript/tests/cases/compiler/isolatedModulesExportImportUninstantiatedNamespace.ts_0_480
// @module: esnext // @isolatedModules: true // @noTypesAndSymbols: true // @Filename: jsx.ts export namespace JSXInternal { export type HTMLAttributes = string export type ComponentChildren = string } // @Filename: factory.ts import { JSXInternal } from "./jsx" export import JSX = JSXInternal; export function ...
{ "end_byte": 480, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/isolatedModulesExportImportUninstantiatedNamespace.ts" }
TypeScript/tests/cases/compiler/genericPrototypeProperty2.ts_0_352
interface EventTarget { x } class BaseEvent { target: EventTarget; } class MyEvent<T extends EventTarget> extends BaseEvent { target: T; } class BaseEventWrapper { t: BaseEvent; } class MyEventWrapper extends BaseEventWrapper { t: MyEvent<any>; // any satisfies constraint and passes assignability che...
{ "end_byte": 352, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericPrototypeProperty2.ts" }
TypeScript/tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts_0_4094
// es2015 const noOp = () => {}; const testReflectApply = Reflect.apply(noOp, this, []); const testReflectConstruct = Reflect.construct(noOp, []); const testReflectDefineProperty = Reflect.defineProperty({}, "", {}); const testReflectDeleteProperty = Reflect.deleteProperty({}, ""); const testReflectGet = Reflect.get({}...
{ "end_byte": 4094, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts" }
TypeScript/tests/cases/compiler/jsdocReferenceGlobalTypeInCommonJs.ts_0_384
// @noEmit: true // @allowJs: true // @checkJs: true // @Filename: a.js const other = require('./other'); /** @type {Puppeteer.Keyboard} */ var ppk; Puppeteer.connect; // @Filename: puppet.d.ts export as namespace Puppeteer; export interface Keyboard { key: string } export function connect(name: string): void; // ...
{ "end_byte": 384, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsdocReferenceGlobalTypeInCommonJs.ts" }
TypeScript/tests/cases/compiler/unicodeStringLiteral.ts_0_23
var ੳ = "Ü­ਲĭ";
{ "end_byte": 23, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unicodeStringLiteral.ts" }
TypeScript/tests/cases/compiler/thisShadowingErrorSpans.ts_0_118
// @strict: true class C { m() { this.m(); function f() { this.m(); } } }
{ "end_byte": 118, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/thisShadowingErrorSpans.ts" }
TypeScript/tests/cases/compiler/importDeclWithExportModifierAndExportAssignment.ts_0_91
//@module: commonjs module x { interface c { } } export import a = x.c; export = x;
{ "end_byte": 91, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importDeclWithExportModifierAndExportAssignment.ts" }
TypeScript/tests/cases/compiler/internalAliasEnum.ts_0_191
// @declaration: true module a { export enum weekend { Friday, Saturday, Sunday } } module c { import b = a.weekend; export var bVal: b = b.Sunday; }
{ "end_byte": 191, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/internalAliasEnum.ts" }
TypeScript/tests/cases/compiler/importHelpersWithImportOrExportDefault.ts_0_392
// @importHelpers: true // @target: es2017 // @module: commonjs,system,amd,es2015,es2020 // @esModuleInterop: true,false // @filename: a.ts export default class { } // @filename: b.ts export { default } from "./a"; export { default as a } from "./a"; import { default as b } from "./a"; void b; // @filename: tslib.d.t...
{ "end_byte": 392, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importHelpersWithImportOrExportDefault.ts" }
TypeScript/tests/cases/compiler/contextualPropertyOfGenericFilteringMappedType.ts_0_621
// @strict: true // @noEmit: true declare function f1<T extends object>( data: T, handlers: { [P in keyof T as P]: (value: T[P], prop: P) => void }, ): void; f1( { foo: 0, bar: "", }, { foo: (value, key) => {}, bar: (value, key) => {}, }, ); declare function f2<T extends object>( data: ...
{ "end_byte": 621, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualPropertyOfGenericFilteringMappedType.ts" }
TypeScript/tests/cases/compiler/strictOptionalProperties3.ts_0_360
// @strictNullChecks: true // @exactOptionalPropertyTypes: true // @allowJs: true // @checkJs: true // @noEmit: true // @filename: a.js /** * @typedef {object} A * @property {number} [value] */ /** @type {A} */ const a = { value: undefined }; // error /** * @typedef {{ value?: number }} B */ /** @type {B} */ c...
{ "end_byte": 360, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/strictOptionalProperties3.ts" }
TypeScript/tests/cases/compiler/voidArrayLit.ts_0_103
var va = [(() => {})()]; // ok (() => {})(); // ok function foo(s:string) {} foo((()=>{})()); // error
{ "end_byte": 103, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/voidArrayLit.ts" }
TypeScript/tests/cases/compiler/inheritedMembersAndIndexSignaturesFromDifferentBases.ts_0_535
// indexer in B is a subtype of indexer in A interface A { [s: string]: { a; }; } interface B { [s: number]: { a; b; }; } interface C { m: {}; } interface D extends A, B, C { } // error because m is not a subtype of {a;} interface E { 0: {}; } interface F extends A, B,...
{ "end_byte": 535, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inheritedMembersAndIndexSignaturesFromDifferentBases.ts" }
TypeScript/tests/cases/compiler/quotedFunctionName1.ts_0_31
class Test1 { "prop1"() { } }
{ "end_byte": 31, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/quotedFunctionName1.ts" }
TypeScript/tests/cases/compiler/allowSyntheticDefaultImports3.ts_0_201
// @allowSyntheticDefaultImports: false // @module: system // @Filename: a.ts import Namespace from "./b"; export var x = new Namespace.Foo(); // @Filename: b.ts export class Foo { member: string; }
{ "end_byte": 201, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/allowSyntheticDefaultImports3.ts" }
TypeScript/tests/cases/compiler/constructorWithCapturedSuper.ts_0_786
let oneA: A; class A { constructor() { return oneA; } } class B extends A { constructor(x: number) { super(); if (x === 1) { return; } while (x < 2) { return; } try { return } catch (e) { ...
{ "end_byte": 786, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constructorWithCapturedSuper.ts" }
TypeScript/tests/cases/compiler/dottedSymbolResolution1.ts_0_766
interface JQuery { find(selector: string): JQuery; } interface JQueryStatic { (selector: string): JQuery; (object: JQuery): JQuery; } class Base { foo() { } } function each(collection: string, callback: (indexInArray: any, valueOfElement: any) => any): any; function each(collection: JQuery, callback...
{ "end_byte": 766, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/dottedSymbolResolution1.ts" }
TypeScript/tests/cases/compiler/genericSpecializationToTypeLiteral1.ts_0_1465
interface IEnumerable<T> { zip<TResult>(second: IEnumerable<T>, resultSelector: (first: T, second: T, index: number) => TResult): IEnumerable<TResult>; zip<TResult>(second: T[], resultSelector: (first: T, second: T, index: number) => TResult): IEnumerable<TResult>; zip<TResult>(...params: any[]): IEnumerab...
{ "end_byte": 1465, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericSpecializationToTypeLiteral1.ts" }
TypeScript/tests/cases/compiler/es6ExportClauseInEs5.ts_0_299
// @target: es5 // @module: commonjs // @declaration: true // @filename: server.ts class c { } interface i { } module m { export var x = 10; } var x = 10; module uninstantiated { } export { c }; export { c as c2 }; export { i, m as instantiatedModule }; export { uninstantiated }; export { x };
{ "end_byte": 299, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ExportClauseInEs5.ts" }
TypeScript/tests/cases/compiler/duplicateVariablesWithAny.ts_0_244
// They should have to be the same even when one of the types is 'any' var x: any; var x = 2; //error var y = ""; var y; //error module N { var x: any; var x = 2; //error var y = ""; var y; //error } var z: any; var z; // ok
{ "end_byte": 244, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateVariablesWithAny.ts" }
TypeScript/tests/cases/compiler/missingSemicolonInModuleSpecifier.ts_0_131
// @module: commonjs // @filename: a.ts export const x = 1; // @filename: b.ts import {x} from "./a" (function() { return 1; }())
{ "end_byte": 131, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/missingSemicolonInModuleSpecifier.ts" }
TypeScript/tests/cases/compiler/constructorsWithSpecializedSignatures.ts_0_676
// errors declare class C { constructor(x: "hi"); constructor(x: "foo"); constructor(x: number); } // ok declare class C2 { constructor(x: "hi"); constructor(x: "foo"); constructor(x: string); } // errors class D { constructor(x: "hi"); constructor(x: "foo"); constructor(x: number)...
{ "end_byte": 676, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constructorsWithSpecializedSignatures.ts" }
TypeScript/tests/cases/compiler/contextualTyping17.ts_0_58
var foo: {id:number;} = {id:4}; foo = {id: 5, name:"foo"};
{ "end_byte": 58, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTyping17.ts" }
TypeScript/tests/cases/compiler/constructorArgsErrors4.ts_0_65
class foo { constructor (private public a: number) { } }
{ "end_byte": 65, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constructorArgsErrors4.ts" }
TypeScript/tests/cases/compiler/strictModeReservedWord2.ts_3_276
se strict" interface public { } interface implements { foo(package, protected); } enum package { } enum foo { public, private, pacakge } const enum private { public, private, pacakge } const enum bar { public, private, pacakge }
{ "end_byte": 276, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/strictModeReservedWord2.ts" }
TypeScript/tests/cases/compiler/es5-asyncFunction.ts_0_133
// @lib: es5,es2015.promise // @target: ES5 declare var x; async function empty() { } async function singleAwait() { await x; }
{ "end_byte": 133, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es5-asyncFunction.ts" }
TypeScript/tests/cases/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameter.ts_0_276
// @strict: true // @noEmit: true // repro https://github.com/microsoft/TypeScript/issues/55394 declare function filter<T>(predicate: (value: T, index: number) => boolean): T; const a = filter((pose?: number) => true); const b = filter((pose?: number, _?: number) => true);
{ "end_byte": 276, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameter.ts" }
TypeScript/tests/cases/compiler/duplicateSymbolsExportMatching.ts_0_1319
//@module: amd module M { export interface E { } interface I { } } module M { export interface E { } // ok interface I { } // ok } // Doesn't match export visibility, but it's in a different parent, so it's ok module M { interface E { } // ok export interface I { } // ok } module N { inter...
{ "end_byte": 1319, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateSymbolsExportMatching.ts" }
TypeScript/tests/cases/compiler/objectLiteralMemberWithModifiers2.ts_0_32
var v = { public get foo() { } }
{ "end_byte": 32, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectLiteralMemberWithModifiers2.ts" }
TypeScript/tests/cases/compiler/capturedLetConstInLoop8.ts_0_2911
function foo() { l0: for (let z = 0; z < 1; ++z) { l1: for (let x = 0; x < 1; ++x) { ll1: for (let y = 0; y < 1; ++y) { (function() { return x + y }); (() => x + y); if (y == 1) { break; }...
{ "end_byte": 2911, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/capturedLetConstInLoop8.ts" }
TypeScript/tests/cases/compiler/recursiveUnionTypeInference.ts_0_94
interface Foo<T> { x: T; } function bar<T>(x: Foo<T> | string): T { return bar(x); }
{ "end_byte": 94, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveUnionTypeInference.ts" }
TypeScript/tests/cases/compiler/argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.ts_0_338
function A() { return class T { a = arguments } } function A1() { return new class T { a = arguments } } function B() { return class T { a = { b: arguments } } } function B1() { return new class T { a = { b: arguments } } } function C() { return class T { a = function () {...
{ "end_byte": 338, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.ts" }
TypeScript/tests/cases/compiler/jsExportMemberMergedWithModuleAugmentation2.ts_0_231
// @allowJs: true // @checkJs: true // @noEmit: true // @Filename: /test.js module.exports = { a: "ok" }; // @Filename: /index.ts import { a } from "./test"; declare module "./test" { export const a: number; } a.toFixed();
{ "end_byte": 231, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsExportMemberMergedWithModuleAugmentation2.ts" }
TypeScript/tests/cases/compiler/staticGetterAndSetter.ts_0_89
class Foo { static get Foo():number { return 0; } static set Foo(n: number) {} }
{ "end_byte": 89, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/staticGetterAndSetter.ts" }
TypeScript/tests/cases/compiler/importHelpersWithExportStarAs.ts_0_298
// @importHelpers: true // @target: es2017 // @module: commonjs,system,amd,es2015,es2020 // @esModuleInterop: true,false // @filename: a.ts export class A { } // @filename: b.ts export * as a from "./a"; // @filename: tslib.d.ts declare module "tslib" { function __importStar(m: any): void; }
{ "end_byte": 298, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importHelpersWithExportStarAs.ts" }
TypeScript/tests/cases/compiler/es6ClassSuperCodegenBug.ts_0_228
// @allowUnreachableCode: true class A { constructor(str1:string, str2:string) {} } class B extends A { constructor() { if (true) { super('a1', 'b1'); } else { super('a2', 'b2'); } } }
{ "end_byte": 228, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ClassSuperCodegenBug.ts" }
TypeScript/tests/cases/compiler/commentsClassMembers.ts_0_5522
// @target: ES5 // @declaration: true // @removeComments: false /** This is comment for c1*/ class c1 { /** p1 is property of c1*/ public p1: number; /** sum with property*/ public p2(/** number to add*/b: number) { return this.p1 + b; } /* trailing comment of method*/ /** getter proper...
{ "end_byte": 5522, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentsClassMembers.ts" }
TypeScript/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts_0_235
//@noUnusedLocals:true //@noUnusedParameters:true var greeter = function (person: string, person2: string) { var unused = 20; function maker(child: string): void { var unused2 = 22; } person2 = "dummy value"; }
{ "end_byte": 235, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts" }
TypeScript/tests/cases/compiler/inlinedAliasAssignableToConstraintSameAsAlias.ts_0_513
interface RelationFields { x: A; y: A[]; z: A[]; } type Name = keyof RelationFields; type ShouldA<RF extends RelationFields, N extends Name> = RF[N] extends A[] ? RF[N][0] : never; class A { x: A; y: A[]; z: A[]; whereRelated< // Works // Type is same as A1, but is not assignable to type A RF ex...
{ "end_byte": 513, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inlinedAliasAssignableToConstraintSameAsAlias.ts" }
TypeScript/tests/cases/compiler/keyofIsLiteralContexualType.ts_0_353
// keyof T is a literal contextual type function foo<T extends { a: string, b: string }>() { let a: (keyof T)[] = ["a", "b"]; let b: (keyof T)[] = ["a", "b", "c"]; } // Repro from #12455 declare function pick<T, K extends keyof T>(obj: T, propNames: K[]): Pick<T, K>; let x = pick({ a: 10, b: 20, c: 30 }, ["...
{ "end_byte": 353, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/keyofIsLiteralContexualType.ts" }
TypeScript/tests/cases/compiler/declarationEmitCastReusesTypeNode3.ts_0_796
// @strict: true // @strictNullChecks: true,false // @declaration: true // @noTypesAndSymbols: true // @emitDeclarationOnly: true type P = { } & { name: string } export let vLet = <P>null! export const vConst = <P>null! export function fn(p = <P>null!) {} export function fnWithRequiredDefaultParam(p = <P>null!, req:...
{ "end_byte": 796, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitCastReusesTypeNode3.ts" }
TypeScript/tests/cases/compiler/implicitAnyFunctionReturnNullOrUndefined.ts_0_733
//@noimplicitany: true // this should be an error function nullWidenFunction() { return null;} // error at "nullWidenFunction" function undefinedWidenFunction() { return undefined; } // error at "undefinedWidenFunction" class C { nullWidenFuncOfC() { // error at "nullWidenFuncOfC" return null...
{ "end_byte": 733, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/implicitAnyFunctionReturnNullOrUndefined.ts" }
TypeScript/tests/cases/compiler/protectedMembers.ts_0_1653
// Class with protected members class C1 { protected x: number; protected static sx: number; protected f() { return this.x; } protected static sf() { return this.sx; } } // Derived class accessing protected members class C2 extends C1 { protected f() { return super.f...
{ "end_byte": 1653, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/protectedMembers.ts" }
TypeScript/tests/cases/compiler/es6ExportDefaultIdentifier.ts_0_82
// @target: es6 // @declaration: true export function f() { } export default f;
{ "end_byte": 82, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ExportDefaultIdentifier.ts" }
TypeScript/tests/cases/compiler/jsxEmptyExpressionNotCountedAsChild.tsx_0_355
// @jsx: react,react-jsx,react-jsxdev // @strict: true /// <reference path="/.lib/react16.d.ts" /> import * as React from 'react' interface Props { children: React.ReactElement<any> } function Wrapper(props: Props) { return <div>{props.children}</div> } const element = ( <Wrapper> {/* comment */} ...
{ "end_byte": 355, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsxEmptyExpressionNotCountedAsChild.tsx" }
TypeScript/tests/cases/compiler/functionWithNoBestCommonType1.ts_0_111
// @allowUnreachableCode: true function foo() { return true; return bar(); } function bar(): void { }
{ "end_byte": 111, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionWithNoBestCommonType1.ts" }
TypeScript/tests/cases/compiler/decoratorMetadataRestParameterWithImportedType.ts_0_745
// @experimentalDecorators: true // @emitDecoratorMetadata: true // @target: es5 // @filename: aux.ts export class SomeClass { field: string; } // @filename: aux1.ts export class SomeClass1 { field: string; } // @filename: aux2.ts export class SomeClass2 { field: string; } // @filename: main.ts import { ...
{ "end_byte": 745, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/decoratorMetadataRestParameterWithImportedType.ts" }
TypeScript/tests/cases/compiler/jsFileClassPropertyType2.ts_0_192
// @allowJs: true // @noEmit: true // @filename: foo.js class C { constructor() { /** @type {number[]}*/ this.p = []; } } // @filename: bar.ts (new C()).p.push("string");
{ "end_byte": 192, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileClassPropertyType2.ts" }
TypeScript/tests/cases/compiler/sideEffectImports3.ts_0_215
// @noUncheckedSideEffectImports: true,false // @module: nodenext // @moduleDetection: legacy,auto,force // @filename: index.ts import "./not-a-module"; // @filename: not-a-module.ts console.log("Hello, world!");
{ "end_byte": 215, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sideEffectImports3.ts" }
TypeScript/tests/cases/compiler/collisionExportsRequireAndAmbientVar.ts_0_641
//@module: amd //@filename: collisionExportsRequireAndAmbientVar_externalmodule.ts export declare var exports: number; export declare var require: string; declare module m1 { var exports: string; var require: number; } module m2 { export declare var exports: number; export declare var require: string; ...
{ "end_byte": 641, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionExportsRequireAndAmbientVar.ts" }