_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/constructorArgsErrors1.ts_0_56
class foo { constructor (static a: number) { } }
{ "end_byte": 56, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constructorArgsErrors1.ts" }
TypeScript/tests/cases/compiler/typeGuardConstructorPrimitiveTypes.ts_0_849
// @target: esnext // Narrow a union of primitive types let var1: string | number | boolean | any[] | symbol | bigint; if (var1.constructor === String) { var1; // string } if (var1.constructor === Number) { var1; // number } if (var1.constructor === Boolean) { var1; // boolean } if (var1.constructor === Ar...
{ "end_byte": 849, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeGuardConstructorPrimitiveTypes.ts" }
TypeScript/tests/cases/compiler/illegalModifiersOnClassElements.ts_0_52
class C { declare foo = 1; export bar = 1; }
{ "end_byte": 52, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/illegalModifiersOnClassElements.ts" }
TypeScript/tests/cases/compiler/commentsAfterFunctionExpression1.ts_0_107
// @removeComments: false var v = { f: a => 0 /*t1*/, g: (a => 0) /*t2*/, h: (a => 0 /*t3*/) }
{ "end_byte": 107, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentsAfterFunctionExpression1.ts" }
TypeScript/tests/cases/compiler/bindingPatternCannotBeOnlyInferenceSource.ts_0_1130
// @strictNullChecks: true declare function f<T>(): T; const {} = f(); // error (only in strictNullChecks) const { p1 } = f(); // error const [] = f(); // error const [e1, e2] = f(); // error // Repro from #43605 type Dispatch<A = { type: any; [extraProps: string]: any }> = { <T extends A>(action: T): T...
{ "end_byte": 1130, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/bindingPatternCannotBeOnlyInferenceSource.ts" }
TypeScript/tests/cases/compiler/moduleExportsUnaryExpression.ts_0_260
// @module: commonjs let x = 1; export function foo(y: number) { if (y <= x++) return y <= x++; if (y <= x--) return y <= x--; if (y <= ++x) return y <= ++x; if (y <= --x) return y <= --x; x++; x--; ++x; --x; } export { x };
{ "end_byte": 260, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleExportsUnaryExpression.ts" }
TypeScript/tests/cases/compiler/implicitAnyDeclareMemberWithoutType.ts_0_286
// @noimplicitany: true // this should be an error interface IFace { member1; // error at "member1" member2: string; constructor(c1, c2: string, c3); // error at "c1, c3, "constructor" funcOfIFace(f1, f2, f3: number); // error at "f1, f2, funcOfIFace" new (); }
{ "end_byte": 286, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/implicitAnyDeclareMemberWithoutType.ts" }
TypeScript/tests/cases/compiler/jsxFactoryNotIdentifierOrQualifiedName.ts_0_1053
//@jsx: react //@target: es6 //@module: commonjs //@jsxFactory: Element.createElement= // @filename: Element.ts declare namespace JSX { interface Element { name: string; isIntrinsic: boolean; isCustomElement: boolean; toString(renderId?: number): string; bindDOM(renderId?: n...
{ "end_byte": 1053, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsxFactoryNotIdentifierOrQualifiedName.ts" }
TypeScript/tests/cases/compiler/enumCodeGenNewLines1.ts_0_39
enum foo { b = 1, c = 2, d = 3 }
{ "end_byte": 39, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumCodeGenNewLines1.ts" }
TypeScript/tests/cases/compiler/classUsedBeforeInitializedVariables.ts_0_1090
// @target: es5 class Test { p1 = 0; p2 = this.p1; p3 = this.p4; p4 = 0; p5?: number; p6?: string; p7 = { hello: (this.p6 = "string"), }; directlyAssigned: any = this.directlyAssigned; withinArrowFunction: any = () => this.withinArrowFunction; withinFunction: any...
{ "end_byte": 1090, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classUsedBeforeInitializedVariables.ts" }
TypeScript/tests/cases/compiler/assignmentToFunction.ts_0_129
function fn() { } fn = () => 3; module foo { function xyz() { function bar() { } bar = null; } }
{ "end_byte": 129, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentToFunction.ts" }
TypeScript/tests/cases/compiler/esModuleInteropImportTSLibHasImport.ts_0_620
// @esModuleInterop: true // @importHelpers: true // @noEmitHelpers: true // @target: es2017 // @module: commonjs // @filename: types.d.ts declare module "tslib" { export const __exportStar: any; export const __importDefault: any; export const __importStar: any; } // @filename: utils/username.ts export const username =...
{ "end_byte": 620, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/esModuleInteropImportTSLibHasImport.ts" }
TypeScript/tests/cases/compiler/contextualTypingOfAccessors.ts_0_148
// not contextually typing accessors var x: { foo: (x: number) => number; } x = { get foo() { return (n)=>n }, set foo(x) {} }
{ "end_byte": 148, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTypingOfAccessors.ts" }
TypeScript/tests/cases/compiler/typeUsedAsTypeLiteralIndex.ts_0_423
// @target: esnext type K = number | string; type T = { [K]: number; // Did you mean to use 'P in K'? } const K1 = Symbol(); type T1 = { [K1]: number; } type K2 = "x" | "y"; type T2 = { [K2]: number; // Did you mean to use 'K in K2'? } type K3 = number | string; type T3 = { [K3]: number; // Did yo...
{ "end_byte": 423, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeUsedAsTypeLiteralIndex.ts" }
TypeScript/tests/cases/compiler/commentOnImportStatement1.ts_0_90
// @module: amd // @removeComments: false /* Copyright */ import foo = require('./foo');
{ "end_byte": 90, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentOnImportStatement1.ts" }
TypeScript/tests/cases/compiler/exportDefaultClassAndValue.ts_0_61
const foo = 1 export default foo export default class Foo {}
{ "end_byte": 61, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportDefaultClassAndValue.ts" }
TypeScript/tests/cases/compiler/blockScopedVariablesUseBeforeDef.ts_0_2048
// @target: ES5 // @lib: esnext, dom function foo0() { let a = x; let x; } function foo1() { let a = () => x; let x; } function foo2() { let a = function () { return x; } let x; } function foo3() { class X { m() { return x;} } let x; } function foo4() { let y = class ...
{ "end_byte": 2048, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/blockScopedVariablesUseBeforeDef.ts" }
TypeScript/tests/cases/compiler/moduleResolutionWithModule.ts_0_344
// @moduleResolution: node16,nodenext // @module: commonjs,node16,nodenext // @filename: node_modules/pkg/package.json { "name": "pkg", "version": "0.0.1", "exports": "./entrypoint.js" } // @filename: node_modules/pkg/entrypoint.d.ts export declare function thing(): void; // @filename: index.ts import * as ...
{ "end_byte": 344, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolutionWithModule.ts" }
TypeScript/tests/cases/compiler/allowSyntheticDefaultImports6.ts_0_202
// @allowSyntheticDefaultImports: false // @module: system // @Filename: b.d.ts declare class Foo { member: string; } export = Foo; // @Filename: a.ts import Foo from "./b"; export var x = new Foo();
{ "end_byte": 202, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/allowSyntheticDefaultImports6.ts" }
TypeScript/tests/cases/compiler/es6ImportNamedImportIdentifiersParsing.ts_0_412
// @target: es6 import { yield } from "somemodule"; // Allowed import { default } from "somemodule"; // Error - as this is keyword that is not allowed as identifier import { yield as default } from "somemodule"; // error to use default as binding name import { default as yield } from "somemodule"; // no error import ...
{ "end_byte": 412, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ImportNamedImportIdentifiersParsing.ts" }
TypeScript/tests/cases/compiler/collisionRestParameterClassConstructor.ts_0_1453
// Constructors class c1 { constructor(_i: number, ...restParameters) { //_i is error var _i = 10; // no error } } class c1NoError { constructor(_i: number) { // no error var _i = 10; // no error } } class c2 { constructor(...restParameters) { var _i = 10; // no error } ...
{ "end_byte": 1453, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionRestParameterClassConstructor.ts" }
TypeScript/tests/cases/compiler/contextualTypingOfTooShortOverloads.ts_0_1162
// @lib: es5 // small repro from #11875 var use: Overload; use((req, res) => {}); interface Overload { (handler1: (req1: string) => void): void; (handler2: (req2: number, res2: number) => void): void; } // larger repro from #11875 let app: MyApp; app.use((err: any, req, res, next) => { return; }); interface ...
{ "end_byte": 1162, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTypingOfTooShortOverloads.ts" }
TypeScript/tests/cases/compiler/requireOfJsonFileWithModuleNodeResolutionEmitEsNext.ts_0_228
// @module: esnext // @moduleResolution: node // @outdir: out/ // @fullEmitPaths: true // @resolveJsonModule: true // @Filename: file1.ts import * as b from './b.json'; // @Filename: b.json { "a": true, "b": "hello" }
{ "end_byte": 228, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/requireOfJsonFileWithModuleNodeResolutionEmitEsNext.ts" }
TypeScript/tests/cases/compiler/useBeforeDeclaration_destructuring.ts_0_92
a; let {a, b = a} = {a: '', b: 1}; b; function test({c, d = c}: Record<string, number>) {}
{ "end_byte": 92, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/useBeforeDeclaration_destructuring.ts" }
TypeScript/tests/cases/compiler/moduleVariableArrayIndexer.ts_0_102
module Bar { export var a = 1; var t = undefined[a][a]; // CG: var t = undefined[Bar.a][a]; }
{ "end_byte": 102, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleVariableArrayIndexer.ts" }
TypeScript/tests/cases/compiler/superInLambdas.ts_0_1592
class User { name: string = "Bob"; sayHello(): void { //console.log("Hello, " + this.name); } } class RegisteredUser extends User { name: string = "Frank"; constructor() { super(); // super call in a constructor super.sayHello(); // super call in a lambda i...
{ "end_byte": 1592, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/superInLambdas.ts" }
TypeScript/tests/cases/compiler/declFileRestParametersOfFunctionAndFunctionType.ts_0_261
// @declaration: true function f1(...args) { } function f2(x: (...args) => void) { } function f3(x: { (...args): void }) { } function f4<T extends (...args) => void>() { } function f5<T extends { (...args): void }>() { } var f6 = () => { return [<any>10]; }
{ "end_byte": 261, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileRestParametersOfFunctionAndFunctionType.ts" }
TypeScript/tests/cases/compiler/es6-declaration-amd.ts_0_166
// @target: ES6 // @sourcemap: false // @declaration: true // @module: amd class A { constructor () { } public B() { return 42; } }
{ "end_byte": 166, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6-declaration-amd.ts" }
TypeScript/tests/cases/compiler/modifiersInObjectLiterals.ts_0_151
let data = { public foo: 'hey', private bar: 'nay', protected baz: 'oh my', abstract noWay: 'yes' }; data.foo + data.bar + data.baz + data.noWay
{ "end_byte": 151, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/modifiersInObjectLiterals.ts" }
TypeScript/tests/cases/compiler/es6ImportWithoutFromClauseNonInstantiatedModule.ts_0_256
// @target: es6 // @declaration: true // @filename: es6ImportWithoutFromClauseNonInstantiatedModule_0.ts export interface i { } // @filename: es6ImportWithoutFromClauseNonInstantiatedModule_1.ts import "es6ImportWithoutFromClauseNonInstantiatedModule_0";
{ "end_byte": 256, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ImportWithoutFromClauseNonInstantiatedModule.ts" }
TypeScript/tests/cases/compiler/jsxFactoryAndReactNamespace.ts_0_1079
//@jsx: react //@target: es6 //@module: commonjs //@reactNamespace: Element //@jsxFactory: Element.createElement // @filename: Element.ts declare namespace JSX { interface Element { name: string; isIntrinsic: boolean; isCustomElement: boolean; toString(renderId?: number): string; ...
{ "end_byte": 1079, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsxFactoryAndReactNamespace.ts" }
TypeScript/tests/cases/compiler/importInTypePosition.ts_0_423
module A { export class Point { constructor(public x: number, public y: number) { } } export var Origin = new Point(0, 0); } // no code gen expected module B { import a = A; //Error generates 'var <Alias> = <EntityName>;' } // no code gen expected module C { import a = A; //Error generate...
{ "end_byte": 423, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importInTypePosition.ts" }
TypeScript/tests/cases/compiler/assignmentToInstantiationExpression.ts_0_203
// @strict: true let obj: { fn?: <T>() => T } = {}; obj.fn<number> = () => 1234; let getValue: <T>() => T; getValue<number> = () => 1234; let getValue2!: <T>() => T; getValue2<number> = () => 1234;
{ "end_byte": 203, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentToInstantiationExpression.ts" }
TypeScript/tests/cases/compiler/assignToPrototype1.ts_0_105
declare class Point { add(dx: number, dy: number): void; } Point.prototype.add = function(dx, dy) { };
{ "end_byte": 105, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignToPrototype1.ts" }
TypeScript/tests/cases/compiler/duplicateObjectLiteralProperty_computedName1.ts_0_393
const t1 = { 1: 1, [1]: 0 // duplicate } const t2 = { 1: 1, [+1]: 0 // duplicate } const t3 = { "1": 1, [+1]: 0 // duplicate } const t4 = { "+1": 1, [+1]: 0 // two different keys, "+1", "1" } const t5 = { "+1": 1, ["+1"]: 0 // duplicate } const t6 = { "-1": 1, [-1]: ...
{ "end_byte": 393, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateObjectLiteralProperty_computedName1.ts" }
TypeScript/tests/cases/compiler/duplicateInterfaceMembers1.ts_0_46
interface Bar { x: number; x: number; }
{ "end_byte": 46, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateInterfaceMembers1.ts" }
TypeScript/tests/cases/compiler/narrowByEquality.ts_0_834
// @strict: true declare let x: number | string | boolean declare let n: number; declare let s: string; declare let b: boolean; declare let xUnknown: unknown; if (x == n) { x; } if (x == s) { x; } if (x == b) { x; } if (x == 1) { x; } if (x == "") { x; } if (x == "foo") { x; } if (x == t...
{ "end_byte": 834, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowByEquality.ts" }
TypeScript/tests/cases/compiler/assignmentCompatBug5.ts_0_200
function foo1(x: { a: number; }) { } foo1({ b: 5 }); function foo2(x: number[]) { } foo2(["s", "t"]); function foo3(x: (n: number) =>number) { }; foo3((s:string) => { }); foo3((n) => { return; });
{ "end_byte": 200, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatBug5.ts" }
TypeScript/tests/cases/compiler/bluebirdStaticThis.ts_0_230
// This version is reduced from the full d.ts by removing almost all the tests // and all the comments. // Then it adds explicit `this` arguments to the static members. // Tests by: Bart van der Schoor <https://github.com/Bartvds>
{ "end_byte": 230, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/bluebirdStaticThis.ts" }
TypeScript/tests/cases/compiler/bluebirdStaticThis.ts_231_7670
export declare class Promise<R> implements Promise.Thenable<R> { constructor(callback: (resolve: (thenableOrResult: R | Promise.Thenable<R>) => void, reject: (error: any) => void) => void); static try<R>(dit: typeof Promise, fn: () => Promise.Thenable<R>, args?: any[], ctx?: any): Promise<R>; static try<R>(dit...
{ "end_byte": 7670, "start_byte": 231, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/bluebirdStaticThis.ts" }
TypeScript/tests/cases/compiler/bluebirdStaticThis.ts_7675_9380
static filter<R>(dit: typeof Promise, values: Promise.Thenable<R[]>, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable<boolean>): Promise<R[]>; static filter<R>(dit: typeof Promise, values: Promise.Thenable<R[]>, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise<...
{ "end_byte": 9380, "start_byte": 7675, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/bluebirdStaticThis.ts" }
TypeScript/tests/cases/compiler/doNotEmitTripleSlashCommentsOnNotEmittedNode.ts_3_185
@removeComments: true // @Filename: file0.ts /// <reference path="file1.ts" /> declare var OData: any; // @Filename: file1.ts /// <reference path="file0.ts" /> interface F { }
{ "end_byte": 185, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/doNotEmitTripleSlashCommentsOnNotEmittedNode.ts" }
TypeScript/tests/cases/compiler/importAnImport.ts_0_76
module c.a.b { import ma = a; } module m0 { import m8 = c.a.b.ma; }
{ "end_byte": 76, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importAnImport.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationDestructuringParametertArrayBindingPattern2.ts_0_705
// @lib: es5 // @sourcemap: true declare var console: { log(msg: any): void; } type Robot = [string, [string, string]]; var robotA: Robot = ["trimmer", ["trimming", "edging"]]; function foo1([, skillA]: Robot) { console.log(skillA); } function foo2([nameMB]: Robot) { console.log(nameMB); } function foo3(...
{ "end_byte": 705, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationDestructuringParametertArrayBindingPattern2.ts" }
TypeScript/tests/cases/compiler/subclassUint8Array.ts_0_94
// @target: esnext // @lib: esnext // @noEmit: true class CustomBuffer extends Uint8Array { }
{ "end_byte": 94, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/subclassUint8Array.ts" }
TypeScript/tests/cases/compiler/constructorTypeWithTypeParameters.ts_0_139
// @declaration: true declare var X: { new <T>(): number; } declare var Y: { new (): number; } var anotherVar: new <T>() => number;
{ "end_byte": 139, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constructorTypeWithTypeParameters.ts" }
TypeScript/tests/cases/compiler/indirectUniqueSymbolDeclarationEmit.ts_0_173
// @lib: es6 // @declaration: true export const x = Symbol(); export const y = Symbol(); declare function rand(): boolean; export function f() { return rand() ? x : y; }
{ "end_byte": 173, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/indirectUniqueSymbolDeclarationEmit.ts" }
TypeScript/tests/cases/compiler/importWithTrailingSlash_noResolve.ts_0_100
// @traceResolution: true // @moduleResolution: node // @Filename: /a.ts import foo from "./foo/";
{ "end_byte": 100, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importWithTrailingSlash_noResolve.ts" }
TypeScript/tests/cases/compiler/functionAndInterfaceWithSeparateErrors.ts_3_117
nction Foo(s: string); function Foo(n: number) { } interface Foo { [s: string]: string; prop: number; }
{ "end_byte": 117, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionAndInterfaceWithSeparateErrors.ts" }
TypeScript/tests/cases/compiler/overloadWithCallbacksWithDifferingOptionalityOnArgs.ts_0_167
function x2(callback: (x?: number) => number); function x2(callback: (x: string) => number); function x2(callback: (x: any) => number) { } x2(() => 1); x2((x) => 1 );
{ "end_byte": 167, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overloadWithCallbacksWithDifferingOptionalityOnArgs.ts" }
TypeScript/tests/cases/compiler/pushTypeGetTypeOfAlias.ts_0_140
// @checkJs: true // @allowJs: true // @noEmit: true // @Filename: bar.js module.exports = function () {}; exports.blah = exports.someProp;
{ "end_byte": 140, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/pushTypeGetTypeOfAlias.ts" }
TypeScript/tests/cases/compiler/nestedBlockScopedBindings8.ts_0_88
var x; for (let x; false; ) { () => x; } var y; for (let y; false; ) { y = 1; }
{ "end_byte": 88, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nestedBlockScopedBindings8.ts" }
TypeScript/tests/cases/compiler/es6ImportNamedImportInExportAssignment.ts_0_271
// @target: es6 // @module: commonjs // @declaration: true // @filename: es6ImportNamedImportInExportAssignment_0.ts export var a = 10; // @filename: es6ImportNamedImportInExportAssignment_1.ts import { a } from "./es6ImportNamedImportInExportAssignment_0"; export = a;
{ "end_byte": 271, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ImportNamedImportInExportAssignment.ts" }
TypeScript/tests/cases/compiler/indexTypeNoSubstitutionTemplateLiteral.ts_0_95
// @strict: true function Foo() {} Foo[`b`] = function () {}; type Test = keyof typeof Foo;
{ "end_byte": 95, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/indexTypeNoSubstitutionTemplateLiteral.ts" }
TypeScript/tests/cases/compiler/narrowingOrderIndependent.ts_0_546
// @strict: true // Repro from #36709 class A { constructor(public stringOrUndefined: string | undefined) {} } class B { constructor(public str: string) {} } const a = new A("123"); if (a instanceof A && a.stringOrUndefined) { new B(a.stringOrUndefined) } if (a.stringOrUndefined && a instanceof A) { ...
{ "end_byte": 546, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowingOrderIndependent.ts" }
TypeScript/tests/cases/compiler/bigIntWithTargetLessThanES2016.ts_0_133
// @target: es2015 // @lib: esnext BigInt(1) ** BigInt(1); // should error let foo = BigInt(2); foo **= BigInt(2); // should error
{ "end_byte": 133, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/bigIntWithTargetLessThanES2016.ts" }
TypeScript/tests/cases/compiler/reactReadonlyHOCAssignabilityReal.tsx_0_375
// @strict: true // @jsx: react /// <reference path="/.lib/react16.d.ts" /> import * as React from "react"; function myHigherOrderComponent<P>(Inner: React.ComponentClass<P & {name: string}>): React.ComponentClass<P> { return class OuterComponent extends React.Component<P> { render() { return <...
{ "end_byte": 375, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reactReadonlyHOCAssignabilityReal.tsx" }
TypeScript/tests/cases/compiler/mappedTypeContextualTypesApplied.ts_0_1126
// @strict: true type TakeString = (s: string) => any; // Various functions accepting an object whose properties are TakeString functions. // Note these all use mapped types. declare function mapped1<T extends {[P in string]: TakeString}>(obj: T): void; declare function mapped2<T extends {[P in keyof T]: TakeString}>(...
{ "end_byte": 1126, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mappedTypeContextualTypesApplied.ts" }
TypeScript/tests/cases/compiler/commentEmitAtEndOfFile1.ts_0_139
// @allowUnusedLabels: true // test var f = '' // test #2 module foo { function bar() { } } // test #3 module empty { } // test #4
{ "end_byte": 139, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentEmitAtEndOfFile1.ts" }
TypeScript/tests/cases/compiler/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts_0_367
type AnyFunction = (...args: any[]) => any; type Params<T> = Parameters<Extract<T, AnyFunction>>; interface Wrapper<T> { call<K extends keyof T>(event: K, ...args: Params<T[K]>): void; } interface AWrapped { foo(): void; } class A { foo: Wrapper<AWrapped>; } interface BWrapped extends AWrapped { bar(): void; } ...
{ "end_byte": 367, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts" }
TypeScript/tests/cases/compiler/inheritedMembersAndIndexSignaturesFromDifferentBases2.ts_0_128
interface A<T> { [n: number]: T; } interface B { foo: number; } interface C extends B, A<string> { } // Should succeed
{ "end_byte": 128, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inheritedMembersAndIndexSignaturesFromDifferentBases2.ts" }
TypeScript/tests/cases/compiler/conditionalTypeGenericInSignatureTypeParameterConstraint.ts_0_150
// should be x type H_inline1<x> = (<o extends x>() => o) extends (() => infer o) ? o : never; type Result = H_inline1<string>; // should be `string`
{ "end_byte": 150, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/conditionalTypeGenericInSignatureTypeParameterConstraint.ts" }
TypeScript/tests/cases/compiler/jsFileCompilationRestParameter.ts_0_94
// @allowJs: true // @filename: a.js // @target: es6 // @outFile: b.js function foo(...a) { }
{ "end_byte": 94, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationRestParameter.ts" }
TypeScript/tests/cases/compiler/genericDefaultsErrors.ts_0_1340
// @declaration: true declare const x: any; declare function f03<T extends string = number>(): void; // error declare function f04<T extends string, U extends number = T>(): void; // error declare function f05<T, U extends number = T>(): void; // error declare function f06<T, U extends T = number>(): void; // error ...
{ "end_byte": 1340, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericDefaultsErrors.ts" }
TypeScript/tests/cases/compiler/spellingSuggestionLeadingUnderscores01.ts_0_176
// @module: commonjs // @filename abc.ts export declare let a: { __foo: 10, } a.___foo // @filename def.ts export let b: { __foo: number } b = { ___foo: 100, }
{ "end_byte": 176, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/spellingSuggestionLeadingUnderscores01.ts" }
TypeScript/tests/cases/compiler/isolatedModulesImportConstEnum.ts_0_183
// @isolatedModules: true // @module: commonjs // @filename: file1.ts import { Foo } from './file2'; console.log(Foo.BAR); // @filename: file2.ts export const enum Foo { BAR, }
{ "end_byte": 183, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/isolatedModulesImportConstEnum.ts" }
TypeScript/tests/cases/compiler/commentOnArrayElement14.ts_3_36
nst array = [1 /* comment */];
{ "end_byte": 36, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentOnArrayElement14.ts" }
TypeScript/tests/cases/compiler/commentsExternalModules2.ts_0_1341
// @module: amd // @target: ES5 // @declaration: true // @removeComments: false // @Filename: commentsExternalModules2_0.ts /** Module comment*/ export module m1 { /** b's comment*/ export var b: number; /** foo's comment*/ function foo() { return b; } /** m2 comments*/ export modul...
{ "end_byte": 1341, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentsExternalModules2.ts" }
TypeScript/tests/cases/compiler/isolatedModulesReExportAlias.ts_0_575
// @isolatedModules: true // @noEmit: true // @noTypesAndSymbols: true // @Filename: /events.d.ts declare module "events" { interface EventEmitterOptions { captureRejections?: boolean; } class EventEmitter { constructor(options?: EventEmitterOptions); } export = EventEmitter; } declare module "node:e...
{ "end_byte": 575, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/isolatedModulesReExportAlias.ts" }
TypeScript/tests/cases/compiler/unionTypeWithLeadingOperator.ts_0_241
// @declaration: true type A = | string; type B = | { type: "INCREMENT" } | { type: "DECREMENT" }; type C = [| 0 | 1, | "foo" | "bar"]; export type D = /*leading0*/ | /*leading1*/ 1 /*trailing1*/ | /*leading2*/ 2 /*trailing2*/;
{ "end_byte": 241, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unionTypeWithLeadingOperator.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationDo.ts_0_94
// @sourcemap: true var i = 0; do { i++; } while (i < 10); do { i++; } while (i < 20);
{ "end_byte": 94, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationDo.ts" }
TypeScript/tests/cases/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.ts_0_1255
// @allowJs: true // @checkJs: true // @strict: true // @target: esnext // @module: nodenext // @moduleResolution: nodenext // @declaration: true // @emitDeclarationOnly: true // @outDir: ./dist-types // @filename: package.json { "name": "typescript-issue", "private": true, "version": "0.0.0", "type": "...
{ "end_byte": 1255, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.ts" }
TypeScript/tests/cases/compiler/contextualTyping26.ts_0_60
function foo(param:{id:number;}){}; foo(<{id:number;}>({}));
{ "end_byte": 60, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTyping26.ts" }
TypeScript/tests/cases/compiler/declarationEmitExpressionInExtends.ts_0_139
// @declaration: true var x: { new<T>(s: any): Q; } class Q { s: string; } class B extends x<string> { } var q: B; q.s;
{ "end_byte": 139, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitExpressionInExtends.ts" }
TypeScript/tests/cases/compiler/objectLitArrayDeclNoNew.ts_0_514
// @lib: es5 declare var console; "use strict"; module Test { export interface IState { } export interface IToken { } export interface ILineTokens { tokens: IToken[]; endState: IState; } export class Gar { public moo: number = 0; } export function bug(): I...
{ "end_byte": 514, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectLitArrayDeclNoNew.ts" }
TypeScript/tests/cases/compiler/indexAt.ts_0_343
// @target: es2021, es2022, esnext [0].at(0); "foo".at(0); new Int8Array().at(0); new Uint8Array().at(0); new Uint8ClampedArray().at(0); new Int16Array().at(0); new Uint16Array().at(0); new Int32Array().at(0); new Uint32Array().at(0); new Float32Array().at(0); new Float64Array().at(0); new BigInt64Array().at(0); new B...
{ "end_byte": 343, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/indexAt.ts" }
TypeScript/tests/cases/compiler/newLexicalEnvironmentForConvertedLoop.ts_0_209
// @target: es5 function baz(x: any) { return [[x, x]]; } function foo(set: any) { for (const [value, i] of baz(set.values)) { const bar: any = []; (() => bar); set.values.push(...[]); } };
{ "end_byte": 209, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/newLexicalEnvironmentForConvertedLoop.ts" }
TypeScript/tests/cases/compiler/letInVarDeclOfForOf_ES5.ts_0_105
// @target: es5 // should not be an error for (var let of [1,2,3]) {} { for (var let of [1,2,3]) {} }
{ "end_byte": 105, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/letInVarDeclOfForOf_ES5.ts" }
TypeScript/tests/cases/compiler/genericMethodOverspecialization.ts_0_513
var names = ["list", "table1", "table2", "table3", "summary"]; interface HTMLElement { clientWidth: number; isDisabled: boolean; } declare var document: Document; interface Document { getElementById(elementId: string): HTMLElement; } var elements = names.map(function (name) { return document.getEleme...
{ "end_byte": 513, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericMethodOverspecialization.ts" }
TypeScript/tests/cases/compiler/mergeSymbolReexportInterface.ts_0_365
// @moduleResolution: node // @filename: main.ts import {Row2, C} from '.' const x : Row2 = { } const y : C = { s: '' } // @filename: ./a.d.ts import '.' declare module '.' { type Row2 = { a: string } type C = { s : string } } // @filename: ./index.d.ts export type {Row2} from './common'; // @filename: ./co...
{ "end_byte": 365, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mergeSymbolReexportInterface.ts" }
TypeScript/tests/cases/compiler/aliasUsedAsNameValue.ts_0_520
// @module: commonjs // @Filename: aliasUsedAsNameValue_0.ts export var id: number; // @Filename: aliasUsedAsNameValue_1.ts export function b(a: any): any { return null; } // @Filename: aliasUsedAsNameValue_2.ts ///<reference path='aliasUsedAsNameValue_0.ts' /> ///<reference path='aliasUsedAsNameValue_1.ts' /> import...
{ "end_byte": 520, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/aliasUsedAsNameValue.ts" }
TypeScript/tests/cases/compiler/declarationEmitPathMappingMonorepo2.ts_0_1352
// @filename: packages/core/src/index.d.ts export * from "./utils"; export { default as SvgIcon } from "./SvgIcon"; // @filename: packages/core/src/SvgIcon.d.ts import { StyledComponentProps } from "@ts-bug/styles"; export interface SvgIconProps extends StyledComponentProps<"root"> { children?: string[]; } export ...
{ "end_byte": 1352, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitPathMappingMonorepo2.ts" }
TypeScript/tests/cases/compiler/controlFlowForIndexSignatures.ts_0_553
// @strictNullChecks: true type Foo = { bar: string }; const boo: Foo = { bar: 'bar' }; function a(aboo1?: Foo) { if (!aboo1) return; const aboo2: { [key: string]: typeof aboo1.bar } = boo; } declare let b: Foo | undefined; if (b) { const bboo: { [key: string]: typeof b.bar } = boo; } b = boo; const bboo...
{ "end_byte": 553, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/controlFlowForIndexSignatures.ts" }
TypeScript/tests/cases/compiler/typeParameterArgumentEquivalence3.ts_0_146
function foo<T,U>() { var x: (item) => T; var y: (item) => boolean; x = y; // Should be an error y = x; // Shound be an error }
{ "end_byte": 146, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeParameterArgumentEquivalence3.ts" }
TypeScript/tests/cases/compiler/exportingContainingVisibleType.ts_0_176
//@module: amd class Foo { public get foo() { var i: Foo; return i; // Should be fine (previous bug report visibility error). } } export var x = 5;
{ "end_byte": 176, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportingContainingVisibleType.ts" }
TypeScript/tests/cases/compiler/contextualOuterTypeParameters.ts_0_876
// @strict: true // @noemit: true // https://github.com/microsoft/TypeScript/issues/59450 declare function f(fun: <T>(t: T) => void): void f(t => { type isArray = (typeof t)[] extends string[] ? true : false; type IsObject = { x: typeof t } extends { x: string } ? true : false; }); const fn1: <T>(x: T) => v...
{ "end_byte": 876, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualOuterTypeParameters.ts" }
TypeScript/tests/cases/compiler/extendFromAny.ts_0_302
declare var Base: any; class C extends Base { known = 1; static sknown = 2; } let c = new C(); c.known.length; // error, 'known' has no 'length' property C.sknown.length; // error, 'sknown' has no 'length' property c.unknown.length; // ok, unknown: any C.sunknown.length; // ok: sunknown: any
{ "end_byte": 302, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/extendFromAny.ts" }
TypeScript/tests/cases/compiler/assignToObjectTypeWithPrototypeProperty.ts_0_86
class XEvent {} var p: XEvent = XEvent.prototype; var x: {prototype: XEvent} = XEvent;
{ "end_byte": 86, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignToObjectTypeWithPrototypeProperty.ts" }
TypeScript/tests/cases/compiler/jsFileCompilationInterfaceSyntax.ts_0_52
// @allowJs: true // @filename: a.js interface I { }
{ "end_byte": 52, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationInterfaceSyntax.ts" }
TypeScript/tests/cases/compiler/emitMemberAccessExpression.ts_0_698
// @Filename: emitMemberAccessExpression_file1.ts /// <reference path="emitMemberAccessExpression_file3.ts" /> "use strict"; // @Filename: emitMemberAccessExpression_file2.ts /// <reference path="emitMemberAccessExpression_file3.ts" /> "use strict"; module Microsoft.PeopleAtWork.Model { export class _Person { ...
{ "end_byte": 698, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emitMemberAccessExpression.ts" }
TypeScript/tests/cases/compiler/declarationEmitToDeclarationDirWithCompositeOption.ts_0_208
// @composite: true // @filename: /foo/tsconfig.json { "compilerOptions": { "composite": true, "declarationDir": "out" } } // @filename: /foo/test.ts interface Foo { x: number; } export default Foo;
{ "end_byte": 208, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitToDeclarationDirWithCompositeOption.ts" }
TypeScript/tests/cases/compiler/interfaceInReopenedModule.ts_0_168
module m { } // In second instance of same module, exported interface is not visible module m { interface f {} export class n { private n: f; } }
{ "end_byte": 168, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/interfaceInReopenedModule.ts" }
TypeScript/tests/cases/compiler/assignmentCompatability5.ts_0_437
module __test1__ { export interface interfaceWithPublicAndOptional<T,U> { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional<number,string> = { one: 1 };; export var __val__obj4 = obj4; } module __test2__ { export interface interfaceOne<T> { one: T; }; var obj1: i...
{ "end_byte": 437, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatability5.ts" }
TypeScript/tests/cases/compiler/declarationEmitDestructuring1.ts_0_326
// @declaration: true function foo([a, b, c]: [string, string, string]): void { } function far([a, [b], [[c]]]: [number, boolean[], string[][]]): void { } function bar({a1, b1, c1}: { a1: number, b1: boolean, c1: string }): void { } function baz({a2, b2: {b1, c1}}: { a2: number, b2: { b1: boolean, c1: string } }): void...
{ "end_byte": 326, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitDestructuring1.ts" }
TypeScript/tests/cases/compiler/inferRestArgumentsMappedTuple.ts_0_920
// @strict: true type MyMappedType<Primitive extends any> = { primitive: Primitive; }; type TupleMapperOld<Tuple extends any[]> = { [Key in keyof Tuple]: Tuple[Key] extends Tuple[number] ? MyMappedType<Tuple[Key]> : never; }; type MyMappedTupleOld = TupleMapperOld<[string, number]>; // [MyMappedType<string>, MyMap...
{ "end_byte": 920, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inferRestArgumentsMappedTuple.ts" }
TypeScript/tests/cases/compiler/isolatedModulesImportConstEnumTypeOnly.ts_0_166
// @isolatedModules: true // @filename: enum.ts export const enum Foo { Bar } // @filename: index.ts import { Foo } from "./enum"; function f(foo: Foo) { return; }
{ "end_byte": 166, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/isolatedModulesImportConstEnumTypeOnly.ts" }
TypeScript/tests/cases/compiler/overloadingOnConstants1.ts_0_868
class Base { foo() { } } class Derived1 extends Base { bar() { } } class Derived2 extends Base { baz() { } } class Derived3 extends Base { biz() { } } interface Document2 { createElement(tagName: 'canvas'): Derived1; createElement(tagName: 'div'): Derived2; createElement(tagName: 'span'): Derived3; cre...
{ "end_byte": 868, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overloadingOnConstants1.ts" }
TypeScript/tests/cases/compiler/arguments.ts_0_334
// @target: ES6 function f() { var x=arguments[12]; (() => arguments)(); } (() => arguments)(); interface I { method(args: typeof arguments): void; fn: (args: typeof arguments) => void; (args: typeof arguments): void; new (args: typeof arguments): void; construct: new (args: typeof argumen...
{ "end_byte": 334, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arguments.ts" }
TypeScript/tests/cases/compiler/nonNullableWithNullableGenericIndexedAccessArg.ts_0_695
// @noEmit: true // @strict: true // repro from #50539 interface StateSchema { states?: { [key: string]: StateSchema; }; } declare class StateNode<TStateSchema extends StateSchema> { schema: TStateSchema; } type StateNodesConfig<TStateSchema extends StateSchema> = { [K in keyof TStateSchema["states"]]: ...
{ "end_byte": 695, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nonNullableWithNullableGenericIndexedAccessArg.ts" }
TypeScript/tests/cases/compiler/debuggerEmit.ts_0_38
var x = function () { debugger; } x();
{ "end_byte": 38, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/debuggerEmit.ts" }