_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/accessorInferredReturnTypeErrorInReturnStatement.ts_0_171
// @strict: true // @declaration: true export var basePrototype = { get primaryPath() { var _this = this; return _this.collection.schema.primaryPath; }, };
{ "end_byte": 171, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/accessorInferredReturnTypeErrorInReturnStatement.ts" }
TypeScript/tests/cases/compiler/manyCompilerErrorsInTheTwoFiles.ts_0_151
// @pretty: true // @filename: a.ts const a =!@#!@$ const b = !@#!@#!@#! OK! HERE's A shouty thing GOTTA GO FAST // @filename: b.ts fhqwhgads to limit
{ "end_byte": 151, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/manyCompilerErrorsInTheTwoFiles.ts" }
TypeScript/tests/cases/compiler/callExpressionWithTypeParameterConstrainedToOuterTypeParameter.ts_0_101
interface I<T> { <U extends T>(u: U): U; } var i: I<string>; var y = i(""); // y should be string
{ "end_byte": 101, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/callExpressionWithTypeParameterConstrainedToOuterTypeParameter.ts" }
TypeScript/tests/cases/compiler/nodeResolution2.ts_0_150
// @module: commonjs // @moduleResolution: node // @filename: node_modules/a.d.ts export var x: number; // @filename: b.ts import y = require("a");
{ "end_byte": 150, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nodeResolution2.ts" }
TypeScript/tests/cases/compiler/classExpressionWithDecorator1.ts_0_76
// @experimentaldecorators: true var v = @decorate class C { static p = 1 };
{ "end_byte": 76, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classExpressionWithDecorator1.ts" }
TypeScript/tests/cases/compiler/selfReferencingFile3.ts_0_81
///<reference path='./selfReferencingFile3.ts'/> class selfReferencingFile3 { }
{ "end_byte": 81, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/selfReferencingFile3.ts" }
TypeScript/tests/cases/compiler/declarationEmitInferredTypeAlias5.ts_3_232
@declaration: true // @skipDefaultLibCheck: true // @Filename: 0.ts export type Data = string | boolean; let obj: Data = true; // @Filename: 1.ts import * as Z from "./0" //let v2: Z.Data; let v = "str" || true; export { v }
{ "end_byte": 232, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitInferredTypeAlias5.ts" }
TypeScript/tests/cases/compiler/declarationEmitLocalClassDeclarationMixin.ts_0_660
// @declaration: true interface Constructor<C> { new (...args: any[]): C; } function mixin<B extends Constructor<{}>>(Base: B) { class PrivateMixed extends Base { bar = 2; } return PrivateMixed; } export class Unmixed { foo = 1; } export const Mixed = mixin(Unmixed); function Filter<C extend...
{ "end_byte": 660, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitLocalClassDeclarationMixin.ts" }
TypeScript/tests/cases/compiler/methodChainError.ts_0_239
class Builder { notMethod: string method(param: string): Builder { return this; } } new Builder() .method("a") .method() .method("a"); new Builder() .method("a") .notMethod() .method("a");
{ "end_byte": 239, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/methodChainError.ts" }
TypeScript/tests/cases/compiler/bind1.ts_0_96
module M { export class C implements I {} // this should be an unresolved symbol I error }
{ "end_byte": 96, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/bind1.ts" }
TypeScript/tests/cases/compiler/extendGlobalThis2.ts_0_73
namespace globalThis { export function foo() { console.log("x"); } }
{ "end_byte": 73, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/extendGlobalThis2.ts" }
TypeScript/tests/cases/compiler/underscoreThisInDerivedClass01.ts_0_626
// @target es5 // Original test intent: // When arrow functions capture 'this', the lexical 'this' owner // currently captures 'this' using a variable named '_this'. // That means that '_this' becomes a reserved identifier in certain places. // // Constructors have adopted the same identifier name ('_this') // for cap...
{ "end_byte": 626, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/underscoreThisInDerivedClass01.ts" }
TypeScript/tests/cases/compiler/mixedStaticAndInstanceClassMembers.ts_0_224
class A { f() {} static m1 (a: string): void; m1 (a: number): void; m1 (a: any): void { } } class B { f() {} m1 (a: string): void; static m1 (a: number): void; m1 (a: any): void { } }
{ "end_byte": 224, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mixedStaticAndInstanceClassMembers.ts" }
TypeScript/tests/cases/compiler/objectLitStructuralTypeMismatch.ts_0_54
// Shouldn't compile var x: { a: number; } = { b: 5 };
{ "end_byte": 54, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectLitStructuralTypeMismatch.ts" }
TypeScript/tests/cases/compiler/errorOnInitializerInInterfaceProperty.ts_0_39
interface Foo { bar: number = 5; }
{ "end_byte": 39, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/errorOnInitializerInInterfaceProperty.ts" }
TypeScript/tests/cases/compiler/nonNullableTypes1.ts_0_640
// @strict: true // @declaration: true function f1<T>(x: T) { let y = x || "hello"; // NonNullable<T> | string } function error(): never { throw new Error(); } function f2<T>(x: T) { // NonNullable<T> return x || error(); } function f3(x: unknown) { let y = x!; // {} } function f4<T extends { x:...
{ "end_byte": 640, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nonNullableTypes1.ts" }
TypeScript/tests/cases/compiler/inferredNonidentifierTypesGetQuotes.ts_0_94
// @declaration: true var x = [{ "a-b": "string" }, {}]; var y = [{ ["a-b"]: "string" }, {}];
{ "end_byte": 94, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inferredNonidentifierTypesGetQuotes.ts" }
TypeScript/tests/cases/compiler/declarationEmitNonExportedBindingPattern.ts_0_372
// @declaration: true // @filename: test.ts function getFoo() { return { foo: { test: 42 } } } const { foo } = getFoo() export type AliasType = typeof foo const { foo: renamed } = getFoo() export type AliasType2 = typeof renamed function getNested() { return { a: { b: { c: 'd' } } } } const { a: { b: { c } }...
{ "end_byte": 372, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitNonExportedBindingPattern.ts" }
TypeScript/tests/cases/compiler/functionDeclarationWithArgumentOfTypeFunctionTypeArray.ts_0_88
// @declaration: true function foo(args: { (x): number }[]) { return args.length; }
{ "end_byte": 88, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionDeclarationWithArgumentOfTypeFunctionTypeArray.ts" }
TypeScript/tests/cases/compiler/lambdaArgCrash.ts_0_467
// @lib: es5 class Event { private _listeners: any[] = []; constructor () { // TODO: remove this._listeners = []; } add(listener: () => any): void { /// <summary>Registers a new listener for the event.</summary> /// <param name="listener">The callback function to register.</param> this._l...
{ "end_byte": 467, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/lambdaArgCrash.ts" }
TypeScript/tests/cases/compiler/contextualTyping38.ts_0_53
var foo = <{ (): number; }> function(a) { return a };
{ "end_byte": 53, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTyping38.ts" }
TypeScript/tests/cases/compiler/parserUnparsedTokenCrash1.ts_0_69
// @allowJs: true // @outDir: ./out // @filename: a.js ( y = 1 ; 2 )
{ "end_byte": 69, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parserUnparsedTokenCrash1.ts" }
TypeScript/tests/cases/compiler/crashInYieldStarInAsyncFunction.ts_0_270
// @target: esnext // https://github.com/microsoft/TypeScript/issues/53145 var obj = { [Symbol.asyncIterator]() { return { next() { return { then() { } }; } }; } }; async function* g() { yield* obj; }
{ "end_byte": 270, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/crashInYieldStarInAsyncFunction.ts" }
TypeScript/tests/cases/compiler/heterogeneousArrayAndOverloads.ts_0_246
class arrTest { test(arg1: number[]); test(arg1: string[]); test(arg1: any[]) { } callTest() { this.test([1, 2, 3, 5]); this.test(["hi"]); this.test([]); this.test([1, 2, "hi", 5]); // Error } }
{ "end_byte": 246, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/heterogeneousArrayAndOverloads.ts" }
TypeScript/tests/cases/compiler/es6ImportEqualsExportModuleEs2015Error.ts_0_117
// @module: es2015 // @filename: a.ts class a { } export = a; // @filename: main.ts import * as a from "./a"; a;
{ "end_byte": 117, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ImportEqualsExportModuleEs2015Error.ts" }
TypeScript/tests/cases/compiler/variableDeclarationInnerCommentEmit.ts_0_133
var a = /*some comment*/ null; var b /*some comment*/ = null; var /*some comment*/ c = null; // no space var a=/*some comment*/null;
{ "end_byte": 133, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/variableDeclarationInnerCommentEmit.ts" }
TypeScript/tests/cases/compiler/unmetTypeConstraintInImportCall.ts_0_168
// @noEmit: true // @filename: file1.ts export type Foo<T extends string> = { foo: T } // @noEmit: true // @filename: file2.ts type Bar<T> = import('./file1').Foo<T>;
{ "end_byte": 168, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unmetTypeConstraintInImportCall.ts" }
TypeScript/tests/cases/compiler/cachedModuleResolution5.ts_0_230
// @moduleResolution: node // @traceResolution: true // @filename: /a/b/node_modules/foo.d.ts export declare let x: number // @filename: /a/b/c/d/e/app.ts import {x} from "foo"; // @filename: /a/b/lib.ts import {x} from "foo";
{ "end_byte": 230, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/cachedModuleResolution5.ts" }
TypeScript/tests/cases/compiler/constraintWithIndexedAccess.ts_0_1966
// #52399 type DataFetchFns = { Boat: { requiresLicense: (id: string) => boolean; maxGroundSpeed: (id: string) => number; description: (id: string) => string; displacement: (id: string) => number; name: (id: string) => string; }; Plane: { requiresLicense: (id:...
{ "end_byte": 1966, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constraintWithIndexedAccess.ts" }
TypeScript/tests/cases/compiler/amdLikeInputDeclarationEmit.ts_0_924
// @declaration: true // @declarationDir: definitions // @emitDeclarationOnly: true // @checkJs: true // @allowJs: true // @filename: typing.d.ts declare function define<T=unknown>(name: string, modules: string[], ready: (...modules: unknown[]) => T); // @filename: deps/BaseClass.d.ts declare module "deps/BaseClass" { ...
{ "end_byte": 924, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/amdLikeInputDeclarationEmit.ts" }
TypeScript/tests/cases/compiler/typePredicatesCanNarrowByDiscriminant.ts_0_462
// @strict: true // #45770 declare const fruit: { kind: 'apple'} | { kind: 'banana' } | { kind: 'cherry' } declare function isOneOf<T, U extends T>(item: T, array: readonly U[]): item is U if (isOneOf(fruit.kind, ['apple', 'banana'] as const)) { fruit.kind fruit } declare const fruit2: { kind: 'apple'} | { k...
{ "end_byte": 462, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typePredicatesCanNarrowByDiscriminant.ts" }
TypeScript/tests/cases/compiler/declFileAmbientExternalModuleWithSingleExportedModule.ts_0_499
//@module: commonjs // @declaration: true // @Filename: declFileAmbientExternalModuleWithSingleExportedModule_0.ts declare module "SubModule" { export module m { export module m3 { interface c { } } } } // @Filename: declFileAmbientExternalModuleWithSingleExportedModule...
{ "end_byte": 499, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileAmbientExternalModuleWithSingleExportedModule.ts" }
TypeScript/tests/cases/compiler/externSemantics.ts_0_57
declare var x=10; declare var v; declare var y:number=3;
{ "end_byte": 57, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/externSemantics.ts" }
TypeScript/tests/cases/compiler/literals-negative.ts_3_297
Type type of the null literal is the Null type. // Null can be converted to anything except Void var n = <number>(null); var s = <string>(null); var b = <boolean>(n); function isVoid() : void { } // Expected error: Values of type null and void cannot be compared if(null === isVoid()) { }
{ "end_byte": 297, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/literals-negative.ts" }
TypeScript/tests/cases/compiler/collisionThisExpressionAndLocalVarInConstructor.ts_0_390
class class1 { constructor() { var x2 = { doStuff: (callback) => () => { var _this = 2; return callback(this); } } } } class class2 { constructor() { var _this = 2; var x2 = { doStuff: (callback) => () => { ...
{ "end_byte": 390, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionThisExpressionAndLocalVarInConstructor.ts" }
TypeScript/tests/cases/compiler/destructuredLateBoundNameHasCorrectTypes.ts_0_242
// @target: es6 let { [Symbol.iterator]: destructured } = []; void destructured; const named = "prop"; let { [named]: computed } = { prop: "b" }; void computed; const notPresent = "prop2"; let { [notPresent]: computed2 } = { prop: "b" };
{ "end_byte": 242, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/destructuredLateBoundNameHasCorrectTypes.ts" }
TypeScript/tests/cases/compiler/functionCall13.ts_0_109
function foo(a:string, ...b:number[]){} foo('foo', 1); foo('foo'); foo(); foo(1, 'bar'); foo('foo', 1, 3);
{ "end_byte": 109, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionCall13.ts" }
TypeScript/tests/cases/compiler/interfaceImplementation4.ts_0_172
interface I1 { iObj:{ }; iNum:number; iAny:any; iFn():void; } class C5 implements I1 { public iNum:number; public iAny:any; public iFn() { } }
{ "end_byte": 172, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/interfaceImplementation4.ts" }
TypeScript/tests/cases/compiler/es5-commonjs4.ts_0_215
// @target: ES5 // @sourcemap: false // @declaration: false // @module: commonjs export default class A { constructor () { } public B() { return 42; } } export var __esModule = 1;
{ "end_byte": 215, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es5-commonjs4.ts" }
TypeScript/tests/cases/compiler/internalAliasEnumInsideLocalModuleWithoutExportAccessError.ts_0_233
//@module: commonjs export module a { export enum weekend { Friday, Saturday, Sunday } } export module c { import b = a.weekend; export var bVal: b = b.Sunday; } var happyFriday = c.b.Friday;
{ "end_byte": 233, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/internalAliasEnumInsideLocalModuleWithoutExportAccessError.ts" }
TypeScript/tests/cases/compiler/arrowFunctionInExpressionStatement1.ts_0_8
() => 0;
{ "end_byte": 8, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arrowFunctionInExpressionStatement1.ts" }
TypeScript/tests/cases/compiler/restTypeRetainsMappyness.ts_0_256
type Foo<T extends any[]> = { [P in keyof T]: T[P] } function test<T extends any[]>(fn: (...args: Foo<T>) => void) { const arr: Foo<T> = {} as any fn(...arr) // Error: Argument of type 'any[]' is not assignable to parameter of type 'Foo<T>' }
{ "end_byte": 256, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/restTypeRetainsMappyness.ts" }
TypeScript/tests/cases/compiler/contextualTypingTwoInstancesOfSameTypeParameter.ts_0_77
function f6<T>(x: (a: T) => T) { return null; } f6(x => f6(y => x = y));
{ "end_byte": 77, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTypingTwoInstancesOfSameTypeParameter.ts" }
TypeScript/tests/cases/compiler/forOfStringConstituents.ts_0_180
interface A { x: 0; y: C[]; } interface B { x: 1; y: CD[]; } interface C { x: 2; } interface D { x: 3; } type AB = A | B; type CD = C | D; declare let x: AB, y: CD; for (y of x.y);
{ "end_byte": 180, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/forOfStringConstituents.ts" }
TypeScript/tests/cases/compiler/genericSpecializations3.ts_0_633
interface IFoo<T> { foo(x: T): T; } var iFoo: IFoo<number>; iFoo.foo(1); class IntFooBad implements IFoo<number> { // error foo(x: string): string { return null; } } var intFooBad: IntFooBad; class IntFoo implements IFoo<number> { foo(x: number): number { return null; } } var intFoo: IntFoo; class Str...
{ "end_byte": 633, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericSpecializations3.ts" }
TypeScript/tests/cases/compiler/literalIntersectionYieldsLiteral.ts_0_69
const x: { type: string } & { type: "string" } = { type: "string" };
{ "end_byte": 69, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/literalIntersectionYieldsLiteral.ts" }
TypeScript/tests/cases/compiler/privateNameWeakMapCollision.ts_0_106
// @target: es2015 function test() { let WeakMap; let WeakSet; class C { #x; } }
{ "end_byte": 106, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privateNameWeakMapCollision.ts" }
TypeScript/tests/cases/compiler/emitBOM.ts_3_129
@emitBOM: true //@declaration: true //@sourcemap: true // JS and d.ts output should have a BOM but not the sourcemap var x;
{ "end_byte": 129, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emitBOM.ts" }
TypeScript/tests/cases/compiler/objectLiteralIndexers.ts_0_324
interface A { x: number; } interface B extends A { y: string; } var a: A; var b: B; var c: any; var o1: { [s: string]: A;[n: number]: B; } = { x: a, 0: b }; // string indexer is A, number indexer is B o1 = { x: b, 0: c }; // both indexers are any o1 = { x: c, 0: b }; // string indexer is any, number indexer ...
{ "end_byte": 324, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectLiteralIndexers.ts" }
TypeScript/tests/cases/compiler/configFileExtendsAsList.ts_0_407
// @Filename: /tsconfig1.json { "compilerOptions": { "strictNullChecks": true } } // @Filename: /tsconfig2.json { "compilerOptions": { "noImplicitAny": true } } // @Filename: /tsconfig.json { "extends": ["./tsconfig1.json", "./tsconfig2.json"] } // @Filename: /index.ts function f(...
{ "end_byte": 407, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/configFileExtendsAsList.ts" }
TypeScript/tests/cases/compiler/alwaysStrictAlreadyUseStrict.ts_0_68
// @alwaysStrict: true "use strict" function f() { var a = []; }
{ "end_byte": 68, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/alwaysStrictAlreadyUseStrict.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationClassWithDefaultConstructorAndCapturedThisStatement.ts_0_91
// @sourcemap: true class Greeter { public a = 10; public returnA = () => this.a; }
{ "end_byte": 91, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationClassWithDefaultConstructorAndCapturedThisStatement.ts" }
TypeScript/tests/cases/compiler/commentOnParameter3.ts_3_101
nction commentedParameters( a /* parameter a */, b /* parameter b */, /* extra comment */ ) { }
{ "end_byte": 101, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentOnParameter3.ts" }
TypeScript/tests/cases/compiler/staticPropSuper.ts_0_480
class A { } class B extends A { public static s: number = 9; constructor() { var x = 1; // should not error super(); } } class C extends A { public p: number = 10; constructor() { var x = 1; // should error } } class D extends A { private p: number = 11; con...
{ "end_byte": 480, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/staticPropSuper.ts" }
TypeScript/tests/cases/compiler/noEmitHelpers2.ts_0_214
// @noemithelpers: true // @experimentaldecorators: true // @emitdecoratormetadata: true // @target: es5 declare var decorator: any; @decorator class A { constructor(a: number, @decorator b: string) { } }
{ "end_byte": 214, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noEmitHelpers2.ts" }
TypeScript/tests/cases/compiler/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts_0_216
// @strict: true // @target: es6 const FOO_SYMBOL = Symbol('Foo'); declare global { interface Promise<T> { [FOO_SYMBOL]?: number; } } export function foo<T>(p: Promise<T>) { p[FOO_SYMBOL] = 3; }
{ "end_byte": 216, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts" }
TypeScript/tests/cases/compiler/es6ClassTest4.ts_0_186
declare class Point { x: number; y: number; add(dx: number, dy: number): Point; mult(p: Point): Point; static origin: Point; constructor(x: number, y: number); }
{ "end_byte": 186, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ClassTest4.ts" }
TypeScript/tests/cases/compiler/unusedTypeParameterInLambda2.ts_0_162
//@noUnusedLocals:true //@noUnusedParameters:true class A { public f1() { return <T, X>() => { var a: X; a; } } }
{ "end_byte": 162, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedTypeParameterInLambda2.ts" }
TypeScript/tests/cases/compiler/jsxRuntimePragma.ts_0_1275
// @jsx: react,react-jsx,react-jsxdev // @filename: one.tsx /// <reference path="/.lib/react16.d.ts" /> /* @jsxRuntime classic */ import * as React from "react"; export const HelloWorld = () => <h1>Hello world</h1>; export const frag = <><div></div></>; export const selfClosing = <img src="./image.png" />; // @filename...
{ "end_byte": 1275, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsxRuntimePragma.ts" }
TypeScript/tests/cases/compiler/targetTypeObjectLiteral.ts_0_110
var z: { x: number; y: (w:string)=>number;} = { x: 12, y: function(w) { return 0; } }
{ "end_byte": 110, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/targetTypeObjectLiteral.ts" }
TypeScript/tests/cases/compiler/isolatedDeclarationErrorsDefault.ts_0_445
// @declaration: true // @isolatedDeclarations: true // @declarationMap: false // @strict: true // @target: ESNext // @fileName: a.ts export default 1 + 1; // @fileName: b.ts export default { foo: 1 + 1 }; // @fileName: c.ts export default [{ foo: 1 + 1 }]; // @fileName: d.ts export default [{ foo: 1 + 1 }] as con...
{ "end_byte": 445, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/isolatedDeclarationErrorsDefault.ts" }
TypeScript/tests/cases/compiler/blockScopedFunctionDeclarationES5.ts_0_70
// @target: ES5 if (true) { function foo() { } foo(); } foo();
{ "end_byte": 70, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/blockScopedFunctionDeclarationES5.ts" }
TypeScript/tests/cases/compiler/interMixingModulesInterfaces3.ts_0_205
module A { module B { export function createB(): B { return null; } } export interface B { name: string; value: number; } } var x: A.B = null;
{ "end_byte": 205, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/interMixingModulesInterfaces3.ts" }
TypeScript/tests/cases/compiler/commentOnAmbientVariable1.ts_0_171
/*!========= Keep this pinned comment ========= */ /*! Don't keep this pinned comment */ declare var v: number; // Don't keep this comment. declare var y: number;
{ "end_byte": 171, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentOnAmbientVariable1.ts" }
TypeScript/tests/cases/compiler/declarationEmitModuleWithScopeMarker.ts_0_245
// @target: es5 // @module: commonjs // @declaration: true declare module "bar" { var before: typeof func; export function normal(): void; export default function func(): typeof func; var after: typeof func; export {} }
{ "end_byte": 245, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitModuleWithScopeMarker.ts" }
TypeScript/tests/cases/compiler/declFileForClassWithPrivateOverloadedFunction.ts_0_118
// @declaration: true class C { private foo(x: number); private foo(x: string); private foo(x: any) { } }
{ "end_byte": 118, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileForClassWithPrivateOverloadedFunction.ts" }
TypeScript/tests/cases/compiler/primitiveMembers.ts_0_449
var x = 5; var r = /yo/; r.source; x.toBAZ(); x.toString(); var n = 0; var N: Number; n = N; // should not work, as 'number' has a different brand N = n; // should work var o: Object = {} var f: Function = (x: string) => x.length; var r2: RegExp = /./g; var n2: Number = 34; var s: String = "yo"; var b: Boolean = t...
{ "end_byte": 449, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/primitiveMembers.ts" }
TypeScript/tests/cases/compiler/genericDefaultsJs.ts_0_1437
// @checkJs: true // @allowJs: true // @noEmit: true // @filename: decls.d.ts declare function f0<T>(x?: T): T; declare function f1<T, U = number>(x?: T): [T, U]; declare class C0<T> { y: T; constructor(x?: T); } declare class C1<T, U = number> { y: [T, U]; constructor(x?: T); } // @filename: main.js co...
{ "end_byte": 1437, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericDefaultsJs.ts" }
TypeScript/tests/cases/compiler/moduleResolutionWithExtensions_unexpected2.ts_0_306
// @noImplicitReferences: true // @traceResolution: true // This tests that a package.json "types" with an unexpected extension is ignored. // @Filename: /node_modules/foo/foo.js This file is not read. // @Filename: /node_modules/foo/package.json { "types": "foo.js" } // @Filename: /a.ts import "foo";
{ "end_byte": 306, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolutionWithExtensions_unexpected2.ts" }
TypeScript/tests/cases/compiler/constDeclarationShadowedByVarDeclaration3.ts_3_219
Ensure only checking for const declarations shadowed by vars class Rule { public regex: RegExp = new RegExp(''); public name: string = ''; constructor(name: string) { this.name = name; } }
{ "end_byte": 219, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constDeclarationShadowedByVarDeclaration3.ts" }
TypeScript/tests/cases/compiler/metadataOfStringLiteral.ts_0_188
// @experimentalDecorators: true // @emitDecoratorMetadata: true function PropDeco(target: Object, propKey: string | symbol) { } class Foo { @PropDeco public foo: "foo" | "bar"; }
{ "end_byte": 188, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/metadataOfStringLiteral.ts" }
TypeScript/tests/cases/compiler/symbolLinkDeclarationEmitModuleNames.ts_0_933
// @declaration: true // @filename: monorepo/core/src/application.ts import { Constructor } from "@loopback/context"; export type ControllerClass = Constructor<any>; // @filename: monorepo/core/src/usage.ts import { ControllerClass } from './application'; import { BindingKey } from '@loopback/context'; export const CO...
{ "end_byte": 933, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/symbolLinkDeclarationEmitModuleNames.ts" }
TypeScript/tests/cases/compiler/parameterReferenceInInitializer1.ts_0_251
function fn<a>(y: Y, set: (y: Y, x: number) => void): a { return undefined; } interface Y { x: number } class C { constructor( y: Y, public x = fn(y, (y, x) => y.x = x) // expected to work, but actually doesn't ) { } }
{ "end_byte": 251, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parameterReferenceInInitializer1.ts" }
TypeScript/tests/cases/compiler/optionalParamTypeComparison.ts_0_95
var f: (s: string, n?: number) => void; var g: (s: string, b?: boolean) => void; f = g; g = f;
{ "end_byte": 95, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/optionalParamTypeComparison.ts" }
TypeScript/tests/cases/compiler/moduleResolution_packageJson_yesAtPackageRoot.ts_0_333
// @noImplicitReferences: true // @traceResolution: true // @Filename: /node_modules/foo/bar/index.js not read // @Filename: /node_modules/foo/package.json { "name": "foo", "version": "1.2.3", "types": "types.d.ts" } // @Filename: /node_modules/foo/types.d.ts export const x = 0; // @Filename: /a.ts import { x } fro...
{ "end_byte": 333, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolution_packageJson_yesAtPackageRoot.ts" }
TypeScript/tests/cases/compiler/yieldExpression1.ts_0_155
// @target: es6 // @strictNullChecks: true function* a() { yield; yield 0; } function* b(): IterableIterator<number> { yield; yield 0; }
{ "end_byte": 155, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/yieldExpression1.ts" }
TypeScript/tests/cases/compiler/emitDecoratorMetadata_object.ts_0_294
// @experimentaldecorators: true // @emitdecoratormetadata: true // @target: ES5 declare const MyClassDecorator: ClassDecorator; declare const MyMethodDecorator: MethodDecorator; @MyClassDecorator class A { constructor(hi: object) {} @MyMethodDecorator method(there: object) {} }
{ "end_byte": 294, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emitDecoratorMetadata_object.ts" }
TypeScript/tests/cases/compiler/enumDeclarationEmitInitializerHasImport.ts_0_203
// @declaration: true // @filename: provider.ts export enum Enum { Value1, Value2, } // @filename: consumer.ts import provider = require('./provider'); export const value = provider.Enum.Value1;
{ "end_byte": 203, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumDeclarationEmitInitializerHasImport.ts" }
TypeScript/tests/cases/compiler/overload1.ts_0_776
module O { export class A { } export class B extends A { } export class C extends B { } export interface I { f(s:string):number; f(n:number):string; g(n1:number,n2:number):number; g(n:number):string; g(a:A):C; g(c:C):string...
{ "end_byte": 776, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overload1.ts" }
TypeScript/tests/cases/compiler/capturedLetConstInLoop7_ES6.ts_0_5264
// @target: ES6 //===let l0: for (let x of []) { (function() { return x}); (() => x); if (x == 1) { break; } if (x == 1) { break l0; } if (x == 2) { continue; } if (x == 2) { continue l0; } } l00: for (let x in []) { (function() { return x}); ...
{ "end_byte": 5264, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/capturedLetConstInLoop7_ES6.ts" }
TypeScript/tests/cases/compiler/classFieldSuperNotAccessibleJs.ts_0_715
// @strict: true // @checkJs: true // @target: esnext // @noEmit: true // @filename: index.js // https://github.com/microsoft/TypeScript/issues/55884 class YaddaBase { constructor() { this.roots = "hi"; /** @type number */ this.justProp; /** @type string */ this['literalEl...
{ "end_byte": 715, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classFieldSuperNotAccessibleJs.ts" }
TypeScript/tests/cases/compiler/esModuleInteropDefaultImports.ts_0_632
// @esModuleInterop: true // @filename: mod.ts declare function fun(): void; export default fun; // @filename: a.ts import mod = require("./mod"); export = mod; // @filename: b.ts import a from "./a"; import { default as b } from "./a"; import c, { default as d } from "./a"; import * as self from "./b"; export { defaul...
{ "end_byte": 632, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/esModuleInteropDefaultImports.ts" }
TypeScript/tests/cases/compiler/importOnAliasedIdentifiers.ts_0_234
module A { export interface X { s: string } export var X: X; } module B { interface A { n: number } import Y = A; // Alias only for module A import Z = A.X; // Alias for both type and member A.X var v: Z = Z; }
{ "end_byte": 234, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importOnAliasedIdentifiers.ts" }
TypeScript/tests/cases/compiler/genericConstraint1.ts_0_136
class C<T> { public bar2<U extends T>(x: T, y: U): T { return null; } } var x = new C<number>(); x.bar2<string>(2, "");
{ "end_byte": 136, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericConstraint1.ts" }
TypeScript/tests/cases/compiler/moduleMemberMissingErrorIsRelative.ts_0_96
// @filename: folder/foo.ts export {}; // @filename: folder/bar.ts import {nosuch} from './foo';
{ "end_byte": 96, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleMemberMissingErrorIsRelative.ts" }
TypeScript/tests/cases/compiler/requireOfJsonFileWithoutResolveJsonModuleAndPathMapping.ts_0_495
// @noImplicitReferences: true // @traceResolution: true // @allowJs: true // @esModuleInterop: true // @fullEmitPaths: true // @resolveJsonModule: false // @Filename: /node_modules/foo/bar/foobar.json { "a": 10 } // @Filename: /a.ts import foobar from "foo/bar/foobar.json"; // @Filename: /tsconfig.json { "compi...
{ "end_byte": 495, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/requireOfJsonFileWithoutResolveJsonModuleAndPathMapping.ts" }
TypeScript/tests/cases/compiler/requireOfJsonFileWithModuleNodeResolutionEmitSystem.ts_0_227
// @module: system // @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": 227, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/requireOfJsonFileWithModuleNodeResolutionEmitSystem.ts" }
TypeScript/tests/cases/compiler/augmentExportEquals3_1.ts_0_461
// @module: amd // @filename: file1.d.ts declare module "file1" { function foo(): void; namespace foo { export var v: number; } export = foo; } // @filename: file2.ts /// <reference path="file1.d.ts"/> import x = require("file1"); x.b = 1; // OK - './file1' is a namespace declare module "fil...
{ "end_byte": 461, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/augmentExportEquals3_1.ts" }
TypeScript/tests/cases/compiler/controlFlowPropertyDeclarations.ts_0_3844
// Repro from ##8913 declare var require:any; var HTMLDOMPropertyConfig = require('react/lib/HTMLDOMPropertyConfig'); // Populate property map with ReactJS's attribute and property mappings // TODO handle/use .Properties value eg: MUST_USE_PROPERTY is not HTML attr for (var propname in HTMLDOMPropertyConfig.Properti...
{ "end_byte": 3844, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/controlFlowPropertyDeclarations.ts" }
TypeScript/tests/cases/compiler/mergeSymbolRexportFunction.ts_0_291
// @moduleResolution: node // @filename: main.ts import {Row} from '.' Row(); // @filename: ./a.d.ts import '.' declare module '.' { const Row: () => void; } // @filename: ./index.d.ts export type {Row} from './common'; // @filename: ./common.d.ts export declare function Row(): void;
{ "end_byte": 291, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mergeSymbolRexportFunction.ts" }
TypeScript/tests/cases/compiler/circularResolvedSignature.ts_0_403
declare function useState<S>(initialState: (() => S)): [S, (s: S) => void]; type Data = Readonly<{ value: number; foo: (arg: any) => void; bar: (arg: any) => void; }>; export function Component() { const [state, setState] = useState<Data>(() => ({ value: "string", // this should be a number ...
{ "end_byte": 403, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/circularResolvedSignature.ts" }
TypeScript/tests/cases/compiler/contextualTyping28.ts_0_41
function foo(param:number[]){}; foo([1]);
{ "end_byte": 41, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTyping28.ts" }
TypeScript/tests/cases/compiler/jsxNamespaceGlobalReexportMissingAliasTarget.tsx_0_2813
// @strict: true // @jsx: react-jsx // @jsxImportSource: preact // @types: preact/jsx-runtime // @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, ke...
{ "end_byte": 2813, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsxNamespaceGlobalReexportMissingAliasTarget.tsx" }
TypeScript/tests/cases/compiler/arrayBindingPatternOmittedExpressions.ts_0_197
// @target: ES6 var results: string[]; { let [, b, , a] = results; let x = { a, b } } function f([, a, , b, , , , s, , , ] = results) { a = s[1]; b = s[2]; }
{ "end_byte": 197, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arrayBindingPatternOmittedExpressions.ts" }
TypeScript/tests/cases/compiler/noErrorUsingImportExportModuleAugmentationInDeclarationFile2.ts_3_129
@module: none // @filename: 1.ts export var j = "hello"; // error // @filename: 0.d.ts export = a; declare var a: number;
{ "end_byte": 129, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noErrorUsingImportExportModuleAugmentationInDeclarationFile2.ts" }
TypeScript/tests/cases/compiler/genericClassInheritsConstructorFromNonGenericClass.ts_0_97
class A extends B<string> { } class B<U> extends C { } class C { constructor(p: string) { } }
{ "end_byte": 97, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericClassInheritsConstructorFromNonGenericClass.ts" }
TypeScript/tests/cases/compiler/getterErrorMessageNotDuplicated.ts_0_183
interface Thing { get style(): Foo; set style(cssText: string | Bar); } interface Foo { hello: string; world: number; } interface Bar extends Foo { extra: any; }
{ "end_byte": 183, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/getterErrorMessageNotDuplicated.ts" }
TypeScript/tests/cases/compiler/deferredTypeReferenceWithinArrayWithinTuple.ts_0_176
type TypeStructure = | ["or", TypeStructure[]] // problem is only here, when using array | ["string"] | ["number"] | ["list", TypeStructure] // with just this it is ok
{ "end_byte": 176, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/deferredTypeReferenceWithinArrayWithinTuple.ts" }
TypeScript/tests/cases/compiler/exportInFunction.ts_0_31
function f() { export = 0;
{ "end_byte": 31, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportInFunction.ts" }
TypeScript/tests/cases/compiler/declarationEmitClassSetAccessorParamNameInJs3.ts_0_236
// @declaration: true // @emitDeclarationOnly: true // @allowJs: true // @filename: foo.js export class Foo { /** * Bar. * * @param {{ prop: string | undefined }} baz Baz. */ set bar({ prop = 'foo' }) {} }
{ "end_byte": 236, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitClassSetAccessorParamNameInJs3.ts" }