_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/staticInterfaceAssignmentCompat.ts_0_158
class Shape { static create(): Shape { return new Shape(); } } interface ShapeFactory { create(): Shape; } var x: ShapeFactory = Shape;
{ "end_byte": 158, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/staticInterfaceAssignmentCompat.ts" }
TypeScript/tests/cases/compiler/globalThis.ts_0_55
var __e = Math.E; // should not generate 'this.Math.E'
{ "end_byte": 55, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/globalThis.ts" }
TypeScript/tests/cases/compiler/moduleResolution_classicPrefersTs.ts_0_262
// @moduleResolution: classic // @allowJs: true // @noEmit: true // @Filename: /dir1/dir2/dir3/a.js export default "dir1/dir2/dir3/a.js"; // @Filename: /dir1/dir2/a.ts export default "dir1/dir2/a.ts"; // @Filename: /dir1/dir2/dir3/index.ts import a from "a";
{ "end_byte": 262, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolution_classicPrefersTs.ts" }
TypeScript/tests/cases/compiler/inheritanceStaticAccessorOverridingAccessor.ts_0_214
class a { static get x() { return "20"; } static set x(aValue: string) { } } class b extends a { static get x() { return "20"; } static set x(aValue: string) { } }
{ "end_byte": 214, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inheritanceStaticAccessorOverridingAccessor.ts" }
TypeScript/tests/cases/compiler/exportDefaultAbstractClass.ts_0_204
// @Filename: a.ts export default abstract class A { a: number; } class B extends A {} new B().a.toExponential(); // @Filename: b.ts import A from './a'; class C extends A {} new C().a.toExponential();
{ "end_byte": 204, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportDefaultAbstractClass.ts" }
TypeScript/tests/cases/compiler/awaitUnionPromise.ts_0_505
// @target: es2015 // https://github.com/Microsoft/TypeScript/issues/18186 class AsyncEnumeratorDone { }; interface IAsyncEnumerator<T> { next1(): Promise<T | AsyncEnumeratorDone>; next2(): Promise<T> | Promise<AsyncEnumeratorDone>; next3(): Promise<T | {}>; next4(): Promise<T | { x: string }>; } asy...
{ "end_byte": 505, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/awaitUnionPromise.ts" }
TypeScript/tests/cases/compiler/modifierParenCast.ts_0_284
//@target: ES5 let readonly: any = undefined; let override: any = undefined; let out: any = undefined; let declare: any = undefined; export const a = (readonly as number); export const b = (override as number); export const c = (out as number); export const d = (declare as number);
{ "end_byte": 284, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/modifierParenCast.ts" }
TypeScript/tests/cases/compiler/chainedAssignmentChecking.ts_0_247
class X { constructor(public z) { } a: number; } class Y { constructor(public z) { } a: number; b: string; } class Z { z: any; c: string; } var c1 = new X(3); var c2 = new Y(5); var c3 = new Z(); c1 = c2 = c3; // Should be error
{ "end_byte": 247, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/chainedAssignmentChecking.ts" }
TypeScript/tests/cases/compiler/contextualTyping.ts_0_5394
// @sourcemap: true // DEFAULT INTERFACES interface IFoo { n: number; s: string; f(i: number, s: string): string; a: number[]; } interface IBar { foo: IFoo; } // CONTEXT: Class property declaration class C1T5 { foo: (i: number, s: string) => number = function(i) { return i; } } //...
{ "end_byte": 5394, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTyping.ts" }
TypeScript/tests/cases/compiler/declarationEmitDefaultExport1.ts_0_64
// @declaration: true // @target: es6 export default class C { }
{ "end_byte": 64, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitDefaultExport1.ts" }
TypeScript/tests/cases/compiler/overloadsInDifferentContainersDisagreeOnAmbient.ts_0_149
declare module M { // Error because body is not ambient and this overload is export function f(); } module M { export function f() { } }
{ "end_byte": 149, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overloadsInDifferentContainersDisagreeOnAmbient.ts" }
TypeScript/tests/cases/compiler/superCallsInConstructor.ts_0_258
class C { foo() {} bar() {} } class Base { x: string; } class Derived extends Base { constructor() { with(new C()) { foo(); super(); bar(); } try {} catch(e) { super(); } } }
{ "end_byte": 258, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/superCallsInConstructor.ts" }
TypeScript/tests/cases/compiler/es5-system2.ts_3_109
@target: ES5 // @sourcemap: false // @declaration: false // @module: system export var __esModule = 1;
{ "end_byte": 109, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es5-system2.ts" }
TypeScript/tests/cases/compiler/genericFunctions2.ts_0_154
// @declaration: true declare function map <T, U > (items: T[], f: (x: T) => U): U[]; var myItems: string[]; var lengths = map(myItems, x => x.length);
{ "end_byte": 154, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericFunctions2.ts" }
TypeScript/tests/cases/compiler/mutuallyRecursiveGenericBaseTypes1.ts_0_241
interface A<T> { foo(): B<T>; // instead of B does see this foo(): void; // instead of B does see this foo2(): B<number>; } interface B<T> extends A<T> { bar(): void; } var b: B<number>; b.foo(); // should not error
{ "end_byte": 241, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mutuallyRecursiveGenericBaseTypes1.ts" }
TypeScript/tests/cases/compiler/declarationEmitIndexTypeNotFound.ts_0_81
// @declaration: true export interface Test { [index: TypeNotFound]: any; }
{ "end_byte": 81, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitIndexTypeNotFound.ts" }
TypeScript/tests/cases/compiler/declFileObjectLiteralWithOnlyGetter.ts_0_189
// @declaration: true // @target: es5 function /*1*/makePoint(x: number) { return { get x() { return x; }, }; }; var /*4*/point = makePoint(2); var /*2*/x = point./*3*/x;
{ "end_byte": 189, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileObjectLiteralWithOnlyGetter.ts" }
TypeScript/tests/cases/compiler/trivialSubtypeReductionNoStructuralCheck2.ts_0_257
// @strict: true // @target: es5 declare const props: WizardStepProps; export class Wizard { get steps() { return { wizard: this as Wizard, ...props, } as WizardStepProps; } } export interface WizardStepProps { wizard?: Wizard; }
{ "end_byte": 257, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/trivialSubtypeReductionNoStructuralCheck2.ts" }
TypeScript/tests/cases/compiler/jsFileMethodOverloads4.ts_0_379
// @declaration: true // @emitDeclarationOnly: true // @allowJs: true // @filename: /a.js export function Foo() { } /** * @overload * @param {string} a * @return {void} */ /** * @overload * @param {number} a * @param {string} b * @return {void} */ /** * @param {string | number} a * @param {string} [b] * ...
{ "end_byte": 379, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileMethodOverloads4.ts" }
TypeScript/tests/cases/compiler/resolutionCandidateFromPackageJsonField1.ts_0_356
// @filename: tsconfig.json { "compilerOptions": { "paths": { "@angular/*": ["./@angular/*"] } } } // @filename: @angular/core/package.json { "name": "@angular/core", "typings": "index.d.ts" } // @filename: @angular/core/index.ts export {}; // @filename: @angular/core/test...
{ "end_byte": 356, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/resolutionCandidateFromPackageJsonField1.ts" }
TypeScript/tests/cases/compiler/selfNameAndImportsEmitInclusion.ts_0_628
// @noTypesAndSymbols: true // @Filename: /tsconfig.json { "compilerOptions": { "module": "nodenext", "outDir": "dist", "rootDir": "src", }, "files": ["src/main.ts"] } // @Filename: /package.json { "name": "pkg", "type": "module", "imports": { "#indirect1": "./src/indirect1.ts" }, "exp...
{ "end_byte": 628, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/selfNameAndImportsEmitInclusion.ts" }
TypeScript/tests/cases/compiler/globalThisDeclarationEmit3.ts_0_198
// @declaration: true // @filename: index.ts import { variable } from "./variable"; export { variable as globalThis }; // @filename: variable.ts import mod = globalThis; export { mod as variable };
{ "end_byte": 198, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/globalThisDeclarationEmit3.ts" }
TypeScript/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.ts_0_382
// @target: es5 // @module: commonjs // @declaration: true // @filename: es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.ts export var a = 10; // @filename: es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts import defaultBinding, * as nameSpaceBinding from "./es6ImportDefaultBindingFollowedWit...
{ "end_byte": 382, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.ts" }
TypeScript/tests/cases/compiler/contextuallyTypedParametersOptionalInJSDoc.ts_0_514
// @strict: true // @checkJs: true // @noEmit: true // @filename: index.js /** * * @param {number} num */ function acceptNum(num) {} /** * @typedef {(a: string, b: number) => void} Fn */ /** @type {Fn} */ const fn1 = /** * @param [b] */ function self(a, b) { acceptNum(b); // error self("");...
{ "end_byte": 514, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextuallyTypedParametersOptionalInJSDoc.ts" }
TypeScript/tests/cases/compiler/crashRegressionTest.ts_0_614
module MsPortal.Util.TemplateEngine { "use strict"; interface TemplateKeyValue { [name: string]: string; } class StringTemplate { private _templateStorage: TemplateStorage; constructor(templateStorage: TemplateStorage) { this._templateStorage = templateStorage; ...
{ "end_byte": 614, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/crashRegressionTest.ts" }
TypeScript/tests/cases/compiler/discriminateWithDivergentAccessors1.ts_0_550
// @strict: true // @noEmit: true type WeirdoBox<T> = | { get done(): false; set done(v: T | null) } | { get done(): true; set done(v: T | null); value: T }; declare const weirdoBox: WeirdoBox<number>; if (weirdoBox.done) { weirdoBox.value; } type WeirdoBox2<T> = | { get done(): false; set done(v: T | null)...
{ "end_byte": 550, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/discriminateWithDivergentAccessors1.ts" }
TypeScript/tests/cases/compiler/missingTypeArguments1.ts_0_573
interface I<T> { } class Y<T> {} class X<T> { p1: () => X; } var a: X<number>; class X2<T> { p2: { [idx: number]: X2 } } var a2: X2<number>; class X3<T> { p3: X3[] } var a3: X3<number>; class X4<T> { p4: I<X4> } var a4: X4<number>; class X5<T> { p5: X5 } var a5: X5<number>; class X6<T> { p...
{ "end_byte": 573, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/missingTypeArguments1.ts" }
TypeScript/tests/cases/compiler/instanceSubtypeCheck2.ts_0_74
class C1<T> { x: C2<T>; } class C2<T> extends C1<T> { x: string }
{ "end_byte": 74, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/instanceSubtypeCheck2.ts" }
TypeScript/tests/cases/compiler/functionOverloads8.ts_0_78
function foo(); function foo(foo:string); function foo(foo?:any){ return '' }
{ "end_byte": 78, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloads8.ts" }
TypeScript/tests/cases/compiler/jsxIntrinsicElementsTypeArgumentErrors.tsx_0_920
// @jsx: react /// <reference path="/.lib/react16.d.ts" /> import * as React from "react"; // opening + closing const a = <div<>></div>; // empty type args const b = <div<number,>></div>; // trailing comma type args const c = <div<Missing>></div>; // nonexistant type args const d = <div<Missing<AlsoMissing>>></div>...
{ "end_byte": 920, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsxIntrinsicElementsTypeArgumentErrors.tsx" }
TypeScript/tests/cases/compiler/duplicateDefaultExport.ts_0_47
export default 0; export default function() {}
{ "end_byte": 47, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateDefaultExport.ts" }
TypeScript/tests/cases/compiler/lambdaParamTypes.ts_0_1130
interface MyArrayWrapper<T> { constructor(initialItems?: T[]); doSomething(predicate: (x: T, y: T) => string): void; } declare function create<T>(initialValues?: T[]): MyArrayWrapper<T>; var thing = create([{ name: "bob", id: 24 }, { name: "doug", id: 32 }]); // Below should all be OK thing.doSomething((x, y...
{ "end_byte": 1130, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/lambdaParamTypes.ts" }
TypeScript/tests/cases/compiler/commentOnArrayElement4.ts_3_76
nst array = [ /* element 1 */ 1, /* end of element 1 */ ];
{ "end_byte": 76, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentOnArrayElement4.ts" }
TypeScript/tests/cases/compiler/arrayLiteralTypeInference.ts_3_676
ass Action { id: number; } class ActionA extends Action { value: string; } class ActionB extends Action { trueNess: boolean; } var x1: Action[] = [ { id: 2, trueness: false }, { id: 3, name: "three" } ] var x2: Action[] = [ new ActionA(), new ActionB() ] var x3: Action[] = [ new Act...
{ "end_byte": 676, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arrayLiteralTypeInference.ts" }
TypeScript/tests/cases/compiler/es6ExportAll.ts_0_248
// @target: es6 // @declaration: true // @filename: server.ts export class c { } export interface i { } export module m { export var x = 10; } export var x = 10; export module uninstantiated { } // @filename: client.ts export * from "server";
{ "end_byte": 248, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ExportAll.ts" }
TypeScript/tests/cases/compiler/typeofStripsFreshness.ts_0_383
interface Collection<T> { elems: T[]; } interface CollectionStatic { new <T>(): Collection<T>; } declare const Collection: CollectionStatic; const ALL = "all"; type All = typeof ALL; const result: Collection<All> = new Collection(); const ANOTHER = "another"; type Another = typeof ANOTHER; type Both = Anoth...
{ "end_byte": 383, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeofStripsFreshness.ts" }
TypeScript/tests/cases/compiler/exportedBlockScopedDeclarations.ts_0_434
// @module: amd const foo = foo; // compile error export const bar = bar; // should be compile error function f() { const bar = bar; // compile error } namespace NS { export const bar = bar; // should be compile error } let foo1 = foo1; // compile error export let bar1 = bar1; // should be compile error function f...
{ "end_byte": 434, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportedBlockScopedDeclarations.ts" }
TypeScript/tests/cases/compiler/innerModExport1.ts_0_366
module Outer { // inner mod 1 var non_export_var: number; module { var non_export_var = 0; export var export_var = 1; function NonExportFunc() { return 0; } export function ExportFunc() { return 0; } } export var outer_var_export = 0; export function outerFunc...
{ "end_byte": 366, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/innerModExport1.ts" }
TypeScript/tests/cases/compiler/functionOverloads30.ts_0_126
function foo(bar:string):string; function foo(bar:number):number; function foo(bar:any):any{ return bar } var x = foo('bar');
{ "end_byte": 126, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloads30.ts" }
TypeScript/tests/cases/compiler/dontShowCompilerGeneratedMembers.ts_0_33
var f: { x: number; <- };
{ "end_byte": 33, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/dontShowCompilerGeneratedMembers.ts" }
TypeScript/tests/cases/compiler/systemModule12.ts_0_104
// @module: system // @isolatedModules: true ///<amd-module name='NamedModule'/> import n from 'file1'
{ "end_byte": 104, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/systemModule12.ts" }
TypeScript/tests/cases/compiler/mappedTypeRecursiveInference.ts_0_413
// @lib: es6, dom interface A { a: A } declare let a: A; type Deep<T> = { [K in keyof T]: Deep<T[K]> } declare function foo<T>(deep: Deep<T>): T; const out = foo(a); out.a out.a.a out.a.a.a.a.a.a.a interface B { [s: string]: B } declare let b: B; const oub = foo(b); oub.b oub.b.b oub.b.a.n.a.n.a let xhr: XMLHttpRequ...
{ "end_byte": 413, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mappedTypeRecursiveInference.ts" }
TypeScript/tests/cases/compiler/constructorArgs.ts_0_183
interface Options { value: number; } class Super { constructor(value:number) { } } class Sub extends Super { constructor(public options:Options) { super(options.value); } }
{ "end_byte": 183, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constructorArgs.ts" }
TypeScript/tests/cases/compiler/trailingCommaInHeterogenousArrayLiteral1.ts_0_196
class arrTest { test(arg1: number[]) { } callTest() { // these two should give the same error this.test([1, 2, "hi", 5, ]); this.test([1, 2, "hi", 5]); } }
{ "end_byte": 196, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/trailingCommaInHeterogenousArrayLiteral1.ts" }
TypeScript/tests/cases/compiler/subclassWithPolymorphicThisIsAssignable.ts_0_373
/* taken from mongoose.Document */ interface Document { increment(): this; } /* our custom model extends the mongoose document */ interface CustomDocument extends Document { } export class Example<Z extends CustomDocument> { constructor() { // types of increment not compatible?? this.test<Z>()...
{ "end_byte": 373, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/subclassWithPolymorphicThisIsAssignable.ts" }
TypeScript/tests/cases/compiler/taggedTemplatesWithIncompleteNoSubstitutionTemplate2.ts_3_137
@target: es6 function f(x: TemplateStringsArray, y: string, z: string) { } // Incomplete call, not enough parameters, at EOF. f `
{ "end_byte": 137, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/taggedTemplatesWithIncompleteNoSubstitutionTemplate2.ts" }
TypeScript/tests/cases/compiler/ambientExportDefaultErrors.ts_0_584
// @filename: foo.d.ts export default 2 + 2; export as namespace Foo; // @filename: foo2.d.ts export = 2 + 2; export as namespace Foo2; // @filename: indirection.d.ts /// <reference path="./foo.d.ts" /> declare module "indirect" { export default typeof Foo.default; } // @filename: indirection2.d.ts /// <referenc...
{ "end_byte": 584, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ambientExportDefaultErrors.ts" }
TypeScript/tests/cases/compiler/objectLitIndexerContextualType.ts_0_310
interface I { [s: string]: (s: string) => number; } interface J { [s: number]: (s: string) => number; } var x: I; var y: J; x = { s: t => t * t, // Should error }; x = { 0: t => t * t, // Should error }; y = { s: t => t * t, // Should error }; y = { 0: t => t * t, // Should error };
{ "end_byte": 310, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectLitIndexerContextualType.ts" }
TypeScript/tests/cases/compiler/inferentialTypingWithFunctionTypeZip.ts_0_203
var pair: <T, S>(x: T) => (y: S) => { x: T; y: S; } var zipWith: <T, S, U>(a: T[], b: S[], f: (x: T) => (y: S) => U) => U[]; var result = zipWith([1, 2], ['a', 'b'], pair); var i = result[0].x; // number
{ "end_byte": 203, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inferentialTypingWithFunctionTypeZip.ts" }
TypeScript/tests/cases/compiler/parseInvalidNullableTypes.ts_0_394
// @strict: true function f1(a: string): a is ?string { return true; } function f2(a: string?) {} function f3(a: number?) {} function f4(a: ?string) {} function f5(a: ?number) {} function f6(a: string): ?string { return true; } const a = 1 as any?; const b: number? = 1; const c = 1 as ?any; const d: ?numb...
{ "end_byte": 394, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parseInvalidNullableTypes.ts" }
TypeScript/tests/cases/compiler/staticGetter1.ts_0_90
// once caused stack overflow class C { static get x() { return this; } }
{ "end_byte": 90, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/staticGetter1.ts" }
TypeScript/tests/cases/compiler/intrinsics.ts_0_318
// @declaration: true var hasOwnProperty: hasOwnProperty; // Error module m1 { export var __proto__; interface __proto__ {} class C<T extends { __proto__: __proto__ }> { } } __proto__ = 0; // Error, __proto__ not defined m1.__proto__ = 0; class Foo<__proto__> { } var foo: (__proto__: number) => void;
{ "end_byte": 318, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/intrinsics.ts" }
TypeScript/tests/cases/compiler/argumentsReferenceInConstructor1_Js.ts_0_244
// @declaration: true // @allowJs: true // @emitDeclarationOnly: true // @filename: /a.js class A { /** * Constructor * * @param {object} [foo={}] */ constructor(foo = {}) { /** * @type object */ this.arguments = foo; } }
{ "end_byte": 244, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/argumentsReferenceInConstructor1_Js.ts" }
TypeScript/tests/cases/compiler/orderMattersForSignatureGroupIdentity.ts_0_347
interface A { (x: { s: string }): string (x: { n: number }): number } interface B { (x: { s: string }): string (x: { n: number }): number } interface C { (x: { n: number }): number (x: { s: string }): string } var v: A; var v: B; v({ s: "", n: 0 }).toLowerCase(); var w: A; var w: C; w({ s:...
{ "end_byte": 347, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/orderMattersForSignatureGroupIdentity.ts" }
TypeScript/tests/cases/compiler/jsExportMemberMergedWithModuleAugmentation.ts_0_412
// @allowJs: true // @checkJs: true // @noEmit: true // @Filename: /test.js class Abcde { /** @type {string} */ x; } module.exports = { Abcde }; // @Filename: /index.ts import { Abcde } from "./test"; declare module "./test" { interface Abcde { b: string } } new Abcde().x; // Bug: the type meaning from /t...
{ "end_byte": 412, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsExportMemberMergedWithModuleAugmentation.ts" }
TypeScript/tests/cases/compiler/libdtsFix.ts_0_44
interface HTMLElement { type: string; }
{ "end_byte": 44, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/libdtsFix.ts" }
TypeScript/tests/cases/compiler/propertyAccess7.ts_0_35
var foo: string; foo.toUpperCase();
{ "end_byte": 35, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/propertyAccess7.ts" }
TypeScript/tests/cases/compiler/genericRecursiveImplicitConstructorErrors1.ts_0_472
//@module: amd export declare module TypeScript { class PullSymbol { } class PullSignatureSymbol <A,B,C> extends PullSymbol { public addSpecialization<A,B,C>(signature: PullSignatureSymbol<A,B,C>, typeArguments: PullTypeSymbol<any,any,any>[]): void; } class PullTypeSymbol <A,B,C> extends PullSymbol { publ...
{ "end_byte": 472, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericRecursiveImplicitConstructorErrors1.ts" }
TypeScript/tests/cases/compiler/inheritanceStaticFuncOverridingAccessorOfFuncType.ts_0_140
class a { static get x(): () => string { return null; } } class b extends a { static x() { return "20"; } }
{ "end_byte": 140, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inheritanceStaticFuncOverridingAccessorOfFuncType.ts" }
TypeScript/tests/cases/compiler/recursiveExportAssignmentAndFindAliasedType4.ts_0_576
//@module: amd // @Filename: recursiveExportAssignmentAndFindAliasedType4_moduleC.ts import self = require("recursiveExportAssignmentAndFindAliasedType4_moduleC"); export = self; // @Filename: recursiveExportAssignmentAndFindAliasedType4_moduleB.ts class ClassB { } export = ClassB; // @Filename: recursiveExportAssign...
{ "end_byte": 576, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveExportAssignmentAndFindAliasedType4.ts" }
TypeScript/tests/cases/compiler/checkJsObjectLiteralHasCheckedKeyof.ts_0_195
// @allowJs: true // @outDir: ./out // @filename: file.js // @ts-check const obj = { x: 1, y: 2 }; /** * @type {keyof typeof obj} */ let selected = "x"; selected = "z"; // should fail
{ "end_byte": 195, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/checkJsObjectLiteralHasCheckedKeyof.ts" }
TypeScript/tests/cases/compiler/staticMemberWithStringAndNumberNames.ts_0_182
class C { static "foo" = 0; static 0 = 1; x = C['foo']; x2 = C['0']; x3 = C[0]; static s = C['foo']; static s2 = C['0']; static s3 = C[0]; }
{ "end_byte": 182, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/staticMemberWithStringAndNumberNames.ts" }
TypeScript/tests/cases/compiler/interfaceDeclaration2.ts_0_132
interface I1 { } module I1 { } interface I2 { } class I2 { } interface I3 { } function I3() { } interface I4 { } var I4:number;
{ "end_byte": 132, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/interfaceDeclaration2.ts" }
TypeScript/tests/cases/compiler/narrowByBooleanComparison.ts_0_2049
// @strict: true // @noEmit: true type A = { type: "A" }; type B = { type: "B" }; type C = { type: "C" }; type MyUnion = A | B | C; const isA = (x: MyUnion): x is A => x.type === "A"; function test1(x: MyUnion) { if (isA(x) !== true) { x; } if (isA(x) !== false) { x; } if (isA(x...
{ "end_byte": 2049, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowByBooleanComparison.ts" }
TypeScript/tests/cases/compiler/twiceNestedKeyofIndexInference.ts_0_826
type Set1<T, K1 extends keyof T> = T extends any[] ? T : Pick<T, Exclude<keyof T, K1>> & { [SK1 in K1]-?: Required<Pick<T, SK1>>; }[K1]; type Set2<T, K1 extends keyof T, K2 extends keyof T[K1]> = T extends any[] ? T : Pick<T, Exclude<keyof T, K1>> & { [SK1 in K1]-?: Required<{ [key in K1]: Set1<T[K1], ...
{ "end_byte": 826, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/twiceNestedKeyofIndexInference.ts" }
TypeScript/tests/cases/compiler/parameterNamesInTypeParameterList.ts_0_301
function f0<T extends typeof a>(a: T) { a.b; } function f1<T extends typeof a>({a}: {a:T}) { a.b; } function f2<T extends typeof a>([a]: T[]) { a.b; } class A { m0<T extends typeof a>(a: T) { a.b } m1<T extends typeof a>({a}: {a:T}) { a.b } m2<T extends typeof a>([a]: T[]) { a.b } }
{ "end_byte": 301, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parameterNamesInTypeParameterList.ts" }
TypeScript/tests/cases/compiler/contextualOverloadListFromArrayUnion.ts_0_1724
// @strict: true // @target: es6 // @filename: one.ts declare const y: never[] | string[]; export const yThen = y.map(item => item.length); // @filename: two.ts declare const y: number[][] | string[]; export const yThen = y.map(item => item.length); // @filename: three.ts // #42504 interface ResizeObserverCallback { ...
{ "end_byte": 1724, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualOverloadListFromArrayUnion.ts" }
TypeScript/tests/cases/compiler/booleanAssignment.ts_0_147
var b = new Boolean(); b = 1; // Error b = "a"; // Error b = {}; // Error var o = {}; o = b; // OK b = true; // OK var b2:boolean; b = b2; // OK
{ "end_byte": 147, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/booleanAssignment.ts" }
TypeScript/tests/cases/compiler/contextualTypeSelfReferencing.ts_0_342
// @strict: true // @noEmit: true // repro from https://github.com/microsoft/TypeScript/issues/54048 type narrow<def> = def extends string ? def : def extends [unknown, ...unknown[]] ? def : { [k in keyof def]: narrow<def[k]>; }; declare const parse: <def>(def: narrow<def>) => def; const result = ...
{ "end_byte": 342, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTypeSelfReferencing.ts" }
TypeScript/tests/cases/compiler/es6ExportAssignment2.ts_0_143
// @target: es6 // @filename: a.ts var a = 10; export = a; // Error: export = not allowed in ES6 // @filename: b.ts import * as a from "a";
{ "end_byte": 143, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ExportAssignment2.ts" }
TypeScript/tests/cases/compiler/jsxNamespaceImplicitImportJSXNamespace.tsx_0_2748
// @strict: true // @jsx: react-jsx // @jsxImportSource: preact // @filename: /node_modules/preact/index.d.ts type Defaultize<Props, Defaults> = // Distribute over unions Props extends any // Make any properties included in Default optional ? Partial<Pick<Props, Extract<keyof Props, keyof Defaults>>> & // Inclu...
{ "end_byte": 2748, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsxNamespaceImplicitImportJSXNamespace.tsx" }
TypeScript/tests/cases/compiler/infinitelyExpandingTypes3.ts_0_359
interface List<T> { data: T; next: List<T>; // will be recursive reference when OwnerList is expanded owner: OwnerList<T>; } interface OwnerList<U> extends List<List<U>> { name: string; } interface OwnerList2<U> extends List<List<U>> { name: string; } var o1: OwnerList<number>; var o2: OwnerList2...
{ "end_byte": 359, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/infinitelyExpandingTypes3.ts" }
TypeScript/tests/cases/compiler/interfaceExtendsClass1.ts_0_292
// @lib: es5 class Control { private state: any; } interface SelectableControl extends Control { select(): void; } class Button extends Control { select() { } } class TextBox extends Control { select() { } } class Image extends Control { } class Location { select() { } }
{ "end_byte": 292, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/interfaceExtendsClass1.ts" }
TypeScript/tests/cases/compiler/modularizeLibrary_TargetES6UsingES6Lib.ts_3_885
@lib: es6 // @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 function function Baz() { } Baz.name; // Using ...
{ "end_byte": 885, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/modularizeLibrary_TargetES6UsingES6Lib.ts" }
TypeScript/tests/cases/compiler/unusedImports8.ts_0_315
//@noUnusedLocals:true //@noUnusedParameters:true // @Filename: file1.ts export class Calculator { handleChar() {} } export function test() { } export function test2() { } // @Filename: file2.ts import {Calculator as calc, test as t1, test2 as t2} from "./file1" var x = new calc(); x.handleChar(); t1();
{ "end_byte": 315, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedImports8.ts" }
TypeScript/tests/cases/compiler/breakTarget3.ts_0_80
// @allowUnusedLabels: true target1: target2: while (true) { break target1; }
{ "end_byte": 80, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/breakTarget3.ts" }
TypeScript/tests/cases/compiler/unionTypeWithRecursiveSubtypeReduction3.ts_0_98
var a27: { prop: number } | { prop: T27 }; type T27 = typeof a27; var b: T27; var s: string = b;
{ "end_byte": 98, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unionTypeWithRecursiveSubtypeReduction3.ts" }
TypeScript/tests/cases/compiler/quotedAccessorName1.ts_0_41
class C { get "foo"() { return 0; } }
{ "end_byte": 41, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/quotedAccessorName1.ts" }
TypeScript/tests/cases/compiler/inferTupleFromBindingPattern.ts_0_86
declare function f<T>(cb: () => T): T; const [e1, e2, e3] = f(() => [1, "hi", true]);
{ "end_byte": 86, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inferTupleFromBindingPattern.ts" }
TypeScript/tests/cases/compiler/primitiveTypeAssignment.ts_0_48
var x = any; var y = number; var z = boolean;
{ "end_byte": 48, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/primitiveTypeAssignment.ts" }
TypeScript/tests/cases/compiler/typeGuardNarrowsIndexedAccessOfKnownProperty4.ts_0_220
// @strict: true class Foo { x: number | undefined; constructor() { this.x = 5; this.x; // number this['x']; // number const key = 'x'; this[key]; // number } }
{ "end_byte": 220, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeGuardNarrowsIndexedAccessOfKnownProperty4.ts" }
TypeScript/tests/cases/compiler/es6ImportNamedImportInEs5.ts_0_1238
// @target: es5 // @module: commonjs // @declaration: true // @filename: es6ImportNamedImportInEs5_0.ts export var a = 10; export var x = a; export var m = a; export var a1 = 10; export var x1 = 10; export var z1 = 10; export var z2 = 10; export var aaaa = 10; // @filename: es6ImportNamedImportInEs5_1.ts import { } f...
{ "end_byte": 1238, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ImportNamedImportInEs5.ts" }
TypeScript/tests/cases/compiler/recursiveConditionalEvaluationNonInfinite.ts_0_240
type Test<T> = [T] extends [any[]] ? { array: Test<T[0]> } : { notArray: T }; declare const x: Test<number[]>; const y: { array: { notArray: number } } = x; // Error declare const a: Test<number>; const b: { notArray: number } = a; // Works
{ "end_byte": 240, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveConditionalEvaluationNonInfinite.ts" }
TypeScript/tests/cases/compiler/pathMappingBasedModuleResolution8_classic.ts_0_422
// @moduleResolution: classic // @module: amd // @traceResolution: true // @filename: c:/root/tsconfig.json { "compilerOptions": { "baseUrl": ".", "paths": { "@speedy/*/testing": [ "*/dist/index.ts" ] } } } // @filename: c:/root/index.ts import {x...
{ "end_byte": 422, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/pathMappingBasedModuleResolution8_classic.ts" }
TypeScript/tests/cases/compiler/declarationEmitScopeConsistency3.ts_0_187
// @strict: true // @declaration: true // @filename: a.ts export const g = (v: "outer") => { const f = (v: "inner") => () => null! as typeof v; const r = f(null!) return r; }
{ "end_byte": 187, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitScopeConsistency3.ts" }
TypeScript/tests/cases/compiler/classImplementsClass7.ts_0_60
class A { private x: number; } class B implements A {}
{ "end_byte": 60, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classImplementsClass7.ts" }
TypeScript/tests/cases/compiler/argumentsReferenceInFunction1_Js.ts_0_349
// @strict: true // @checkJs: true // @noEmit: true // @filename: index.js const format = function(f) { var str = ''; var i = 1; var args = arguments; var len = args.length; for (var x = args[i]; i < len; x = args[++i]) { str += ' ' + x; } return str; }; const debuglog = function() { return forma...
{ "end_byte": 349, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/argumentsReferenceInFunction1_Js.ts" }
TypeScript/tests/cases/compiler/genericConstraintDeclaration.ts_3_112
@declaration:true class List<T extends {}>{ static empty<T extends {}>(): List<T>{return null;} }
{ "end_byte": 112, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericConstraintDeclaration.ts" }
TypeScript/tests/cases/compiler/inferenceOptionalProperties.ts_0_845
// @strict: true // @exactOptionalPropertyTypes: true // @declaration: true declare function test<T>(x: { [key: string]: T }): T; declare let x1: { a?: string, b?: number }; declare let x2: { a?: string, b?: number | undefined }; const y1 = test(x1); const y2 = test(x2); var v1: Required<{ a?: string, b?: number }>...
{ "end_byte": 845, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inferenceOptionalProperties.ts" }
TypeScript/tests/cases/compiler/systemModule9.ts_0_326
// @module: system // @isolatedModules: true import * as ns from 'file1'; import {a, b as c} from 'file2'; import d from 'file3' import 'file4' import e, * as ns2 from 'file5'; import ns3 = require('file6'); ns.f(); a(); c(); d(); e(); ns2.f(); ns3.f(); export * from 'file7'; var x, y = true; export {x}; export {y ...
{ "end_byte": 326, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/systemModule9.ts" }
TypeScript/tests/cases/compiler/contextualTypeOfIndexedAccessParameter.ts_0_323
// @strict: true type Keys = "a" | "b"; type OptionsForKey = { a: { cb: (p: number) => number } } & { b: {} }; declare function f<K extends Keys>(key: K, options: OptionsForKey[K]): void; f("a", { cb: p => p, }); function g< K extends "a" | "b">(x: ({ a: string } & { b: string })[K], y: string) { x = y;...
{ "end_byte": 323, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTypeOfIndexedAccessParameter.ts" }
TypeScript/tests/cases/compiler/contextualTypingReturnStatementWithReturnTypeAnnotation.ts_0_481
// @strict: true // @noEmit: true type PropOfRaw<T> = readonly T[] | "not-array" | "no-prop"; declare function isString(text: unknown): text is string; declare function getPropFromRaw<T>( prop: "files" | "include" | "exclude" | "references", validateElement: (value: unknown) => boolean, elementTypeName: string...
{ "end_byte": 481, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTypingReturnStatementWithReturnTypeAnnotation.ts" }
TypeScript/tests/cases/compiler/missingMemberErrorHasShortPath.ts_0_191
// @useCaseSensitiveFileNames: false // @filename: C:/foo/bar/Baz/src/utils.ts export function exist() {} // @filename: C:/foo/bar/Baz/src/sample.ts import { exit } from "./utils.js"; exit()
{ "end_byte": 191, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/missingMemberErrorHasShortPath.ts" }
TypeScript/tests/cases/compiler/genericClassPropertyInheritanceSpecialization.ts_0_2094
interface KnockoutObservableBase<T> { peek(): T; (): T; (value: T): void; } interface KnockoutObservable<T> extends KnockoutObservableBase<T> { equalityComparer(a: T, b: T): boolean; valueHasMutated(): void; valueWillMutate(): void; } interface KnockoutObservableArray<T> extends KnockoutObserv...
{ "end_byte": 2094, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericClassPropertyInheritanceSpecialization.ts" }
TypeScript/tests/cases/compiler/noImplicitAnyParametersInAmbientModule.ts_3_1082
@noImplicitAny: true declare module D_M { // No implicit-'any' errors. function dm_f1(): void; // No implicit-'any' errors. function dm_f2(x): void; // No implicit-'any' errors. function dm_f3(x: any): void; // No implicit-'any' errors. function dm_f4(x, y, z): void; // No impli...
{ "end_byte": 1082, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noImplicitAnyParametersInAmbientModule.ts" }
TypeScript/tests/cases/compiler/es6DeclOrdering.ts_0_228
class Bar { //public bar() { } public foo() { return this._store.length; } constructor(store: string) { this._store = store; // this is an error for some reason? Unresolved symbol store } }
{ "end_byte": 228, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6DeclOrdering.ts" }
TypeScript/tests/cases/compiler/mergedClassNamespaceRecordCast.ts_0_279
class C1 { foo() {} } new C1() as Record<string, unknown>; class C2 { foo() {} } namespace C2 { export const unrelated = 3; } new C2() as Record<string, unknown>; C2.unrelated new C2().unrelated namespace C3 { export const unrelated = 3; } C3 as Record<string, unknown>;
{ "end_byte": 279, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mergedClassNamespaceRecordCast.ts" }
TypeScript/tests/cases/compiler/decoratorMetadataTypeOnlyExport.ts_0_277
// @experimentalDecorators: true // @emitDecoratorMetadata: true // @filename: ./a.ts class Foo {} export type { Foo }; // @filename: ./b.ts import { Foo } from "./a"; const Decorator: ClassDecorator = () => undefined; @Decorator class Bar { constructor(par: Foo) {} }
{ "end_byte": 277, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/decoratorMetadataTypeOnlyExport.ts" }
TypeScript/tests/cases/compiler/typeParameterListWithTrailingComma1.ts_0_15
class C<T,> { }
{ "end_byte": 15, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeParameterListWithTrailingComma1.ts" }
TypeScript/tests/cases/compiler/avoid.ts_0_240
function f() { var x=1; } var y=f(); // error void fn var why:any=f(); // error void fn var w:any; w=f(); // error void fn class C { g() { } } var z=new C().g(); // error void fn var N=new f(); // ok with void fn
{ "end_byte": 240, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/avoid.ts" }