_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/recursiveExportAssignmentAndFindAliasedType6.ts_0_906
//@module: amd // @Filename: recursiveExportAssignmentAndFindAliasedType6_moduleC.ts import self = require("recursiveExportAssignmentAndFindAliasedType6_moduleD"); export = self; // @Filename: recursiveExportAssignmentAndFindAliasedType6_moduleD.ts import self = require("recursiveExportAssignmentAndFindAliasedType6_mo...
{ "end_byte": 906, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveExportAssignmentAndFindAliasedType6.ts" }
TypeScript/tests/cases/compiler/typeParameterAssignmentWithConstraints.ts_0_102
function f<A, B extends A>() { var a: A; var b: B; a = b; // Error: Can't convert B to A }
{ "end_byte": 102, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeParameterAssignmentWithConstraints.ts" }
TypeScript/tests/cases/compiler/genericRecursiveImplicitConstructorErrors3.ts_0_1244
module TypeScript { export class MemberName <A,B,C>{ static create<A,B,C>(arg1: any, arg2?: any, arg3?: any): MemberName { } } } module TypeScript { export class PullSymbol <A,B,C>{ public type: PullTypeSymbol = null; } export class PullTypeSymbol <A,B,C>extends PullSymbol ...
{ "end_byte": 1244, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericRecursiveImplicitConstructorErrors3.ts" }
TypeScript/tests/cases/compiler/genericIsNeverEmptyObject.ts_0_229
// @strict: true // Repro from #29067 function test<T extends { a: string }>(obj: T) { let { a, ...rest } = obj; return { ...rest, b: a }; } let o1 = { a: 'hello', x: 42 }; let o2: { b: string, x: number } = test(o1);
{ "end_byte": 229, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericIsNeverEmptyObject.ts" }
TypeScript/tests/cases/compiler/unusedDestructuring.ts_0_247
// @noUnusedLocals: true // @noUnusedParameters: true export {}; declare const o: any; const { a, b } = o; const { c, d } = o; d; const { e } = o; const { f: g } = o; const { h } = o, { i } = o; function f({ a, b }, { c, d }, { e }) { d; }
{ "end_byte": 247, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedDestructuring.ts" }
TypeScript/tests/cases/compiler/arrayToLocaleStringES5.ts_0_2698
// @target: es5 let str: string; const arr = [1, 2, 3]; str = arr.toLocaleString(); // OK str = arr.toLocaleString('en-US'); // should be error str = arr.toLocaleString('en-US', { style: 'currency', currency: 'EUR' }); // should be error const dates: readonly Date[] = [new Date(), new Date()]; str = dates.toLocaleStr...
{ "end_byte": 2698, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arrayToLocaleStringES5.ts" }
TypeScript/tests/cases/compiler/propertyAccess5.ts_0_18
undefined.toBAZ();
{ "end_byte": 18, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/propertyAccess5.ts" }
TypeScript/tests/cases/compiler/declarationEmitNestedAnonymousMappedType.ts_0_349
// @declaration: true export function enumFromStrings<const Members extends readonly string[]>() { type Part1 = { [key in keyof Members as Members[key] extends string ? Members[key] : never]: Members[key]; }; type Part2 = { [Property in keyof Part1]: Part1[Property] }; return Obj...
{ "end_byte": 349, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitNestedAnonymousMappedType.ts" }
TypeScript/tests/cases/compiler/systemModule10.ts_0_187
// @module: system // @isolatedModules: true import n, {x} from 'file1' import n2 = require('file2'); export {x} export {x as y} export {n} export {n as n1} export {n2} export {n2 as n3}
{ "end_byte": 187, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/systemModule10.ts" }
TypeScript/tests/cases/compiler/arithmeticOnInvalidTypes.ts_0_92
var x: Number; var y: Number; var z = x + y; var z2 = x - y; var z3 = x * y; var z4 = x / y;
{ "end_byte": 92, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arithmeticOnInvalidTypes.ts" }
TypeScript/tests/cases/compiler/functionOverloads32.ts_0_140
function foo(bar:string):string; function foo(bar:number):number; function foo(bar:any):any{ return bar } var baz:number; var x = foo(baz);
{ "end_byte": 140, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloads32.ts" }
TypeScript/tests/cases/compiler/amdModuleName2.ts_0_185
//@module: amd ///<amd-module name='FirstModuleName'/> ///<amd-module name='SecondModuleName'/> class Foo { x: number; constructor() { this.x = 5; } } export = Foo;
{ "end_byte": 185, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/amdModuleName2.ts" }
TypeScript/tests/cases/compiler/internalAliasEnumInsideTopLevelModuleWithExport.ts_0_199
//@module: amd // @declaration: true export module a { export enum weekend { Friday, Saturday, Sunday } } export import b = a.weekend; export var bVal: b = b.Sunday;
{ "end_byte": 199, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/internalAliasEnumInsideTopLevelModuleWithExport.ts" }
TypeScript/tests/cases/compiler/mappedTypeWithNameClauseAppliedToArrayType.ts_0_229
// @strict: true // @noEmit: true type Mappy<T extends unknown[]> = { [K in keyof T as K]: T[K] }; type NotArray = Mappy<number[]>; declare function doArrayStuff(x: unknown[]): void; declare const x: NotArray; doArrayStuff(x);
{ "end_byte": 229, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mappedTypeWithNameClauseAppliedToArrayType.ts" }
TypeScript/tests/cases/compiler/nestedIfStatement.ts_0_67
if (0) { } else if (1) { } else if (2) { } else if (3) { } else { }
{ "end_byte": 67, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nestedIfStatement.ts" }
TypeScript/tests/cases/compiler/declarationEmitTypeofThisInClass.ts_0_194
// @declaration: true // @strict: true class Foo { public foo!: string public bar!: typeof this.foo //Public property 'bar' of exported class has or is using private name 'this'.(4031) }
{ "end_byte": 194, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitTypeofThisInClass.ts" }
TypeScript/tests/cases/compiler/ramdaToolsNoInfinite.ts_1_3491
// All the following types are explained here: // https://medium.freecodecamp.org/typescript-curry-ramda-types-f747e99744ab // https://github.com/pirix-gh/medium/blob/master/types-curry-ramda/src/index.ts declare namespace Tools { type Head<T extends any[]> = T extends [any, ...any[]] ? T[0] ...
{ "end_byte": 3491, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ramdaToolsNoInfinite.ts" }
TypeScript/tests/cases/compiler/interfaceWithMultipleDeclarations.ts_0_677
interface I1<V> { } interface I1<S> { // Name mismatch } interface I1<T, U extends T> { // Length mismatch } interface I1<V extends string> { // constraint present } interface I1<V, X extends V> { // Length mismatch } interface I1 { // Length mismatch } interface I2<T extends string> { } interface I2<T extends () => s...
{ "end_byte": 677, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/interfaceWithMultipleDeclarations.ts" }
TypeScript/tests/cases/compiler/commentOnArrayElement6.ts_3_37
nst array = [1, /* comment */];
{ "end_byte": 37, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentOnArrayElement6.ts" }
TypeScript/tests/cases/compiler/augmentExportEquals2.ts_0_370
// @module: amd // @filename: file1.ts function foo() {} export = foo; // @filename: file2.ts import x = require("./file1"); // should error since './file1' does not have namespace meaning declare module "./file1" { interface A { a } } // @filename: file3.ts // @filename: file3.ts import x = require("./file1")...
{ "end_byte": 370, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/augmentExportEquals2.ts" }
TypeScript/tests/cases/compiler/spreadObjectWithIndexDoesNotAddUndefinedToLocalIndex.ts_0_120
// @strict: true declare const m: { [k: string]: string }; const x: { [k: string]: string } = { ...m, ["a" + "b"]: "" };
{ "end_byte": 120, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/spreadObjectWithIndexDoesNotAddUndefinedToLocalIndex.ts" }
TypeScript/tests/cases/compiler/strictModeReservedWordInModuleDeclaration.ts_3_109
se strict" module public { } module private { } module public.whatever { } module private.public.foo { }
{ "end_byte": 109, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/strictModeReservedWordInModuleDeclaration.ts" }
TypeScript/tests/cases/compiler/typePredicateInherit.ts_0_653
interface A { method1(): this is { a: 1 } method2(): boolean; method3(): this is { a: 1 }; } class B implements A { method1() { } // should error method2() { } // should error method3() { // should error return true } } class C { method1(): this is { a: 1 } { return...
{ "end_byte": 653, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typePredicateInherit.ts" }
TypeScript/tests/cases/compiler/constructorOverloads9.ts_0_116
// @target: esnext export class C { a; constructor(); constructor(x = '') { this.a = x; } }
{ "end_byte": 116, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constructorOverloads9.ts" }
TypeScript/tests/cases/compiler/nodeColonModuleResolution2.ts_0_1045
// @moduleResolution: node // @traceResolution: true // @filename: /a/b/tsconfig.json { "compilerOptions": { "paths": { "fake:thing": ["./node_modules/fake/thing"] } } } // @filename: /a/b/node_modules/fake/thing/index.d.ts export namespace constants { const NODE_PERFORMANCE_GC...
{ "end_byte": 1045, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nodeColonModuleResolution2.ts" }
TypeScript/tests/cases/compiler/mapOnTupleTypes01.ts_0_1055
// @declaration: true // @noImplicitAny: true // @strictNullChecks: true export let mapOnLooseArrayLiteral = [1, 2, 3, 4].map(n => n * n); // Length 1 let numTuple: [number] = [1]; export let a = numTuple.map(x => x * x); // Length 2 let numNum: [number, number] = [ 100, 100]; let strStr: [string, string] =...
{ "end_byte": 1055, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mapOnTupleTypes01.ts" }
TypeScript/tests/cases/compiler/typeResolution.ts_0_4466
//@module: amd // @sourcemap: true export module TopLevelModule1 { export module SubModule1 { export module SubSubModule1 { export class ClassA { public AisIn1_1_1() { // Try all qualified names of this type var a1: ClassA; a1.AisIn1_1_1();...
{ "end_byte": 4466, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeResolution.ts" }
TypeScript/tests/cases/compiler/reexportWrittenCorrectlyInDeclaration.ts_0_399
// https://github.com/Microsoft/TypeScript/issues/8612 // @declaration: true // @filename: ThingA.ts export class ThingA { } // @filename: ThingB.ts export class ThingB { } // @filename: Things.ts export {ThingA} from "./ThingA"; export {ThingB} from "./ThingB"; // @filename: Test.ts import * as things from "./Thin...
{ "end_byte": 399, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reexportWrittenCorrectlyInDeclaration.ts" }
TypeScript/tests/cases/compiler/exportEqualsUmd.ts_0_45
// @module: umd export = { ["hi"]: "there" };
{ "end_byte": 45, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportEqualsUmd.ts" }
TypeScript/tests/cases/compiler/namedFunctionExpressionAssignedToClassProperty.ts_0_135
class Foo{ a = function bar(){ }; // this shouldn't crash the compiler... constructor(){ } }
{ "end_byte": 135, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/namedFunctionExpressionAssignedToClassProperty.ts" }
TypeScript/tests/cases/compiler/es5ExportDefaultClassDeclaration2.ts_0_102
// @target: es5 // @module: commonjs // @declaration: true export default class { method() { } }
{ "end_byte": 102, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es5ExportDefaultClassDeclaration2.ts" }
TypeScript/tests/cases/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions.ts_0_104
const regex = /\p{ascii}\p{Sc=Unknown}\p{sc=unknownX}\p{Script_Declensions=Inherited}\p{scx=inherit}/u;
{ "end_byte": 104, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions.ts" }
TypeScript/tests/cases/compiler/staticVisibility2.ts_0_145
// @noImplicitAny: true class Square { static sideLength; constructor(sideLength: number) { this.sideLength = sideLength; } }
{ "end_byte": 145, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/staticVisibility2.ts" }
TypeScript/tests/cases/compiler/objectLiteralIndexerNoImplicitAny.ts_3_91
@noImplicitAny: true interface I { [s: string]: any; } var x: I = { p: null }
{ "end_byte": 91, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectLiteralIndexerNoImplicitAny.ts" }
TypeScript/tests/cases/compiler/declarationEmitReexportedSymlinkReference2.ts_0_1742
// @filename: monorepo/pkg1/dist/index.d.ts export * from './types'; // @filename: monorepo/pkg1/dist/types.d.ts export declare type A = { id: string; }; export declare type B = { id: number; }; export declare type IdType = A | B; export declare class MetadataAccessor<T, D extends IdType = IdType> { readonl...
{ "end_byte": 1742, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitReexportedSymlinkReference2.ts" }
TypeScript/tests/cases/compiler/recursiveMods.ts_0_304
// @allowUnreachableCode: true // @module: commonjs export module Foo { export class C {} } export module Foo { function Bar() : C { if (true) { return Bar();} return new C(); } function Baz() : C { var c = Baz(); return Bar(); } function Gar() { var c : C = Baz(); return; } }
{ "end_byte": 304, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveMods.ts" }
TypeScript/tests/cases/compiler/commentOnIfStatement1.ts_0_48
// @removeComments: false // Test if (true) { }
{ "end_byte": 48, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentOnIfStatement1.ts" }
TypeScript/tests/cases/compiler/missingTypeArguments3.ts_0_1409
declare module linq { interface Enumerable<T> { OrderByDescending(keySelector?: string): OrderedEnumerable<T>; GroupBy<TKey>(keySelector: (element: T) => TKey): Enumerable<Grouping<TKey, T>>; GroupBy<TKey, TElement>(keySelector: (element: T) => TKey, elementSelector: (element: T) => TElemen...
{ "end_byte": 1409, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/missingTypeArguments3.ts" }
TypeScript/tests/cases/compiler/stringLiteralPropertyNameWithLineContinuation1.ts_0_42
var x = {'text\ ':'hello'} x.text = "bar"
{ "end_byte": 42, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/stringLiteralPropertyNameWithLineContinuation1.ts" }
TypeScript/tests/cases/compiler/typeParametersShouldNotBeEqual2.ts_0_250
function ff<T extends Date, U extends Date, V>(x: T, y: U, z: V) { var zz: Object; x = x; // Ok x = y; // Ok x = z; // Error z = x; // Error y = z; // Error z = y; // Error x = zz; // Error zz = x; // Ok }
{ "end_byte": 250, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeParametersShouldNotBeEqual2.ts" }
TypeScript/tests/cases/compiler/checkSuperCallBeforeThisAccess.ts_0_1944
// @strict: true // @target: esnext // @useDefineForClassFields: false class A { x = 1; } class C1 extends A { constructor(n: number) { let a1 = this; // Error let a2 = this.x; // Error let a3 = super.x; // Error let a4 = () => this; let a5 = () => this.x; le...
{ "end_byte": 1944, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/checkSuperCallBeforeThisAccess.ts" }
TypeScript/tests/cases/compiler/duplicateConstructorOverloadSignature.ts_0_95
class C { constructor(x: number); constructor(x: number); constructor(x: any) { } }
{ "end_byte": 95, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateConstructorOverloadSignature.ts" }
TypeScript/tests/cases/compiler/incompleteDottedExpressionAtEOF.ts_0_62
// used to leak __missing into error message var p2 = window.
{ "end_byte": 62, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/incompleteDottedExpressionAtEOF.ts" }
TypeScript/tests/cases/compiler/moduleAndInterfaceWithSameName.ts_0_435
module Foo1 { export module Bar { export var x = 42; } export interface Bar { y: string; } } module Foo2 { module Bar { export var x = 42; } export interface Bar { y: string; } } var z2 = Foo2.Bar.y; // Error for using interface name as a value. modu...
{ "end_byte": 435, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleAndInterfaceWithSameName.ts" }
TypeScript/tests/cases/compiler/isolatedDeclarationErrorsExpressions.ts_0_4450
// @declaration: true // @isolatedDeclarations: true // @declarationMap: false // @strict: true // @target: ESNext declare function time(): bigint export const numberConst = 1; export const numberConstBad1 = 1 + 1; export const numberConstBad2 = Math.random(); export const numberConstBad3 = numberConst; export const ...
{ "end_byte": 4450, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/isolatedDeclarationErrorsExpressions.ts" }
TypeScript/tests/cases/compiler/noObjectKeysToKeyofT.ts_0_272
// @target: es2016 // Do not change Object.keys to return keyof T. // The current return type (string[]) is intentional. Object.keys({ a: 0 }).push("b"); // See also // https://stackoverflow.com/questions/55012174/why-doesnt-object-keys-return-a-keyof-type-in-typescript
{ "end_byte": 272, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noObjectKeysToKeyofT.ts" }
TypeScript/tests/cases/compiler/indexSignatureWithAccessibilityModifier.ts_0_91
interface I { [public x: string]: string; } class C { [public x: string]: string }
{ "end_byte": 91, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/indexSignatureWithAccessibilityModifier.ts" }
TypeScript/tests/cases/compiler/contextualTyping9.ts_0_54
var foo:{id:number;}[] = [{id:1}, {id:2, name:"foo"}];
{ "end_byte": 54, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTyping9.ts" }
TypeScript/tests/cases/compiler/nonMergedDeclarationsAndOverloads.ts_0_120
class A { m1: string; f() {} m1 (a: string): void; m1 (a: number): void; m1 (a: any): void { } }
{ "end_byte": 120, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nonMergedDeclarationsAndOverloads.ts" }
TypeScript/tests/cases/compiler/jsFileCompilationDecoratorSyntax.ts_0_109
// @allowJs: true // @noEmit: true // @experimentalDecorators: true // @filename: a.js @internal class C { }
{ "end_byte": 109, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationDecoratorSyntax.ts" }
TypeScript/tests/cases/compiler/fallFromLastCase1.ts_0_368
// @noFallthroughCasesInSwitch: true declare function use(a: string); function foo1(a: number) { switch (a) { case 1: use("1"); break; case 2: use("2"); } } function foo2(a: number) { switch (a) { case 1: use("1"); break...
{ "end_byte": 368, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/fallFromLastCase1.ts" }
TypeScript/tests/cases/compiler/jsdocPropertyTagInvalid.ts_0_239
// @allowJs: true // @checkJs: true // @noEmit: true // @Filename: /a.js /** * @typedef MyType * @property {sting} [x] */ /** @param {MyType} p */ export function f(p) { } // @Filename: /b.js import { f } from "./a.js" f({ x: 42 })
{ "end_byte": 239, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsdocPropertyTagInvalid.ts" }
TypeScript/tests/cases/compiler/moduleResolutionWithSymlinks_referenceTypes.ts_0_1663
// Symlinks are always resolved for type reference directives. // NOTE: This test would still compile without errors even if they were not, // because `processTypeReferenceDirective` also checks for textual equivalence of file contents. // But the `moduleResolutionWithSymlinks_referenceTypes.trace.json` shows the diffe...
{ "end_byte": 1663, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolutionWithSymlinks_referenceTypes.ts" }
TypeScript/tests/cases/compiler/augmentedClassWithPrototypePropertyOnModule.ts_0_146
declare module m { var f; var prototype; // This should be error since prototype would be static property on class m } declare class m { }
{ "end_byte": 146, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/augmentedClassWithPrototypePropertyOnModule.ts" }
TypeScript/tests/cases/compiler/genericTypeWithMultipleBases1.ts_0_251
//@module: commonjs export interface I1 { m1: () => void; } export interface I2 { m2: () => void; } export interface I3<T> extends I1, I2 { //export interface I3<T> extends I2, I1 { p1: T; } var x: I3<number>; x.p1; x.m1(); x.m2();
{ "end_byte": 251, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericTypeWithMultipleBases1.ts" }
TypeScript/tests/cases/compiler/primitiveConstraints2.ts_0_182
class C<T> { public bar2<U extends T>(x: T, y: U): T { return null; } } var x = new C<number>(); x.bar2(2, ""); // should error x.bar2<string>(2, ""); // should error
{ "end_byte": 182, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/primitiveConstraints2.ts" }
TypeScript/tests/cases/compiler/duplicateVarAndImport.ts_0_79
// no error since module is not instantiated var a; module M { } import a = M;
{ "end_byte": 79, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateVarAndImport.ts" }
TypeScript/tests/cases/compiler/undefinedAssignableToGenericMappedIntersection.ts_0_193
// @strict: true type Errors<T> = { [P in keyof T]: string | undefined } & {all: string | undefined}; function foo<T>() { let obj!: Errors<T> let x!: keyof T; obj[x] = undefined; }
{ "end_byte": 193, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/undefinedAssignableToGenericMappedIntersection.ts" }
TypeScript/tests/cases/compiler/noUnusedLocals_potentialPredicateUnusedParam.ts_0_170
// @strict: true // @noEmit: true // @noUnusedLocals: true // @noUnusedParameters: true function potentialPredicateUnusedParam(a: unknown) { return !!Math.random(); }
{ "end_byte": 170, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noUnusedLocals_potentialPredicateUnusedParam.ts" }
TypeScript/tests/cases/compiler/statics.ts_0_656
module M { export class C { x: number; constructor(public c1: number, public c2: number, c3: number) { this.x = C.y+this.c1+this.c2+c3; this.g = (v:number) => C.f(this.x+C.y+v+this.c1+this.c2+C.pub); } static priv=2; static pub=3; static y=C.p...
{ "end_byte": 656, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/statics.ts" }
TypeScript/tests/cases/compiler/assignmentCompatability28.ts_0_337
module __test1__ { export interface interfaceWithPublicAndOptional<T,U> { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional<number,string> = { one: 1 };; export var __val__obj4 = obj4; } module __test2__ { export var aa:{one:boolean;};; export var __val__aa = aa; } __test2__.__val__aa = __te...
{ "end_byte": 337, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatability28.ts" }
TypeScript/tests/cases/compiler/moduleResolutionWithSuffixes_threeLastIsBlank2.ts_0_441
// moduleSuffixes has three entries, and the last one is blank. Module resolution should match on the second suffix. // @filename: /tsconfig.json { "compilerOptions": { "moduleResolution": "node", "traceResolution": true, "moduleSuffixes": ["-ios", "__native", ""] } } // @filename: /index.ts import { native }...
{ "end_byte": 441, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolutionWithSuffixes_threeLastIsBlank2.ts" }
TypeScript/tests/cases/compiler/recursiveTypeParameterConstraintReferenceLacksTypeArgs.ts_0_24
class A<T extends A> { }
{ "end_byte": 24, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveTypeParameterConstraintReferenceLacksTypeArgs.ts" }
TypeScript/tests/cases/compiler/nodeNextImportModeImplicitIndexResolution2.ts_0_1150
// @module: nodenext // @Filename: /node_modules/@types/dedent/package.json { "name": "@types/dedent", "version": "1.0.0", "main": "" } // @Filename: /node_modules/@types/dedent2/package.json { "name": "@types/dedent2", "version": "1.0.0", "main": "asdfasdfasdf" } // @Filename: /node_modules/@types/dedent3/package.j...
{ "end_byte": 1150, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nodeNextImportModeImplicitIndexResolution2.ts" }
TypeScript/tests/cases/compiler/multipleBaseInterfaesWithIncompatibleProperties.ts_0_74
interface A<T> { x: T } interface C extends A<string>, A<number> { }
{ "end_byte": 74, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/multipleBaseInterfaesWithIncompatibleProperties.ts" }
TypeScript/tests/cases/compiler/classImplementsClass5.ts_0_204
class A { private x = 1; foo(): number { return 1; } } class C implements A { private x = 1; foo() { return 1; } } class C2 extends A {} var c: C; var c2: C2; c = c2; c2 = c;
{ "end_byte": 204, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classImplementsClass5.ts" }
TypeScript/tests/cases/compiler/transformArrowInBlockScopedLoopVarInitializer.ts_0_184
// @target: es5 // https://github.com/Microsoft/TypeScript/issues/11236 while (true) { let local = null; var a = () => local; // <-- Lambda should be converted to function() }
{ "end_byte": 184, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/transformArrowInBlockScopedLoopVarInitializer.ts" }
TypeScript/tests/cases/compiler/typeGuardNarrowsIndexedAccessOfKnownProperty6.ts_0_411
// @strict: true declare const aIndex: "key"; const a: { key?: { x?: number } } = {}; if (a[aIndex] && a[aIndex].x) { a[aIndex].x // number } declare const bIndex: "key"; const b: { key: { x?: number } } = { key: {} }; if (b[bIndex].x) { b[bIndex].x // number } declare const cIndex: 1; interface Foo { x:...
{ "end_byte": 411, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeGuardNarrowsIndexedAccessOfKnownProperty6.ts" }
TypeScript/tests/cases/compiler/emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts_0_1053
// This should behave the same as emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts // Begin types from Lodash. interface Dictionary<T> { [index: string]: T; } interface NumericDictionary<T> { [index: number]: T; } type ObjectIterator<TObject, TResult> = ( value: TObject[keyof TObject], key: string, ...
{ "end_byte": 1053, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts" }
TypeScript/tests/cases/compiler/arithAssignTyping.ts_0_221
class f { } f += ''; // error f += 1; // error f -= 1; // error f *= 1; // error f /= 1; // error f %= 1; // error f &= 1; // error f |= 1; // error f <<= 1; // error f >>= 1; // error f >>>= 1; // error f ^= 1; // error
{ "end_byte": 221, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arithAssignTyping.ts" }
TypeScript/tests/cases/compiler/typeArgInference2.ts_0_436
interface Item { name: string; } declare function foo<T extends Item>(x?: T, y?: T): T; var z1 = foo(null); // any var z2 = foo(); // Item var z3 = foo({ name: null }); // { name: any } var z4 = foo({ name: "abc" }); // { name: string } var z5 = foo({ name: "...
{ "end_byte": 436, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeArgInference2.ts" }
TypeScript/tests/cases/compiler/exportAssignmentWithDeclareAndExportModifiers.ts_3_57
@module: commonjs var x; export declare export = x;
{ "end_byte": 57, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportAssignmentWithDeclareAndExportModifiers.ts" }
TypeScript/tests/cases/compiler/multipleInheritance.ts_0_511
class B1 { public x; } class B2 { public x; } class C extends B1, B2 { // duplicate member } class D1 extends B1 { } class D2 extends B2 { } class E extends D1, D2 { // nope, duplicate member } class N { public y:number; } class ND extends N { // any is assignable to number public y; } class Goo...
{ "end_byte": 511, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/multipleInheritance.ts" }
TypeScript/tests/cases/compiler/genericTypeAssertions2.ts_0_347
class A<T> { foo(x: T) { } } class B<T> extends A<T> { bar(): T { return null; } } var foo = new A<number>(); var r: A<string> = <B<string>>new B(); var r2: A<number> = <B<string>>new B(); // error var r3: B<number> = <A<number>>new B(); // error var r4: A<number> = <A<number>>new A(); var r5: A<number...
{ "end_byte": 347, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericTypeAssertions2.ts" }
TypeScript/tests/cases/compiler/externalModuleWithoutCompilerFlag1.ts_1_114
// Not on line 0 because we want to verify the error is placed in the appropriate location. export module M { }
{ "end_byte": 114, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/externalModuleWithoutCompilerFlag1.ts" }
TypeScript/tests/cases/compiler/promiseIdentityWithAny2.ts_0_672
export interface IPromise<T, V> { then<U, W>(callback: (x: T) => IPromise<U, W>): IPromise<U, W>; } interface Promise<T, V> { then(callback: (x: T) => Promise<any, any>): Promise<any, any>; } // Error because type parameter arity doesn't match var x: IPromise<string, number>; var x: Promise<string, boolean>; ...
{ "end_byte": 672, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/promiseIdentityWithAny2.ts" }
TypeScript/tests/cases/compiler/covariance1.ts_0_262
module M { interface X { m1:number; } export class XX implements X { constructor(public m1:number) { } } interface Y { x:X; } export function f(y:Y) { } var a:X; f({x:a}); // ok var b:XX; f({x:b}); // ok covariant subtype }
{ "end_byte": 262, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/covariance1.ts" }
TypeScript/tests/cases/compiler/functionExpressionWithResolutionOfTypeNamedArguments01.ts_3_78
terface arguments { } var x = function f() { <arguments>arguments; }
{ "end_byte": 78, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionExpressionWithResolutionOfTypeNamedArguments01.ts" }
TypeScript/tests/cases/compiler/transformNestedGeneratorsWithTry.ts_0_587
// @target: ES5 // @lib: es5,es6 // @filename: main.ts // https://github.com/Microsoft/TypeScript/issues/11177 import * as Bluebird from 'bluebird'; async function a(): Bluebird<void> { try { const b = async function b(): Bluebird<void> { try { await Bluebird.resolve(); // -- remove this and it comp...
{ "end_byte": 587, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/transformNestedGeneratorsWithTry.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationDestructuringForObjectBindingPattern2.ts_0_3578
// @lib: es5 // @sourcemap: true declare var console: { log(msg: any): void; } interface Robot { name: string; skill: string; } interface MultiRobot { name: string; skills: { primary: string; secondary: string; }; } let robot: Robot = { name: "mower", skill: "mowing" }; let mul...
{ "end_byte": 3578, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationDestructuringForObjectBindingPattern2.ts" }
TypeScript/tests/cases/compiler/inferredFunctionReturnTypeIsEmptyType.ts_0_131
// @allowUnreachableCode: true function foo() { if (true) { return 42; } else { return "42"; } };
{ "end_byte": 131, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inferredFunctionReturnTypeIsEmptyType.ts" }
TypeScript/tests/cases/compiler/breakTarget1.ts_0_23
target: break target;
{ "end_byte": 23, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/breakTarget1.ts" }
TypeScript/tests/cases/compiler/out-flag3.ts_0_209
// @target: ES5 // @sourcemap: true // @declaration: true // @module: commonjs // @outFile: c.js // @outFile: d.js // --out and --outFile error // @Filename: a.ts class A { } // @Filename: b.ts class B { }
{ "end_byte": 209, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/out-flag3.ts" }
TypeScript/tests/cases/compiler/declarationEmitMappedTypeDistributivityPreservesConstraints.ts_0_428
// @declaration: true // @filename: types.ts type Fns = Record<string, (...params: unknown[]) => unknown> type Map<T extends Fns> = { [K in keyof T]: T[K]; }; type AllArg<T extends Fns> = { [K in keyof T]: Parameters<T[K]> }; function fn<T extends { x: Map<T['x']> }>(sliceIndex: T): AllArg<T['x']> { return null!...
{ "end_byte": 428, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitMappedTypeDistributivityPreservesConstraints.ts" }
TypeScript/tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNode.ts_3_243
@removeComments: true class C { /*! remove pinned comment anywhere else */ public foo(x: string, y: any) public foo(x: string, y: number) { } } var x = 10; /*! remove pinned comment anywhere else */ declare var OData: any;
{ "end_byte": 243, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNode.ts" }
TypeScript/tests/cases/compiler/unionTypeWithRecursiveSubtypeReduction1.ts_0_247
class Module { public members: Class[]; } class Namespace { public members: (Class | Property)[]; } class Class { public parent: Namespace; } class Property { public parent: Module | Class; } var t: Class | Property; t.parent;
{ "end_byte": 247, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unionTypeWithRecursiveSubtypeReduction1.ts" }
TypeScript/tests/cases/compiler/infinitelyExpandingTypes1.ts_0_318
interface List<T> { data: T; next: List<T>; owner: List<List<T>>; } interface MyList<T> { data: T; next: MyList<T>; owner: MyList<MyList<T>>; } var l: List<number>; var m: MyList<number>; l == m; // should error var l2: List<string>; l == l2; // should error; l == l; // should not error
{ "end_byte": 318, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/infinitelyExpandingTypes1.ts" }
TypeScript/tests/cases/compiler/unicodeEscapesInNames01.ts_0_2130
// @target: es5,es2015,esnext // @sourcemap: true // @filename: identifierVariableWithEscape1.ts export let \u0078 = 10; x++; // @filename: identifierVariableWithEscape2.ts export let x\u0078 = 10; xx++; // @filename: identifierVariableWithExtendedEscape1.ts export let \u{78} = 10; x++; // @filename: identifierVari...
{ "end_byte": 2130, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unicodeEscapesInNames01.ts" }
TypeScript/tests/cases/compiler/exportEqualsProperty.ts_0_757
// This test is just like exportDefaultProperty, but with `export =`. // @Filename: declarations.d.ts declare namespace foo.bar { export type X = number; export const X: number; } declare module "foobar" { export = foo.bar; } declare module "foobarx" { export = foo.bar.X; } // @Filename: a.ts namesp...
{ "end_byte": 757, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportEqualsProperty.ts" }
TypeScript/tests/cases/compiler/letInConstDeclarations_ES6.ts_0_130
// @target: es6 // All use of let in const declaration should be an error const x = 50, let = 5; { const x = 10, let = 20; }
{ "end_byte": 130, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/letInConstDeclarations_ES6.ts" }
TypeScript/tests/cases/compiler/contextuallyTypedParametersWithInitializers2.ts_0_472
// @strict: true // @noEmit: true declare function test1< TContext, TMethods extends Record<string, (ctx: TContext, ...args: never[]) => unknown>, >(context: TContext, methods: TMethods): void; test1( { count: 0, }, { checkLimit: (ctx, max = 500) => {}, hasAccess: (ctx, user: { name: string }) =...
{ "end_byte": 472, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextuallyTypedParametersWithInitializers2.ts" }
TypeScript/tests/cases/compiler/inheritSameNamePrivatePropertiesFromDifferentOrigins.ts_0_126
class C { private x: number; } class C2 { private x: number; } interface A extends C, C2 { // error y: string; }
{ "end_byte": 126, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inheritSameNamePrivatePropertiesFromDifferentOrigins.ts" }
TypeScript/tests/cases/compiler/renamingDestructuredPropertyInFunctionType2.ts_0_1011
// @filename: a.d.ts type O = { a: string; b: number; c: number; }; type F1 = (arg: number) => any; type F2 = ({ a: string }: O) => any; type F3 = ({ a: string, b, c }: O) => any; type F4 = ({ a: string }: O) => any; type F5 = ({ a: string, b, c }: O) => any; type F6 = ({ a: string }) => typeof string; type F7 = ...
{ "end_byte": 1011, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/renamingDestructuredPropertyInFunctionType2.ts" }
TypeScript/tests/cases/compiler/blockScopedSameNameFunctionDeclarationES6.ts_0_325
// @target: ES6 function foo(a: number) { if (a === 10) { function foo() { } // duplicate foo(); foo(10); // not ok } else { function foo() { } // duplicate foo(); foo(10);// not ok } foo(10); // not ok foo(); } foo(10); foo(); // not ok - needs n...
{ "end_byte": 325, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/blockScopedSameNameFunctionDeclarationES6.ts" }
TypeScript/tests/cases/compiler/parseJsxExtends2.ts_0_150
// @jsx: react // @filename: index.tsx declare const React: any; export function Foo() { // Error: T is not declared. return <T extends/> }
{ "end_byte": 150, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parseJsxExtends2.ts" }
TypeScript/tests/cases/compiler/ParameterList5.ts_0_33
function A(): (public B) => C { }
{ "end_byte": 33, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ParameterList5.ts" }
TypeScript/tests/cases/compiler/letInLetDeclarations_ES5.ts_0_126
// @target: es5 // All use of let in const declaration should be an error let x = 50, let = 5; { let x = 10, let = 20; }
{ "end_byte": 126, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/letInLetDeclarations_ES5.ts" }
TypeScript/tests/cases/compiler/internalAliasFunctionInsideTopLevelModuleWithoutExport.ts_0_189
//@module: commonjs // @declaration: true export module a { export function foo(x: number) { return x; } } import b = a.foo; export var bVal = b(10); export var bVal2 = b;
{ "end_byte": 189, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/internalAliasFunctionInsideTopLevelModuleWithoutExport.ts" }
TypeScript/tests/cases/compiler/contextualTyping12.ts_0_71
class foo { public bar:{id:number;}[] = [{id:1}, {id:2, name:"foo"}]; }
{ "end_byte": 71, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTyping12.ts" }
TypeScript/tests/cases/compiler/compilerOptionsOutAndNoEmit.ts_0_69
// @outFile: outDir // @noEmit: true // @fileName: a.ts class c { }
{ "end_byte": 69, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/compilerOptionsOutAndNoEmit.ts" }