_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/declarationEmitExportAssignment.ts_0_227
// @target: es5 // @module: commonjs // @declaration: true // @filename: utils.ts export function foo() { } export function bar() { } export interface Buzz { } // @filename: index.ts import {foo} from "./utils"; export = foo;
{ "end_byte": 227, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitExportAssignment.ts" }
TypeScript/tests/cases/compiler/assignmentToObject.ts_0_86
var a = { toString: 5 }; var b: {} = a; // ok var c: Object = a; // should be error
{ "end_byte": 86, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentToObject.ts" }
TypeScript/tests/cases/compiler/aliasUsageInGenericFunction.ts_0_768
// @module: commonjs // @Filename: aliasUsageInGenericFunction_backbone.ts export class Model { public someData: string; } // @Filename: aliasUsageInGenericFunction_moduleA.ts import Backbone = require("./aliasUsageInGenericFunction_backbone"); export class VisualizationModel extends Backbone.Model { // intere...
{ "end_byte": 768, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/aliasUsageInGenericFunction.ts" }
TypeScript/tests/cases/compiler/accessStaticMemberFromInstanceMethod01.ts_0_75
class C { foo: string; static bar() { let k = foo; } }
{ "end_byte": 75, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/accessStaticMemberFromInstanceMethod01.ts" }
TypeScript/tests/cases/compiler/requiredInitializedParameter4.ts_0_58
//@declaration: true class C1 { method(a = 0, b) { } }
{ "end_byte": 58, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/requiredInitializedParameter4.ts" }
TypeScript/tests/cases/compiler/defaultNamedExportWithType1.ts_0_81
// @target: esnext type Foo = number; export const Foo = 1; export default Foo;
{ "end_byte": 81, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/defaultNamedExportWithType1.ts" }
TypeScript/tests/cases/compiler/overloadAssignmentCompat.ts_1_990
// ok - overload signatures are assignment compatible with their implementation class Accessor {} function attr(name: string): string; function attr(name: string, value: string): Accessor; function attr(map: any): Accessor; function attr(nameOrMap: any, value?: string): any { if (nameOrMap && typeof nameOrMap === ...
{ "end_byte": 990, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overloadAssignmentCompat.ts" }
TypeScript/tests/cases/compiler/overloadCrash.ts_0_260
interface I1 {a:number; b:number;}; interface I2 {c:number; d:number;}; interface I3 {a:number; b:number; c:number; d:number;}; declare function foo(...n:I1[]); declare function foo(n1:I2, n3:I2); var i3:I3; foo(i3, i3); // should not crash the compiler :)
{ "end_byte": 260, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overloadCrash.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationDestructuringForOfArrayBindingPatternDefaultValues2.ts_0_3044
// @lib: es5 // @sourcemap: true declare var console: { log(msg: any): void; } type Robot = [number, string, string]; type MultiSkilledRobot = [string, [string, string]]; let robotA: Robot = [1, "mower", "mowing"]; let robotB: Robot = [2, "trimmer", "trimming"]; let robots = [robotA, robotB]; function getRobots() ...
{ "end_byte": 3044, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationDestructuringForOfArrayBindingPatternDefaultValues2.ts" }
TypeScript/tests/cases/compiler/operationsAvailableOnPromisedType.ts_0_483
async function fn( a: number, b: Promise<number>, c: Promise<string[]>, d: Promise<{ prop: string }>, e: Promise<() => void>, f: Promise<() => void> | (() => void), g: Promise<{ new(): any }> ) { // All errors a | b; b | a; a + b; a > b; b++; --b; a === b; ...
{ "end_byte": 483, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/operationsAvailableOnPromisedType.ts" }
TypeScript/tests/cases/compiler/forInStrictNullChecksNoError.ts_0_200
// @strictNullChecks: true function f(x: { [key: string]: number; } | null | undefined) { for (const key in x) { // 1 console.log(x[key]); // 2 } x["no"]; // should still error }
{ "end_byte": 200, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/forInStrictNullChecksNoError.ts" }
TypeScript/tests/cases/compiler/prefixedNumberLiteralAssignToNumberLiteralType.ts_0_31
let x: 1 = +1; let y: -1 = -1;
{ "end_byte": 31, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/prefixedNumberLiteralAssignToNumberLiteralType.ts" }
TypeScript/tests/cases/compiler/errorOnEnumReferenceInCondition.ts_0_428
// @strict: true enum Nums { Zero = 0, One = 1, } const a = Nums.Zero ? "a" : "b"; const b = Nums.One ? "a" : "b"; if (Nums.Zero) { Nums; } else { Nums; } if (Nums.One) { Nums; } else { Nums; } enum Strs { Empty = "", A = "A", } const c = Strs.Empty ? "a" : "b"; const d = Strs.A ?...
{ "end_byte": 428, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/errorOnEnumReferenceInCondition.ts" }
TypeScript/tests/cases/compiler/noTypeArgumentOnReturnType1.ts_0_44
class A<T>{ foo(): A{ return null; } }
{ "end_byte": 44, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noTypeArgumentOnReturnType1.ts" }
TypeScript/tests/cases/compiler/noImplicitUseStrict_es6.ts_0_80
// @module: es6 // @target: es6 // @noImplicitUseStrict: true export var x = 0;
{ "end_byte": 80, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noImplicitUseStrict_es6.ts" }
TypeScript/tests/cases/compiler/useUnknownInCatchVariables01.ts_0_570
// @useUnknownInCatchVariables: true try { // ... } catch (e) { // error! void e.toUpperCase(); void e++; void e(); if (typeof e === "string") { // works! // We've narrowed 'e' down to the type 'string'. console.log(e.toUpperCase()); } if (e instanceof Error) { ...
{ "end_byte": 570, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/useUnknownInCatchVariables01.ts" }
TypeScript/tests/cases/compiler/declarationEmitPrivateAsync.ts_0_103
// @lib: es6 // @declaration: true export class Foo { private async baz() { return; } }
{ "end_byte": 103, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitPrivateAsync.ts" }
TypeScript/tests/cases/compiler/contextualTypeBasedOnIntersectionWithAnyInTheMix1.ts_0_828
// @strict: true // @noEmit: true type ComponentType<P> = (p: P) => any; type ComponentProps<C> = C extends ComponentType<infer P> ? P : never; type Attrs<P, A extends Partial<P>> = A; interface StyledFunction< C extends ComponentType<any>, O extends object = {}, A extends keyof any = never, > { attrs< U...
{ "end_byte": 828, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTypeBasedOnIntersectionWithAnyInTheMix1.ts" }
TypeScript/tests/cases/compiler/contextualTyping36.ts_0_66
var foo = <{ id: number; }[]>[{ id: 4 }, <{ id: number; }>({ })];
{ "end_byte": 66, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTyping36.ts" }
TypeScript/tests/cases/compiler/destructuringInVariableDeclarations1.ts_0_95
// @target: es6 // @module: commonjs export let { toString } = 1; { let { toFixed } = 1; }
{ "end_byte": 95, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/destructuringInVariableDeclarations1.ts" }
TypeScript/tests/cases/compiler/exportDefaultTypeAndClass.ts_0_61
export default class Foo {} type Bar = {} export default Bar
{ "end_byte": 61, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportDefaultTypeAndClass.ts" }
TypeScript/tests/cases/compiler/assigningFunctionToTupleIssuesError.ts_0_47
declare let a: () => void; let b: [string] = a;
{ "end_byte": 47, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assigningFunctionToTupleIssuesError.ts" }
TypeScript/tests/cases/compiler/untypedArgumentInLambdaExpression.ts_0_101
declare function f(fn: (a: string) => string); f((input): string => { return "." + input; });
{ "end_byte": 101, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/untypedArgumentInLambdaExpression.ts" }
TypeScript/tests/cases/compiler/targetTypeVoidFunc.ts_0_129
function f1(): { new (): number; } { return function () { return; } }; var x = f1(); var y = new x(); var z = new (f1())();
{ "end_byte": 129, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/targetTypeVoidFunc.ts" }
TypeScript/tests/cases/compiler/tsxSpreadDoesNotReportExcessProps.tsx_0_325
// @esModuleInterop: true // @skipLibCheck: true // @jsx: react // @strict: true /// <reference path="/.lib/react16.d.ts" /> import React from "react"; class MyComponent extends React.Component<{dataSource: number[], onClick?: any}, {}> { render() { return (<div {...this.props} className="ok"></div>); ...
{ "end_byte": 325, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/tsxSpreadDoesNotReportExcessProps.tsx" }
TypeScript/tests/cases/compiler/noImplicitAnyParametersInAmbientClass.ts_3_2373
@noImplicitAny: true declare class D_C { // No implicit-'any' errors. public pub_f1(): void; // Implicit-'any' errors for x. public pub_f2(x): void; // No implicit-'any' errors. public pub_f3(x: any): void; // Implicit-'any' errors for x, y, and z. public pub_f4(x, y, z): void; ...
{ "end_byte": 2373, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noImplicitAnyParametersInAmbientClass.ts" }
TypeScript/tests/cases/compiler/typeofStrictNull.ts_0_59
// @strictNullChecks: true let a: number; let b: typeof a;
{ "end_byte": 59, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeofStrictNull.ts" }
TypeScript/tests/cases/compiler/jsdocTypedefNoCrash2.ts_0_149
// @target: es6 // @allowJs: true // @outDir: ./dist // @filename: export.js export type foo = 5; /** * @typedef {{ * }} */ export const foo = 5;
{ "end_byte": 149, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsdocTypedefNoCrash2.ts" }
TypeScript/tests/cases/compiler/classWithMultipleBaseClasses.ts_0_196
class A { foo() { } } class B { bar() { } } interface I { baz(); } interface J { bat(); } class D implements I, J { baz() { } bat() { } } interface I extends A, B { }
{ "end_byte": 196, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classWithMultipleBaseClasses.ts" }
TypeScript/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision4.ts_0_484
// @noemithelpers: true // @experimentaldecorators: true // @emitdecoratormetadata: true // @target: es5 // @module: commonjs // @filename: db.ts export class db { public doSomething() { } } // @filename: service.ts import db from './db'; // error no default export function someDecorator(target) { return t...
{ "end_byte": 484, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision4.ts" }
TypeScript/tests/cases/compiler/indexedAccessImplicitlyAny.ts_0_110
// @target: esnext // @noImplicitAny: true interface I { foof: number }; declare const i: I; i.foo; i["foo"];
{ "end_byte": 110, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/indexedAccessImplicitlyAny.ts" }
TypeScript/tests/cases/compiler/signatureCombiningRestParameters5.ts_0_612
// @strict: true // @noEmit: true declare const test1: | ((...args: [a: string | number, b: number | boolean]) => void) | ((...args: [c: number | boolean, d: string | boolean]) => void); test1(42, true); test1(42, [true]); // error declare function test2< A extends readonly unknown[], B extends readonly unkn...
{ "end_byte": 612, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/signatureCombiningRestParameters5.ts" }
TypeScript/tests/cases/compiler/es5ModuleInternalNamedImports.ts_0_776
// @target: ES5 // @module: AMD export module M { // variable export var M_V = 0; // interface export interface M_I { } //calss export class M_C { } // instantiated module export module M_M { var x; } // uninstantiated module export module M_MU { } // function export fun...
{ "end_byte": 776, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es5ModuleInternalNamedImports.ts" }
TypeScript/tests/cases/compiler/declarationEmitComputedNameCausesImportToBePainted.ts_0_318
// @declaration: true // @lib: es6 // @filename: context.ts export const Key = Symbol(); export interface Context { [Key]: string; } // @filename: index.ts import { Key, Context } from "./context"; export const context: Context = { [Key]: 'bar', } export const withContext = ({ [Key]: value }: Context) => value;
{ "end_byte": 318, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitComputedNameCausesImportToBePainted.ts" }
TypeScript/tests/cases/compiler/inferPropertyWithContextSensitiveReturnStatement.ts_0_220
// @noEmit: true // @strict: true // repro #50687 declare function repro<T>(config: { params: T; callback: () => (params: T) => number; }): void; repro({ params: 1, callback: () => { return a => a + 1 }, });
{ "end_byte": 220, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inferPropertyWithContextSensitiveReturnStatement.ts" }
TypeScript/tests/cases/compiler/thisReferencedInFunctionInsideArrowFunction1.ts_0_103
var foo = (dummy) => { }; function test() { foo(() => function () { return this; } ); }
{ "end_byte": 103, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/thisReferencedInFunctionInsideArrowFunction1.ts" }
TypeScript/tests/cases/compiler/deeplyNestedAssignabilityErrorsCombined.ts_0_347
let x = { a: { b: { c: { d: { e: { f() { return { g: "hello" }; } } } } } } }; let y = { a: { b: { c: { d: { e: { f() { return { g: 12345 }; } } } } } } }; x = y; class Ctor1 { g = "ok" } class Ctor2 { g = 12; } let x2 = { a: { b: { c: { d: { e: { f: Ctor1 } } } } } }; let y2 = { a: { b: { c: { d: { e: { f: ...
{ "end_byte": 347, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/deeplyNestedAssignabilityErrorsCombined.ts" }
TypeScript/tests/cases/compiler/isolatedDeclarationErrorsObjects.ts_0_1423
// @declaration: true // @isolatedDeclarations: true // @declarationMap: false // @strict: true // @target: ESNext export let o = { a: 1, b: "" } export let oBad = { a: Math.random(), } export const V = 1; export let oBad2 = { a: { b: Math.random(), }, c: { d: 1, e: V,...
{ "end_byte": 1423, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/isolatedDeclarationErrorsObjects.ts" }
TypeScript/tests/cases/compiler/requireOfJsonFileWithModuleEmitUndefined.ts_0_181
// @outdir: out/ // @fullEmitPaths: true // @resolveJsonModule: true // @Filename: file1.ts import * as b from './b.json'; // @Filename: b.json { "a": true, "b": "hello" }
{ "end_byte": 181, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/requireOfJsonFileWithModuleEmitUndefined.ts" }
TypeScript/tests/cases/compiler/contextualSignatureInstantiation4.ts_0_873
// @strict: true // Repros from #32976 declare class Banana<T extends string> { constructor(a: string, property: T) } declare function fruitFactory1<TFruit>(Fruit: new (...args: any[]) => TFruit): TFruit const banana1 = fruitFactory1(Banana) // Banana<any> declare function fruitFactory2<TFruit>(Fruit: new (a: strin...
{ "end_byte": 873, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualSignatureInstantiation4.ts" }
TypeScript/tests/cases/compiler/implicitAnyAnyReturningFunction.ts_0_271
// @declaration: true function A() { return <any>""; } function B() { var someLocal: any = {}; return someLocal; } class C { public A() { return <any>""; } public B() { var someLocal: any = {}; return someLocal; } }
{ "end_byte": 271, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/implicitAnyAnyReturningFunction.ts" }
TypeScript/tests/cases/compiler/jsDeclarationsWithDefaultAsNamespaceLikeMerge.ts_0_612
// @declaration: true // @allowJs: true // @emitDeclarationOnly: true // @filename: /helper.d.ts type Computed = () => any; interface Mapper<R> { <Key extends string>(map: Key[]): { [K in Key]: R }; <Map extends Record<string, string>>(map: Map): { [K in keyof Map]: R }; } interface NamespacedMappers { map...
{ "end_byte": 612, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsDeclarationsWithDefaultAsNamespaceLikeMerge.ts" }
TypeScript/tests/cases/compiler/enumOperations.ts_0_285
enum Enum { None = 0 } var enumType: Enum = Enum.None; var numberType: number = 0; var anyType: any = 0; enumType ^ numberType; numberType ^ anyType; enumType & anyType; enumType | anyType; enumType ^ anyType; ~anyType; enumType <<anyType; enumType >>anyType; enumType >>>anyType;
{ "end_byte": 285, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumOperations.ts" }
TypeScript/tests/cases/compiler/requireOfJsonFileWithModuleNodeResolutionEmitEs2015.ts_0_227
// @module: es2015 // @moduleResolution: node // @outdir: out/ // @fullEmitPaths: true // @resolveJsonModule: true // @Filename: file1.ts import * as b from './b.json'; // @Filename: b.json { "a": true, "b": "hello" }
{ "end_byte": 227, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/requireOfJsonFileWithModuleNodeResolutionEmitEs2015.ts" }
TypeScript/tests/cases/compiler/continueInIterationStatement1.ts_0_28
while (true) { continue; }
{ "end_byte": 28, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/continueInIterationStatement1.ts" }
TypeScript/tests/cases/compiler/intersectionReductionGenericStringLikeType.ts_0_623
// @strict: true // @noEmit: true // https://github.com/microsoft/TypeScript/issues/57736 type obj = { foo: 1; bar: 2; }; type keyContaining1< str extends string, keys extends keyof obj = keyof obj, > = keys extends infer key extends keyof obj ? key extends `${string}${str}${string}` ? obj[ke...
{ "end_byte": 623, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/intersectionReductionGenericStringLikeType.ts" }
TypeScript/tests/cases/compiler/discriminateWithMissingProperty.ts_0_282
// @strict: true // @noEmit: true type Arg = { mode: "numeric", data: number, } | { mode: "alphabetic", data: string, } | { data: string | Uint8Array; } declare function foo(arg: Arg): void; foo({ mode: "numeric", data: new Uint8Array([30]) }); // Should error
{ "end_byte": 282, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/discriminateWithMissingProperty.ts" }
TypeScript/tests/cases/compiler/parameterPropertyInitializerInInitializers.ts_0_73
class Foo { constructor(public x: number, public y: number = x) { } }
{ "end_byte": 73, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parameterPropertyInitializerInInitializers.ts" }
TypeScript/tests/cases/compiler/divergentAccessorsTypes4.ts_0_458
// @target: es5 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) { } get prop2(): string { return ""; } set prop2(s: string | 42) { } } declare const i: One & Two; //...
{ "end_byte": 458, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/divergentAccessorsTypes4.ts" }
TypeScript/tests/cases/compiler/typeReferenceDirectives12.ts_0_686
// @noImplicitReferences: true // @declaration: true // @typeRoots: /types // @traceResolution: true // @outFile: output.js // @currentDirectory: / // @filename: /types/lib/index.d.ts interface Lib { x } // @filename: /main.ts export class Cls { x } // @filename: /mod1.ts /// <reference types="lib" /> import ...
{ "end_byte": 686, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeReferenceDirectives12.ts" }
TypeScript/tests/cases/compiler/strictNullNotNullIndexTypeNoLib.ts_0_642
// @strictNullChecks: true // @noLib: true type Readonly<T> = {readonly [K in keyof T]: T[K]} interface A { params?: { name: string; }; } class Test<T extends A> { attrs: Readonly<T>; m() { this.attrs.params!.name; } } interface Foo { foo?: number; } class FooClass<P extends Foo = Foo> {...
{ "end_byte": 642, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/strictNullNotNullIndexTypeNoLib.ts" }
TypeScript/tests/cases/compiler/elaborationForPossiblyCallableTypeStillReferencesArgumentAtTopLevel.ts_0_82
declare var ohno: new () => number; declare function ff(t: number): void; ff(ohno)
{ "end_byte": 82, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/elaborationForPossiblyCallableTypeStillReferencesArgumentAtTopLevel.ts" }
TypeScript/tests/cases/compiler/moduleIdentifiers.ts_3_153
dule M { interface P { x: number; y: number; } export var a = 1 } //var p: M.P; //var m: M = M; var x1 = M.a; //var x2 = m.a; //var q: m.P;
{ "end_byte": 153, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleIdentifiers.ts" }
TypeScript/tests/cases/compiler/checkSuperCallBeforeThisAccessing4.ts_3_358
ass Based { } class Derived extends Based { public x: number; constructor() { (() => { this; // No error }); () => { this; // No error }; (() => { this; // No error })(); super(); super(); this.x = 10;...
{ "end_byte": 358, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/checkSuperCallBeforeThisAccessing4.ts" }
TypeScript/tests/cases/compiler/typeInterfaceDeclarationsInBlockStatements1.ts_0_458
// @strict: true // @declaration: true // https://github.com/microsoft/TypeScript/issues/60175 function f1() { if (true) type s = string; console.log("" as s); } function f2() { if (true) { type s = string; } console.log("" as s); } function f3() { if (true) interface s { length: number; ...
{ "end_byte": 458, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeInterfaceDeclarationsInBlockStatements1.ts" }
TypeScript/tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors1.ts_0_175
(arg1?, arg2) => 101; (...arg?) => 102; (...arg) => 103; (...arg:number [] = []) => 104; // Uninitialized parameter makes the initialized one required (arg1 = 1, arg2) => 1;
{ "end_byte": 175, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors1.ts" }
TypeScript/tests/cases/compiler/nodeNextPackageSelfNameWithOutDirRootDir.ts_0_286
// @module: nodenext // @outDir: ./dist // @rootDir: . // @filename: package.json { "name": "@this/package", "type": "module", "exports": { ".": "./dist/index.js" } } // @filename: index.ts import * as me from "@this/package"; me.thing(); export function thing(): void {}
{ "end_byte": 286, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nodeNextPackageSelfNameWithOutDirRootDir.ts" }
TypeScript/tests/cases/compiler/tsxDeepAttributeAssignabilityError.tsx_0_517
// @jsx: react // @noLib: true // @skipLibCheck: true // @libFiles: react.d.ts,lib.d.ts // @Filename: my-component.tsx import * as React from 'react' interface MyProps { x: string; y: MyInnerProps; } interface MyInnerProps { value: string; } export function MyComponent(_props: MyProps) { return <spa...
{ "end_byte": 517, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/tsxDeepAttributeAssignabilityError.tsx" }
TypeScript/tests/cases/compiler/deepExcessPropertyCheckingWhenTargetIsIntersection.ts_0_639
interface StatelessComponent<P = {}> { (props: P & { children?: number }, context?: any): null; } const TestComponent: StatelessComponent<TestProps> = (props) => { return null; } interface ITestProps { ariaLabel?: string; } interface NestedProp<TProps> { props: TProps; } interface TestProps { icon: Ne...
{ "end_byte": 639, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/deepExcessPropertyCheckingWhenTargetIsIntersection.ts" }
TypeScript/tests/cases/compiler/spyComparisonChecking.ts_0_542
interface Spy { (...params: any[]): any; identity: string; and: Function; mostRecentCall: { args: any[]; }; argsForCall: any[]; } type SpyObj<T> = T & { [k in keyof T]: Spy; } declare function createSpyObj<T>( name: string, names: Array<keyof T>): SpyObj<T>; function mock<T>(spyName: str...
{ "end_byte": 542, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/spyComparisonChecking.ts" }
TypeScript/tests/cases/compiler/metadataOfClassFromAlias.ts_0_387
// @experimentalDecorators: true // @emitDecoratorMetadata: true // @target: es5 // @module: commonjs // @filename: auxiliry.ts export class SomeClass { field: string; } //@filename: test.ts import { SomeClass } from './auxiliry'; function annotation(): PropertyDecorator { return (target: any): void => { }; }...
{ "end_byte": 387, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/metadataOfClassFromAlias.ts" }
TypeScript/tests/cases/compiler/thisInSuperCall3.ts_0_145
class Base { constructor(a: any) {} } class Foo extends Base { public x: number = 0; constructor() { super(this); } }
{ "end_byte": 145, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/thisInSuperCall3.ts" }
TypeScript/tests/cases/compiler/assignmentCompatability1.ts_0_327
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 = {};; export var __val__aa = aa; } __test2__.__val__aa = __test1__.__va...
{ "end_byte": 327, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatability1.ts" }
TypeScript/tests/cases/compiler/isolatedDeclarationsAddUndefined2.ts_0_555
// @isolatedDeclarations: true // @declaration: true // @strict: true // https://github.com/microsoft/TypeScript/issues/60123 export class Bar { constructor(private x?: Array | undefined) {} } export class Bar2 { constructor(private x?: Array) {} } export class Bar3 { constructor(private x: Array | unde...
{ "end_byte": 555, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/isolatedDeclarationsAddUndefined2.ts" }
TypeScript/tests/cases/compiler/es6ExportEqualsInterop.ts_0_3957
// @module: commonjs // @filename: modules.d.ts declare module "interface" { interface Foo { x: number; y: number; } export = Foo; } declare module "variable" { var Foo: { a: number; b: number; } export = Foo; } declare module "interface-variable" { interfa...
{ "end_byte": 3957, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ExportEqualsInterop.ts" }
TypeScript/tests/cases/compiler/declarationEmitDestructuring5.ts_3_202
@declaration: true function baz([, z, , ]) { } function foo([, b, ]: [any, any]): void { } function bar([z, , , ]) { } function bar1([z, , , ] = [1, 3, 4, 6, 7]) { } function bar2([,,z, , , ]) { }
{ "end_byte": 202, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitDestructuring5.ts" }
TypeScript/tests/cases/compiler/parseShortform.ts_0_208
interface I { w: { z: I; (): boolean; [s: string]: { x: any; y: any; }; [n: number]: { x: any; y: any; }; }; x: boolean; y: (s: string) => boolean; z: I; }
{ "end_byte": 208, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parseShortform.ts" }
TypeScript/tests/cases/compiler/readonlyInNonPropertyParameters.ts_0_218
//@target: ES5 // `readonly` won't work outside of property parameters class X { method(readonly x: number) {} set x(readonly value: number) {} } (readonly x) => 0; // OK to use `readonly` as a name (readonly) => 0;
{ "end_byte": 218, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/readonlyInNonPropertyParameters.ts" }
TypeScript/tests/cases/compiler/super2.ts_0_668
// Case 5 class Base5 { public x() { return "BaseX"; } public y() { return "BaseY"; } } class Sub5 extends Base5 { public x() { return "SubX"; } } class SubSub5 extends Sub5 { public x() { return super.x(); } public y() { return super.y(...
{ "end_byte": 668, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/super2.ts" }
TypeScript/tests/cases/compiler/multiLinePropertyAccessAndArrowFunctionIndent1.ts_0_159
return this.edit(role) .then((role: Role) => this.roleService.add(role) .then((data: ng.IHttpPromiseCallbackArg<Role>) => data.data));
{ "end_byte": 159, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/multiLinePropertyAccessAndArrowFunctionIndent1.ts" }
TypeScript/tests/cases/compiler/accessorWithoutBody2.ts_0_38
// @target: ES5 var v = { set foo(a) }
{ "end_byte": 38, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/accessorWithoutBody2.ts" }
TypeScript/tests/cases/compiler/interfacedecl.ts_0_585
// @declaration: true interface a0 { (): string; (a, b, c?: string): number; new (): string; new (s: string); [n: number]: ()=>string; [s: string]: any; p1; p2: string; p3?; p4?: number; p5: (s: number) =>string; f1(); f2? (); f3(a: string): number; f4...
{ "end_byte": 585, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/interfacedecl.ts" }
TypeScript/tests/cases/compiler/interfaceClassMerging2.ts_0_517
interface Foo { interfaceFooMethod(): this; interfaceFooProperty: this; } class Foo { classFooProperty: this; classFooMethod(): this { return this; } } interface Bar { interfaceBarMethod(): this; interfaceBarProperty: this; } class Bar extends Foo { classBarProperty: this; ...
{ "end_byte": 517, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/interfaceClassMerging2.ts" }
TypeScript/tests/cases/compiler/optionalParameterInDestructuringWithInitializer.ts_0_1242
// @strictNullChecks: true // https://github.com/Microsoft/TypeScript/issues/17080 declare function f(a:number,b:number): void; function func1( {a, b}: {a: number, b?: number} = {a: 1, b: 2} ) { f(a, b) // error } function func2( {a, b = 3}: {a: number, b?:number} = {a: 1,b: 2} ) { f(a, b) // no error } fun...
{ "end_byte": 1242, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/optionalParameterInDestructuringWithInitializer.ts" }
TypeScript/tests/cases/compiler/capturedLetConstInLoop1_ES6.ts_0_1748
// @target: ES6 //==== let for (let x in {}) { (function() { return x}); (() => x); } for (let x of []) { (function() { return x}); (() => x); } for (let x = 0; x < 1; ++x) { (function() { return x}); (() => x); } while (1 === 1) { let x; (function() { return x}); (() => x); } do...
{ "end_byte": 1748, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/capturedLetConstInLoop1_ES6.ts" }
TypeScript/tests/cases/compiler/raiseErrorOnParameterProperty.ts_0_68
class C1 { constructor(public x: X) { } } var c1 = new C1(0);
{ "end_byte": 68, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/raiseErrorOnParameterProperty.ts" }
TypeScript/tests/cases/compiler/externSyntax.ts_0_168
declare var v; declare module M { export class D { public p; } export class C { public f(); public g() { } // error body } }
{ "end_byte": 168, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/externSyntax.ts" }
TypeScript/tests/cases/compiler/importHelpersWithImportOrExportDefaultNoTslib.3.ts_0_274
// @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 import { default as b } from "./a"; void b;
{ "end_byte": 274, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importHelpersWithImportOrExportDefaultNoTslib.3.ts" }
TypeScript/tests/cases/compiler/constantOverloadFunction.ts_0_368
class Base { foo() { } } class Derived1 extends Base { bar() { } } class Derived2 extends Base { baz() { } } class Derived3 extends Base { biz() { } } function foo(tagName: 'canvas'): Derived1; function foo(tagName: 'div'): Derived2; function foo(tagName: 'span'): Derived3; function foo(tagName: string): Base; functi...
{ "end_byte": 368, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constantOverloadFunction.ts" }
TypeScript/tests/cases/compiler/crashInresolveReturnStatement.ts_0_386
class WorkItemToolbar { public onToolbarItemClick() { WITDialogs.createCopyOfWorkItem(); } } class CreateCopyOfWorkItemDialog { public getDialogResult() { return null; } } function createWorkItemDialog<P0>(dialogType: P0) { } class WITDialogs { public static createCopyOfWorkItem() { ...
{ "end_byte": 386, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/crashInresolveReturnStatement.ts" }
TypeScript/tests/cases/compiler/selfReference.ts_0_107
// @noImplicitAny: true declare function asFunction<T>(value: T): () => T; asFunction(() => { return 1; });
{ "end_byte": 107, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/selfReference.ts" }
TypeScript/tests/cases/compiler/unionWithIndexSignature.ts_0_563
// @strict: true interface NumList { kind: 'n'; [x: number]: number; } interface StrList { kind: 's'; [x: number]: string; } export function foo<T extends NumList | StrList>(arr: T & (NumList | StrList)) { let zz = arr[1]; // Error } // Repro from #38102 export type TypedArray = Int32Array | Uint8Array; ...
{ "end_byte": 563, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unionWithIndexSignature.ts" }
TypeScript/tests/cases/compiler/namespaceMergedWithFunctionWithOverloadsUsage.ts_0_314
// @filename: file.d.ts declare namespace Foo { interface Whatever { prop: any; } } declare function Foo(opts?: Foo.Whatever): void; declare function Foo(cb: Function, opts?: Foo.Whatever): void; export = Foo; // @filename: index.ts import X = require("./file"); X(0); // shouldn't cause a crash
{ "end_byte": 314, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/namespaceMergedWithFunctionWithOverloadsUsage.ts" }
TypeScript/tests/cases/compiler/undefinedTypeAssignment3.ts_0_22
var undefined = null;
{ "end_byte": 22, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/undefinedTypeAssignment3.ts" }
TypeScript/tests/cases/compiler/alwaysStrictModule3.ts_3_82
@alwaysStrict: true // @module: es2015 // module ES2015 export const a = 1;
{ "end_byte": 82, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/alwaysStrictModule3.ts" }
TypeScript/tests/cases/compiler/assignToInvalidLHS.ts_0_182
declare var y:any; // Below is actually valid JavaScript (see http://es5.github.com/#x8.7 ), even though will always fail at runtime with 'invalid left-hand side' var x = new y = 5;
{ "end_byte": 182, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignToInvalidLHS.ts" }
TypeScript/tests/cases/compiler/nestedThisContainer.ts_0_177
// @noImplicitThis:true type Foo = any; const foo: Foo = {}; foo.bar = function () { const self: Foo = this; }; foo.zab = (function () { const self: Foo = this; });
{ "end_byte": 177, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nestedThisContainer.ts" }
TypeScript/tests/cases/compiler/templateLiteralIntersection3.ts_0_382
// @strict: true // @noEmit: true type Path = string & { _pathBrand: any }; declare const path: Path; declare const options1: { prop: number; } & { [k: string]: boolean; }; options1[`foo`] = false; options1[`foo/${path}`] = false; // Lowercase<`foo/${Path}`> => `foo/${Lowercase<Path>}` declare const lowercasePath...
{ "end_byte": 382, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/templateLiteralIntersection3.ts" }
TypeScript/tests/cases/compiler/modularizeLibrary_UsingES5LibAndES6FeatureLibs.ts_3_285
@lib: es5,es2015.core,es2015.symbol,es2015.proxy,es2015.generator,es2015.iterable,es2015.reflect // @target: es6 var s = Symbol(); var t = {}; var p = new Proxy(t, {}); Reflect.ownKeys({}); function* idGen() { let i = 10; while (i < 20) { yield i + 2; } }
{ "end_byte": 285, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/modularizeLibrary_UsingES5LibAndES6FeatureLibs.ts" }
TypeScript/tests/cases/compiler/jsFileCompilationOptionalClassElementSyntaxOfClass.ts_0_110
// @allowJs: true // @noTypesAndSymbols: true // @filename: a.js class C { foo?() { } bar? = 1; }
{ "end_byte": 110, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationOptionalClassElementSyntaxOfClass.ts" }
TypeScript/tests/cases/compiler/classVarianceResolveCircularity1.ts_0_229
// @strict: true // Issue #52813 class Bar<T> { num!: number; Value = callme(this).num; Field: number = callme(this).num; } declare function callme(x: Bar<any>): Bar<any>; declare function callme(x: object): string;
{ "end_byte": 229, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classVarianceResolveCircularity1.ts" }
TypeScript/tests/cases/compiler/checkJsFiles_skipDiagnostics.ts_0_411
// @allowJs: true // @checkJs: true // @noEmit: true // @fileName: a.js var x = 0; /// @ts-ignore x(); /// @ts-ignore x(); /// @ts-ignore x( 2, 3); // @ts-ignore // come comment // some other comment // @another x(); /* @ts-ignore */ /*another comment that could be multiline*/ x(); /* @ts-ignore c...
{ "end_byte": 411, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/checkJsFiles_skipDiagnostics.ts" }
TypeScript/tests/cases/compiler/import_reference-to-type-alias.ts_0_382
// @Filename: file1.ts export module App { export module Services { export class UserServices { public getUserName(): string { return "Bill Gates"; } } } } // @Filename: file2.ts // @module: amd import appJs = require("file1"); import Services = appJs.App...
{ "end_byte": 382, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/import_reference-to-type-alias.ts" }
TypeScript/tests/cases/compiler/inheritanceGrandParentPrivateMemberCollision.ts_0_112
class A { private myMethod() { } } class B extends A { } class C extends B { private myMethod() { } }
{ "end_byte": 112, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inheritanceGrandParentPrivateMemberCollision.ts" }
TypeScript/tests/cases/compiler/controlFlowCommaExpressionFunctionCall.ts_0_301
const otherValue = () => true; const value : number | string = null as any; function isNumber(obj: any): obj is number { return true; // method implementation irrelevant } // Bad case - fails if (isNumber((otherValue(), value))) { const b = value; // string | number , but should be number }
{ "end_byte": 301, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/controlFlowCommaExpressionFunctionCall.ts" }
TypeScript/tests/cases/compiler/continueNotInIterationStatement4.ts_0_90
// @allowUnusedLabels: true TWO: while (true){ var x = () => { continue TWO; } }
{ "end_byte": 90, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/continueNotInIterationStatement4.ts" }
TypeScript/tests/cases/compiler/genericFunctionsWithOptionalParameters2.ts_0_284
interface Utils { fold<T, S>(c: Array<T>, folder?: (s: S, t: T) => T, init?: S): T; } var utils: Utils; utils.fold(); // error utils.fold(null); // no error utils.fold(null, null); // no error utils.fold(null, null, null); // error: Unable to invoke type with no call signatures
{ "end_byte": 284, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericFunctionsWithOptionalParameters2.ts" }
TypeScript/tests/cases/compiler/destructureOfVariableSameAsShorthand.ts_0_700
// https://github.com/microsoft/TypeScript/issues/38969 interface AxiosResponse<T = never> { data: T; } declare function get<T = never, R = AxiosResponse<T>>(): Promise<R>; async function main() { // These work examples as expected get().then((response) => { // body is never const body = r...
{ "end_byte": 700, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/destructureOfVariableSameAsShorthand.ts" }
TypeScript/tests/cases/compiler/invalidTripleSlashReference.ts_0_200
/// <reference path='filedoesnotexist.ts'/> /// <reference path='otherdoesnotexist.d.ts'/> // this test doesn't actually give the errors you want due to the way the compiler reports errors var x = 1;
{ "end_byte": 200, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/invalidTripleSlashReference.ts" }
TypeScript/tests/cases/compiler/modularizeLibrary_ErrorFromUsingES6FeaturesWithOnlyES5Lib.ts_3_959
@lib: es5 // @target: es6 // All will be error from using ES6 features but only include ES5 library // Using Es6 array function f(x: number, y: number, z: number) { return Array.from(arguments); } f(1, 2, 3); // no error // Using ES6 collection var m = new Map<string, number>(); m.clear(); // Using ES6 iterabl...
{ "end_byte": 959, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/modularizeLibrary_ErrorFromUsingES6FeaturesWithOnlyES5Lib.ts" }