_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/declFileTypeofClass.ts_0_221
// @declaration: true class c { static x : string; private static y: number; private x3: string; public y3: number; } var x: c; var y = c; var z: typeof c; class genericC<T> { } var genericX = genericC;
{ "end_byte": 221, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileTypeofClass.ts" }
TypeScript/tests/cases/compiler/coAndContraVariantInferences7.ts_0_516
// @strict: true // @noEmit: true type Request<TSchema extends Schema> = { query: TSchema["query"]; }; type Schema = { query?: unknown; body?: unknown }; declare function route<TSchema extends Schema>(obj: { pre: (a: TSchema) => void; schema: TSchema; handle: (req: Request<TSchema>) => void; }): void; const...
{ "end_byte": 516, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/coAndContraVariantInferences7.ts" }
TypeScript/tests/cases/compiler/importNonExportedMember9.ts_0_193
// @esModuleInterop: true // @module: commonjs // @checkJs: true // @allowJs: true // @noEmit: true // @Filename: a.ts class Foo {} export = Foo; // @Filename: b.js import { Foo } from './a';
{ "end_byte": 193, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importNonExportedMember9.ts" }
TypeScript/tests/cases/compiler/castTest.ts_1_508
var x : any = 0; var z = <number> x; var y = x + z; var a = <any>0; var b = <boolean>true; var s = <string>""; var ar = <any[]>null; var f = <(res : number) => void>null; declare class Point { x: number; y: number; add(dx: number, dy: number): Point; mult(p: Point): Point; constructor(x: number,...
{ "end_byte": 508, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/castTest.ts" }
TypeScript/tests/cases/compiler/commentsOnRequireStatement.ts_3_261
@target: es5 // @module: commonjs // @Filename: 0.ts export var subject = 10; // @Filename: 1.ts export var subject1 = 10; // @Filename: 2.ts /* blah0 */ // blah // blah // blah export {subject} from './0'; /* blah1 */ export {subject1} from './1';
{ "end_byte": 261, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentsOnRequireStatement.ts" }
TypeScript/tests/cases/compiler/nodeNextModuleResolution2.ts_0_332
// @moduleResolution: nodenext // @traceResolution: true // @filename: /a/node_modules/foo/index.d.ts export declare let x: number // @filename: /a/node_modules/foo/package.json { "name": "foo", "type": "module", "exports": { ".": "./index.d.ts" } } // @filename: /a/b/c/d/e/app.mts import {x} ...
{ "end_byte": 332, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nodeNextModuleResolution2.ts" }
TypeScript/tests/cases/compiler/anonClassDeclarationEmitIsAnon.ts_0_674
// @declaration: true // @filename: wrapClass.ts export function wrapClass(param: any) { return class Wrapped { foo() { return param; } } } export type Constructor<T = {}> = new (...args: any[]) => T; export function Timestamped<TBase extends Constructor>(Base: TBase) { return ...
{ "end_byte": 674, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/anonClassDeclarationEmitIsAnon.ts" }
TypeScript/tests/cases/compiler/collisionThisExpressionAndLocalVarInFunction.ts_0_119
// @lib: es5 var console: { log(val: any); } function x() { var _this = 5; x => { console.log(this.x); }; }
{ "end_byte": 119, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionThisExpressionAndLocalVarInFunction.ts" }
TypeScript/tests/cases/compiler/getterMissingReturnError.ts_0_43
class test { public get p2(){ } }
{ "end_byte": 43, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/getterMissingReturnError.ts" }
TypeScript/tests/cases/compiler/defaultOfAnyInStrictNullChecks.ts_0_143
// @strictNullChecks: true // Regression test for #8295 function foo() { try { } catch (e) { let s = e.message; } }
{ "end_byte": 143, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/defaultOfAnyInStrictNullChecks.ts" }
TypeScript/tests/cases/compiler/circularReferenceInReturnType.ts_0_548
// @strict: true // @noEmit: true // inference fails for res1 and res2, but ideally should not declare function fn1<T>(cb: () => T): string; const res1 = fn1(() => res1); declare function fn2<T>(): (cb: () => any) => (a: T) => void; const res2 = fn2()(() => res2); declare function fn3<T>(): <T2>(cb: (arg: T2) => any...
{ "end_byte": 548, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/circularReferenceInReturnType.ts" }
TypeScript/tests/cases/compiler/requireOfJsonFileWithModuleNodeResolutionEmitAmd.ts_0_224
// @module: amd // @moduleResolution: node // @outdir: out/ // @fullEmitPaths: true // @resolveJsonModule: true // @Filename: file1.ts import * as b from './b.json'; // @Filename: b.json { "a": true, "b": "hello" }
{ "end_byte": 224, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/requireOfJsonFileWithModuleNodeResolutionEmitAmd.ts" }
TypeScript/tests/cases/compiler/declarationEmitDefaultExport4.ts_0_82
// @declaration: true // @target: es6 export default function () { return 1; }
{ "end_byte": 82, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitDefaultExport4.ts" }
TypeScript/tests/cases/compiler/internalAliasInitializedModuleInsideLocalModuleWithoutExportAccessError.ts_0_207
//@module: commonjs export module a { export module b { export class c { } } } export module c { import b = a.b; export var x: b.c = new b.c(); } export var d = new c.b.c();
{ "end_byte": 207, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/internalAliasInitializedModuleInsideLocalModuleWithoutExportAccessError.ts" }
TypeScript/tests/cases/compiler/capturedLetConstInLoop4_ES6.ts_0_2438
// @target: ES6 //======let export function exportedFoo() { return v0 + v00 + v1 + v2 + v3 + v4 + v5 + v6 + v7 + v8; } for (let x of []) { var v0 = x; (function() { return x + v0}); (() => x); } for (let x in []) { var v00 = x; (function() { return x + v00}); (() => x); } for (le...
{ "end_byte": 2438, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/capturedLetConstInLoop4_ES6.ts" }
TypeScript/tests/cases/compiler/mappedTypeUnionConstraintInferences.ts_0_761
// @declaration: true // @keyofStringsOnly: true export declare type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>; export declare type PartialProperties<T, K extends keyof T> = Partial<Pick<T, K>> & Omit<T, K>; export function doSomething_Actual<T extends { prop: string; }>(a: T) { const x: { [P in...
{ "end_byte": 761, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mappedTypeUnionConstraintInferences.ts" }
TypeScript/tests/cases/compiler/autolift4.ts_0_433
class Point { constructor(public x: number, public y: number) { } getDist() { return Math.sqrt(this.x*this.x + this.y*this.y); } static origin = new Point(0,0); } class Point3D extends Point { constructor(x: number, y: number, public z: number, m:number) { super(x, y); ...
{ "end_byte": 433, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/autolift4.ts" }
TypeScript/tests/cases/compiler/noCrashOnMixin.ts_0_360
class Abstract { protected constructor() { } } class Concrete extends Abstract { } type Constructor<T = {}> = new (...args: any[]) => T; function Mixin<TBase extends Constructor>(Base: TBase) { return class extends Base { }; } class Empty { } class CrashTrigger extends Mixin(Empty) { public tri...
{ "end_byte": 360, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noCrashOnMixin.ts" }
TypeScript/tests/cases/compiler/importElisionEnum.ts_0_186
// @Filename: enum.ts export enum MyEnum { a = 0, b, c, d } // @Filename: index.ts import { MyEnum as MyEnumFromModule } from "./enum"; enum MyEnum { a = MyEnumFromModule.a }
{ "end_byte": 186, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importElisionEnum.ts" }
TypeScript/tests/cases/compiler/recursiveBaseCheck6.ts_0_58
class S18<A> extends S18<{ S19: A; }>{ } (new S18()).blah;
{ "end_byte": 58, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveBaseCheck6.ts" }
TypeScript/tests/cases/compiler/privacyCheckTypeOfInvisibleModuleError.ts_0_132
//@declaration: true module Outer { module Inner { export var m: typeof Inner; } export var f: typeof Inner; }
{ "end_byte": 132, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyCheckTypeOfInvisibleModuleError.ts" }
TypeScript/tests/cases/compiler/interfaceWithCommaSeparators.ts_0_62
var v: { bar(): void, baz } interface Foo { bar(): void, baz }
{ "end_byte": 62, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/interfaceWithCommaSeparators.ts" }
TypeScript/tests/cases/compiler/privacyGloInterface.ts_0_2082
module m1 { export class C1_public { private f1() { } } class C2_private { } export interface C3_public { (c1: C1_public); (c1: C2_private); (): C1_public; (c2: number): C2_private; new (c1: C1_public); new (c1: C2_private); ...
{ "end_byte": 2082, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyGloInterface.ts" }
TypeScript/tests/cases/compiler/inheritanceStaticPropertyOverridingMethod.ts_0_100
class a { static x() { return "20"; } } class b extends a { static x: string; }
{ "end_byte": 100, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inheritanceStaticPropertyOverridingMethod.ts" }
TypeScript/tests/cases/compiler/exportDefaultProperty.ts_0_790
// This test is just like exportEqualsProperty, but with `export default`. // @Filename: declarations.d.ts declare namespace foo.bar { export type X = number; export const X: number; } declare module "foobar" { export default foo.bar; } declare module "foobarx" { export default foo.bar.X; } // @File...
{ "end_byte": 790, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportDefaultProperty.ts" }
TypeScript/tests/cases/compiler/namespaces2.ts_0_96
module A { export module B { export class C { } } } var c: A.B.C = new A.B.C();
{ "end_byte": 96, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/namespaces2.ts" }
TypeScript/tests/cases/compiler/objectLiteralWithSemicolons3.ts_0_26
var v = { a; b; c; }
{ "end_byte": 26, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectLiteralWithSemicolons3.ts" }
TypeScript/tests/cases/compiler/functionOverloads40.ts_0_154
function foo(bar:{a:number;}[]):string; function foo(bar:{a:boolean;}[]):number; function foo(bar:{a:any;}[]):any{ return bar } var x = foo([{a:'bar'}]);
{ "end_byte": 154, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloads40.ts" }
TypeScript/tests/cases/compiler/collisionArgumentsClassConstructor.ts_0_2201
// Constructors class c1 { constructor(i: number, ...arguments) { // error var arguments: any[]; // no error } } class c12 { constructor(arguments: number, ...rest) { // error var arguments = 10; // no error } } class c1NoError { constructor(arguments: number) { // no error v...
{ "end_byte": 2201, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionArgumentsClassConstructor.ts" }
TypeScript/tests/cases/compiler/jsxChildrenIndividualErrorElaborations.tsx_0_1350
// @jsx: react // @strict: true // @filename: index.tsx /// <reference path="/.lib/react16.d.ts" /> import * as React from "react"; interface Props { children: (x: number) => string; } export function Blah(props: Props) { return <></>; } // Incompatible child. var a = <Blah> {x => x} </Blah> // Blah component...
{ "end_byte": 1350, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsxChildrenIndividualErrorElaborations.tsx" }
TypeScript/tests/cases/compiler/es6ImportWithoutFromClauseAmd.ts_0_336
// @module: amd // @declaration: true // @filename: es6ImportWithoutFromClauseAmd_0.ts export var a = 10; // @filename: es6ImportWithoutFromClauseAmd_1.ts export var b = 10; // @filename: es6ImportWithoutFromClauseAmd_2.ts import "es6ImportWithoutFromClauseAmd_0"; import "es6ImportWithoutFromClauseAmd_2"; var _a = ...
{ "end_byte": 336, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ImportWithoutFromClauseAmd.ts" }
TypeScript/tests/cases/compiler/exportAssignmentInternalModule.ts_0_240
//@module: amd // @Filename: exportAssignmentInternalModule_A.ts module M { export var x; } export = M; // @Filename: exportAssignmentInternalModule_B.ts import modM = require("exportAssignmentInternalModule_A"); var n: number = modM.x;
{ "end_byte": 240, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportAssignmentInternalModule.ts" }
TypeScript/tests/cases/compiler/narrowingTypeofUndefined2.ts_0_305
// @strict: true declare function takeArray(arr: Array<unknown>): void; function fn<T extends Array<unknown> | undefined>(arg: T) { if (typeof arg !== "undefined") { takeArray(arg); const n: Array<unknown> = arg; for (const p of arg) { } const m = [...arg]; } }
{ "end_byte": 305, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowingTypeofUndefined2.ts" }
TypeScript/tests/cases/compiler/ArrowFunctionExpression1.ts_0_34
var v = (public x: string) => { };
{ "end_byte": 34, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ArrowFunctionExpression1.ts" }
TypeScript/tests/cases/compiler/emitThisInSuperMethodCall.ts_0_403
class User { sayHello() { } } class RegisteredUser extends User { f() { () => { function inner() { super.sayHello(); } }; } g() { function inner() { () => { super.sayHello(); } } } ...
{ "end_byte": 403, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emitThisInSuperMethodCall.ts" }
TypeScript/tests/cases/compiler/expandoFunctionNestedAssigments.ts_0_848
// @lib: esnext // @declaration: true function Foo(): void { } let d: number = (Foo.inVariableInit = 1); function bar(p = (Foo.inNestedFunction = 1)) { } (Foo.bla = { foo: 1}).foo = (Foo.baz = 1) + (Foo.bar = 0); if(Foo.fromIf = 1) { Foo.inIf = 1; } while(Foo.fromWhileCondition = 1) { Foo.fromWhileBody...
{ "end_byte": 848, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/expandoFunctionNestedAssigments.ts" }
TypeScript/tests/cases/compiler/detachedCommentAtStartOfFunctionBody1.ts_0_242
class TestFile { foo(message: string): () => string { /// <summary>Test summary</summary> /// <param name="message" type="String" /> /// <returns type="Function" /> return () => message + this.name; } }
{ "end_byte": 242, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/detachedCommentAtStartOfFunctionBody1.ts" }
TypeScript/tests/cases/compiler/functionOverloads11.ts_0_59
function foo():number; function foo():string { return "" }
{ "end_byte": 59, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloads11.ts" }
TypeScript/tests/cases/compiler/es6UseOfTopLevelRequire.ts_0_269
// @target: ES6 // @filename: b.ts export default function require(s: string): void { } // @filename: c.ts export const exports = 0; export default exports; // @filename: a.ts import require from "./b" require("arg"); import exports from "./c" var x = exports + 2;
{ "end_byte": 269, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6UseOfTopLevelRequire.ts" }
TypeScript/tests/cases/compiler/commonjsAccessExports.ts_0_308
// @module: commonjs // @allowJs: true // @checkJs: true // @noEmit: true // @Filename: /a.js exports.x = 0; exports.x; // Works nested { // 'exports' does not provide a contextual type to a function-class exports.Cls = function() { this.x = 0; } } const instance = new exports.Cls();
{ "end_byte": 308, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commonjsAccessExports.ts" }
TypeScript/tests/cases/compiler/impliedNodeFormatEmit1.ts_0_666
// @allowJs: true // @checkJs: true // @outDir: dist // @module: esnext, commonjs, amd, system, umd, preserve // @moduleResolution: bundler // @noTypesAndSymbols: true // @Filename: /a.ts export const _ = 0; // @Filename: /b.mts export const _ = 0; // @Filename: /c.cts export const _ = 0; // @Filename: /d.js export...
{ "end_byte": 666, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/impliedNodeFormatEmit1.ts" }
TypeScript/tests/cases/compiler/outModuleConcatES6.ts_0_240
// @target: ES6 // @sourcemap: true // @declaration: true // @module: es6 // @outFile: all.js // This should be an error // @Filename: ref/a.ts export class A { } // @Filename: b.ts import {A} from "./ref/a"; export class B extends A { }
{ "end_byte": 240, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/outModuleConcatES6.ts" }
TypeScript/tests/cases/compiler/indexedAccessRelation.ts_0_276
// Repro from #14723 class Component<S> { setState<K extends keyof S>(state: Pick<S, K>) {} } export interface State<T> { a?: T; } class Foo {} class Comp<T extends Foo, S> extends Component<S & State<T>> { foo(a: T) { this.setState({ a: a }); } }
{ "end_byte": 276, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/indexedAccessRelation.ts" }
TypeScript/tests/cases/compiler/reexportMissingDefault.ts_0_117
// @filename: b.ts export const b = null; // @filename: a.ts export { b } from "./b"; export { default } from "./b";
{ "end_byte": 117, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reexportMissingDefault.ts" }
TypeScript/tests/cases/compiler/objectLiteralMemberWithQuestionMark1.ts_0_22
var v = { foo?() { } }
{ "end_byte": 22, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectLiteralMemberWithQuestionMark1.ts" }
TypeScript/tests/cases/compiler/assertionFunctionWildcardImport1.ts_0_621
// @strict: true // @filename: src/core/_namespaces/ts.ts import * as Debug from "../debug"; export { Debug }; // @filename: src/core/debug.ts export declare function assert(expression: unknown): asserts expression; // @filename: src/core/foo.ts import * as ts from "./_namespaces/ts"; import { Debug } from "./_name...
{ "end_byte": 621, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assertionFunctionWildcardImport1.ts" }
TypeScript/tests/cases/compiler/functionSubtypingOfVarArgs2.ts_0_320
class EventBase { private _listeners: { (...args: any[]): void; }[] = []; add(listener: (...args: any[]) => void): void { this._listeners.push(listener); } } class StringEvent extends EventBase { add(listener: (items: string, moreitems: number) => void ) { super.add(listener); } }
{ "end_byte": 320, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionSubtypingOfVarArgs2.ts" }
TypeScript/tests/cases/compiler/paramsOnlyHaveLiteralTypesWhenAppropriatelyContextualized.ts_0_771
// @strict: true // Using a homomorphic mapped type over `T` // Produces a lower-priority inference for `T` than other // positions, allowing one to override the priority the argument // order would usually imply type Lower<T> = { [K in keyof T]: T[K] }; export function appendToOptionalArray< K extends string | numb...
{ "end_byte": 771, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/paramsOnlyHaveLiteralTypesWhenAppropriatelyContextualized.ts" }
TypeScript/tests/cases/compiler/noCatchBlock.ts_0_73
//@sourceMap: true try { // ... } finally { // N.B. No 'catch' block }
{ "end_byte": 73, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noCatchBlock.ts" }
TypeScript/tests/cases/compiler/parseUnaryExpressionNoTypeAssertionInJsx1.ts_0_119
// @allowJs: true // @noEmit: true // @checkJs: true // @filename: index.js const x = "oops"; const y = + <number> x;
{ "end_byte": 119, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parseUnaryExpressionNoTypeAssertionInJsx1.ts" }
TypeScript/tests/cases/compiler/jsxFactoryIdentifierWithAbsentParameter.ts_0_286
//@jsx: react //@target: es6 //@module: commonjs //@jsxFactory: createElement //@sourcemap: true // @filename: test.tsx declare module JSX { interface IntrinsicElements { [s: string]: any; } } export class AppComponent { render() { return <div />; } }
{ "end_byte": 286, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsxFactoryIdentifierWithAbsentParameter.ts" }
TypeScript/tests/cases/compiler/ambientRequireFunction.ts_0_345
// @module: commonjs, preserve // @allowJs: true // @outDir: ./out/ // @filename: node.d.ts declare function require(moduleName: string): any; declare module "fs" { export function readFileSync(s: string): string; } // @filename: app.js /// <reference path="node.d.ts"/> const fs = require("fs"); const text = f...
{ "end_byte": 345, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ambientRequireFunction.ts" }
TypeScript/tests/cases/compiler/variableDeclarationInStrictMode1.ts_0_54
// @skipDefaultLibCheck: false "use strict"; var eval;
{ "end_byte": 54, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/variableDeclarationInStrictMode1.ts" }
TypeScript/tests/cases/compiler/multipleExportAssignments.ts_0_325
//@module: commonjs interface connectModule { (res, req, next): void; } interface connectExport { use: (mod: connectModule) => connectExport; listen: (port: number) => void; } var server: { (): connectExport; test1: connectModule; test2(): connectModule; }; export = server; export = connectExpor...
{ "end_byte": 325, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/multipleExportAssignments.ts" }
TypeScript/tests/cases/compiler/mergedDeclarations1.ts_0_355
interface Point { x: number; y: number; } function point(x: number, y: number): Point { return { x: x, y: y }; } module point { export var origin = point(0, 0); export function equals(p1: Point, p2: Point) { return p1.x == p2.x && p1.y == p2.y; } } var p1 = point(0, 0); var p2 = point.or...
{ "end_byte": 355, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mergedDeclarations1.ts" }
TypeScript/tests/cases/compiler/sourceMap-SingleSpace1.ts_0_37
// @target: ES5 // @sourcemap: true
{ "end_byte": 37, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMap-SingleSpace1.ts" }
TypeScript/tests/cases/compiler/declarationEmitLateBoundAssignments2.ts_0_1192
// @strict: true // @declaration: true // @target: es6 // https://github.com/microsoft/TypeScript/issues/54811 const c = "C" const num = 1 const numStr = "10" const withWhitespace = "foo bar" const emoji = "🤷‍♂️" export function decl() {} decl["B"] = 'foo' export function decl2() {} decl2[c] = 0 export function d...
{ "end_byte": 1192, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitLateBoundAssignments2.ts" }
TypeScript/tests/cases/compiler/staticFieldWithInterfaceContext.ts_0_923
interface I { x: { a: "a" }; } let c: I = class { // should typecheck the same as the last line static x = { a: "a" }; }; c.x = { a: "a" }; const ex = "x"; let c2: I = class { static [ex] = { a: "a" }; }; c[ex] = { a: "a" }; function f(c: I = class { static x = { a: "a" } }) { } let { c: c3 }: { c: I } =...
{ "end_byte": 923, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/staticFieldWithInterfaceContext.ts" }
TypeScript/tests/cases/compiler/jsFileCompilationOptionalParameter.ts_0_55
// @allowJs: true // @filename: a.js function F(p?) { }
{ "end_byte": 55, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationOptionalParameter.ts" }
TypeScript/tests/cases/compiler/jsExpandoObjectDefineProperty.ts_0_203
// @allowJs: true // @checkJs: true // @noEmit: true // @filename: index.js var chrome = {} Object.defineProperty(chrome, 'devtools', { value: {}, enumerable: true }) chrome.devtools.inspectedWindow = {}
{ "end_byte": 203, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsExpandoObjectDefineProperty.ts" }
TypeScript/tests/cases/compiler/varianceCantBeStrictWhileStructureIsnt.ts_0_387
// @strict: false // @strictFunctionTypes: false // under non-strict-function-types, all the below should work interface Foo<T> { member: (cb: T) => void; } interface Bar<T> { member: (cb: T) => void; } declare var a: Foo<string>; declare var b: Foo<"">; declare var a2: Bar<string>; declare var b2: Bar<"">; ...
{ "end_byte": 387, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/varianceCantBeStrictWhileStructureIsnt.ts" }
TypeScript/tests/cases/compiler/narrowingNoInfer1.ts_0_670
// @strict: true // @noEmit: true // https://github.com/microsoft/TypeScript/issues/58266 type TaggedA = { _tag: "a" }; type TaggedB = { _tag: "b" }; type TaggedUnion = TaggedA | TaggedB; const m: { result: NoInfer<TaggedUnion> }[] = []; function map<A, B>(items: readonly A[], f: (a: NoInfer<A>) => B) { return i...
{ "end_byte": 670, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowingNoInfer1.ts" }
TypeScript/tests/cases/compiler/circularInferredTypeOfVariable.ts_0_313
// @target: es6 // Repro from #14428 (async () => { function foo(p: string[]): string[] { return []; } function bar(p: string[]): string[] { return []; } let a1: string[] | undefined = []; while (true) { let a2 = foo(a1!); a1 = await bar(a2); } });
{ "end_byte": 313, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/circularInferredTypeOfVariable.ts" }
TypeScript/tests/cases/compiler/genericClassWithStaticsUsingTypeArguments.ts_0_324
// Should be error to use 'T' in all declarations within Foo. class Foo<T> { static a = (n: T) => { }; static b: T; static c: T[] = []; static d = false || ((x: T) => x || undefined)(null) static e = function (x: T) { return null; } static f(xs: T[]): T[] { return xs.reverse(); ...
{ "end_byte": 324, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericClassWithStaticsUsingTypeArguments.ts" }
TypeScript/tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments3.ts_0_213
function f<T, U>(t1: T, u1: U, pf1: (u2: U) => T, pf2: (t2: T) => U): [T, U] { return [t1, pf2(t1)]; } interface A { a: A; } interface B extends A { b: B; } var a: A, b: B; var d = f(a, b, u2 => u2.b, t2 => t2);
{ "end_byte": 213, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments3.ts" }
TypeScript/tests/cases/compiler/narrowTypeByInstanceof.ts_7_583
ass Match { public range(): any { return undefined; } } class FileMatch { public resource(): any { return undefined; } } type FileMatchOrMatch = FileMatch | Match; let elementA: FileMatchOrMatch, elementB: FileMatchOrMatch; if (elementA instanceof...
{ "end_byte": 583, "start_byte": 7, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowTypeByInstanceof.ts" }
TypeScript/tests/cases/compiler/unusedMultipleParameter2InContructor.ts_0_198
//@noUnusedLocals:true //@noUnusedParameters:true class Dummy { constructor(person: string, person2: string, person3: string) { var unused = 20; person2 = "Dummy value"; } }
{ "end_byte": 198, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedMultipleParameter2InContructor.ts" }
TypeScript/tests/cases/compiler/umdGlobalConflict.ts_0_316
//@filename: v1/index.d.ts export as namespace Alpha; export var x: string; //@filename: v2/index.d.ts export as namespace Alpha; export var y: number; //@filename: consumer.ts import * as v1 from './v1'; import * as v2 from './v2'; //@filename: global.ts // Should be OK, first in wins const p: string = Alpha.x;
{ "end_byte": 316, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/umdGlobalConflict.ts" }
TypeScript/tests/cases/compiler/forInStatement7.ts_0_49
var a: number; var expr: any; for (a in expr) { }
{ "end_byte": 49, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/forInStatement7.ts" }
TypeScript/tests/cases/compiler/genericArrayMethods1.ts_3_64
r x:string[] = [0,1].slice(0); // this should be an error
{ "end_byte": 64, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericArrayMethods1.ts" }
TypeScript/tests/cases/compiler/castNewObjectBug.ts_0_46
interface Foo { } var xx = <Foo> new Object();
{ "end_byte": 46, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/castNewObjectBug.ts" }
TypeScript/tests/cases/compiler/typeGuardNarrowsIndexedAccessOfKnownProperty1.ts_0_1923
// @strict: true interface Square { ["dash-ok"]: "square"; ["square-size"]: number; } interface Rectangle { ["dash-ok"]: "rectangle"; width: number; height: number; } interface Circle { ["dash-ok"]: "circle"; radius: number; } type Shape = Square | Rectangle | Circle; interface Subshape {...
{ "end_byte": 1923, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeGuardNarrowsIndexedAccessOfKnownProperty1.ts" }
TypeScript/tests/cases/compiler/mappedTypePartialNonHomomorphicBaseConstraint.ts_0_166
export type Errors<D> = { readonly [K in keyof D | "base"]?: string[] }; class Model<D> { getErrors(): Errors<D> { return { base: ["some base error"] }; } }
{ "end_byte": 166, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mappedTypePartialNonHomomorphicBaseConstraint.ts" }
TypeScript/tests/cases/compiler/declarationEmitPropertyNumericStringKey.ts_0_262
// @declaration: true // https://github.com/microsoft/TypeScript/issues/55292 const STATUS = { ["404"]: "not found", } as const; const hundredStr = "100"; const obj = { [hundredStr]: "foo" }; const hundredNum = 100; const obj2 = { [hundredNum]: "bar" };
{ "end_byte": 262, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitPropertyNumericStringKey.ts" }
TypeScript/tests/cases/compiler/inferenceLimit.ts_0_847
// @target: es6 // @module: commonjs // @filename: file1.ts "use strict"; import * as MyModule from "./mymodule"; export class BrokenClass { constructor() {} public brokenMethod(field: string, value: string) { return new Promise<Array<MyModule.MyModel>>((resolve, reject) => { let result: Array<MyModule.My...
{ "end_byte": 847, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inferenceLimit.ts" }
TypeScript/tests/cases/compiler/classImplementsClass2.ts_0_171
class A { foo(): number { return 1; } } class C implements A {} // error class C2 extends A { foo() { return 1; } } var c: C; var c2: C2; c = c2; c2 = c;
{ "end_byte": 171, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classImplementsClass2.ts" }
TypeScript/tests/cases/compiler/externFunc.ts_0_60
declare function parseInt(s:string):number; parseInt("2");
{ "end_byte": 60, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/externFunc.ts" }
TypeScript/tests/cases/compiler/underscoreEscapedNameInEnum.ts_0_53
enum E { "__foo" = 1, bar = E["__foo"] + 1 }
{ "end_byte": 53, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/underscoreEscapedNameInEnum.ts" }
TypeScript/tests/cases/compiler/exportedInterfaceInaccessibleInCallbackInModule.ts_0_441
//@module: amd export interface ProgressCallback { (progress:any):any; } // --- Generic promise export declare class TPromise<V> { constructor(init:(complete: (value:V)=>void, error:(err:any)=>void, progress:ProgressCallback)=>void, oncancel?: any); // removing this method fixes the error squiggle..... pub...
{ "end_byte": 441, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportedInterfaceInaccessibleInCallbackInModule.ts" }
TypeScript/tests/cases/compiler/genericTypeAssertions5.ts_0_445
interface A { foo(): string; } interface B extends A { bar(): number; } interface C extends A { baz(): number; } var a: A; var b: B; var c: C; function foo2<T extends A>(x: T) { var y = x; y = a; // error: cannot convert A to T y = b; // error: cannot convert B to T y = c; // error: cann...
{ "end_byte": 445, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericTypeAssertions5.ts" }
TypeScript/tests/cases/compiler/augmentExportEquals6_1.ts_0_422
// @module: amd // @filename: file1.d.ts declare module "file1" { class foo {} namespace foo { class A {} } export = foo; } // @filename: file2.ts /// <reference path="file1.d.ts"/> import x = require("file1"); // OK - './file1' is a namespace declare module "file1" { interface A { a: n...
{ "end_byte": 422, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/augmentExportEquals6_1.ts" }
TypeScript/tests/cases/compiler/declarationEmitIsolatedDeclarationErrorNotEmittedForNonEmittedFile.ts_0_2049
// @declaration: true // @isolatedDeclarations: true // @filename: node_modules/@trpc/server/internals/config.d.ts export interface RootConfig<T> { prop: T; } // @filename: node_modules/@trpc/server/internals/utils.d.ts export interface ErrorFormatterShape<T={}> { prop: T; } export type PickFirstDefined<TType, ...
{ "end_byte": 2049, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitIsolatedDeclarationErrorNotEmittedForNonEmittedFile.ts" }
TypeScript/tests/cases/compiler/importHelpersVerbatimModuleSyntax.ts_0_1108
// @importHelpers: true // @target: es2017 // @module: preserve // @moduleResolution: bundler // @verbatimModuleSyntax: true // @Filename: /node_modules/tslib/package.json { "name": "tslib", "main": "tslib.js", "module": "tslib.es6.js", "jsnext:main": "tslib.es6.js", "typings": "tslib.d.ts", "exports": { ...
{ "end_byte": 1108, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importHelpersVerbatimModuleSyntax.ts" }
TypeScript/tests/cases/compiler/incrementalInvalid.ts_0_38
// @incremental: true const x = 10;
{ "end_byte": 38, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/incrementalInvalid.ts" }
TypeScript/tests/cases/compiler/commonJsIsolatedModules.ts_0_184
// @Filename: tsconfig.json { "compilerOptions": { "allowJs": true, "outDir": "foo", "isolatedModules": true, } } // @Filename: index.js module.exports = {} var x = 1
{ "end_byte": 184, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commonJsIsolatedModules.ts" }
TypeScript/tests/cases/compiler/publicMemberImplementedAsPrivateInDerivedClass.ts_0_83
interface Qux { Bar: number; } class Foo implements Qux { private Bar: number; }
{ "end_byte": 83, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/publicMemberImplementedAsPrivateInDerivedClass.ts" }
TypeScript/tests/cases/compiler/moduleDeclarationExportStarShadowingGlobalIsNameable.ts_0_488
// @declaration: true // @filename: model/index.ts export * from "./account"; // @filename: model/account.ts export interface Account { myAccNum: number; } interface Account2 { myAccNum: number; } export { Account2 as Acc }; // @filename: index.ts declare global { interface Account { someProp: num...
{ "end_byte": 488, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleDeclarationExportStarShadowingGlobalIsNameable.ts" }
TypeScript/tests/cases/compiler/typeParameterExtendingUnion1.ts_0_204
class Animal { run() { } } class Cat extends Animal { meow } class Dog extends Animal { woof } function run(a: Animal) { a.run(); } function f<T extends Cat | Dog>(a: T) { a.run(); run(a); }
{ "end_byte": 204, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeParameterExtendingUnion1.ts" }
TypeScript/tests/cases/compiler/typeCheckingInsideFunctionExpressionInArray.ts_0_126
var functions = [function () { var k: string = 10; k = new Object(); [1, 2, 3].NonexistantMethod(); derp(); }];
{ "end_byte": 126, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeCheckingInsideFunctionExpressionInArray.ts" }
TypeScript/tests/cases/compiler/declarationFileOverwriteErrorWithOut.ts_0_123
// @declaration: true // @outFile: /out.js // @Filename: /out.d.ts declare class c { } // @FileName: /a.ts class d { }
{ "end_byte": 123, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationFileOverwriteErrorWithOut.ts" }
TypeScript/tests/cases/compiler/classExpressionWithStaticProperties2.ts_0_139
//@target: es5 var v = class C { static a = 1; static b static c = { x: "hi" } static d = C.c.x + " world"; };
{ "end_byte": 139, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classExpressionWithStaticProperties2.ts" }
TypeScript/tests/cases/compiler/derivedInterfaceCallSignature.ts_0_928
interface D3SvgPath { (data: any, index?: number): string; x(): (data: any, index?: number) => number; y(): (data: any, index?: number) => number; interpolate(): string; tension(): number; defined(): (data: any, index?: number) => boolean; } interface D3SvgArea extends D3SvgPath { x(x: (da...
{ "end_byte": 928, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/derivedInterfaceCallSignature.ts" }
TypeScript/tests/cases/compiler/breakTarget6.ts_0_32
while (true) { break target; }
{ "end_byte": 32, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/breakTarget6.ts" }
TypeScript/tests/cases/compiler/promisePermutations.ts_0_6483
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?: (progress: any) => void): Promise<U>; then<U>(success?: (value: T) => U, e...
{ "end_byte": 6483, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/promisePermutations.ts" }
TypeScript/tests/cases/compiler/promisePermutations.ts_6484_10318
var s6d = s6.then(sPromise, sPromise, sPromise).then(sIPromise, sIPromise, sIPromise); // ok var r7: IPromise<string>; var r7a = r7.then(testFunction7, testFunction7, testFunction7); // error var r7b = r7.then(sIPromise, sIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var s7: Promise<string>; var s7...
{ "end_byte": 10318, "start_byte": 6484, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/promisePermutations.ts" }
TypeScript/tests/cases/compiler/sourceMap-EmptyFile1.ts_0_35
// @target: ES5 // @sourcemap: true
{ "end_byte": 35, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMap-EmptyFile1.ts" }
TypeScript/tests/cases/compiler/defaultIndexProps1.ts_0_107
class Foo { public v = "Yo"; } var f = new Foo(); var q = f["v"]; var o = {v:"Yo2"}; var q2 = o["v"];
{ "end_byte": 107, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/defaultIndexProps1.ts" }
TypeScript/tests/cases/compiler/inferenceAndHKTs.ts_0_762
// @strict: true // @noEmit: true // Repro from #53970 export interface TypeLambda { readonly A: unknown; } export interface TypeClass<F extends TypeLambda> { readonly _F: F; } export type Apply<F extends TypeLambda, A> = F extends { readonly type: unknown } ? (F & { readonly A: A })['type'] : { rea...
{ "end_byte": 762, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inferenceAndHKTs.ts" }
TypeScript/tests/cases/compiler/resolveModuleNameWithSameLetDeclarationName1.ts_3_73
clare module foo { interface Bar { } } let foo: foo.Bar;
{ "end_byte": 73, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/resolveModuleNameWithSameLetDeclarationName1.ts" }
TypeScript/tests/cases/compiler/noCrashOnParameterNamedRequire.ts_0_184
// @allowJs: true // @checkJs: true // @outDir: ./built // @filename: index.js (function(require, module, exports){ const mod = require("./mod"); mod.foo; })(null, null, null);
{ "end_byte": 184, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noCrashOnParameterNamedRequire.ts" }