_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/unexportedInstanceClassVariables.ts_0_101
module M{ class A{ constructor(val:string){} } } module M{ class A {} var a = new A(); }
{ "end_byte": 101, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unexportedInstanceClassVariables.ts" }
TypeScript/tests/cases/compiler/nonArrayRestArgs.ts_0_79
function foo(...rest: number) { // error var x: string = rest[0]; return x; }
{ "end_byte": 79, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nonArrayRestArgs.ts" }
TypeScript/tests/cases/compiler/vardecl.ts_0_1578
// @declaration: true var simpleVar; var anotherVar: any; var varWithSimpleType: number; var varWithArrayType: number[]; var varWithInitialValue = 30; var withComplicatedValue = { x: 30, y: 70, desc: "position" }; declare var declaredVar; declare var declareVar2 declare var declaredVar3; declare var deckareVarWith...
{ "end_byte": 1578, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/vardecl.ts" }
TypeScript/tests/cases/compiler/conditionalExpressionNewLine1.ts_0_18
var v = a ? b : c;
{ "end_byte": 18, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/conditionalExpressionNewLine1.ts" }
TypeScript/tests/cases/compiler/discriminantNarrowingCouldBeCircular.ts_0_1121
// @strict: true // @lib: es2022 // #57705, 57690 declare function is<T>(v: T): v is T; const o: Record<string, string> | undefined = {}; if (o) { for (const key in o) { const value = o[key]; if (is<string>(value)) { } } } type SomeRecord = { a: string }; declare const kPresentationInheritanceParents:...
{ "end_byte": 1121, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/discriminantNarrowingCouldBeCircular.ts" }
TypeScript/tests/cases/compiler/staticInstanceResolution2.ts_0_100
class A { } A.hasOwnProperty('foo'); class B { constructor() { } } B.hasOwnProperty('foo');
{ "end_byte": 100, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/staticInstanceResolution2.ts" }
TypeScript/tests/cases/compiler/primaryExpressionMods.ts_0_407
module M { export interface P { x: number; y: number; } export var a = 1; } var p: M.P; // Used as ModuleName var m: M = M; // Used as TypeName and PrimaryExpression (error on TypeName) var m2: typeof M = M; // Used as PrimaryExpression in TypeQuery var x1 = M.a; // Used as Pri...
{ "end_byte": 407, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/primaryExpressionMods.ts" }
TypeScript/tests/cases/compiler/genericOverloadSignatures.ts_0_402
interface A { <T>(x: T): void; <T>(x: T): void; } function f<T>(a: T); function f<T>(a: T); function f(a) { } interface I2 { f<T>(x: T): number; f<T>(x: T): string; } interface I3<T> { f(x: T): number; f(x: T): string; } class C2<T> { } var b: { new <T>(x: T, y: string): C2<T>; new <...
{ "end_byte": 402, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericOverloadSignatures.ts" }
TypeScript/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.ts_0_224
// @module: commonjs // @declaration: true // @filename: server.ts export var a = 10; // @filename: client.ts export import defaultBinding, * as nameSpaceBinding from "./server"; export var x: number = nameSpaceBinding.a;
{ "end_byte": 224, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.ts" }
TypeScript/tests/cases/compiler/unusedImports14.ts_0_363
//@noUnusedLocals:true //@module: commonjs //@jsx: react // @filename: foo.tsx import React = 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 createClass<P, S>(spec); } decl...
{ "end_byte": 363, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedImports14.ts" }
TypeScript/tests/cases/compiler/intersectionsOfLargeUnions2.ts_0_966
// @strict: true // Repro from #24233 declare global { interface ElementTagNameMap { [index: number]: HTMLElement } interface HTMLElement { [index: number]: HTMLElement; } } export function assertIsElement(node: Node | null): node is Element { let nodeType = node === null ? null ...
{ "end_byte": 966, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/intersectionsOfLargeUnions2.ts" }
TypeScript/tests/cases/compiler/privacyFunctionParameterDeclFile.ts_0_4835
// @module: commonjs // @declaration: true // @Filename:privacyFunctionParameterDeclFile_externalModule.ts class privateClass { } export class publicClass { } export interface publicInterfaceWithPrivateParmeterTypes { new (param: privateClass): publicClass; // Error (param: privateClass): publicClass; // Err...
{ "end_byte": 4835, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyFunctionParameterDeclFile.ts" }
TypeScript/tests/cases/compiler/privacyFunctionParameterDeclFile.ts_4837_10060
export module publicModule { class privateClass { } export class publicClass { } export interface publicInterfaceWithPrivateParmeterTypes { new (param: privateClass): publicClass; // Error (param: privateClass): publicClass; // Error myMethod(param: privateClass): void; //...
{ "end_byte": 10060, "start_byte": 4837, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyFunctionParameterDeclFile.ts" }
TypeScript/tests/cases/compiler/privacyFunctionParameterDeclFile.ts_10062_16086
module privateModule { class privateClass { } export class publicClass { } export interface publicInterfaceWithPrivateParmeterTypes { new (param: privateClass): publicClass; (param: privateClass): publicClass; myMethod(param: privateClass): void; } export interface...
{ "end_byte": 16086, "start_byte": 10062, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyFunctionParameterDeclFile.ts" }
TypeScript/tests/cases/compiler/privacyFunctionParameterDeclFile.ts_16088_26024
module publicModuleInGlobal { class privateClass { } export class publicClass { } module privateModule { class privateClass { } export class publicClass { } export interface publicInterfaceWithPrivateParmeterTypes { new (param: privateClass): p...
{ "end_byte": 26024, "start_byte": 16088, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyFunctionParameterDeclFile.ts" }
TypeScript/tests/cases/compiler/privacyFunctionParameterDeclFile.ts_26030_26855
interface privateInterfaceWithPrivateModuleParameterTypes { new (param: privateModule.publicClass): publicClass; (param: privateModule.publicClass): publicClass; myMethod(param: privateModule.publicClass): void; } class privateClassWithPrivateModuleParameterTypes { static myPubli...
{ "end_byte": 26855, "start_byte": 26030, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyFunctionParameterDeclFile.ts" }
TypeScript/tests/cases/compiler/commentsAfterCaseClauses2.ts_3_424
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: // default retur...
{ "end_byte": 424, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentsAfterCaseClauses2.ts" }
TypeScript/tests/cases/compiler/declarationEmitPrivateSymbolCausesVarDeclarationEmit2.ts_0_297
// @declaration: true // @lib: es6 // @filename: a.ts export const x = Symbol(); // @filename: b.ts import { x } from "./a"; export class C { private [x]: number = 1; } // @filename: c.ts import { x } from "./a"; import { C } from "./b"; export class D extends C { private [x]: 12 = 12; }
{ "end_byte": 297, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitPrivateSymbolCausesVarDeclarationEmit2.ts" }
TypeScript/tests/cases/compiler/avoidCycleWithVoidExpressionReturnedFromArrow.ts_0_414
// @strict: true // @noEmit: true type HowlErrorCallback = (soundId: number, error: unknown) => void; interface HowlOptions { onplayerror?: HowlErrorCallback | undefined; } class Howl { constructor(public readonly options: HowlOptions) {} once(name: "unlock", fn: () => void) { console.log(name, fn); } } ...
{ "end_byte": 414, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/avoidCycleWithVoidExpressionReturnedFromArrow.ts" }
TypeScript/tests/cases/compiler/promisePermutations3.ts_0_6478
// same as promisePermutations but without the same overloads in IPromise<T> interface Promise<T> { then<U>(success?: (value: T) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; then<U>(success?: (value: T) => Promise<U>, error?: (error: any) => U, progress?: ...
{ "end_byte": 6478, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/promisePermutations3.ts" }
TypeScript/tests/cases/compiler/promisePermutations3.ts_6479_10002
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, sPromise); // ok? var r...
{ "end_byte": 10002, "start_byte": 6479, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/promisePermutations3.ts" }
TypeScript/tests/cases/compiler/narrowedImports.ts_0_452
// @strictNullChecks: true // @Filename: /a.d.ts declare const a0: number | undefined; export default a0; export const a1: number | undefined; // @Filename: /b.d.ts declare const b: number | undefined; declare namespace b {} export = b; // @Filename: /x.ts import a0, { a1, a1 as a2 } from "./a"; import * as b0 from ...
{ "end_byte": 452, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowedImports.ts" }
TypeScript/tests/cases/compiler/genericFunctionTypedArgumentsAreFixed.ts_0_84
declare function map<T, U>(f: (x: T) => U, xs: T[]): U[]; map((a) => a.length, [1]);
{ "end_byte": 84, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericFunctionTypedArgumentsAreFixed.ts" }
TypeScript/tests/cases/compiler/argumentsUsedInObjectLiteralProperty.ts_0_176
class A { public static createSelectableViewModel(initialState?: any, selectedValue?: any) { return { selectedValue: arguments.length }; } }
{ "end_byte": 176, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/argumentsUsedInObjectLiteralProperty.ts" }
TypeScript/tests/cases/compiler/overloadResolutionOverNonCTLambdas.ts_0_577
module Bugs { class A { } // replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; function bug2(message:string, ...args:any[]):string { var result= message.replace(/\{(\d+)\}/g, function(match, ...rest) { var index= rest[0]; return typeof args[ind...
{ "end_byte": 577, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overloadResolutionOverNonCTLambdas.ts" }
TypeScript/tests/cases/compiler/genericTypeArgumentInference1.ts_0_455
module Underscore { export interface Iterator<T, U> { (value: T, index: any, list: any): U; } export interface Static { all<T>(list: T[], iterator?: Iterator<T, boolean>, context?: any): T; identity<T>(value: T): T; } } declare var _: Underscore.Static; var r = _.all([true, 1, n...
{ "end_byte": 455, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericTypeArgumentInference1.ts" }
TypeScript/tests/cases/compiler/invariantGenericErrorElaboration.ts_0_581
// @strict: true // Repro from #19746 const wat: Runtype<any> = Num; const Foo = Obj({ foo: Num }) interface Runtype<A> { constraint: Constraint<this> witness: A } interface Num extends Runtype<number> { tag: 'number' } declare const Num: Num interface Obj<O extends { [_ in string]: Runtype<any> }> extends R...
{ "end_byte": 581, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/invariantGenericErrorElaboration.ts" }
TypeScript/tests/cases/compiler/recursiveFieldSetting.ts_0_345
// #32721 class Recursive1 { constructor(private readonly parent?: Recursive1) {} private depth: number = this.parent ? this.parent.depth + 1 : 0; } class Recursive2 { parent!: Recursive2; depth: number = this.parent.depth; } class Recursive3 { parent!: Recursive3; depth: number = this.parent...
{ "end_byte": 345, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveFieldSetting.ts" }
TypeScript/tests/cases/compiler/inferenceFromIncompleteSource.ts_0_267
// @strict: true // Repro from #42030 interface ListProps<T, K extends keyof T> { items: T[]; itemKey: K; prop: number; } declare const Component: <T, K extends keyof T>(x: ListProps<T, K>) => void; Component({items: [{name:' string'}], itemKey: 'name' });
{ "end_byte": 267, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inferenceFromIncompleteSource.ts" }
TypeScript/tests/cases/compiler/signatureLengthMismatchWithOptionalParameters.ts_0_119
function callee(n: number | undefined, m: string) { } function caller(arg: (n?: number) => void) { } caller(callee);
{ "end_byte": 119, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/signatureLengthMismatchWithOptionalParameters.ts" }
TypeScript/tests/cases/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts_3_184
@target: ES6 class A { blub = 6; } class B extends A { constructor(public x: number) { "use strict"; 'someStringForEgngInject'; super() } }
{ "end_byte": 184, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts" }
TypeScript/tests/cases/compiler/nodeResolution7.ts_0_177
// @module: commonjs // @moduleResolution: node // @filename: node_modules/a/index.d.ts declare module "a" { var x: number; } // @filename: b.ts import y = require("a");
{ "end_byte": 177, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nodeResolution7.ts" }
TypeScript/tests/cases/compiler/privateInterfaceProperties.ts_0_171
interface i1 { name:string; } // should be an error class c1 implements i1 { private name:string; } // should be ok class c2 implements i1 { public name:string; }
{ "end_byte": 171, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privateInterfaceProperties.ts" }
TypeScript/tests/cases/compiler/typePredicateStructuralMatch.ts_0_650
// Repro from #12235 getResults1([]); getResults1({data: []}); getResults2([]); getResults2({data: []}); type Result = { value: string }; type Results = Result[]; function isResponseInData<T>(value: T | { data: T}): value is { data: T } { return value.hasOwnProperty('data'); } function getResults1(value: Resul...
{ "end_byte": 650, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typePredicateStructuralMatch.ts" }
TypeScript/tests/cases/compiler/declarationEmitClassMemberNameConflict2.ts_0_304
// @target: es5 // @module: commonjs // @declaration: true const Bar = 'bar'; enum Hello { World } enum Hello1 { World1 } class Foo { // Same names + string => OK Bar = Bar; // Same names + enum => OK Hello = Hello; // Different names + enum => OK Hello2 = Hello1; }
{ "end_byte": 304, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitClassMemberNameConflict2.ts" }
TypeScript/tests/cases/compiler/contextualTypingOfConditionalExpression2.ts_0_178
class A { foo: number; } class B extends A { bar: number; } class C extends A { baz: number; } var x2: (a: A) => void = true ? (a: C) => a.foo : (b: number) => { };
{ "end_byte": 178, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTypingOfConditionalExpression2.ts" }
TypeScript/tests/cases/compiler/unusedTypeParameters5.ts_0_133
//@noUnusedLocals:true //@noUnusedParameters:true class A<Dummy> { public x: Dummy; } var x: { new <T, U, K>(a: T): A<U>; }
{ "end_byte": 133, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedTypeParameters5.ts" }
TypeScript/tests/cases/compiler/es5-asyncFunctionBinaryExpressions.ts_0_2067
// @lib: es5,es2015.promise // @noEmitHelpers: true // @allowUnreachableCode: true // @target: ES5 declare var x, y, z, a, b, c; async function binaryPlus0() { (await x) + y; } async function binaryPlus1() { x + await y; } async function binaryLogicalAnd0() { (await x) && y; } async function binaryLogic...
{ "end_byte": 2067, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es5-asyncFunctionBinaryExpressions.ts" }
TypeScript/tests/cases/compiler/moduleElementsInWrongContext3.ts_0_651
module P { { 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 }; expor...
{ "end_byte": 651, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleElementsInWrongContext3.ts" }
TypeScript/tests/cases/compiler/functionSignatureAssignmentCompat1.ts_0_319
interface ParserFunc { (eventEmitter: number, buffer: string): void; } interface Parsers { raw: ParserFunc; readline(delimiter?: string): ParserFunc; } var parsers: Parsers; var c: ParserFunc = parsers.raw; // ok! var d: ParserFunc = parsers.readline; // not ok var e: ParserFunc = parsers.readline(); // ok
{ "end_byte": 319, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionSignatureAssignmentCompat1.ts" }
TypeScript/tests/cases/compiler/collisionThisExpressionAndLocalVarInAccessors.ts_0_818
// @target: es5 class class1 { get a(): number { var x2 = { doStuff: (callback) => () => { var _this = 2; return callback(this); } } return 10; } set a(val: number) { var x2 = { doStuff: (callback) => () => ...
{ "end_byte": 818, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionThisExpressionAndLocalVarInAccessors.ts" }
TypeScript/tests/cases/compiler/customAsyncIterator.ts_0_481
// @target: esnext // @useDefineForClassFields: false // GH: https://github.com/microsoft/TypeScript/issues/33239 class ConstantIterator<T> implements AsyncIterator<T, void, T | undefined> { constructor(private constant: T) { } async next(value?: T): Promise<IteratorResult<T>> { if (value != null) ...
{ "end_byte": 481, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/customAsyncIterator.ts" }
TypeScript/tests/cases/compiler/inferringAnyFunctionType4.ts_0_91
function f<T extends (p1: number) => number>(p: T): T { return p; } var v = f(x => x);
{ "end_byte": 91, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inferringAnyFunctionType4.ts" }
TypeScript/tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts_0_2031
// @lib: es2015 // es2016 const testIncludes = ["hello"].includes("world"); // es2017 const testStringPadStart = "".padStart(2); const testStringPadEnd = "".padEnd(2); const testObjectConstructorValues = Object.values({}); const testObjectConstructorEntries = Object.entries({}); const testObjectConstructorGetOwnPrope...
{ "end_byte": 2031, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts" }
TypeScript/tests/cases/compiler/callOverloads3.ts_1_305
function Foo():Foo; // error function Foo(s:string):Foo; // error class Foo { // error bar1() { /*WScript.Echo("bar1");*/ } constructor(x: any) { // WScript.Echo("Constructor function has executed"); } } //class Foo(s: String); var f1 = new Foo("hey"); f1.bar1(); Foo(); Foo("s");
{ "end_byte": 305, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/callOverloads3.ts" }
TypeScript/tests/cases/compiler/recursivelyExpandingUnionNoStackoverflow.ts_0_85
type N<T, K extends string> = T | { [P in K]: N<T, K> }[K]; type M = N<number, "M">;
{ "end_byte": 85, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursivelyExpandingUnionNoStackoverflow.ts" }
TypeScript/tests/cases/compiler/compilerOptionsDeclarationAndNoEmit.ts_0_71
// @declaration: true // @noEmit: true // @fileName: a.ts class c { }
{ "end_byte": 71, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/compilerOptionsDeclarationAndNoEmit.ts" }
TypeScript/tests/cases/compiler/accessorDeclarationEmitVisibilityErrors.ts_0_108
// @target: es6 // @strict: true // @declaration: true export class Q { set bet(arg: DoesNotExist) {} }
{ "end_byte": 108, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/accessorDeclarationEmitVisibilityErrors.ts" }
TypeScript/tests/cases/compiler/classDeclarationMergedInModuleWithContinuation.ts_0_142
module M { export class N { } export module N { export var v = 0; } } module M { export class O extends M.N { } }
{ "end_byte": 142, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classDeclarationMergedInModuleWithContinuation.ts" }
TypeScript/tests/cases/compiler/this_inside-object-literal-getters-and-setters.ts_0_295
module ObjectLiteral { var ThisInObjectLiteral = { _foo: '1', get foo(): string { return this._foo; }, set foo(value: string) { this._foo = value; }, test: function () { return this._foo; } } }
{ "end_byte": 295, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/this_inside-object-literal-getters-and-setters.ts" }
TypeScript/tests/cases/compiler/keywordField.ts_0_87
var obj:any = {}; obj.if = 1; var a = { if: "test" } var n = a.if var q = a["if"];
{ "end_byte": 87, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/keywordField.ts" }
TypeScript/tests/cases/compiler/infinitelyExpandingBaseTypes2.ts_0_112
interface A<T> { x : A<()=>T> } interface B<T> { x : B<()=>T> } var a: A<string> var b: B<string> = a
{ "end_byte": 112, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/infinitelyExpandingBaseTypes2.ts" }
TypeScript/tests/cases/compiler/jsxImportInAttribute.tsx_0_284
//@jsx: preserve //@module: commonjs //@filename: component.d.ts declare module "Test" { export default class Text { } } //@filename: consumer.tsx /// <reference path="component.d.ts" /> import Test from 'Test'; let x = Test; // emit test_1.default <anything attr={Test} />; // ?
{ "end_byte": 284, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsxImportInAttribute.tsx" }
TypeScript/tests/cases/compiler/nodeNextPackageImportMapRootDir.ts_0_327
// @module: nodenext // @outDir: ./dist // @rootDir: . // @filename: package.json { "name": "@this/package", "type": "module", "exports": { ".": "./dist/index.js" }, "imports": { "#dep": "./dist/index.js" } } // @filename: index.ts import * as me from "#dep"; me.thing(); export function thing(): v...
{ "end_byte": 327, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nodeNextPackageImportMapRootDir.ts" }
TypeScript/tests/cases/compiler/narrowingTruthyObject.ts_0_676
// @strict: true function foo(x: unknown, b: boolean) { if (typeof x === 'object') { x.toString(); } if (typeof x === 'object' && x) { x.toString(); } if (x && typeof x === 'object') { x.toString(); } if (b && x && typeof x === 'object') { x.toString(); }...
{ "end_byte": 676, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowingTruthyObject.ts" }
TypeScript/tests/cases/compiler/objectFreeze.ts_0_318
const f = Object.freeze(function foo(a: number, b: string) { return false; }); f(1, "") === false; class C { constructor(a: number) { } } const c = Object.freeze(C); new c(1); const a = Object.freeze([1, 2, 3]); a[0] = a[2].toString(); const o = Object.freeze({ a: 1, b: "string", c: true }); o.b = o.a.toString();
{ "end_byte": 318, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectFreeze.ts" }
TypeScript/tests/cases/compiler/privacyCheckExportAssignmentOnExportedGenericInterface2.ts_0_179
//@module: amd //@declaration: true export = Foo; interface Foo<T> { } function Foo<T>(array: T[]): Foo<T> { return undefined; } module Foo { export var x = "hello"; }
{ "end_byte": 179, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyCheckExportAssignmentOnExportedGenericInterface2.ts" }
TypeScript/tests/cases/compiler/classExpressionWithStaticPropertiesES61.ts_0_96
//@target: es6 var v = class C { static a = 1; static b = 2; static c = C.a + 3; };
{ "end_byte": 96, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classExpressionWithStaticPropertiesES61.ts" }
TypeScript/tests/cases/compiler/declFileOptionalInterfaceMethod.ts_0_52
// @declaration: true interface X { f? <T>(); }
{ "end_byte": 52, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileOptionalInterfaceMethod.ts" }
TypeScript/tests/cases/compiler/moduleAugmentationImportsAndExports2.ts_0_643
// @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": 643, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleAugmentationImportsAndExports2.ts" }
TypeScript/tests/cases/compiler/collisionCodeGenModuleWithMemberClassConflict.ts_0_184
module m1 { export class m1 { } } var foo = new m1.m1(); module m2 { export class m2 { } export class _m2 { } } var foo = new m2.m2(); var foo = new m2._m2();
{ "end_byte": 184, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionCodeGenModuleWithMemberClassConflict.ts" }
TypeScript/tests/cases/compiler/createArray.ts_0_191
var na=new number[]; class C { } new C[]; var ba=new boolean[]; var sa=new string[]; function f(s:string):number { return 0; } if (ba[14]) { na[2]=f(sa[3]); } new C[1]; // not an error
{ "end_byte": 191, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/createArray.ts" }
TypeScript/tests/cases/compiler/genericConstraintOnExtendedBuiltinTypes2.ts_0_475
module EndGate { export interface ICloneable { Clone(): any; } } interface Number extends EndGate.ICloneable { } module EndGate.Tweening { export class Tween<T extends ICloneable>{ private _from: T; constructor(from: T) { this._from = from.Clone(); } } } m...
{ "end_byte": 475, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericConstraintOnExtendedBuiltinTypes2.ts" }
TypeScript/tests/cases/compiler/assignmentToReferenceTypes.ts_0_176
// Should all be allowed module M { } M = null; class C { } C = null; enum E { } E = null; function f() { } f = null; var x = 1; x = null; function g(x) { x = null; }
{ "end_byte": 176, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentToReferenceTypes.ts" }
TypeScript/tests/cases/compiler/m7Bugs.ts_0_323
// scenario 1 interface ISomething { something: number; } var s: ISomething = <ISomething>({ }); // scenario 2 interface A { x: string; } interface B extends A { } var x: B = <B>{ }; class C1 { public x: string; } class C2 extends C1 {} var y1: C1 = new C2(); var y2: C1 = <C1> new C2(); var y3: C1 = <C1> {}...
{ "end_byte": 323, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/m7Bugs.ts" }
TypeScript/tests/cases/compiler/classOverloadForFunction2.ts_0_36
function bar(): string; class bar {}
{ "end_byte": 36, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classOverloadForFunction2.ts" }
TypeScript/tests/cases/compiler/moduleResolutionWithSuffixes_one_externalModulePath.ts_0_842
// moduleSuffixes has one entry and there's a matching package with a specific path. // @fullEmitPaths: true // @filename: /tsconfig.json { "compilerOptions": { "allowJs": true, "checkJs": false, "outDir": "bin", "moduleResolution": "node", "traceResolution": true, "moduleSuffixes": [".ios"] } } // @file...
{ "end_byte": 842, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolutionWithSuffixes_one_externalModulePath.ts" }
TypeScript/tests/cases/compiler/discriminatedUnionErrorMessage.ts_0_259
type Square = { kind: "sq", size: number } type Rectangle = { kind: "rt", x: number, y: number } type Circle = { kind: "cr", radius: number } type Shape = | Square | Rectangle | Circle; let shape: Shape = { kind: "sq", x: 12, y: 13, }
{ "end_byte": 259, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/discriminatedUnionErrorMessage.ts" }
TypeScript/tests/cases/compiler/emptyFile-souremap.ts_0_79
// @target: ES5 // @sourcemap: true // @declaration: false // @module: commonjs
{ "end_byte": 79, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emptyFile-souremap.ts" }
TypeScript/tests/cases/compiler/noUnusedLocals_typeParameterMergedWithParameter.ts_0_220
// @noUnusedLocals: true // @noUnusedParameters: true function useNone<T>(T: number) {} function useParam<T>(T: number) { return T; } function useTypeParam<T>(T: T) {} function useBoth<T>(T: T) { return T; }
{ "end_byte": 220, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noUnusedLocals_typeParameterMergedWithParameter.ts" }
TypeScript/tests/cases/compiler/nestedBlockScopedBindings3.ts_0_886
function a0() { { for (let x = 0; x < 1; ) { () => x; } } { for (let x;;) { () => x; } } } function a1() { for (let x; x < 1;) { () => x; } for (let x;;) { () => x; } } function a2() { for (let x; x < 1;) { ...
{ "end_byte": 886, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nestedBlockScopedBindings3.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationDestructuringVariableStatement.ts_0_516
// @lib: es5 // @sourcemap: true interface Robot { name: string; skill: string; } declare var console: { log(msg: string): void; } var hello = "hello"; var robotA: Robot = { name: "mower", skill: "mowing" }; var robotB: Robot = { name: "trimmer", skill: "trimming" }; var { name: nameA } = robotA; var { name...
{ "end_byte": 516, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationDestructuringVariableStatement.ts" }
TypeScript/tests/cases/compiler/es5-asyncFunctionArrayLiterals.ts_0_583
// @lib: es5,es2015.promise // @noEmitHelpers: true // @target: ES5 declare var x, y, z, a; async function arrayLiteral0() { x = [await y, z]; } async function arrayLiteral1() { x = [y, await z]; } async function arrayLiteral2() { x = [...(await y), z]; } async function arrayLiteral3() { x = [...y, ...
{ "end_byte": 583, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es5-asyncFunctionArrayLiterals.ts" }
TypeScript/tests/cases/compiler/reservedWords3.ts_3_113
nction f1(enum) {} function f2(class) {} function f3(function) {} function f4(while) {} function f5(for) {}
{ "end_byte": 113, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reservedWords3.ts" }
TypeScript/tests/cases/compiler/constantOverloadFunctionNoSubtypeError.ts_0_369
class Base { foo() { } } class Derived1 extends Base { bar() { } } class Derived2 extends Base { baz() { } } class Derived3 extends Base { biz() { } } function foo(tagName: 'canvas'): Derived3; function foo(tagName: 'div'): Derived2; function foo(tagName: 'span'): Derived1; function foo(tagName: number): Base; functi...
{ "end_byte": 369, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constantOverloadFunctionNoSubtypeError.ts" }
TypeScript/tests/cases/compiler/moduleResolutionWithRequireAndImport.ts_0_310
// @traceResolution: true // @filename: /other.ts export const other = 123; // @filename: /index.ts declare const require: any; const a: typeof import('./other') = null as any function foo() { const a = require('../outside-of-rootdir/foo'); const { other }: { other: string } = require('./other'); }
{ "end_byte": 310, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolutionWithRequireAndImport.ts" }
TypeScript/tests/cases/compiler/conditionalTypeDoesntSpinForever.ts_0_5665
// @target: es6 // A *self-contained* demonstration of the problem follows... // Test this by running `tsc --target es6` on the command-line, rather than through another build tool such as Gulp, Webpack, etc. export enum PubSubRecordIsStoredInRedisAsA { redisHash = "redisHash", jsonEncodedRedisString = "jsonEn...
{ "end_byte": 5665, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/conditionalTypeDoesntSpinForever.ts" }
TypeScript/tests/cases/compiler/moduleSymbolMerging.ts_0_214
// @declaration: true // @Filename: A.ts module A { export interface I {} } // @Filename: B.ts ///<reference path="A.ts" preserve="true" /> module A { ; } module B { export function f(): A.I { return null; } }
{ "end_byte": 214, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleSymbolMerging.ts" }
TypeScript/tests/cases/compiler/classExtendsClauseClassMergedWithModuleNotReferingConstructor.ts_0_145
class A { a: number; } module A { export var v: string; } module Foo { var A = 1; class B extends A { b: string; } }
{ "end_byte": 145, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classExtendsClauseClassMergedWithModuleNotReferingConstructor.ts" }
TypeScript/tests/cases/compiler/bindingPatternContextualTypeDoesNotCauseWidening.ts_0_212
declare function pick<O, T extends keyof O>(keys: T[], obj?: O): Pick<O, T>; const _ = pick(['b'], { a: 'a', b: 'b' }); // T: "b" const { } = pick(['b'], { a: 'a', b: 'b' }); // T: "b" | "a" ??? (before fix)
{ "end_byte": 212, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/bindingPatternContextualTypeDoesNotCauseWidening.ts" }
TypeScript/tests/cases/compiler/spellingSuggestionGlobal3.ts_0_75
const global = { x: true } globals.x // should suggest `global` (GH#42209)
{ "end_byte": 75, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/spellingSuggestionGlobal3.ts" }
TypeScript/tests/cases/compiler/optionalArgsWithDefaultValues.ts_0_244
function foo(x: number, y?:boolean=false, z?=0) {} class CCC { public foo(x: number, y?:boolean=false, z?=0) {} static foo2(x: number, y?:boolean=false, z?=0) {} } var a = (x?=0) => { return 1; }; var b = (x, y?:number = 2) => { x; };
{ "end_byte": 244, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/optionalArgsWithDefaultValues.ts" }
TypeScript/tests/cases/compiler/contextualTyping19.ts_0_58
var foo:{id:number;}[] = [{id:1}]; foo = [{id:1}, {id:2}];
{ "end_byte": 58, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTyping19.ts" }
TypeScript/tests/cases/compiler/capturedLetConstInLoop13.ts_0_367
class Main { constructor() { this.register("a", "b", "c"); } private register(...names: string[]): void { for (let name of names) { this.bar({ [name + ".a"]: () => { this.foo(name); }, }); } } private bar(a: any): void { } priv...
{ "end_byte": 367, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/capturedLetConstInLoop13.ts" }
TypeScript/tests/cases/compiler/negativeZero.ts_0_11
var x = -0
{ "end_byte": 11, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/negativeZero.ts" }
TypeScript/tests/cases/compiler/importTypeTypeofClassStaticLookup.ts_0_143
// @filename: a.d.ts export declare class A { static foo(): void; } // @filename: index.d.ts export const foo: typeof import("./a").A.foo;
{ "end_byte": 143, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importTypeTypeofClassStaticLookup.ts" }
TypeScript/tests/cases/compiler/dynamicImportsDeclaration.ts_0_486
// @declaration: true // @module: nodenext // @target: esnext // @filename: /case0.ts export default 0; // @filename: /case1.ts export default 1; // @filename: /caseFallback.ts export default 'fallback'; // @filename: /index.ts export const mod = await (async () => { const x: number = 0; switch (x) { case 0...
{ "end_byte": 486, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/dynamicImportsDeclaration.ts" }
TypeScript/tests/cases/compiler/capturedLetConstInLoop6.ts_0_3361
// ====let for (let x of []) { (function() { return x}); (() => x); if (x == 1) { break; } if (x == 2) { continue; } } for (let x in []) { (function() { return x}); (() => x); if (x == "1") { break; } if (x == "2") { continue; } } for (l...
{ "end_byte": 3361, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/capturedLetConstInLoop6.ts" }
TypeScript/tests/cases/compiler/regularExpressionExtendedUnicodeEscapes.ts_0_127
// @target: esnext const regexes: RegExp[] = [ /\u{10000}[\u{10000}]/, /\u{10000}[\u{10000}]/u, /\u{10000}[\u{10000}]/v, ];
{ "end_byte": 127, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/regularExpressionExtendedUnicodeEscapes.ts" }
TypeScript/tests/cases/compiler/interfaceInheritance2.ts_0_74
interface I6 { ():void; } interface I7 extends I6 { } var v1:I7; v1();
{ "end_byte": 74, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/interfaceInheritance2.ts" }
TypeScript/tests/cases/compiler/declarationsForFileShadowingGlobalNoError.ts_0_381
// @declaration: true // @lib: dom,es6 // @filename: dom.ts export type DOMNode = Node; // @filename: custom.ts export type Node = {}; // @filename: index.ts import { Node } from './custom' import { DOMNode } from './dom' type Constructor = new (...args: any[]) => any export const mixin = (Base: Constructor) => { r...
{ "end_byte": 381, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationsForFileShadowingGlobalNoError.ts" }
TypeScript/tests/cases/compiler/returnTypeParameter.ts_0_158
function f<T>(a: T): T { } // error, no return statement function f2<T>(a: T): T { return T; } // bug was that this satisfied the return statement requirement
{ "end_byte": 158, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/returnTypeParameter.ts" }
TypeScript/tests/cases/compiler/conflictMarkerTrivia1.ts_0_71
class C { <<<<<<< HEAD v = 1; ======= v = 2; >>>>>>> Branch-a }
{ "end_byte": 71, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/conflictMarkerTrivia1.ts" }
TypeScript/tests/cases/compiler/tsxNotUsingApparentTypeOfSFC.tsx_0_559
// @jsx: react // @strict: true // @esModuleInterop: true /// <reference path="/.lib/react16.d.ts" /> import React from 'react'; function test<P>(wrappedProps: P) { let MySFC = function(props: P) { return <>hello</>; }; class MyComponent extends React.Component<P> { render() { ...
{ "end_byte": 559, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/tsxNotUsingApparentTypeOfSFC.tsx" }
TypeScript/tests/cases/compiler/spellingSuggestionModule.ts_0_179
declare module "foobar" { export const x: number; } foobar; declare module 'barfoo' { export const x: number; } barfoo; declare module farboo { export const x: number; } faroo;
{ "end_byte": 179, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/spellingSuggestionModule.ts" }
TypeScript/tests/cases/compiler/ambiguousOverload.ts_0_385
function foof(bar: string, y): number; function foof(bar: string, x): string; function foof(bar: any): any { return bar }; var x: number = foof("s", null); var y: string = foof("s", null); function foof2(bar: string, x): string; function foof2(bar: string, y): number; function foof2(bar: any): any { return bar }; var ...
{ "end_byte": 385, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ambiguousOverload.ts" }
TypeScript/tests/cases/compiler/pathMappingBasedModuleResolution1_amd.ts_0_274
// @module: amd // @traceResolution: true // @filename: c:/root/tsconfig.json { "compilerOptions": { "paths": { "*": [ "*", "generated/*" ] } } } // @filename: c:/root/f1.ts export var x = 1;
{ "end_byte": 274, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/pathMappingBasedModuleResolution1_amd.ts" }
TypeScript/tests/cases/compiler/cloduleTest2.ts_0_864
module T1 { module m3d { export var y = 2; } declare class m3d { constructor(foo); foo(): void ; static bar(); } var r = new m3d(); // error } module T2 { declare class m3d { constructor(foo); foo(): void; static bar(); } module m3d { export var y = 2; } var r = new m3d(); // error } module T3...
{ "end_byte": 864, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/cloduleTest2.ts" }
TypeScript/tests/cases/compiler/quotedPropertyName2.ts_0_37
class Test1 { static "prop1" = 0; }
{ "end_byte": 37, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/quotedPropertyName2.ts" }
TypeScript/tests/cases/compiler/contextualTypingOfArrayLiterals1.ts_0_101
interface I { [x: number]: Date; } var x3: I = [new Date(), 1]; var r2 = x3[1]; r2.getDate();
{ "end_byte": 101, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTypingOfArrayLiterals1.ts" }