_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/divergentAccessorsTypes3.ts_0_779
// @target: es5 class One { get prop1(): string { return ""; } set prop1(s: string | number) { } get prop2(): string { return ""; } set prop2(s: string | number) { } prop3: number; get prop4(): string { return ""; } set prop4(s: string | number) { } } class Two { get prop1(): string { return ""; } ...
{ "end_byte": 779, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/divergentAccessorsTypes3.ts" }
TypeScript/tests/cases/compiler/specializationOfExportedClass.ts_0_66
module M { export class C<T> { } } var x = new M.C<string>();
{ "end_byte": 66, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/specializationOfExportedClass.ts" }
TypeScript/tests/cases/compiler/nestedExcessPropertyChecking.ts_0_1723
// @strict: true type A1 = { x: { a?: string } }; type B1 = { x: { b?: string } }; type C1 = { x: { c: string } }; const ab1: A1 & B1 = {} as C1; // Error type A2 = { a?: string }; type B2 = { b?: string }; type C2 = { c: string }; const ab2: A2 & B2 = {} as C2; // Error enum E { A = "A" } let x: { nope?: any...
{ "end_byte": 1723, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nestedExcessPropertyChecking.ts" }
TypeScript/tests/cases/compiler/moduleResolutionWithSuffixes_one_jsModule.ts_0_602
// moduleSuffixes has one entry and there's a matching file. module name explicitly includes JS file extension. // @fullEmitPaths: true // @filename: /tsconfig.json { "compilerOptions": { "allowJs": true, "checkJs": false, "outDir": "bin", "moduleResolution": "node", "traceResolution": true, "moduleSuffixe...
{ "end_byte": 602, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolutionWithSuffixes_one_jsModule.ts" }
TypeScript/tests/cases/compiler/constDeclarations2.ts_0_180
// @target: ES6 // @declaration: true // No error module M { export const c1 = false; export const c2: number = 23; export const c3 = 0, c4 :string = "", c5 = null; }
{ "end_byte": 180, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constDeclarations2.ts" }
TypeScript/tests/cases/compiler/jsFileCompilationBindErrors.ts_0_378
// @allowJs: true // @checkJs: true // @noEmit: true // @allowUnreachableCode: false // @filename: a.js let C = "sss"; let C = 0; // Error: Cannot redeclare block-scoped variable 'C'. function f() { return; return; // Error: Unreachable code detected. } function b() { "use strict"; var arguments = ...
{ "end_byte": 378, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationBindErrors.ts" }
TypeScript/tests/cases/compiler/declFileEmitDeclarationOnlyError2.ts_0_90
// @noEmit: true // @emitDeclarationOnly: true // @filename: hello.ts var hello = "yo!";
{ "end_byte": 90, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileEmitDeclarationOnlyError2.ts" }
TypeScript/tests/cases/compiler/objectCreate.ts_0_574
// @strictNullChecks: true declare var union: null | { a: number, b: string }; var n = Object.create(null); // object var t = Object.create({ a: 1, b: "" }); // {a: number, b: string } var u = Object.create(union); // object | {a: number, b: string } var e = Object.create({}); //...
{ "end_byte": 574, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectCreate.ts" }
TypeScript/tests/cases/compiler/switchFallThroughs.ts_0_257
function R1(index: number) { switch (index) { case 0: case 1: case 2: var a = 'a'; return a; case 3: case 4: { return 'b'; } case 5: default: return 'c'; } }
{ "end_byte": 257, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/switchFallThroughs.ts" }
TypeScript/tests/cases/compiler/tsxDefaultImports.ts_0_184
// @Filename: a.ts enum SomeEnum { one, } export default class SomeClass { public static E = SomeEnum; } // @Filename: b.ts import {default as Def} from "./a" let a = Def.E.one;
{ "end_byte": 184, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/tsxDefaultImports.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationDecorators.ts_0_1614
// @sourcemap: true // @target: es5 // @experimentaldecorators: true declare function ClassDecorator1(target: Function): void; declare function ClassDecorator2(x: number): (target: Function) => void; declare function PropertyDecorator1(target: Object, key: string | symbol, descriptor?: PropertyDescriptor): void; declar...
{ "end_byte": 1614, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationDecorators.ts" }
TypeScript/tests/cases/compiler/importDeclarationUsedAsTypeQuery.ts_0_346
// @module: commonjs // @declaration: true // @Filename: importDeclarationUsedAsTypeQuery_require.ts export class B { id: number; } // @Filename: importDeclarationUsedAsTypeQuery_1.ts ///<reference path='importDeclarationUsedAsTypeQuery_require.ts'/> import a = require('./importDeclarationUsedAsTypeQuery_require')...
{ "end_byte": 346, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importDeclarationUsedAsTypeQuery.ts" }
TypeScript/tests/cases/compiler/emitDecoratorMetadata_isolatedModules.ts_0_811
// @experimentalDecorators: true // @emitDecoratorMetadata: true // @isolatedModules: true // @module: commonjs,esnext // @Filename: type1.ts interface T1 {} export type { T1 } // @Filename: type2.ts export interface T2 {} // @Filename: class3.ts export class C3 {} // @Filename: index.ts import { T1 } from "./type1...
{ "end_byte": 811, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emitDecoratorMetadata_isolatedModules.ts" }
TypeScript/tests/cases/compiler/indexWithoutParamType2.ts_0_84
class C { // Used to be indexer, now it is a computed property [x]: string }
{ "end_byte": 84, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/indexWithoutParamType2.ts" }
TypeScript/tests/cases/compiler/checkSuperCallBeforeThisAccessing3.ts_3_298
ass Based { } class Derived extends Based { public x: number; constructor() { class innver { public y: boolean; constructor() { this.y = true; } } super(); this.x = 10; var that = this; } }
{ "end_byte": 298, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/checkSuperCallBeforeThisAccessing3.ts" }
TypeScript/tests/cases/compiler/declarationEmitLocalClassHasRequiredDeclare.ts_0_176
// @declaration: true export declare namespace A { namespace X { } } class X { } export class A { static X = X; } export declare namespace Y { } export class Y { }
{ "end_byte": 176, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitLocalClassHasRequiredDeclare.ts" }
TypeScript/tests/cases/compiler/multipleInferenceContexts.ts_0_515
// @strict: true type ConstructorOptions<Data> = & ComponentOptionsProperties<Data> & ThisType<Instance<Data>>; interface ComponentOptionsProperties<Data> { data: Data; render(): unknown; } interface Instance<Data> { get<K extends keyof Data>(name: K): unknown; } declare var Moon: { <Data>(o...
{ "end_byte": 515, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/multipleInferenceContexts.ts" }
TypeScript/tests/cases/compiler/genericIndexedAccessMethodIntersectionCanBeAccessed.ts_0_462
// @strict: true type ExtendedService<T> = { [K in keyof T]: T[K] & { __$daemonMode?: string; __$action?: string; }; }; type Service<T> = { [K in keyof T]: T[K] & {id?: string}; }; export const createService = <T>( ServiceCtr: ExtendedService<T> & Service<T> ) => { Object.keys(Serv...
{ "end_byte": 462, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericIndexedAccessMethodIntersectionCanBeAccessed.ts" }
TypeScript/tests/cases/compiler/unusedTypeParameters9.ts_0_362
//@noUnusedLocals:true //@noUnusedParameters:true // clas + interface class C1<T> { } interface C1<T> { a: T; } // interface + class class C2<T> { a: T; } interface C2<T> { } // interfaces interface C3<T> { a(c: (p: T) => void): void; } interface C3<T> { b: string; } interface C3<T> { c: number; } interface C3<T> { ...
{ "end_byte": 362, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedTypeParameters9.ts" }
TypeScript/tests/cases/compiler/assignmentCompatability6.ts_0_439
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 interface interfaceWithOptional<T> { one?: T; }; var obj3: i...
{ "end_byte": 439, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatability6.ts" }
TypeScript/tests/cases/compiler/doNotWidenAtObjectLiteralPropertyAssignment.ts_0_283
interface ITestEventInterval { begin: number; } interface IIntervalTreeNode { interval: ITestEventInterval; children?: IIntervalTreeNode[]; } var test: IIntervalTreeNode[] = [{ interval: { begin: 0 }, children: null }]; // was error here because best common type is {}
{ "end_byte": 283, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/doNotWidenAtObjectLiteralPropertyAssignment.ts" }
TypeScript/tests/cases/compiler/declarationEmitDestructuring2.ts_0_289
// @declaration: true function f({x = 10, y: [a, b, c, d] = [1, 2, 3, 4]} = { x: 10, y: [2, 4, 6, 8] }) { } function g([a, b, c, d] = [1, 2, 3, 4]) { } function h([a, [b], [[c]], {x = 10, y: [a, b, c], z: {a1, b1}}]){ } function h1([a, [b], [[c]], {x = 10, y = [1, 2, 3], z: {a1, b1}}]){ }
{ "end_byte": 289, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitDestructuring2.ts" }
TypeScript/tests/cases/compiler/commentOnClassMethod1.ts_0_120
// @removeComments: false class WebControls { /** * Render a control */ createControl(): any { } }
{ "end_byte": 120, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentOnClassMethod1.ts" }
TypeScript/tests/cases/compiler/elidedEmbeddedStatementsReplacedWithSemicolon.ts_0_307
if (1) const enum A {} else const enum B {} do const enum C {} while (0); while (0) const enum D {} for (;0;) const enum E {} for (let _ in []) const enum F {} for (let _ of []) const enum G {} // @ts-ignore suppress `with` statement error with (window) const enum H {}
{ "end_byte": 307, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/elidedEmbeddedStatementsReplacedWithSemicolon.ts" }
TypeScript/tests/cases/compiler/overloadingOnConstants2.ts_0_624
class C { private x = 1; } class D extends C {} class E { private y = 1; } function foo(x: "hi", items: string[]): D; function foo(x: "bye", items: string[]): E; function foo(x: string, items: string[]): C { return null; } var a: D = foo("hi", []); // D var b: E = foo("bye", []); // E var c = foo("um", []); ...
{ "end_byte": 624, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overloadingOnConstants2.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern.ts_0_516
// @lib: es5 // @sourcemap: true declare var console: { log(msg: string): void; } type Robot = [number, string, string]; var robotA: Robot = [1, "mower", "mowing"]; var robotB: Robot = [2, "trimmer", "trimming"]; let [, nameA] = robotA; let [numberB] = robotB; let [numberA2, nameA2, skillA2] = robotA; let [numbe...
{ "end_byte": 516, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern.ts" }
TypeScript/tests/cases/compiler/jsFileCompilationConstModifier.ts_0_67
// @allowJs: true // @filename: a.js // @noEmit: true const c = 10;
{ "end_byte": 67, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationConstModifier.ts" }
TypeScript/tests/cases/compiler/APISample_Watch.ts_3_3609
@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_Watch.ts /* * Note: This test is a public API sample. The...
{ "end_byte": 3609, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/APISample_Watch.ts" }
TypeScript/tests/cases/compiler/cyclicGenericTypeInstantiationInference.ts_0_310
function foo<T>() { var z = foo<typeof y>(); var y: { y2: typeof z }; return y; } function bar<T>() { var z = bar<typeof y>(); var y: { y2: typeof z; } return y; } var a = foo<number>(); var b = bar<number>(); function test<T>(x: typeof a): void { } test(b);
{ "end_byte": 310, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/cyclicGenericTypeInstantiationInference.ts" }
TypeScript/tests/cases/compiler/nestedFreshLiteral.ts_0_242
// @strictNullChecks: true interface CSSProps { color?: string } interface NestedCSSProps { nested?: NestedSelector } interface NestedSelector { prop: CSSProps; } let stylen: NestedCSSProps = { nested: { prop: { colour: 'red' } } }
{ "end_byte": 242, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nestedFreshLiteral.ts" }
TypeScript/tests/cases/compiler/declarationEmitExpressionInExtends7.ts_0_76
// @declaration: true export default class extends SomeUndefinedFunction {}
{ "end_byte": 76, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitExpressionInExtends7.ts" }
TypeScript/tests/cases/compiler/destructuringInVariableDeclarations6.ts_0_94
// @target: es6 // @module: umd let { toString } = 1; { let { toFixed } = 1; } export {};
{ "end_byte": 94, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/destructuringInVariableDeclarations6.ts" }
TypeScript/tests/cases/compiler/contextualTyping31.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/contextualTyping31.ts" }
TypeScript/tests/cases/compiler/referenceTypesPreferedToPathIfPossible.ts_0_281
// @declaration: true // @noImplicitReferences: true // @filename: /.src/node_modules/@types/node/index.d.ts declare module "url" { export class Url {} export function parse(): Url; } // @filename: usage.ts import { parse } from "url"; export const thing = () => parse();
{ "end_byte": 281, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/referenceTypesPreferedToPathIfPossible.ts" }
TypeScript/tests/cases/compiler/genericObjectCreationWithoutTypeArgs.ts_0_150
class SS<T>{ } var x1 = new SS<number>(); // OK var x2 = new SS<number>; // OK var x3 = new SS(); // OK var x4 = new SS; // OK
{ "end_byte": 150, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericObjectCreationWithoutTypeArgs.ts" }
TypeScript/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision3.ts_0_513
// @noemithelpers: true // @experimentaldecorators: true // @emitdecoratormetadata: true // @target: es5 // @module: commonjs // @filename: db.ts export class db { public doSomething() { } } // @filename: service.ts import db = require('./db'); function someDecorator(target) { return target; } @someDecorat...
{ "end_byte": 513, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision3.ts" }
TypeScript/tests/cases/compiler/functionReturn.ts_0_269
// @allowUnreachableCode: true function f0(): void { } function f1() { var n: any = f0(); } function f2(): any { } function f3(): string { return; } function f4(): string { return ''; return; } function f5(): string { return ''; return undefined; }
{ "end_byte": 269, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionReturn.ts" }
TypeScript/tests/cases/compiler/parseImportAttributesError.ts_0_886
// @noImplicitReferences: true // @module: nodenext // @declaration: true // @outDir: out // @filename: /node_modules/pkg/package.json { "name": "pkg", "version": "0.0.1", "exports": { "import": "./import.js", "require": "./require.js" } } // @filename: /node_modules/pkg/import.d.ts exp...
{ "end_byte": 886, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parseImportAttributesError.ts" }
TypeScript/tests/cases/compiler/esmModeDeclarationFileWithExportAssignment.ts_0_240
// @target: esnext // @module: nodenext // @allowSyntheticDefaultImports: true // @strict: true // @filename: other.d.mts declare function example(): 5; export = example; // @filename: main.mts import example from "./other.mjs"; example();
{ "end_byte": 240, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/esmModeDeclarationFileWithExportAssignment.ts" }
TypeScript/tests/cases/compiler/unusedLocalsInMethod2.ts_0_122
//@noUnusedLocals:true //@noUnusedParameters:true class greeter { public function1() { var x, y = 10; } }
{ "end_byte": 122, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedLocalsInMethod2.ts" }
TypeScript/tests/cases/compiler/inferenceOuterResultNotIncorrectlyInstantiatedWithInnerResult.ts_0_883
// @target: es6 // simple example export class Test<A, B> { constructor(public a: A, public b: B) { } test<C>(c: C): Test<B, C> { return new Test(this.b, c); } } // complicated one interface Supervisor<out T> { zip<A>(right: Supervisor<A>): Supervisor<[T, A]>; } export class Zip<out T0, out T...
{ "end_byte": 883, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inferenceOuterResultNotIncorrectlyInstantiatedWithInnerResult.ts" }
TypeScript/tests/cases/compiler/declarationEmitDefaultExportWithTempVarNameWithBundling.ts_0_105
// @declaration: true // @module: system // @outFile: app.js // @Filename: pi.ts export default 3.14159;
{ "end_byte": 105, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitDefaultExportWithTempVarNameWithBundling.ts" }
TypeScript/tests/cases/compiler/collisionSuperAndParameter.ts_0_1820
// @target: es5 class Foo { a() { var lamda = (_super: number) => { // No Error return x => this; // New scope. So should inject new _this capture } } b(_super: number) { // No Error var lambda = () => { return x => this; // New scope. So should inject...
{ "end_byte": 1820, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionSuperAndParameter.ts" }
TypeScript/tests/cases/compiler/functionsWithModifiersInBlocks1.ts_0_93
{ declare function f() { } export function f() { } declare export function f() { } }
{ "end_byte": 93, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionsWithModifiersInBlocks1.ts" }
TypeScript/tests/cases/compiler/privacyVar.ts_0_6365
//@module: commonjs export module m1 { export class C1_public { private f1() { } } class C2_private { } export class C3_public { private C3_v1_private: C1_public; public C3_v2_public: C1_public; private C3_v3_private: C2_private; public C3_v4_public:...
{ "end_byte": 6365, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyVar.ts" }
TypeScript/tests/cases/compiler/noImplicitAnyNamelessParameter.ts_0_287
// @noImplicitAny: true class C { } declare var a: { m(...string): void } declare var b: (string, C) => void; declare var c: { (C, number): void }; declare var d: { m(boolean, C, object, undefined): void } // note: null and void do not parse correctly without a preceding parameter name
{ "end_byte": 287, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noImplicitAnyNamelessParameter.ts" }
TypeScript/tests/cases/compiler/signatureCombiningRestParameters2.ts_0_248
// @strict: true // @lib: dom,esnext // @noEmit: true interface Console { log(message?: any, ...optionalParams: any[]): void; } let logs: string[] = []; let originalLog: typeof console.log; console.log = (...args) => { logs.push(...args); };
{ "end_byte": 248, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/signatureCombiningRestParameters2.ts" }
TypeScript/tests/cases/compiler/mismatchedExplicitTypeParameterAndArgumentType.ts_0_467
function map<T, U>(xs: T[], f: (x: T) => U) { var ys: U[] = []; xs.forEach(x => ys.push(f(x))); return ys; } var r0 = map([1, ""], (x) => x.toString()); var r5 = map<any, any>([1, ""], (x) => x.toString()); var r6 = map<Object, Object>([1, ""], (x) => x.toString()); var r7 = map<number, string>([1, ""], (x...
{ "end_byte": 467, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mismatchedExplicitTypeParameterAndArgumentType.ts" }
TypeScript/tests/cases/compiler/contextualSignatureInstantiation3.ts_0_530
function map<T, U>(items: T[], f: (x: T) => U): U[]{ return items.map(f); } function identity<T>(x: T) { return x; } function singleton<T>(x: T) { return [x]; } var xs = [1, 2, 3]; // Have compiler check that we get the correct types var v1: number[]; var v1 = xs.map(identity); // Error if not numb...
{ "end_byte": 530, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualSignatureInstantiation3.ts" }
TypeScript/tests/cases/compiler/discriminatedUnionWithIndexSignature.ts_0_473
// @strict: true export interface UnionAltA { type?: 'text'; } export interface UnionAltB { type?: 'image' | 'video' | 'document'; } export type ValueUnion = UnionAltA | UnionAltB; export type MapOrSingleton = | { [key: string]: ValueUnion; } | ValueUnion; const withoutAsConst: MapOrSin...
{ "end_byte": 473, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/discriminatedUnionWithIndexSignature.ts" }
TypeScript/tests/cases/compiler/declInput.ts_0_195
// @declaration: true interface bar { } class bar { public f() { return ''; } public g() { return {a: <bar>null, b: undefined, c: void 4 }; } public h(x = 4, y = null, z = '') { x++; } }
{ "end_byte": 195, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declInput.ts" }
TypeScript/tests/cases/compiler/modularizeLibrary_ErrorFromUsingWellknownSymbolWithOutES6WellknownSymbolLib.ts_3_195
@lib: es5,es2015.core function f(x: number, y: number, z: number) { return Array.from(arguments); } f(1, 2, 3); // no error let a = ['c', 'd']; a[Symbol.isConcatSpreadable] = false;
{ "end_byte": 195, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/modularizeLibrary_ErrorFromUsingWellknownSymbolWithOutES6WellknownSymbolLib.ts" }
TypeScript/tests/cases/compiler/tripleSlashReferenceAbsoluteWindowsPath.ts_0_117
//@Filename: C:\a\b\c.ts const x = 5; //@Filename: C:\a\b\d.ts /// <reference path="C:\a\b\c.ts" /> const y = x + 3;
{ "end_byte": 117, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/tripleSlashReferenceAbsoluteWindowsPath.ts" }
TypeScript/tests/cases/compiler/promiseDefinitionTest.ts_0_77
// @target: es5 class Promise<T> {} async function foo() {} const x = foo();
{ "end_byte": 77, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/promiseDefinitionTest.ts" }
TypeScript/tests/cases/compiler/excessiveStackDepthFlatArray.ts_0_1235
// @lib: es2019,dom // @jsx: react // @Filename: index.tsx interface MiddlewareArray<T> extends Array<T> {} declare function configureStore(options: { middleware: MiddlewareArray<any> }): void; declare const defaultMiddleware: MiddlewareArray<any>; configureStore({ middleware: [...defaultMiddleware], // Should not ...
{ "end_byte": 1235, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/excessiveStackDepthFlatArray.ts" }
TypeScript/tests/cases/compiler/classUpdateTests.ts_0_1469
// // test codegen for instance properties // class A { public p1 = 0; private p2 = 0; p3; } class B { public p1 = 0; private p2 = 0; p3; constructor() {} } class C { constructor(public p1=0, private p2=0, p3=0) {} } // // test requirements for super calls // class D { // NO ERROR } class E extends D { /...
{ "end_byte": 1469, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classUpdateTests.ts" }
TypeScript/tests/cases/compiler/collisionThisExpressionAndAliasInGlobal.ts_0_82
module a { export var b = 10; } var f = () => this; import _this = a; // Error
{ "end_byte": 82, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionThisExpressionAndAliasInGlobal.ts" }
TypeScript/tests/cases/compiler/betterErrorForAccidentalCall.ts_0_198
declare function foo(): string; foo()(1 as number).toString(); foo() (1 as number).toString(); foo() (1 as number).toString(); foo() (1 + 2).toString(); foo() (<number>1).toString();
{ "end_byte": 198, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/betterErrorForAccidentalCall.ts" }
TypeScript/tests/cases/compiler/jsxCallbackWithDestructuring.tsx_0_843
// @jsx: preserve // @noImplicitAny: true // @strictNullChecks: true // minimal component interface Component<P = {}, S = {}> { } declare class Component<P, S> { constructor(props: P, context?: any); render(): {}; props: Readonly<{ children?: {} }> & Readonly<P>; } declare global { namespace JSX { ...
{ "end_byte": 843, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsxCallbackWithDestructuring.tsx" }
TypeScript/tests/cases/compiler/checkJsObjectLiteralIndexSignatures.ts_0_256
// @allowJs: true // @noImplicitAny: true // @outDir: ./out // @filename: file.js // @ts-check let n = Math.random(); let s = `${n}`; const numericIndex = { [n]: 1 }; numericIndex[n].toFixed(); const stringIndex = { [s]: 1 }; stringIndex[s].toFixed();
{ "end_byte": 256, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/checkJsObjectLiteralIndexSignatures.ts" }
TypeScript/tests/cases/compiler/keyRemappingKeyofResult.ts_0_1920
// @target: es6 const sym = Symbol("") type Orig = { [k: string]: any, str: any, [sym]: any } type Okay = Exclude<keyof Orig, never> // type Okay = string | number | typeof sym type Remapped = { [K in keyof Orig as {} extends Record<K, any> ? never : K]: any } /* type Remapped = { str: any; [sym]: any; } */ /...
{ "end_byte": 1920, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/keyRemappingKeyofResult.ts" }
TypeScript/tests/cases/compiler/assignmentStricterConstraints.ts_0_129
var f = function <T, S extends T>(x: T, y: S): void { x = y } var g = function <T, S>(x: T, y: S): void { } g = f g(1, "")
{ "end_byte": 129, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentStricterConstraints.ts" }
TypeScript/tests/cases/compiler/indexer.ts_0_157
interface JQueryElement { id:string; } interface JQuery { [n:number]:JQueryElement; } var jq:JQuery={ 0: { id : "a" }, 1: { id : "b" } }; jq[0].id;
{ "end_byte": 157, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/indexer.ts" }
TypeScript/tests/cases/compiler/jsFileCompilationWithMapFileAsJsWithInlineSourceMap.ts_0_157
// @allowJs: true // @inlineSourceMap: true // @filename: a.ts class c { } // @filename: b.js.map function foo() { } // @filename: b.js function bar() { }
{ "end_byte": 157, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationWithMapFileAsJsWithInlineSourceMap.ts" }
TypeScript/tests/cases/compiler/constDeclarations-access.ts_0_80
// @target: ES6 // @Filename: file1.ts const x = 0 // @Filename: file2.ts x++;
{ "end_byte": 80, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constDeclarations-access.ts" }
TypeScript/tests/cases/compiler/declarationEmitEnumReadonlyProperty.ts_0_123
// @declaration: true enum E { A = 'a', B = 'b' } class C { readonly type = E.A; } let x: E.A = new C().type;
{ "end_byte": 123, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitEnumReadonlyProperty.ts" }
TypeScript/tests/cases/compiler/reachabilityCheckWithEmptyDefault.ts_0_123
declare function print(s: string): void; function foo(x: any) { switch(x) { case 1: return; default: } print('1'); }
{ "end_byte": 123, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reachabilityCheckWithEmptyDefault.ts" }
TypeScript/tests/cases/compiler/constructorWithSuperAndPrologue.es5.ts_0_269
// @target: es5 // https://github.com/microsoft/TypeScript/issues/48761 "use strict"; class A { public constructor() { console.log("A") } } class B extends A { constructor() { "ngInject"; console.log("B") super(); } }
{ "end_byte": 269, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constructorWithSuperAndPrologue.es5.ts" }
TypeScript/tests/cases/compiler/inheritanceOfGenericConstructorMethod2.ts_0_306
module M { export class C1 { } export class C2<T> { } } module N { export class D1 extends M.C1 { } export class D2<T> extends M.C2<T> { } } var c = new M.C2<number>(); // no error var n = new N.D1(); // no error var n2 = new N.D2<number>(); // error var n3 = new N.D2(); // no error, D2<any>
{ "end_byte": 306, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inheritanceOfGenericConstructorMethod2.ts" }
TypeScript/tests/cases/compiler/thisExpressionInCallExpressionWithTypeArguments.ts_0_78
class C { public foo() { [1,2,3].map<any,any>((x) => { return this; })} }
{ "end_byte": 78, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/thisExpressionInCallExpressionWithTypeArguments.ts" }
TypeScript/tests/cases/compiler/nonNullParameterExtendingStringAssignableToString.ts_0_256
// @strict: true declare function foo(p: string): void; function fn<T extends string | undefined, U extends string>(one: T, two: U) { let three = Boolean() ? one : two; foo(one!); foo(two!); foo(three!); // this line is the important one }
{ "end_byte": 256, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nonNullParameterExtendingStringAssignableToString.ts" }
TypeScript/tests/cases/compiler/declareIdentifierAsBeginningOfStatementExpression01.ts_0_53
class C { } var declare: any; declare instanceof C;
{ "end_byte": 53, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declareIdentifierAsBeginningOfStatementExpression01.ts" }
TypeScript/tests/cases/compiler/ambiguousGenericAssertion1.ts_0_184
function f<T>(x: T): T { return null; } var r = <T>(x: T) => x; var r2 = < <T>(x: T) => T>f; // valid var r3 = <<T>(x: T) => T>f; // ambiguous, appears to the parser as a << operation
{ "end_byte": 184, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ambiguousGenericAssertion1.ts" }
TypeScript/tests/cases/compiler/capturedLetConstInLoop8_ES6.ts_0_2927
// @target: ES6 function foo() { l0: for (let z = 0; z < 1; ++z) { l1: for (let x = 0; x < 1; ++x) { ll1: for (let y = 0; y < 1; ++y) { (function() { return x + y }); (() => x + y); if (y == 1) { break; ...
{ "end_byte": 2927, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/capturedLetConstInLoop8_ES6.ts" }
TypeScript/tests/cases/compiler/requiredInitializedParameter3.ts_0_105
//@declaration: true interface I1 { method(); } class C1 implements I1 { method(a = 0, b?) { } }
{ "end_byte": 105, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/requiredInitializedParameter3.ts" }
TypeScript/tests/cases/compiler/nonContextuallyTypedLogicalOr.ts_0_152
interface Contextual { dummy; p?: number; } interface Ellement { dummy; p: any; } var c: Contextual; var e: Ellement; (c || e).dummy;
{ "end_byte": 152, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nonContextuallyTypedLogicalOr.ts" }
TypeScript/tests/cases/compiler/decoratorsOnComputedProperties.ts_0_4787
// @target: es6 // @experimentalDecorators: true function x(o: object, k: PropertyKey) { } let i = 0; function foo(): string { return ++i + ""; } const fieldNameA: string = "fieldName1"; const fieldNameB: string = "fieldName2"; const fieldNameC: string = "fieldName3"; class A { @x ["property"]: any; @x [Symbo...
{ "end_byte": 4787, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/decoratorsOnComputedProperties.ts" }
TypeScript/tests/cases/compiler/duplicateVarsAcrossFileBoundaries.ts_0_510
// @Filename: duplicateVarsAcrossFileBoundaries_0.ts var x = 3; var y = ""; // @Filename: duplicateVarsAcrossFileBoundaries_1.ts var x = true; var z = 3; // @Filename: duplicateVarsAcrossFileBoundaries_2.ts var x = ""; var y = 3; var z = false; // @Filename: duplicateVarsAcrossFileBoundaries_3.ts var x = 0; var y = ...
{ "end_byte": 510, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateVarsAcrossFileBoundaries.ts" }
TypeScript/tests/cases/compiler/unknownLikeUnionObjectFlagsNotPropagated.ts_0_366
// @strict: true // @noEmit: true // @lib: esnext // repro from #52475#issuecomment-1411215277 type MyType = {} | null | undefined; const myVar: MyType = null as MyType; myVar?.toLocaleString; myVar; async function myUnusedFunction() { const fetch1 = Promise.resolve(['hello', 'world']); const [data1] = awa...
{ "end_byte": 366, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unknownLikeUnionObjectFlagsNotPropagated.ts" }
TypeScript/tests/cases/compiler/reverseMappedTypeContextualTypeNotCircular.ts_0_422
type Selector<S, R> = (state: S) => R; declare function createStructuredSelector<S, T>( selectors: {[K in keyof T]: Selector<S, T[K]>}, ): Selector<S, T>; const editable = () => ({}); const mapStateToProps = createStructuredSelector({ editable: (state: any, props: any) => editable(), // expect "Type '(state: any...
{ "end_byte": 422, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reverseMappedTypeContextualTypeNotCircular.ts" }
TypeScript/tests/cases/compiler/bestCommonTypeWithContextualTyping.ts_0_568
interface Contextual { dummy; p?: number; } interface Ellement { dummy; p: any; } var e: Ellement; // All of these should pass. Neither type is a supertype of the other, but the RHS should // always use Ellement in these examples (not Contextual). Because Ellement is assignable // to Contextual, no e...
{ "end_byte": 568, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/bestCommonTypeWithContextualTyping.ts" }
TypeScript/tests/cases/compiler/jsxFactoryQualifiedName.ts_0_1071
//@jsx: react //@target: es6 //@module: commonjs //@jsxFactory: Element.createElement //@sourcemap: true // @filename: Element.ts declare namespace JSX { interface Element { name: string; isIntrinsic: boolean; isCustomElement: boolean; toString(renderId?: number): string; bi...
{ "end_byte": 1071, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsxFactoryQualifiedName.ts" }
TypeScript/tests/cases/compiler/es5-commonjs.ts_0_188
// @target: ES5 // @sourcemap: false // @declaration: false // @module: commonjs export default class A { constructor () { } public B() { return 42; } }
{ "end_byte": 188, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es5-commonjs.ts" }
TypeScript/tests/cases/compiler/moduleResolution_packageJson_scopedPackage.ts_0_258
// @noImplicitReferences: true // @traceResolution: true // @Filename: /node_modules/@foo/bar/package.json { "types": "types.d.ts" } // @Filename: /node_modules/@foo/bar/types.d.ts export const x: number; // @Filename: /a.ts import { x } from "@foo/bar";
{ "end_byte": 258, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolution_packageJson_scopedPackage.ts" }
TypeScript/tests/cases/compiler/blockScopedBindingsReassignedInLoop4.ts_0_200
function f1() { for (let x = 1, y = 2; x < y; ++x, --y) { let a = () => x++ + y++; if (x == 1) { return 1; } else { y = 5; } } }
{ "end_byte": 200, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/blockScopedBindingsReassignedInLoop4.ts" }
TypeScript/tests/cases/compiler/noErrorsInCallback.ts_0_150
class Bar { constructor(public foo: string) { } } var one = new Bar({}); // Error [].forEach(() => { var two = new Bar({}); // No error? });
{ "end_byte": 150, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noErrorsInCallback.ts" }
TypeScript/tests/cases/compiler/arrayLiteral2.ts_0_22
var v30 = [1, 2], v31;
{ "end_byte": 22, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arrayLiteral2.ts" }
TypeScript/tests/cases/compiler/functionOverloads25.ts_0_112
function foo():string; function foo(bar:string):number; function foo(bar?:any):any{ return '' }; var x = foo();
{ "end_byte": 112, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloads25.ts" }
TypeScript/tests/cases/compiler/nonMergedOverloads.ts_0_57
var f = 10; export function f(); export function f() { }
{ "end_byte": 57, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nonMergedOverloads.ts" }
TypeScript/tests/cases/compiler/exportAssignmentClass.ts_0_214
//@module: amd // @Filename: exportAssignmentClass_A.ts class C { public p = 0; } export = C; // @Filename: exportAssignmentClass_B.ts import D = require("exportAssignmentClass_A"); var d = new D(); var x = d.p;
{ "end_byte": 214, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportAssignmentClass.ts" }
TypeScript/tests/cases/compiler/forInModule.ts_0_55
module Foo { for (var i = 0; i < 1; i++) { i+i; } }
{ "end_byte": 55, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/forInModule.ts" }
TypeScript/tests/cases/compiler/modulePrologueSystem.ts_0_53
// @module: system "use strict"; export class Foo {}
{ "end_byte": 53, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/modulePrologueSystem.ts" }
TypeScript/tests/cases/compiler/inferTypesWithFixedTupleExtendsAtVariadicPosition.ts_0_2160
// @strict: true // @noEmit: true // repro #51138 type SubTup2FixedLength<T extends unknown[]> = T extends [ ...infer B extends [any, any], any ] ? B : never; type SubTup2FixedLengthTest = SubTup2FixedLength<[a: 0, b: 1, c: 2]>; type SubTup2Variadic<T extends unknown[]> = T extends [ ...infer B extends [a...
{ "end_byte": 2160, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inferTypesWithFixedTupleExtendsAtVariadicPosition.ts" }
TypeScript/tests/cases/compiler/duplicateVariableDeclaration1.ts_0_11
var v var v
{ "end_byte": 11, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateVariableDeclaration1.ts" }
TypeScript/tests/cases/compiler/exportSpecifierAndExportedMemberDeclaration.ts_0_188
declare module "m2" { export module X { interface I { } } function Y(); export { Y as X }; function Z(): X.I; } declare module "m2" { function Z2(): X.I; }
{ "end_byte": 188, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportSpecifierAndExportedMemberDeclaration.ts" }
TypeScript/tests/cases/compiler/reexportMissingDefault8.ts_0_123
// @esModuleInterop: true // @filename: b.ts const b = null; export = b; // @filename: a.ts export { default } from "./b";
{ "end_byte": 123, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reexportMissingDefault8.ts" }
TypeScript/tests/cases/compiler/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.ts_0_256
// @traceResolution: true // @Filename: /node_modules/foo/package.json { "name": "foo", "version": "1.2.3", "main": "src/index.js" } // @Filename: /node_modules/foo/src/index.d.ts export const x: number; // @Filename: /index.ts import { x } from "foo";
{ "end_byte": 256, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.ts" }
TypeScript/tests/cases/compiler/narrowByClauseExpressionInSwitchTrue8.ts_0_658
// @strict: true // @noEmit: true function foo(cond1: boolean, cond2: boolean) { switch (true) { case cond1: cond1; // Should be true // ^? cond2; // Should be boolean // ^? break; case cond2: cond1; // Should be false? ...
{ "end_byte": 658, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowByClauseExpressionInSwitchTrue8.ts" }
TypeScript/tests/cases/compiler/shorthandPropertyUndefined.ts_0_14
var a = { b };
{ "end_byte": 14, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/shorthandPropertyUndefined.ts" }
TypeScript/tests/cases/compiler/typeArgInferenceWithNull.ts_0_317
// All legal function fn4<T extends string>(n: T) { } fn4(null); function fn5<T extends { x: string }>(n: T) { } fn5({ x: null }); function fn6<T extends { x: string }>(n: T, fun: (x: T) => void, n2: T) { } fn6({ x: null }, y => { }, { x: "" }); // y has type { x: any }, but ideally would have type { x: string }
{ "end_byte": 317, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeArgInferenceWithNull.ts" }