_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts_0_543
class LanguageSpec_section_4_5_error_cases { public set AnnotatedSetter_SetterFirst(a: number) { } public get AnnotatedSetter_SetterFirst() { return ""; } public get AnnotatedSetter_SetterLast() { return ""; } public set AnnotatedSetter_SetterLast(a: number) { } public get AnnotatedGetter_GetterFi...
{ "end_byte": 543, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts" }
TypeScript/tests/cases/compiler/noImplicitAnyInBareInterface.ts_3_150
@noImplicitAny: true interface Entry { // Should return error for implicit any on `new` and `foo`. new (); few() : any; foo(); }
{ "end_byte": 150, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noImplicitAnyInBareInterface.ts" }
TypeScript/tests/cases/compiler/tripleSlashTypesReferenceWithMissingExports.ts_0_332
// @module: commonjs,node16,nodenext // @filename: node_modules/pkg/index.d.ts interface GlobalThing { a: number } // @filename: node_modules/pkg/package.json { "name": "pkg", "types": "index.d.ts", "exports": "some-other-thing.js" } // @filename: usage.ts /// <reference types="pkg" /> const a: GlobalThing...
{ "end_byte": 332, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/tripleSlashTypesReferenceWithMissingExports.ts" }
TypeScript/tests/cases/compiler/exportDeclarationsInAmbientNamespaces.ts_1_131
declare namespace Q { function _try(method: Function, ...args: any[]): any; export { _try as try }; } Q.try(() => { });
{ "end_byte": 131, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportDeclarationsInAmbientNamespaces.ts" }
TypeScript/tests/cases/compiler/recursiveInferenceBug.ts_0_122
function f(x: number) { var z = f(x); return x; } var zz = { g: () =>{ }, get f() { return "abc"; }, };
{ "end_byte": 122, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveInferenceBug.ts" }
TypeScript/tests/cases/compiler/controlFlowArrays.ts_0_3197
// @strictNullChecks: true // @noImplicitAny: true declare function cond(): boolean; function f1() { let x = []; x[0] = 5; x[1] = "hello"; x[2] = true; return x; // (string | number | boolean)[] } function f2() { let x = []; x.push(5); x.push("hello"); x.push(true); return x;...
{ "end_byte": 3197, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/controlFlowArrays.ts" }
TypeScript/tests/cases/compiler/moduleResolutionWithSuffixes_threeLastIsBlank4.ts_0_311
// moduleSuffixes has three entries, and the last one is blank. Module resolution should fail. // @filename: /tsconfig.json { "compilerOptions": { "moduleResolution": "node", "traceResolution": true, "moduleSuffixes": ["-ios", "__native", ""] } } // @filename: /index.ts import { base } from "./foo";
{ "end_byte": 311, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolutionWithSuffixes_threeLastIsBlank4.ts" }
TypeScript/tests/cases/compiler/commentsEnums.ts_0_277
// @target: ES5 // @declaration: true // @removeComments: false /** Enum of colors*/ enum Colors { /** Fancy name for 'blue'*/ Cornflower /* blue */, /** Fancy name for 'pink'*/ FancyPink } // trailing comment var x = Colors.Cornflower; x = Colors.FancyPink;
{ "end_byte": 277, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentsEnums.ts" }
TypeScript/tests/cases/compiler/augmentExportEquals4.ts_0_372
// @module: amd // @filename: file1.ts class foo {} namespace foo { export var v = 1; } export = foo; // @filename: file2.ts import x = require("./file1"); x.b = 1; // OK - './file1' is a namespace declare module "./file1" { interface A { a } let b: number; } // @filename: file3.ts import * as x from "...
{ "end_byte": 372, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/augmentExportEquals4.ts" }
TypeScript/tests/cases/compiler/jsFileCompilationTypeOfParameter.ts_0_62
// @allowJs: true // @filename: a.js function F(a: number) { }
{ "end_byte": 62, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationTypeOfParameter.ts" }
TypeScript/tests/cases/compiler/declarationEmitTypeParamMergedWithPrivate.ts_0_169
// @declaration: true // @target: es6 export class Test<T> { private get T(): T { throw ""; } public test(): T { return null as any; } }
{ "end_byte": 169, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitTypeParamMergedWithPrivate.ts" }
TypeScript/tests/cases/compiler/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts_0_752
// https://github.com/Microsoft/TypeScript/issues/25379 interface Map<K, V> { // ... } export type ImmutableTypes = IImmutableMap<any>; export type ImmutableModel<T> = { [K in keyof T]: T[K] extends ImmutableTypes ? T[K] : never }; export interface IImmutableMap<T extends ImmutableModel<T>> extends Map<string, ...
{ "end_byte": 752, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts" }
TypeScript/tests/cases/compiler/ClassDeclarationWithInvalidConstOnPropertyDeclaration2.ts_0_33
class C { const x = 10; }
{ "end_byte": 33, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ClassDeclarationWithInvalidConstOnPropertyDeclaration2.ts" }
TypeScript/tests/cases/compiler/commentsFormatting.ts_0_2839
// @target: ES5 // @declaration: true // @removeComments: false module m { /** this is first line - aligned to class declaration * this is 4 spaces left aligned * this is 3 spaces left aligned * this is 2 spaces left aligned * this is 1 spaces left aligned * this is at same level as first line * thi...
{ "end_byte": 2839, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentsFormatting.ts" }
TypeScript/tests/cases/compiler/modulePrologueCommonjs.ts_0_55
// @module: commonjs "use strict"; export class Foo {}
{ "end_byte": 55, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/modulePrologueCommonjs.ts" }
TypeScript/tests/cases/compiler/declFileClassWithStaticMethodReturningConstructor.ts_0_128
//@module: commonjs // @declaration: true export class Enhancement { public static getType() { return this; } }
{ "end_byte": 128, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileClassWithStaticMethodReturningConstructor.ts" }
TypeScript/tests/cases/compiler/es6ModuleInternalNamedImports2.ts_0_666
// @target: ES6 export module M { // variable export var M_V = 0; // interface export interface M_I { } //calss export class M_C { } // instantiated module export module M_M { var x; } // uninstantiated module export module M_MU { } // function export function M_F() { } ...
{ "end_byte": 666, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ModuleInternalNamedImports2.ts" }
TypeScript/tests/cases/compiler/declFileInternalAliases.ts_0_238
// @declaration: true module m { export class c { } } module m1 { import x = m.c; export var d = new x(); // emit the type as m.c } module m2 { export import x = m.c; export var d = new x(); // emit the type as x }
{ "end_byte": 238, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileInternalAliases.ts" }
TypeScript/tests/cases/compiler/strictNullNotNullIndexTypeShouldWork.ts_0_575
// @strictNullChecks: true interface A { params?: { name: string; }; } class Test<T extends A> { attrs: Readonly<T>; m() { this.attrs.params!.name; } } interface Foo { foo?: number; } class FooClass<P extends Foo = Foo> { properties: Readonly<P>; foo(): number { const { ...
{ "end_byte": 575, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/strictNullNotNullIndexTypeShouldWork.ts" }
TypeScript/tests/cases/compiler/typeGuardConstructorDerivedClass.ts_0_981
// Derived class with different structures class C1 { property1: number; } class C2 extends C1 { property2: number; } let var1: C2 | string; if (var1.constructor === C1) { var1; // never var1.property1; // error } if (var1.constructor === C2) { var1; // C2 var1.property1; // number } // Deriv...
{ "end_byte": 981, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeGuardConstructorDerivedClass.ts" }
TypeScript/tests/cases/compiler/jsFileClassPropertyInitalizationInObjectLiteral.ts_0_136
// @allowJs: true // @noEmit: true // @filename: foo.js module.exports = function () { class A { } return { c: A.b = 1, } };
{ "end_byte": 136, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileClassPropertyInitalizationInObjectLiteral.ts" }
TypeScript/tests/cases/compiler/multivar.ts_0_568
var a,b,c; var x=1,y=2,z=3; module m2 { export var a, b2: number = 10, b; var m1; var a2, b22: number = 10, b222; var m3; class C { constructor (public b) { } } export class C2 { constructor (public b) { } } var m; declare var d1, d2; var b...
{ "end_byte": 568, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/multivar.ts" }
TypeScript/tests/cases/compiler/enumWithQuotedElementName2.ts_0_21
enum E { "fo'o", }
{ "end_byte": 21, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumWithQuotedElementName2.ts" }
TypeScript/tests/cases/compiler/interfaceExtendsClassWithPrivate2.ts_0_434
class C { public foo(x: any) { return x; } private x = 1; } interface I extends C { other(x: any): any; } class D extends C implements I { // error public foo(x: any) { return x; } private x = 2; private y = 3; other(x: any) { return x; } bar() {} } class D2 extends C implements I { ...
{ "end_byte": 434, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/interfaceExtendsClassWithPrivate2.ts" }
TypeScript/tests/cases/compiler/es5ExportDefaultClassDeclaration4.ts_0_224
// @target: es5 // @module: commonjs // @declaration: true declare module "foo" { export var before: C; export default class C { method(): C; } export var after: C; export var t: typeof C; }
{ "end_byte": 224, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es5ExportDefaultClassDeclaration4.ts" }
TypeScript/tests/cases/compiler/fixingTypeParametersRepeatedly1.ts_0_283
declare function f<T>(x: T, y: (p: T) => T, z: (p: T) => T): T; f("", x => null, x => x.toLowerCase()); // First overload of g should type check just like f declare function g<T>(x: T, y: (p: T) => T, z: (p: T) => T): T; declare function g(); g("", x => null, x => x.toLowerCase());
{ "end_byte": 283, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/fixingTypeParametersRepeatedly1.ts" }
TypeScript/tests/cases/compiler/decoratorWithUnderscoreMethod.ts_0_498
// @lib: es5 // @noemithelpers: true // @experimentaldecorators: true declare var console : { log(arg: string): void }; function dec(): Function { return function (target: any, propKey: string, descr: PropertyDescriptor): void { console.log(target[propKey]); //logs undefined //propKey has t...
{ "end_byte": 498, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/decoratorWithUnderscoreMethod.ts" }
TypeScript/tests/cases/compiler/reuseTypeAnnotationImportTypeInGlobalThisTypeArgument.ts_0_896
// @checkJs: true // @declaration: true // @module: preserve // @emitDeclarationOnly: true // @noTypesAndSymbols: true // @Filename: /contractHelper.d.ts export function handleParamGovernance(zcf: any): { publicMixin: { getGovernedParams: () => globalThis.ERef<import("./types.js").ParamStateRecord>; }; }; // ...
{ "end_byte": 896, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reuseTypeAnnotationImportTypeInGlobalThisTypeArgument.ts" }
TypeScript/tests/cases/compiler/indexerAsOptional.ts_0_186
interface indexSig { //Index signatures can't be optional [idx?: number]: any; //err } class indexSig2 { //Index signatures can't be optional [idx?: number]: any //err }
{ "end_byte": 186, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/indexerAsOptional.ts" }
TypeScript/tests/cases/compiler/binaryArithmatic1.ts_0_17
var v = 4 | null;
{ "end_byte": 17, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/binaryArithmatic1.ts" }
TypeScript/tests/cases/compiler/letInVarDeclOfForIn_ES5.ts_0_105
// @target: es5 // should not be an error for (var let in [1,2,3]) {} { for (var let in [1,2,3]) {} }
{ "end_byte": 105, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/letInVarDeclOfForIn_ES5.ts" }
TypeScript/tests/cases/compiler/systemModuleTrailingComments.ts_0_62
// @module: system export const test = "TEST"; //some comment
{ "end_byte": 62, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/systemModuleTrailingComments.ts" }
TypeScript/tests/cases/compiler/newNamesInGlobalAugmentations1.ts_0_335
// @target: es6 // @filename: f1.d.ts export {}; declare module M.M1 { export let x: number; } declare global { interface SymbolConstructor { observable: symbol; } class Cls {x} let [a, b]: number[]; export import X = M.M1.x; } // @filename: main.ts Symbol.observable; new Cls().x let...
{ "end_byte": 335, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/newNamesInGlobalAugmentations1.ts" }
TypeScript/tests/cases/compiler/moduleAndInterfaceSharingName.ts_0_132
module X { export module Y { export interface Z { } } export interface Y { } } var z: X.Y.Z = null; var z2: X.Y;
{ "end_byte": 132, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleAndInterfaceSharingName.ts" }
TypeScript/tests/cases/compiler/wrappedRecursiveGenericType.ts_0_335
interface X<T> { e: T; } interface A<T> { a: B<T>; val: T; } interface B<T> { b: A<X<T>>; val: T; } var x: A<number>; x.val = 5; // val -> number x.a.val = 5; // val -> number x.a.b.val = 5; // val -> X<number> (This should be an error) x.a.b.a.val = 5; // val -> X<number> (This shou...
{ "end_byte": 335, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/wrappedRecursiveGenericType.ts" }
TypeScript/tests/cases/compiler/typeAliasFunctionTypeSharedSymbol.ts_0_292
// Repro from comment in #21496 function Mixin<TBase extends {new (...args: any[]): {}}>(Base: TBase) { return class extends Base { }; } type Mixin = ReturnTypeOf<typeof Mixin> type ReturnTypeOf<V> = V extends (...args: any[])=>infer R ? R : never; type Crashes = number & Mixin;
{ "end_byte": 292, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeAliasFunctionTypeSharedSymbol.ts" }
TypeScript/tests/cases/compiler/augmentedTypeBracketNamedPropertyAccess.ts_0_318
interface Object { data: number; } interface Function { functionData: string; } var o = {}; var f = function () { }; var r1 = o['data']; // Should be number var r2 = o['functionData']; // Should be any (no property found) var r3 = f['functionData']; // Should be string var r4 = f['data']; // Should be number
{ "end_byte": 318, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/augmentedTypeBracketNamedPropertyAccess.ts" }
TypeScript/tests/cases/compiler/argumentsReferenceInMethod7_Js.ts_0_179
// @declaration: true // @allowJs: true // @emitDeclarationOnly: true // @filename: /a.js class A { m() { /** * @type Function */ this.callee = arguments.callee; } }
{ "end_byte": 179, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/argumentsReferenceInMethod7_Js.ts" }
TypeScript/tests/cases/compiler/commentsOnObjectLiteral3.ts_0_340
// @removeComments: false // @target: ES5 var v = { //property prop: 1 /* multiple trailing comments */ /*trailing comments*/, //property func: function () { }, //PropertyName + CallSignature func1() { }, //getter get a() { return this.prop; } /*trailing 1*/, //setter set a(value) { this.prop = value; ...
{ "end_byte": 340, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentsOnObjectLiteral3.ts" }
TypeScript/tests/cases/compiler/interfaceDeclaration6.ts_3_158
terface i1 { foo: number; }; interface i2 extends i1 { foo: number; }; interface i3 extends i1 { foo: string; }; interface i4 { bar():any; bar():any; }
{ "end_byte": 158, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/interfaceDeclaration6.ts" }
TypeScript/tests/cases/compiler/enumInitializersWithExponents.ts_0_171
// Must be integer literals. declare enum E { a = 1e3, // ok b = 1e25, // ok c = 1e-3, // error d = 1e-9, // error e = 1e0, // ok f = 1e+25 // ok }
{ "end_byte": 171, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumInitializersWithExponents.ts" }
TypeScript/tests/cases/compiler/umdDependencyCommentName1.ts_0_91
//@module: umd ///<amd-dependency path='bar' name='b'/> import m1 = require("m2") m1.f();
{ "end_byte": 91, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/umdDependencyCommentName1.ts" }
TypeScript/tests/cases/compiler/arrayFrom.ts_0_1287
// @lib: es2015 // Tests fix for #20432, ensures Array.from accepts all valid inputs // Also tests for #19682 interface A { a: string; } interface B { b: string; } const inputA: A[] = []; const inputB: B[] = []; const inputALike: ArrayLike<A> = { length: 0 }; const inputARand = getEither(inputA, inputALike); co...
{ "end_byte": 1287, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arrayFrom.ts" }
TypeScript/tests/cases/compiler/moduleAliasAsFunctionArgument.ts_0_348
//@module: amd // @Filename: moduleAliasAsFunctionArgument_0.ts export var x: number; // @Filename: moduleAliasAsFunctionArgument_1.ts ///<reference path='moduleAliasAsFunctionArgument_0.ts'/> import a = require('moduleAliasAsFunctionArgument_0'); function fn(arg: { x: number }) { } a.x; // OK fn(a); // Error: prope...
{ "end_byte": 348, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleAliasAsFunctionArgument.ts" }
TypeScript/tests/cases/compiler/propertyAccess3.ts_0_30
var foo: boolean; foo.toBAZ();
{ "end_byte": 30, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/propertyAccess3.ts" }
TypeScript/tests/cases/compiler/dynamicImportWithNestedThis_es2015.ts_0_225
// @lib: es2015 // @target: es2015 // @module: umd // https://github.com/Microsoft/TypeScript/issues/17564 class C { private _path = './other'; dynamic() { return import(this._path); } } const c = new C(); c.dynamic();
{ "end_byte": 225, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/dynamicImportWithNestedThis_es2015.ts" }
TypeScript/tests/cases/compiler/declFileModuleAssignmentInObjectLiteralProperty.ts_0_116
// @declaration: true module m1 { export class c { } } var d = { m1: { m: m1 }, m2: { c: m1.c }, };
{ "end_byte": 116, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileModuleAssignmentInObjectLiteralProperty.ts" }
TypeScript/tests/cases/compiler/declarationEmitDistributiveConditionalWithInfer.ts_0_222
// @declaration: true // @lib: es2020 // This function's type is changed on declaration export const fun = ( subFun: <Collection, Field extends keyof Collection>() => FlatArray<Collection[Field], 0>[]) => { };
{ "end_byte": 222, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitDistributiveConditionalWithInfer.ts" }
TypeScript/tests/cases/compiler/systemModule16.ts_0_252
// @module: system // @isolatedModules: true import * as x from "foo"; import * as y from "bar"; export * from "foo"; export * from "bar" export {x} export {y} import {a1, b1, c1 as d1} from "foo"; export {a2, b2, c2 as d2} from "bar"; x,y,a1,b1,d1;
{ "end_byte": 252, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/systemModule16.ts" }
TypeScript/tests/cases/compiler/spreadIntersection.ts_0_200
var intersection: { a: number } & { b: string }; var o1: { a: number, b: string }; var o1 = { ...intersection }; var o2: { a: number, b: string, c: boolean }; var o2 = { ...intersection, c: false };
{ "end_byte": 200, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/spreadIntersection.ts" }
TypeScript/tests/cases/compiler/objectLiteralExcessProperties.ts_0_1588
interface Book { foreword: string; } interface Cover { color?: string; } var b1: Book = { forword: "oops" }; var b2: Book | string = { foreward: "nope" }; var b3: Book | (Book[]) = [{ foreword: "hello" }, { forwards: "back" }]; var b4: Book & Cover = { foreword: "hi", colour: "blue" }; var b5: Book & Cove...
{ "end_byte": 1588, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectLiteralExcessProperties.ts" }
TypeScript/tests/cases/compiler/voidFunctionAssignmentCompat.ts_0_736
var fa = function(): any { return 3; } fa = function() { } // should not work var fv = function(): void {} fv = function() { return 0; } // should work function execAny(callback:(val:any)=>any) { return callback(0) } execAny(function () {}); // should work function execVoid(callback:(val:any)=>void) { callback(0); }...
{ "end_byte": 736, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/voidFunctionAssignmentCompat.ts" }
TypeScript/tests/cases/compiler/functionOverloads34.ts_0_137
function foo(bar:{a:number;}):string; function foo(bar:{a:boolean;}):number; function foo(bar:{a:any;}):any{ return bar } var x = foo();
{ "end_byte": 137, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloads34.ts" }
TypeScript/tests/cases/compiler/numericClassMembers1.ts_0_119
class C234 { 0 = 1; 0.0 = 2; } class C235 { 0.0 = 1; '0' = 2; } class C236 { '0.0' = 1; '0' = 2; }
{ "end_byte": 119, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/numericClassMembers1.ts" }
TypeScript/tests/cases/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.ts_0_234
// @strict: true // @checkJs: true // @declaration: true // @outDir: out // @filename: index.js /** * @typedef Options * @property {string} opt */ /** * @param {Options} options */ module.exports = function loader(options) {}
{ "end_byte": 234, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.ts" }
TypeScript/tests/cases/compiler/noCrashOnNoLib.ts_0_108
// @noLib: true export function f() { let e: {}[]; while (true) { e = [...(e || [])]; } }
{ "end_byte": 108, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noCrashOnNoLib.ts" }
TypeScript/tests/cases/compiler/restParamModifier2.ts_0_56
class C { constructor(public ...rest: string[]) {} }
{ "end_byte": 56, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/restParamModifier2.ts" }
TypeScript/tests/cases/compiler/optionsSourcemapInlineSources.ts_0_56
// @sourcemap: true // @inlineSources: true var a = 10;
{ "end_byte": 56, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/optionsSourcemapInlineSources.ts" }
TypeScript/tests/cases/compiler/nestedModulePrivateAccess.ts_0_110
module a{ var x:number; module b{ var y = x; // should not be an error } }
{ "end_byte": 110, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nestedModulePrivateAccess.ts" }
TypeScript/tests/cases/compiler/implicitAnyFromCircularInference.ts_0_660
// @noimplicitany: true // @target: es5 // Error expected var a: typeof a; // Error expected on b or c var b: typeof c; var c: typeof b; // Error expected var d: Array<typeof d>; function f() { return f; } // Error expected function g() { return g(); } // Error expected var f1 = function () { return f1(); }; ...
{ "end_byte": 660, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/implicitAnyFromCircularInference.ts" }
TypeScript/tests/cases/compiler/innerTypeCheckOfLambdaArgument.ts_0_262
function takesCallback(callback: (n) =>any) { } takesCallback( function inner(n) { // this line should raise an error // otherwise, there's a bug in overload resolution / partial typechecking var k: string = 10; } );
{ "end_byte": 262, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/innerTypeCheckOfLambdaArgument.ts" }
TypeScript/tests/cases/compiler/exportPrivateType.ts_0_546
module foo { class C1 { x: string; y: C1; } class C2 { test() { return true; } } interface I1 { (a: string, b: string): string; (x: number, y: number): I1; } interface I2 { x: string; y: number; } // None of the types ar...
{ "end_byte": 546, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportPrivateType.ts" }
TypeScript/tests/cases/compiler/nanEquality.ts_0_604
declare const x: number; if (x === NaN) {} if (NaN === x) {} if (x == NaN) {} if (NaN == x) {} if (x !== NaN) {} if (NaN !== x) {} if (x != NaN) {} if (NaN != x) {} if (x === ((NaN))) {} if (((NaN)) === x) {} if (x !== ((NaN))) {} if (((NaN)) !== x) {} if (NaN === NaN) {} if (NaN !== NaN) {} if (NaN == NaN) {} ...
{ "end_byte": 604, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nanEquality.ts" }
TypeScript/tests/cases/compiler/typeOfPrototype.ts_0_95
class Foo { bar = 3; static bar = ''; } Foo.prototype.bar = undefined; // Should be OK
{ "end_byte": 95, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeOfPrototype.ts" }
TypeScript/tests/cases/compiler/exportVisibility.ts_0_123
//@module: commonjs export class Foo { } export var foo = new Foo(); export function test(foo: Foo) { return true; }
{ "end_byte": 123, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportVisibility.ts" }
TypeScript/tests/cases/compiler/thisIndexOnExistingReadonlyFieldIsNotNever.ts_0_675
// @strict: true declare class Component<P, S = {}> { readonly props: Readonly<{ children?: unknown }> & Readonly<P>; state: Readonly<S>; } interface CoachMarkAnchorProps<C> { anchorRef?: (anchor: C) => void; } type AnchorType<P> = Component<P>; class CoachMarkAnchorDecorator { decorateComponent<P>(anc...
{ "end_byte": 675, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/thisIndexOnExistingReadonlyFieldIsNotNever.ts" }
TypeScript/tests/cases/compiler/declareExternalModuleWithExportAssignedFundule.ts_0_363
declare module "express" { export = express; function express(): express.ExpressServer; module express { export interface ExpressServer { enable(name: string): ExpressServer; post(path: RegExp, handler: (req: Function) => void ): void; } export class E...
{ "end_byte": 363, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declareExternalModuleWithExportAssignedFundule.ts" }
TypeScript/tests/cases/compiler/anyIsAssignableToObject.ts_0_118
interface P { p: {}; } interface Q extends P { // Check assignability here. Any is assignable to {} p: any; }
{ "end_byte": 118, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/anyIsAssignableToObject.ts" }
TypeScript/tests/cases/compiler/allowImportClausesToMergeWithTypes.ts_0_365
// @filename: b.ts export const zzz = 123; export default zzz; // @filename: a.ts export default interface zzz { x: string; } import zzz from "./b"; const x: zzz = { x: "" }; zzz; export { zzz as default }; // @filename: index.ts import zzz from "./a"; const x: zzz = { x: "" }; zzz; import originalZZZ from "...
{ "end_byte": 365, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/allowImportClausesToMergeWithTypes.ts" }
TypeScript/tests/cases/compiler/destructuringAssignmentWithExportedName.ts_0_626
// @target: es2015 // @module: commonjs export let exportedFoo: any; let nonexportedFoo: any; // sanity checks exportedFoo = null; nonexportedFoo = null; if (null as any) { ({ exportedFoo, nonexportedFoo } = null as any); } else if (null as any) { ({ foo: exportedFoo, bar: nonexportedFoo } = null as any); } else...
{ "end_byte": 626, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/destructuringAssignmentWithExportedName.ts" }
TypeScript/tests/cases/compiler/typeParameterAssignmentCompat1.ts_0_307
interface Foo<T> { frobble(value: T): T; } function f<T, U>(): Foo<U> { var x: Foo<T>; var y: Foo<U>; x = y; // should be an error return x; } class C<T> { f<U>(): Foo<U> { var x: Foo<T>; var y: Foo<U>; x = y; // should be an error return x; } }
{ "end_byte": 307, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeParameterAssignmentCompat1.ts" }
TypeScript/tests/cases/compiler/genericClassesInModule2.ts_0_393
//@module: amd export class A<T1>{ constructor( public callback: (self: A<T1>) => void) { var child = new B(this); } AAA( callback: (self: A<T1>) => void) { var child = new B(this); } } export interface C<T1>{ child: B<T1>; (self: C<T1>): void; new(callback: (self: C<T1>) =>...
{ "end_byte": 393, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericClassesInModule2.ts" }
TypeScript/tests/cases/compiler/optionalParamReferencingOtherParams3.ts_0_46
function right(a = b, b = a) { a; b; }
{ "end_byte": 46, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/optionalParamReferencingOtherParams3.ts" }
TypeScript/tests/cases/compiler/assignmentNestedInLiterals.ts_0_175
// @noImplicitAny: true var target, x, y; target = [x = 1, y = x]; var aegis, a, b; aegis = { x: a = 1, y: b = a }; var kowloona, c, d; for (kowloona of [c = 1, d = c]) { }
{ "end_byte": 175, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentNestedInLiterals.ts" }
TypeScript/tests/cases/compiler/typeParameterArgumentEquivalence5.ts_0_152
function foo<T,U>() { var x: () => (item) => U; var y: () => (item) => T; x = y; // Should be an error y = x; // Shound be an error }
{ "end_byte": 152, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeParameterArgumentEquivalence5.ts" }
TypeScript/tests/cases/compiler/collisionRestParameterUnderscoreIUsage.ts_0_227
// @lib: es5 declare var console: { log(msg?: string): void; }; var _i = "This is what I'd expect to see"; class Foo { constructor(...args: any[]) { console.log(_i); // This should result in error } } new Foo();
{ "end_byte": 227, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionRestParameterUnderscoreIUsage.ts" }
TypeScript/tests/cases/compiler/pathMappingBasedModuleResolution5_classic.ts_0_920
// @module: amd // @traceResolution: true // paths is defined in tsconfig.json // @filename: c:/root/tsconfig.json { "compilerOptions": { "baseUrl": ".", "paths": { "*": [ "*", "generated/*" ], "components/*": [ ...
{ "end_byte": 920, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/pathMappingBasedModuleResolution5_classic.ts" }
TypeScript/tests/cases/compiler/unusedVariablesinBlocks1.ts_0_117
//@noUnusedLocals:true //@noUnusedParameters:true function f1 () { let x = 10; { let x = 11; } }
{ "end_byte": 117, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedVariablesinBlocks1.ts" }
TypeScript/tests/cases/compiler/reactReduxLikeDeferredInferenceAllowsAssignment.ts_0_3883
// @strict: true declare class Component<P> { constructor(props: Readonly<P>); constructor(props: P, context?: any); readonly props: Readonly<P> & Readonly<{ children?: {} }>; } interface ComponentClass<P = {}> { new (props: P, context?: any): Component<P>; propTypes?: WeakValidationMap<P>; defaultProps?: P...
{ "end_byte": 3883, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reactReduxLikeDeferredInferenceAllowsAssignment.ts" }
TypeScript/tests/cases/compiler/didYouMeanElaborationsForExpressionsWhichCouldBeCalled.ts_0_357
class Bar { x!: string; } declare function getNum(): number; declare function foo(arg: { x: Bar, y: Date }, item: number, items?: [number, number, number]): void; foo({ x: Bar, y: Date }, getNum()); foo({ x: new Bar(), y: new Date() }, getNum); foo({ x: new Bar(), y: new Date() }, getN...
{ "end_byte": 357, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/didYouMeanElaborationsForExpressionsWhichCouldBeCalled.ts" }
TypeScript/tests/cases/compiler/jsNoImplicitAnyNoCascadingReferenceErrors.ts_0_308
// @allowJs: true // @checkJs: true // @noImplicitAny: true // @outDir: ./built // @filename: somelib.d.ts export declare class Foo<T> { prop: T; } // @filename: index.js import {Foo} from "./somelib"; class MyFoo extends Foo { constructor() { super(); this.prop.alpha = 12; } }
{ "end_byte": 308, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsNoImplicitAnyNoCascadingReferenceErrors.ts" }
TypeScript/tests/cases/compiler/inlineSourceMap2.ts_0_198
// @target: ES5 // @sourcemap: true // @maproot: file:///folder // @sourceroot: file:///folder // @outFile: outfile.js // @inlinesourcemap: true // configuration errors var x = 0; console.log(x);
{ "end_byte": 198, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inlineSourceMap2.ts" }
TypeScript/tests/cases/compiler/es6Module.ts_0_112
// @target: ES6 export class A { constructor () { } public B() { return 42; } }
{ "end_byte": 112, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6Module.ts" }
TypeScript/tests/cases/compiler/staticMethodReferencingTypeArgument1.ts_0_388
module Editor { export class List<T> { next: List<T>; prev: List<T>; constructor(public isHead: boolean, public data: T) { } static MakeHead(): List<T> { var entry: List<T> = new List<T>(true, null); // can't access T here entry.prev = entry; ...
{ "end_byte": 388, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/staticMethodReferencingTypeArgument1.ts" }
TypeScript/tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts_0_3312
// @allowUnreachableCode: true // @target: es5 function f1(): string { // errors because there are no return statements } function f2(): string { // Permissible; returns undefined. return; } function f3(): string { return "Okay, because this is a return expression."; } function f4(): void { // ...
{ "end_byte": 3312, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts" }
TypeScript/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts_0_228
//@noUnusedLocals:true //@noUnusedParameters:true function greeter(person: string, person2: string) { var unused = 20; function maker(child: string): void { var unused2 = 22; } person2 = "dummy value"; }
{ "end_byte": 228, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts" }
TypeScript/tests/cases/compiler/eventEmitterPatternWithRecordOfFunction.ts_0_319
// @strict: true interface A { emit(event: string, ...args: any[]): boolean; } type Args<F> = F extends (...args: infer A) => void ? A : never; type EventMap = Record<string, Function>; interface B<M extends EventMap> extends A { emit<Event extends keyof M>(event: Event, ...args: Args<M[Event]>): boolean; }
{ "end_byte": 319, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/eventEmitterPatternWithRecordOfFunction.ts" }
TypeScript/tests/cases/compiler/declarationEmitToDeclarationDirWithoutCompositeAndDeclarationOptions.ts_0_169
// @filename: /foo/tsconfig.json { "compilerOptions": { "declarationDir": "out" } } // @filename: /foo/test.ts interface Foo { x: number; } export default Foo;
{ "end_byte": 169, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitToDeclarationDirWithoutCompositeAndDeclarationOptions.ts" }
TypeScript/tests/cases/compiler/modularizeLibrary_NoErrorDuplicateLibOptions1.ts_3_1280
@lib: es5,es6,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; /...
{ "end_byte": 1280, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/modularizeLibrary_NoErrorDuplicateLibOptions1.ts" }
TypeScript/tests/cases/compiler/visSyntax.ts_0_96
module M { export class C { } export interface I { } export var x=10; }
{ "end_byte": 96, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/visSyntax.ts" }
TypeScript/tests/cases/compiler/mergeMultipleInterfacesReexported.ts_0_478
// @filename: index.ts export * from './eventList'; // @filename: test.ts import { EventList } from "./eventList"; declare const p012: "p0" | "p1" | "p2" const t: keyof EventList = p012 // @filename: eventList.ts export interface EventList { p0: []; } // @filename: foo.ts declare module './index' { interfac...
{ "end_byte": 478, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mergeMultipleInterfacesReexported.ts" }
TypeScript/tests/cases/compiler/tupleTypeInference2.ts_0_596
// @strict: true // Repro from #22564 type A<R> = [R] | [R, string]; declare function f<T>(x: A<T>): T; f([undefined, ''] as [never, string]); // T: never f([undefined, ''] as [void, string]); // T: void // Repro from #22563 type B<R, S> = [R] | [R, S]; declare function g<T, U>(f: B<T, U>): U; g([[]] as [void[]]); ...
{ "end_byte": 596, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/tupleTypeInference2.ts" }
TypeScript/tests/cases/compiler/extendGlobalThis.ts_0_233
// @filename: extension.d.ts declare global { namespace globalThis { var test: string; } } export {} // @filename: index.ts import "./extention"; globalThis.tests = "a-b"; console.log(globalThis.test.split("-"));
{ "end_byte": 233, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/extendGlobalThis.ts" }
TypeScript/tests/cases/compiler/indexSignatureOfTypeUnknownStillRequiresIndexSignature.ts_0_211
declare function f<T extends unknown = unknown>(x: { [x: string]: T }): T; var stooges = [ { name: "moe", age: 40 }, { name: "larry", age: 50 }, { name: "curly", age: 60 } ]; f(stooges); // Should throw
{ "end_byte": 211, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/indexSignatureOfTypeUnknownStillRequiresIndexSignature.ts" }
TypeScript/tests/cases/compiler/FunctionDeclaration6.ts_0_46
{ function foo(); function bar() { } }
{ "end_byte": 46, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/FunctionDeclaration6.ts" }
TypeScript/tests/cases/compiler/returnStatement1.ts_0_129
// @allowUnreachableCode: true function f() { return function (s) { var x = s; }; ("harmless extra line"); }
{ "end_byte": 129, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/returnStatement1.ts" }
TypeScript/tests/cases/compiler/recursiveTupleTypeInference.ts_0_418
// @strict: true // Repro from #37475 export type A = "number" | "null" | A[]; export type F<T> = null extends T ? [F<NonNullable<T>>, "null"] : T extends number ? "number" : never; export type G<T> = { [k in keyof T]: F<T[k]> }; interface K { b: number | null; } const gK: { [key in keyof K]: ...
{ "end_byte": 418, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveTupleTypeInference.ts" }
TypeScript/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts.ts_0_671
// @module: commonjs // @declaration: true // @filename: server.ts export class a { } export class x { } export class m { } export class a11 { } export class a12 { } export class x11 { } // @filename: client.ts import defaultBinding1, { } from "./server"; import defaultBinding2, { a } from "./server"; export var x1 =...
{ "end_byte": 671, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts.ts" }
TypeScript/tests/cases/compiler/commentOnArrayElement12.ts_3_43
nst array = [ ,, /* comment */ ];
{ "end_byte": 43, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentOnArrayElement12.ts" }
TypeScript/tests/cases/compiler/noErrorTruncation.ts_0_486
// @noErrorTruncation type SomeLongOptionA = { someLongOptionA: string } type SomeLongOptionB = { someLongOptionB: string } type SomeLongOptionC = { someLongOptionC: string } type SomeLongOptionD = { someLongOptionD: string } type SomeLongOptionE = { someLongOptionE: string } type SomeLongOptionF = { someLongOptionF: ...
{ "end_byte": 486, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noErrorTruncation.ts" }