_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/genericsManyTypeParameters.ts_0_2714
function Foo< a1, a21, a31, a41, a51, a61, a119, a22, a32, a42, a52, a62, a219, a23, a33, a43, a53, a63, a319, a24, a34, a44, a54, a64, a419, a25, a35, a45, a55, a65, a519, a26, a36, a46, a56, a66, a619, a27, a37, a47, a57, a67, a71, a28, a38, a48, a58, a68, a81, a29, a39, a49, a59, ...
{ "end_byte": 2714, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericsManyTypeParameters.ts" }
TypeScript/tests/cases/compiler/parserConstructorDeclaration12.ts_0_199
class C { constructor<>() { } constructor<> () { } constructor <>() { } constructor <> () { } constructor< >() { } constructor< > () { } constructor < >() { } constructor < > () { } }
{ "end_byte": 199, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parserConstructorDeclaration12.ts" }
TypeScript/tests/cases/compiler/invalidSplice.ts_0_29
var arr = [].splice(0,3,4,5);
{ "end_byte": 29, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/invalidSplice.ts" }
TypeScript/tests/cases/compiler/superErrors.ts_0_1308
function foo() { // super in a non class context var x = super; var y = () => super; var z = () => () => () => super; } class User { name: string = "Bob"; sayHello(): void { //console.log("Hello, " + this.name); } } class RegisteredUser extends User { name: string = "Frank"; ...
{ "end_byte": 1308, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/superErrors.ts" }
TypeScript/tests/cases/compiler/strictModeEnumMemberNameReserved.ts_0_68
"use strict"; enum E { static } const x1: E.static = E.static;
{ "end_byte": 68, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/strictModeEnumMemberNameReserved.ts" }
TypeScript/tests/cases/compiler/declarationEmitWithInvalidPackageJsonTypings.ts_0_590
// @declaration: true // @filename: /p1/node_modules/csv-parse/lib/index.d.ts export function bar(): number; // @filename: /p1/node_modules/csv-parse/package.json { "main": "./lib", "name": "csv-parse", "types": [ "./lib/index.d.ts", "./lib/sync.d.ts" ], "version": "4.8.2" } // @filename: /p1/index.ts...
{ "end_byte": 590, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitWithInvalidPackageJsonTypings.ts" }
TypeScript/tests/cases/compiler/substitutionTypesInIndexedAccessTypes.ts_0_439
// @strict: true // Repro from #31086 type UserArgs = { select?: boolean }; type Subset<T, U> = { [key in keyof T]: key extends keyof U ? T[key] : never }; declare function withBoundary<T extends UserArgs>(args?: Subset<T, UserArgs>): T; declare function withoutBoundary<T extends UserArgs>(args?: T): T; const bo...
{ "end_byte": 439, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/substitutionTypesInIndexedAccessTypes.ts" }
TypeScript/tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfConstructor.ts_3_498
@removeComments: true class A { constructor() { // Single Line Comment var x = 10; } } class B { constructor() { /* Multi-line comment */ var y = 10; } } class C { constructor() { // Single Line Comment with more than one blank line ...
{ "end_byte": 498, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfConstructor.ts" }
TypeScript/tests/cases/compiler/staticIndexSignatureAndNormalIndexSignature.ts_0_67
class Foo { [p: string]: any; static [p: string]: number; }
{ "end_byte": 67, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/staticIndexSignatureAndNormalIndexSignature.ts" }
TypeScript/tests/cases/compiler/declarationEmitTypeofRest.ts_0_367
// @declaration: true // @target: es2015 // @fileName: v1.ts export const v1 = (...a: [n: "n", a: "a"]): { /** r rest param */ a: typeof a, } => { return null! } // @fileName: v2.ts const n = Symbol(); export const v2 = (...a: [n: "n", a: "a"]): { /** r rest param */ a: typeof a, /** module va...
{ "end_byte": 367, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitTypeofRest.ts" }
TypeScript/tests/cases/compiler/noUnusedLocals_selfReference_skipsBlockLocations.ts_0_255
// @noUnusedLocals: true namespace n { function f() { f; } switch (0) { case 0: function g() { g; } default: function h() { h; } } }
{ "end_byte": 255, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noUnusedLocals_selfReference_skipsBlockLocations.ts" }
TypeScript/tests/cases/compiler/duplicateOverloadInTypeAugmentation1.ts_0_340
interface Array<T> { reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; } var a: Array<string>; var r5 = a.redu...
{ "end_byte": 340, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateOverloadInTypeAugmentation1.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementNestedObjectBindingPattern.ts_0_774
// @lib: es5 // @sourcemap: true declare var console: { log(msg: string): void; } interface Robot { name: string; skills: { primary: string; secondary: string; }; } var robotA: Robot = { name: "mower", skills: { primary: "mowing", secondary: "none" } }; var robotB: Robot = { name: "trimm...
{ "end_byte": 774, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementNestedObjectBindingPattern.ts" }
TypeScript/tests/cases/compiler/jsFileCompilationNoErrorWithoutDeclarationsWithJsFileReferenceWithNoOut.ts_0_223
// @allowJs: true // @filename: a.ts class c { } // @filename: b.ts /// <reference path="c.js"/> // no error on above reference path since not emitting declarations function foo() { } // @filename: c.js function bar() { }
{ "end_byte": 223, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationNoErrorWithoutDeclarationsWithJsFileReferenceWithNoOut.ts" }
TypeScript/tests/cases/compiler/circularReferenceInReturnType2.ts_0_1216
// @strict: true // @noEmit: true type ObjectType<Source> = { kind: "object"; __source: (source: Source) => void; }; type Field<Source, Key extends string> = { __key: (key: Key) => void; __source: (source: Source) => void; }; declare const object: <Source>() => < Fields extends { [Key in keyof Fields]:...
{ "end_byte": 1216, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/circularReferenceInReturnType2.ts" }
TypeScript/tests/cases/compiler/unusedPrivateVariableInClass1.ts_0_91
//@noUnusedLocals:true //@noUnusedParameters:true class greeter { private x: string; }
{ "end_byte": 91, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedPrivateVariableInClass1.ts" }
TypeScript/tests/cases/compiler/verifyDefaultLib_webworker.ts_0_162
// @strictNullChecks: true // @noImplicitAny: true // @noImplicitThis: true // @skipDefaultLibCheck: false // @lib: es2015,es2016,es2017,webworker var x: Worker;
{ "end_byte": 162, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/verifyDefaultLib_webworker.ts" }
TypeScript/tests/cases/compiler/excessPropertiesInOverloads.ts_0_128
// @strict: true declare function fn(a: { x: string }): void; declare function fn(a: { y: string }): void; fn({ z: 3, a: 3 });
{ "end_byte": 128, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/excessPropertiesInOverloads.ts" }
TypeScript/tests/cases/compiler/contextualTyping37.ts_0_50
var foo = <{ id: number; }[]>[{ foo: "s" }, { }];
{ "end_byte": 50, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTyping37.ts" }
TypeScript/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision5.ts_0_472
// @noemithelpers: true // @experimentaldecorators: true // @emitdecoratormetadata: true // @target: es5 // @module: commonjs // @filename: db.ts export default class db { public doSomething() { } } // @filename: service.ts import db from './db'; function someDecorator(target) { return target; } @someDecor...
{ "end_byte": 472, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision5.ts" }
TypeScript/tests/cases/compiler/es5-asyncFunctionNestedLoops.ts_0_279
// @lib: es5,es2015.promise // @noEmitHelpers: true // @target: ES5 declare var x, y, z, a, b, c; async function nestedLoops() { A: while (x) { await y; while (z) { continue A; } while (a) { continue; } } }
{ "end_byte": 279, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es5-asyncFunctionNestedLoops.ts" }
TypeScript/tests/cases/compiler/baseTypeAfterDerivedType.ts_0_252
interface Derived extends Base { method(...args: any[]): void; } interface Base { method(...args: any[]): void; } class Derived2 implements Base2 { method(...args: any[]): void { } } interface Base2 { method(...args: any[]): void; }
{ "end_byte": 252, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/baseTypeAfterDerivedType.ts" }
TypeScript/tests/cases/compiler/APISample_WatchWithDefaults.ts_3_2662
@module: commonjs // @skipLibCheck: true // @noImplicitAny:true // @strictNullChecks:true // @noTypesAndSymbols: true // @filename: node_modules/typescript/package.json { "name": "typescript", "types": "/.ts/typescript.d.ts" } // @filename: APISample_WatchWithDefaults.ts /* * Note: This test is a public API...
{ "end_byte": 2662, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/APISample_WatchWithDefaults.ts" }
TypeScript/tests/cases/compiler/unusedLocalsInMethod4.ts_0_3147
// @strict: true function f<T, NonNull extends {}>() { let x1: number[]; // should error let x2: number[] | null; // should error let x3: number[] | undefined; // should not error let x4: number[] | undefined | null; // should not error let x5!: number[]; // should not error let x6: any; // sho...
{ "end_byte": 3147, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedLocalsInMethod4.ts" }
TypeScript/tests/cases/compiler/partiallyAmbientFundule.ts_0_108
declare module foo { export function x(): any; } function foo () { } // Legal, because module is ambient
{ "end_byte": 108, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/partiallyAmbientFundule.ts" }
TypeScript/tests/cases/compiler/declarationEmitInvalidReference2.ts_0_68
// @declaration: true /// <reference path="invalid.ts" /> var x = 0;
{ "end_byte": 68, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitInvalidReference2.ts" }
TypeScript/tests/cases/compiler/exportDefaultParenthesize.ts_0_664
// @target: es5 // @module: esnext // @filename: commalist.ts export default { ['foo'+'']: 42, ['foo'+'']: 42, ['foo'+'']: 42, ['foo'+'']: 42, ['foo'+'']: 42, ['foo'+'']: 42, ['foo'+'']: 42, ['foo'+'']: 42, ['foo'+'']: 42, ['foo'+'']: 42, ['foo'+'']: 42, ['foo'+'']: 42, ...
{ "end_byte": 664, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportDefaultParenthesize.ts" }
TypeScript/tests/cases/compiler/duplicateObjectLiteralProperty_computedNameNegative1.ts_0_337
// @strict: true // @noEmit: true // repro from https://github.com/microsoft/TypeScript/issues/56341 function bar(props: { x?: string; y?: string }) { const { x = "", y = "" } = props; return { [x]: 1, [y]: 2, }; } function foo({ x = "", y = "" }: { x?: string; y?: string }) { return { [x]: 1, ...
{ "end_byte": 337, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateObjectLiteralProperty_computedNameNegative1.ts" }
TypeScript/tests/cases/compiler/nestedSuperCallEmit.ts_0_551
// @target: es5 // @noTypesAndSymbols: true // https://github.com/microsoft/TypeScript/issues/55646 abstract class Foo { constructor(shouldThrow: boolean) { if (shouldThrow) { throw new Error('Please retry'); } else { console.log('OK'); } } } class Bar extends F...
{ "end_byte": 551, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nestedSuperCallEmit.ts" }
TypeScript/tests/cases/compiler/implicitAnyNewExprLackConstructorSignature.ts_0_100
//@noimplicitany: true function Point() { this.x = 3; } var x: any = new Point(); // error at "new"
{ "end_byte": 100, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/implicitAnyNewExprLackConstructorSignature.ts" }
TypeScript/tests/cases/compiler/declFileClassExtendsNull.ts_0_73
// @target: ES5 // @declaration: true class ExtendsNull extends null { }
{ "end_byte": 73, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileClassExtendsNull.ts" }
TypeScript/tests/cases/compiler/declFileExportAssignmentImportInternalModule.ts_0_481
//@module: commonjs // @declaration: true module m3 { export module m2 { export interface connectModule { (res, req, next): void; } export interface connectExport { use: (mod: connectModule) => connectExport; listen: (port: number) => void; } ...
{ "end_byte": 481, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileExportAssignmentImportInternalModule.ts" }
TypeScript/tests/cases/compiler/collisionCodeGenModuleWithAccessorChildren.ts_0_590
module M { export var x = 3; class c { private y; set Z(M) { this.y = x; } } } module M { class d { private y; set Z(p) { var M = 10; this.y = x; } } } module M { // Shouldnt be _M class e { private y; ...
{ "end_byte": 590, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionCodeGenModuleWithAccessorChildren.ts" }
TypeScript/tests/cases/compiler/staticMethodsReferencingClassTypeParameters.ts_0_47
class C<T> { static s(p: T) { return p; } }
{ "end_byte": 47, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/staticMethodsReferencingClassTypeParameters.ts" }
TypeScript/tests/cases/compiler/signatureCombiningRestParameters4.ts_0_1234
// @strict: true // @noEmit: true declare class Node<Options = any> { type: string; name: string; parent: Node | null; child: Node | null; options: Options; } interface NodeConfig<Options = any> { extendMarkSchema?: | (( this: { name: string; options: Options; }, ...
{ "end_byte": 1234, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/signatureCombiningRestParameters4.ts" }
TypeScript/tests/cases/compiler/moduleResolutionNoResolve.ts_0_126
// @module:commonjs // @noResolve: true // @filename: a.ts import a = require('./b'); // @filename: b.ts export var c = '';
{ "end_byte": 126, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolutionNoResolve.ts" }
TypeScript/tests/cases/compiler/inheritSameNamePropertiesWithDifferentOptionality.ts_0_119
interface C { x?: number; } interface C2 { x: number; } interface A extends C, C2 { // error y: string; }
{ "end_byte": 119, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inheritSameNamePropertiesWithDifferentOptionality.ts" }
TypeScript/tests/cases/compiler/primitiveTypeAsInterfaceName.ts_0_19
interface number {}
{ "end_byte": 19, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/primitiveTypeAsInterfaceName.ts" }
TypeScript/tests/cases/compiler/declarationEmitObjectAssignedDefaultExport.ts_0_1283
// @target: es6 // @module: commonjs // @declaration: true // @filename: node_modules/styled-components/node_modules/hoist-non-react-statics/index.d.ts interface Statics { "$$whatever": string; } declare namespace hoistNonReactStatics { type NonReactStatics<T> = {[X in Exclude<keyof T, keyof Statics>]: T[X]} } ...
{ "end_byte": 1283, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitObjectAssignedDefaultExport.ts" }
TypeScript/tests/cases/compiler/typeReferenceDirectives13.ts_0_363
// @noImplicitReferences: true // @declaration: true // @typeRoots: /types // @traceResolution: true // @currentDirectory: / // @filename: /ref.d.ts export interface $ { x } // @filename: /types/lib/index.d.ts declare let $: { x: number } // @filename: /app.ts /// <reference types="lib"/> import {$} from "./ref"; ex...
{ "end_byte": 363, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeReferenceDirectives13.ts" }
TypeScript/tests/cases/compiler/divergentAccessorsTypes5.ts_0_712
// @target: es5 // Not really different from divergentAccessorsTypes4.ts, // but goes through the deferred type code class One { get prop1(): string { return ""; } set prop1(s: string | number) { } prop2: number; } class Two { get prop1(): "hello" { return "hello"; } set prop1(s: "hello" | number) { } ...
{ "end_byte": 712, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/divergentAccessorsTypes5.ts" }
TypeScript/tests/cases/compiler/stripInternal1.ts_0_107
// @declaration:true // @stripInternal:true class C { foo(): void { } // @internal bar(): void { } }
{ "end_byte": 107, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/stripInternal1.ts" }
TypeScript/tests/cases/compiler/typeArgumentInferenceWithConstraintAsCommonRoot.ts_0_288
interface Animal { x } interface Giraffe extends Animal { y } interface Elephant extends Animal { z } function f<T extends Animal>(x: T, y: T): T { return undefined; } var g: Giraffe; var e: Elephant; f(g, e); // valid because both Giraffe and Elephant satisfy the constraint. T is Animal
{ "end_byte": 288, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeArgumentInferenceWithConstraintAsCommonRoot.ts" }
TypeScript/tests/cases/compiler/constDeclarations-ambient.ts_0_178
// @target: ES6 // No error declare const c1: boolean; declare const c2: number; declare const c3, c4 :string, c5: any; declare module M { const c6; const c7: number; }
{ "end_byte": 178, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constDeclarations-ambient.ts" }
TypeScript/tests/cases/compiler/genericCapturingFunctionNarrowing.ts_0_596
function needsToNarrowTheType<First extends { foo: string }, Second extends { bar: string }, SubFirst extends First, SubFirstMore extends First & {other: string}>(thing: First | SubFirst | SubFirstMore | Second) { if (hasAFoo(thing)) { console.log(thing.foo); } else { // I would expect this ...
{ "end_byte": 596, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericCapturingFunctionNarrowing.ts" }
TypeScript/tests/cases/compiler/genericOfACloduleType2.ts_0_248
class G<T>{ bar(x: T) { return x; } } module M { export class C { foo() { } } export module C { export class X { } } var g1 = new G<C>(); g1.bar(null).foo(); // no error } module N { var g2 = new G<M.C>() }
{ "end_byte": 248, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericOfACloduleType2.ts" }
TypeScript/tests/cases/compiler/exactSpellingSuggestion.ts_0_174
// Fixes #16245 -- always suggest the exact match, even when // other options are very close enum U8 { BIT_0 = 1 << 0, BIT_1 = 1 << 1, BIT_2 = 1 << 2 } U8.bit_2
{ "end_byte": 174, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exactSpellingSuggestion.ts" }
TypeScript/tests/cases/compiler/importAsBaseClass.ts_0_234
// @module: commonjs // @Filename: importAsBaseClass_0.ts export class Greeter { greet() { return 'greet' } } // @Filename: importAsBaseClass_1.ts import Greeter = require("./importAsBaseClass_0"); class Hello extends Greeter { }
{ "end_byte": 234, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importAsBaseClass.ts" }
TypeScript/tests/cases/compiler/declarationEmitIndexTypeArray.ts_0_133
// @declaration: true function doSomethingWithKeys<T>(...keys: (keyof T)[]) { } const utilityFunctions = { doSomethingWithKeys };
{ "end_byte": 133, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitIndexTypeArray.ts" }
TypeScript/tests/cases/compiler/truthinessCallExpressionCoercion1.ts_0_1780
// @strictNullChecks:true function onlyErrorsWhenTestingNonNullableFunctionType(required: () => boolean, optional?: () => boolean) { // error required ? console.log('required') : undefined; // ok optional ? console.log('optional') : undefined; // ok !!required ? console.log('not required') : ...
{ "end_byte": 1780, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/truthinessCallExpressionCoercion1.ts" }
TypeScript/tests/cases/compiler/implicitAnyDeclareTypePropertyWithoutType.ts_0_470
// @noimplicitany: true class C { constructor() { } } // this should be an error var x: { y; z; } // error at "y,z" var x1: { y1: C; z1; }; // error at "z1" var x11: { new (); }; // error at "new" var x2: (y2) => number; // error at "y2" var x3: (x3: string, y3) => void ; // error at ...
{ "end_byte": 470, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/implicitAnyDeclareTypePropertyWithoutType.ts" }
TypeScript/tests/cases/compiler/functionVariableInReturnTypeAnnotation.ts_0_65
function bar(): typeof b { var b = 1; return undefined; }
{ "end_byte": 65, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionVariableInReturnTypeAnnotation.ts" }
TypeScript/tests/cases/compiler/reorderProperties.ts_0_222
interface A<T> { x: T } interface B<T> { x: T } interface C<S> extends A<D<S>> { y: S } interface D<S> extends B<C<S>> { y: S } var c: C<{ s: string; n: number }> var d: D<{ n: number; s: string }> = c
{ "end_byte": 222, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reorderProperties.ts" }
TypeScript/tests/cases/compiler/import_var-referencing-an-imported-module-alias.ts_0_168
// @Filename: host.ts export class Host { } // @Filename: consumer.ts // @module: amd import host = require("host"); var hostVar = host; var v = new hostVar.Host();
{ "end_byte": 168, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/import_var-referencing-an-imported-module-alias.ts" }
TypeScript/tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts_3_197
@target: ES6 class A { blub = 6; } class B extends A { blah = 2; constructor(public x: number) { "use strict"; 'someStringForEgngInject'; super() } }
{ "end_byte": 197, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts" }
TypeScript/tests/cases/compiler/checkSuperCallBeforeThisAccessing5.ts_3_145
ass Based { constructor(...arg) { } } class Derived extends Based { public x: number; constructor() { super(this.x); } }
{ "end_byte": 145, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/checkSuperCallBeforeThisAccessing5.ts" }
TypeScript/tests/cases/compiler/constEnumMergingWithValues1.ts_0_104
//@module: amd //@filename: m1.ts function foo() {} module foo { const enum E { X } } export = foo
{ "end_byte": 104, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constEnumMergingWithValues1.ts" }
TypeScript/tests/cases/compiler/augmentedTypesVar.ts_0_645
// var then var var x1 = 1; var x1 = 2; // var then function var x2 = 1; // error function x2() { } // error var x3 = 1; var x3 = () => { } // error // var then class var x4 = 1; // error class x4 { } // error var x4a = 1; // error class x4a { public foo() { } } // error // var then enum var x5 = 1; enum x5 { One...
{ "end_byte": 645, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/augmentedTypesVar.ts" }
TypeScript/tests/cases/compiler/scopingInCatchBlocks.ts_0_154
try { } catch(ex1) { throw ex1; } try { } catch(ex1) { } // should not error try { } catch(ex1) { } // should not error var x = ex1; // should error
{ "end_byte": 154, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/scopingInCatchBlocks.ts" }
TypeScript/tests/cases/compiler/declarationEmitDestructuring4.ts_3_327
@declaration: true // For an array binding pattern with empty elements, // we will not make any modification and will emit // the similar binding pattern users' have written function baz([]) { } function baz1([] = [1,2,3]) { } function baz2([[]] = [[1,2,3]]) { } function baz3({}) { } function baz4({} = { x: 10 }) { }...
{ "end_byte": 327, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitDestructuring4.ts" }
TypeScript/tests/cases/compiler/specializedSignatureOverloadReturnTypeWithIndexers.ts_0_466
interface A { f(p: string): { [p: string]: string; }; f(p: "spec"): { [p: string]: any; } // Should be ok } interface B { f(p: string): { [p: number]: string; }; f(p: "spec"): { [p: string]: any; } // Should be ok } interface C { f(p: string): { [p: number]: string; }; f(p: "spec"): { [p: number...
{ "end_byte": 466, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/specializedSignatureOverloadReturnTypeWithIndexers.ts" }
TypeScript/tests/cases/compiler/thisInSuperCall2.ts_0_311
class Base { constructor(a: any) {} } class Foo extends Base { public x: number; constructor() { super(this); // error: "super" has to be called before "this" accessing } } class Foo2 extends Base { public x: number = 0; constructor() { super(this); // error } }
{ "end_byte": 311, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/thisInSuperCall2.ts" }
TypeScript/tests/cases/compiler/inheritedStringIndexersFromDifferentBaseTypes.ts_0_461
// string indexer tests interface A { [s: string]: number; } interface B { [s: string]: number; } interface C extends A, B { } // ok interface D { [s: string]: string; } interface E extends A, D { } // error // Same tests for number indexer interface A2 { [s: number]: number; } interface B2 { [s:...
{ "end_byte": 461, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inheritedStringIndexersFromDifferentBaseTypes.ts" }
TypeScript/tests/cases/compiler/intersectionsAndReadonlyProperties.ts_0_470
// readonly and non-readonly type Intersection1 = { readonly a: number } & { a: number }; declare let i1: Intersection1; i1.a = 2; // getter and setter type Intersection2 = { get a(): number } & { set a(v: number) }; declare let i2: Intersection2; i2.a = 2; // assignment to an all read-only property should still be...
{ "end_byte": 470, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/intersectionsAndReadonlyProperties.ts" }
TypeScript/tests/cases/compiler/accessorWithInitializer.ts_0_78
// @target: es5 class C { set X(v = 0) { } static set X(v2 = 0) { } }
{ "end_byte": 78, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/accessorWithInitializer.ts" }
TypeScript/tests/cases/compiler/voidUndefinedReduction.ts_0_262
// @strict: true // Repro from #42786 function isDefined<T>(value: T | undefined | null | void): value is T { return value !== undefined && value !== null; } declare const foo: string | undefined; if (isDefined(foo)) { console.log(foo.toUpperCase()); }
{ "end_byte": 262, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/voidUndefinedReduction.ts" }
TypeScript/tests/cases/compiler/generatorES6_6.ts_0_77
// @target: es6 class C { *[Symbol.iterator]() { let a = yield 1; } }
{ "end_byte": 77, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/generatorES6_6.ts" }
TypeScript/tests/cases/compiler/genericReturnTypeFromGetter1.ts_0_211
//@module: amd export interface A<T> { new (dbSet: DbSet<T>): T; } export class DbSet<T> { _entityType: A; get entityType() { return this._entityType; } // used to ICE without return type annotation }
{ "end_byte": 211, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericReturnTypeFromGetter1.ts" }
TypeScript/tests/cases/compiler/dynamicImportWithNestedThis_es5.ts_0_222
// @lib: es2015 // @target: es5 // @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": 222, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/dynamicImportWithNestedThis_es5.ts" }
TypeScript/tests/cases/compiler/alwaysStrictModule2.ts_0_229
// @alwaysStrict: true // @outFile: out.js // @fileName: a.ts module M { export function f() { var arguments = []; } } // @fileName: b.ts module M { export function f2() { var arguments = []; } }
{ "end_byte": 229, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/alwaysStrictModule2.ts" }
TypeScript/tests/cases/compiler/potentiallyUnassignedVariableInCatch.ts_0_96
// @strict: true let foo; try { if (Math.random() > 0.5) { foo = 1234; } } catch { foo; }
{ "end_byte": 96, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/potentiallyUnassignedVariableInCatch.ts" }
TypeScript/tests/cases/compiler/externalModuleImmutableBindings.ts_0_845
// @module: commonjs // @Filename: f1.ts export var x = 1; // @Filename: f2.ts // all mutations below are illegal and should be fixed import * as stuff from './f1'; var n = 'baz'; stuff.x = 0; stuff['x'] = 1; stuff.blah = 2; stuff[n] = 3; stuff.x++; stuff['x']++; stuff['blah']++; stuff[n]++; (stuff.x) = 0; (stuff...
{ "end_byte": 845, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/externalModuleImmutableBindings.ts" }
TypeScript/tests/cases/compiler/argumentsBindsToFunctionScopeArgumentList.ts_0_117
var arguments = 10; function foo(a) { arguments = 10; /// This shouldnt be of type number and result in error. }
{ "end_byte": 117, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/argumentsBindsToFunctionScopeArgumentList.ts" }
TypeScript/tests/cases/compiler/deferredLookupTypeResolution.ts_0_737
// @strict: true // @declaration: true // Repro from #17456 type StringContains<S extends string, L extends string> = ( { [K in S]: 'true' } & { [key: string]: 'false' } )[L] type ObjectHasKey<O, L extends string> = StringContains<Extract<keyof O, string>, L> type First<T> = ObjectHasKey<T, '0'>; //...
{ "end_byte": 737, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/deferredLookupTypeResolution.ts" }
TypeScript/tests/cases/compiler/staticPrototypePropertyOnClass.ts_0_228
class c1 { } class c2<T> { } class c3 { constructor() { } } class c4 { constructor(param: string); constructor(param: number); constructor(param: any) { } } var a = c1; var b = c2; var c = c3; var d = c4;
{ "end_byte": 228, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/staticPrototypePropertyOnClass.ts" }
TypeScript/tests/cases/compiler/deprecatedCompilerOptions6.ts_0_476
// @typeScriptVersion: 5.0 // @filename: /foo/tsconfig.json { "compilerOptions": { "module": "amd", "target": "ES3", "noImplicitUseStrict": true, "keyofStringsOnly": true, "suppressExcessPropertyErrors": true, "suppressImplicitAnyIndexErrors": true, "noStrictG...
{ "end_byte": 476, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/deprecatedCompilerOptions6.ts" }
TypeScript/tests/cases/compiler/undefinedTypeAssignment2.ts_0_24
var undefined = void 0;
{ "end_byte": 24, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/undefinedTypeAssignment2.ts" }
TypeScript/tests/cases/compiler/superCallOutsideConstructor.ts_0_252
class C { foo() { } } class D extends C { x = super(); constructor() { super(); var y = () => { super(); } var y2 = function() { super(); } } } var d = new D();
{ "end_byte": 252, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/superCallOutsideConstructor.ts" }
TypeScript/tests/cases/compiler/importHelpersWithImportOrExportDefaultNoTslib.2.ts_0_266
// @importHelpers: true // @target: es2017 // @module: commonjs,system,amd,es2015,es2020 // @esModuleInterop: true,false // @noEmit: true // @noTypesAndSymbols: true // @filename: a.ts export default class { } // @filename: b.ts export { default as a } from "./a";
{ "end_byte": 266, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importHelpersWithImportOrExportDefaultNoTslib.2.ts" }
TypeScript/tests/cases/compiler/genericClassesRedeclaration.ts_0_3622
declare module TypeScript { interface IIndexable<T> { [s: string]: T; } function createIntrinsicsObject<T>(): IIndexable<T>; interface IHashTable<T> { getAllKeys(): string[]; add(key: string, data: T): boolean; addOrUpdate(key: string, data: T): boolean; map(fn: (...
{ "end_byte": 3622, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericClassesRedeclaration.ts" }
TypeScript/tests/cases/compiler/protectedAccessThroughContextualThis.ts_0_468
// @strict: true class Foo { protected protec = 'bar'; private privat = ''; copy!: string constructor() { bindCopy.call(this) bindCopy2.call(this) } } function bindCopy(this: Foo) { this.copy = this.protec; // Should OK console.log(this.privat); // Should error } type BindingFunction = (this: F...
{ "end_byte": 468, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/protectedAccessThroughContextualThis.ts" }
TypeScript/tests/cases/compiler/exportImportNonInstantiatedModule2.ts_0_307
//@module: amd //@declaration: true // @Filename: w1.ts export = Widget1 interface Widget1 { name: string; } // @Filename: exporter.ts export import w = require('./w1'); // @Filename: consumer.ts import e = require('./exporter'); export function w(): e.w { // Should be OK return {name: 'value' }; }
{ "end_byte": 307, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportImportNonInstantiatedModule2.ts" }
TypeScript/tests/cases/compiler/templateLiteralIntersection2.ts_0_475
// @strict: true // @noEmit: true type Path = string & { _pathBrand: any }; type JoinedPath = `${Path}/${Path}`; declare function joinedPath(p: JoinedPath): void; joinedPath("foo/bar"); declare const somePath: Path; joinedPath(`${somePath}/${somePath}`); type StartsWithA = `a${string}`; type EndsWithA = `${stri...
{ "end_byte": 475, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/templateLiteralIntersection2.ts" }
TypeScript/tests/cases/compiler/argumentsObjectIterator01_ES6.ts_0_238
//@target: ES6 function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] { let result = []; for (let arg of arguments) { result.push(arg + arg); } return <[any, any, any]>result; }
{ "end_byte": 238, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/argumentsObjectIterator01_ES6.ts" }
TypeScript/tests/cases/compiler/recursiveClassInstantiationsWithDefaultConstructors.ts_0_197
module TypeScript2 { export class MemberName { public prefix: string = ""; } export class MemberNameArray extends MemberName { } } var a = new TypeScript2.MemberNameArray()
{ "end_byte": 197, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveClassInstantiationsWithDefaultConstructors.ts" }
TypeScript/tests/cases/compiler/genericFunctionsWithOptionalParameters3.ts_0_595
class Collection<T> { public add(x: T) { } } interface Utils { fold<T, S>(c?: Collection<T>, folder?: (s: S, t: T) => T, init?: S): T; mapReduce<T, U, V>(c: Collection<T>, mapper: (x: T) => U, reducer: (y: U) => V): Collection<V>; } var utils: Utils; var c = new Collection<string>(); var r3 = utils.mapReduc...
{ "end_byte": 595, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericFunctionsWithOptionalParameters3.ts" }
TypeScript/tests/cases/compiler/clodulesDerivedClasses.ts_0_250
class Shape { id: number; } module Shape.Utils { export function convert(): Shape { return null;} } class Path extends Shape { name: string; } module Path.Utils { export function convert2(): Path { return null; } }
{ "end_byte": 250, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/clodulesDerivedClasses.ts" }
TypeScript/tests/cases/compiler/typeValueConflict1.ts_0_159
module M1 { export class A { } } module M2 { var M1 = 0; // Should error. M1 should bind to the variable, not to the module. class B extends M1.A { } }
{ "end_byte": 159, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeValueConflict1.ts" }
TypeScript/tests/cases/compiler/declarationEmitInterfaceWithNonEntityNameExpressionHeritage.ts_0_73
// @declaration: true class A { } interface Class extends (typeof A) { }
{ "end_byte": 73, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitInterfaceWithNonEntityNameExpressionHeritage.ts" }
TypeScript/tests/cases/compiler/moduleProperty2.ts_0_259
module M { function f() { var x; } var y; export var z; var test1=x; var test2=y; // y visible because same module } module N { var test3=M.y; // nope y private property of M var test4=M.z; // ok public property of M }
{ "end_byte": 259, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleProperty2.ts" }
TypeScript/tests/cases/compiler/systemModuleAmbientDeclarations.ts_0_537
// @module: system // @isolatedModules: true // @filename: file1.ts declare class Promise { } declare function Foo(): void; declare class C {} declare enum E {X = 1}; export var promise = Promise; export var foo = Foo; export var c = C; export var e = E; // @filename: file2.ts export declare function foo(); // @fil...
{ "end_byte": 537, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/systemModuleAmbientDeclarations.ts" }
TypeScript/tests/cases/compiler/collisionSuperAndLocalFunctionInConstructor.ts_0_413
function _super() { // No error } class Foo { constructor() { function _super() { // No error } } } class b extends Foo { constructor() { super(); function _super() { // Should be error } } } class c extends Foo { constructor() { super(); var x...
{ "end_byte": 413, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionSuperAndLocalFunctionInConstructor.ts" }
TypeScript/tests/cases/compiler/spreadOfParamsFromGeneratorMakesRequiredParams.ts_0_169
declare function call<Fn extends (...args: any[]) => any>( fn: Fn, ...args: Parameters<Fn> ): any; call(function* (a: 'a') { }); // error, 2nd argument required
{ "end_byte": 169, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/spreadOfParamsFromGeneratorMakesRequiredParams.ts" }
TypeScript/tests/cases/compiler/classFunctionMerging2.ts_0_218
declare abstract class A { constructor(p: number); a: number; } declare function B(p: string): B; declare class B extends A { constructor(p: string); b: number; } let b = new B("Hey") console.log(b.a)
{ "end_byte": 218, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classFunctionMerging2.ts" }
TypeScript/tests/cases/compiler/es6ImportNameSpaceImportInEs5.ts_0_365
// @target: es5 // @module: commonjs // @declaration: true // @filename: es6ImportNameSpaceImportInEs5_0.ts export var a = 10; // @filename: es6ImportNameSpaceImportInEs5_1.ts import * as nameSpaceBinding from "./es6ImportNameSpaceImportInEs5_0"; var x = nameSpaceBinding.a; import * as nameSpaceBinding2 from "./es6...
{ "end_byte": 365, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ImportNameSpaceImportInEs5.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationEnums.ts_0_112
// @sourcemap: true enum e { x, y, x } enum e2 { x = 10, y = 10, z, x2 } enum e3 { }
{ "end_byte": 112, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationEnums.ts" }
TypeScript/tests/cases/compiler/fakeInfinity1.ts_0_521
// @strict: true // @declaration: true // These are not actually the real infinity. export type PositiveInfinity = 1e999; export type NegativeInfinity = -1e999; export type TypeOfInfinity = typeof Infinity; export type TypeOfNaN = typeof NaN; type A = 1e999; type B = 1e9999; declare let a: A; declare let b: B; a =...
{ "end_byte": 521, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/fakeInfinity1.ts" }
TypeScript/tests/cases/compiler/typePredicateWithThisParameter.ts_0_374
// Repro from #15310 interface Foo { foo: string; } interface Bar { bar: string; } function isFoo1(object: {}): object is Foo { return 'foo' in object; } function isFoo2(this: void, object: {}): object is Foo { return 'foo' in object; } declare let test: Foo | Bar; if (isFoo1(test)) { test.foo ...
{ "end_byte": 374, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typePredicateWithThisParameter.ts" }
TypeScript/tests/cases/compiler/arrayBufferIsViewNarrowsType.ts_0_154
var obj: Object; if (ArrayBuffer.isView(obj)) { // isView should be a guard that narrows type to ArrayBufferView. var ab: ArrayBufferView = obj; }
{ "end_byte": 154, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arrayBufferIsViewNarrowsType.ts" }
TypeScript/tests/cases/compiler/isolatedModulesES6.ts_0_78
// @isolatedModules: true // @target: es6 // @filename: file1.ts export var x;
{ "end_byte": 78, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/isolatedModulesES6.ts" }