_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/identityForSignaturesWithTypeParametersAndAny.ts_0_350
var f: <T, U>(x: T, y: U) => T; var f: <T, U>(x: any, y: any) => any; var g: <T, U>(x: T, y: U) => T; var g: <T>(x: any, y: any) => any; var h: <T, U>(x: T, y: U) => T; var h: (x: any, y: any) => any; var i: <T, U>(x: T, y: U) => T; var i: <T, U>(x: any, y: string) => any; var j: <T, U>(x: T, y: U) => T; var j: <T,...
{ "end_byte": 350, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/identityForSignaturesWithTypeParametersAndAny.ts" }
TypeScript/tests/cases/compiler/couldNotSelectGenericOverload.ts_0_250
function makeArray<T>(items: T[]): T[] { return items; } var b = [1, ""]; var b1G = makeArray(1, ""); // any, no error var b2G = makeArray(b); // any[] function makeArray2(items: any[]): any[] { return items; } var b3G = makeArray2(1, ""); // error
{ "end_byte": 250, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/couldNotSelectGenericOverload.ts" }
TypeScript/tests/cases/compiler/declFileGenericClassWithGenericExtendedClass.ts_0_219
// @declaration: true interface IFoo { baz: Baz; } class Base<T> { } class Derived<T> extends Base<T> { } interface IBar<T> { derived: Derived<T>; } class Baz implements IBar<Baz> { derived: Derived<Baz>; }
{ "end_byte": 219, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileGenericClassWithGenericExtendedClass.ts" }
TypeScript/tests/cases/compiler/narrowingByDiscriminantInLoop.ts_0_1740
// @strictNullChecks: true // Repro from #9977 type IDLMemberTypes = OperationMemberType | ConstantMemberType; interface IDLTypeDescription { origin: string; } interface InterfaceType { members: IDLMemberTypes[]; } interface OperationMemberType { type: "operation"; idlType: IDLTypeDescription; } i...
{ "end_byte": 1740, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowingByDiscriminantInLoop.ts" }
TypeScript/tests/cases/compiler/sideEffectImports1.ts_0_181
// @noUncheckedSideEffectImports: true,false // @module: commonjs,nodenext,preserve import "does-not-exist"; import "./does-not-exist-either"; import "./does-not-exist-either.js";
{ "end_byte": 181, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sideEffectImports1.ts" }
TypeScript/tests/cases/compiler/expandoFunctionNestedAssigmentsDeclared.ts_0_1429
// @lib: esnext // @declaration: true function Foo(): void { } declare namespace Foo { var bla: { foo: number; }; var baz: number; var bar: number; var fromIf: number; var inIf: number; var fromWhileCondition: number; var fromWhileBody: number; var fromWhileBodyNested: numb...
{ "end_byte": 1429, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/expandoFunctionNestedAssigmentsDeclared.ts" }
TypeScript/tests/cases/compiler/objectCreationExpressionInFunctionParameter.ts_0_122
class A { constructor(public a1: string) { } } function foo(x = new A(123)) { //should error, 123 is not string }}
{ "end_byte": 122, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectCreationExpressionInFunctionParameter.ts" }
TypeScript/tests/cases/compiler/ambientPropertyDeclarationInJs.ts_0_212
// @allowJs: true // @checkJs: true // @noEmit: true // @filename: /test.js class Foo { constructor() { this.prop = {}; } declare prop: string; method() { this.prop.foo } }
{ "end_byte": 212, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ambientPropertyDeclarationInJs.ts" }
TypeScript/tests/cases/compiler/promiseIdentity.ts_0_715
export interface IPromise<T> { then<U>(callback: (x: T) => IPromise<U>): IPromise<U>; } interface Promise<T> { then<U>(callback: (x: T) => Promise<U>): Promise<U>; } var x: IPromise<string>; var x: Promise<string>; interface IPromise2<T, V> { then<U, W>(callback: (x: T) => IPromise2<U, W>): IPromise2<W, U...
{ "end_byte": 715, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/promiseIdentity.ts" }
TypeScript/tests/cases/compiler/awaitInClassInAsyncFunction.ts_0_233
// @target: esnext // @useDefineForClassFields: false // https://github.com/microsoft/TypeScript/issues/34887 async function bar() { return 2; } async function foo() { return new class { baz = await bar(); }; }
{ "end_byte": 233, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/awaitInClassInAsyncFunction.ts" }
TypeScript/tests/cases/compiler/decoratorMetadataForMethodWithNoReturnTypeAnnotation01.ts_0_250
// @noemithelpers: true // @experimentaldecorators: true // @emitdecoratormetadata: true // @target: es5 declare var decorator: any; class MyClass { constructor(test: string, test2: number) { } @decorator doSomething() { } }
{ "end_byte": 250, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/decoratorMetadataForMethodWithNoReturnTypeAnnotation01.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationDestructuringForObjectBindingPattern.ts_0_2113
// @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": 2113, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationDestructuringForObjectBindingPattern.ts" }
TypeScript/tests/cases/compiler/objectLiteralMemberWithoutBlock1.ts_0_18
var v = { foo(); }
{ "end_byte": 18, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectLiteralMemberWithoutBlock1.ts" }
TypeScript/tests/cases/compiler/importUsedInExtendsList1.ts_0_338
// @module: commonjs // @Filename: importUsedInExtendsList1_require.ts export class Super { foo: string; } // @Filename: importUsedInExtendsList1_1.ts ///<reference path='importUsedInExtendsList1_require.ts'/> import foo = require('./importUsedInExtendsList1_require'); class Sub extends foo.Super { } var s: Sub; var r...
{ "end_byte": 338, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importUsedInExtendsList1.ts" }
TypeScript/tests/cases/compiler/allowJscheckJsTypeParameterNoCrash.ts_0_471
// @checkJs: true // @allowJs: true // @outDir: ./dist // @filename: func.ts interface ComponentOptions<V> { watch: Record<string, WatchHandler<any>>; } type WatchHandler<T> = (val: T) => void; declare function extend(options: ComponentOptions<{}>): void; export var vextend = extend; // @filename: app.js import {ve...
{ "end_byte": 471, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/allowJscheckJsTypeParameterNoCrash.ts" }
TypeScript/tests/cases/compiler/scopeCheckExtendedClassInsideStaticMethod1.ts_0_129
class C { private v; public p; static s; } class D extends C { static c() { v = 1; this.p = 1; s = 1; } }
{ "end_byte": 129, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/scopeCheckExtendedClassInsideStaticMethod1.ts" }
TypeScript/tests/cases/compiler/callSignaturesShouldBeResolvedBeforeSpecialization.ts_0_266
interface I1<T> { (value: T): void; field1: I1<boolean>; } function foo() { var test: I1<string>; test("expects boolean instead of string"); // should not error - "test" should not expect a boolean test(true); // should error - string expected }
{ "end_byte": 266, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/callSignaturesShouldBeResolvedBeforeSpecialization.ts" }
TypeScript/tests/cases/compiler/requireOfJsonFileWithoutExtension.ts_0_342
// @module: commonjs // @outdir: out/ // @allowJs: true // @fullEmitPaths: true // @resolveJsonModule: true // @Filename: file1.ts import b1 = require('./b'); // This should not resolve let x = b1.a; import b2 = require('./b.json'); if (x) { let b = b2.b; x = (b1.b === b); } // @Filename: b.json { "a": tr...
{ "end_byte": 342, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/requireOfJsonFileWithoutExtension.ts" }
TypeScript/tests/cases/compiler/assignmentCompatBug2.ts_0_653
var b2: { b: number;} = { a: 0 }; // error b2 = { a: 0 }; // error b2 = {b: 0, a: 0 }; var b3: { f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }; b3 = { f: (n) => { return 0; }, g: (s) => { return 0; }, m: 0, }; // ok b3 = { f: (n) => { return 0; }, g: (s) ...
{ "end_byte": 653, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatBug2.ts" }
TypeScript/tests/cases/compiler/library_RegExpExecArraySlice.ts_0_198
// RegExpExecArray.slice can have zero, one, or two arguments var regExpExecArrayValue: RegExpExecArray; regExpExecArrayValue.slice(); regExpExecArrayValue.slice(0); regExpExecArrayValue.slice(0,1);
{ "end_byte": 198, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/library_RegExpExecArraySlice.ts" }
TypeScript/tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2023.ts_1_767
// @noEmit: true // @target: es5, esnext // @strict: true export let array = [0, 2, 3, 4]; function somePredicate(x: any): boolean { return x === 4; } export let lastIndex1 = array.findLastIndex(v => v === 4); export let lastIndex2 = array.findLastIndex(somePredicate); export let last1 = array.findLast(somePred...
{ "end_byte": 767, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2023.ts" }
TypeScript/tests/cases/compiler/es6ImportNamedImportMergeErrors.ts_0_739
// @module: commonjs // @filename: es6ImportNamedImportMergeErrors_0.ts export var a = 10; export var x = a; export var z = a; export var z1 = a; // @filename: es6ImportNamedImportMergeErrors_1.ts import { a } from "./es6ImportNamedImportMergeErrors_0"; interface a { } // shouldnt be error import { x as x1 } from "./...
{ "end_byte": 739, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ImportNamedImportMergeErrors.ts" }
TypeScript/tests/cases/compiler/trackedSymbolsNoCrash.ts_0_7125
// @strict: true // @declaration: true // @filename: ast.ts export enum SyntaxKind { Node0, Node1, Node2, Node3, Node4, Node5, Node6, Node7, Node8, Node9, Node10, Node11, Node12, Node13, Node14, Node15, Node16, Node17, Node18, Node19, Node20, Node21, Node22, Node23, Node24, Node25, Node26, Node27, Node28, Node29, Node...
{ "end_byte": 7125, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/trackedSymbolsNoCrash.ts" }
TypeScript/tests/cases/compiler/trackedSymbolsNoCrash.ts_7126_9324
export interface Node86 { kind: SyntaxKind.Node86; propNode86: number; } export interface Node87 { kind: SyntaxKind.Node87; propNode87: number; } export interface Node88 { kind: SyntaxKind.Node88; propNode88: number; } export interface Node89 { kind: SyntaxKind.Node89; propNode89: number; } export interface Node90 { ki...
{ "end_byte": 9324, "start_byte": 7126, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/trackedSymbolsNoCrash.ts" }
TypeScript/tests/cases/compiler/parseJsxElementInUnaryExpressionNoCrash2.ts_0_64
// @allowJs: true // @outDir: ./out // @filename: a.js ~<></> <
{ "end_byte": 64, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parseJsxElementInUnaryExpressionNoCrash2.ts" }
TypeScript/tests/cases/compiler/declarationEmitCastReusesTypeNode1.ts_0_824
// @strict: true // @strictNullChecks: true,false // @declaration: true // @noTypesAndSymbols: true // @emitDeclarationOnly: true type P = { } & { name: string } export let vLet = null! as P export const vConst = null! as P export function fn(p = null! as P) {} export function fnWithRequiredDefaultParam(p = null! as...
{ "end_byte": 824, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitCastReusesTypeNode1.ts" }
TypeScript/tests/cases/compiler/requireOfAnEmptyFile1.ts_0_179
// @module: commonjs //requireOfAnEmptyFile1 // @Filename: requireOfAnEmptyFile1_a.ts import fs = require('./requireOfAnEmptyFile1_b'); // @Filename: requireOfAnEmptyFile1_b.ts
{ "end_byte": 179, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/requireOfAnEmptyFile1.ts" }
TypeScript/tests/cases/compiler/isolatedModulesPlainFile-ES6.ts_0_90
// @target: es6 // @isolatedModules: true declare function run(a: number): void; run(1);
{ "end_byte": 90, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/isolatedModulesPlainFile-ES6.ts" }
TypeScript/tests/cases/compiler/contextualTyping15.ts_0_89
class foo { public bar: { (): number; (i: number): number; } = function() { return 1 }; }
{ "end_byte": 89, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTyping15.ts" }
TypeScript/tests/cases/compiler/optionsInlineSourceMapMapRoot.ts_0_57
// @mapRoot: local // @inlineSourceMap: true var a = 10;
{ "end_byte": 57, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/optionsInlineSourceMapMapRoot.ts" }
TypeScript/tests/cases/compiler/argumentsReferenceInConstructor7_Js.ts_0_189
// @declaration: true // @allowJs: true // @emitDeclarationOnly: true // @filename: /a.js class A { constructor() { /** * @type Function */ this.callee = arguments.callee; } }
{ "end_byte": 189, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/argumentsReferenceInConstructor7_Js.ts" }
TypeScript/tests/cases/compiler/specializedLambdaTypeArguments.ts_0_66
class X<A> { prop: X< <Tany>() => Tany >; } var a: X<boolean>;
{ "end_byte": 66, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/specializedLambdaTypeArguments.ts" }
TypeScript/tests/cases/compiler/reactNamespaceJSXEmit.tsx_0_266
//@jsx: react //@reactNamespace: myReactLib declare var myReactLib: any; declare var foo: any; declare var Bar: any; declare var _Bar: any; declare var x: any; <foo data/>; <Bar x={x} />; <x-component />; <Bar {...x} />; <Bar { ...x } y={2} />; <_Bar { ...x } />;
{ "end_byte": 266, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reactNamespaceJSXEmit.tsx" }
TypeScript/tests/cases/compiler/functionsWithImplicitReturnTypeAssignableToUndefined.ts_0_1263
// @noImplicitReturns: false // @strictNullChecks: true, false function f1(): unknown { if (Math.random() < 0.5) return true; // Implicit return, but undefined is always assignable to unknown. } type MyUnknown = unknown; function f2(): unknown { if (Math.random() < 0.5) return true; // Implicit retu...
{ "end_byte": 1263, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionsWithImplicitReturnTypeAssignableToUndefined.ts" }
TypeScript/tests/cases/compiler/declarationEmitAliasFromIndirectFile.ts_0_818
// @declaration: true // @filename: locale.d.ts export type Locale = { weekdays: { shorthand: [string, string, string, string, string, string, string]; longhand: [string, string, string, string, string, string, string]; }; }; export type CustomLocale = { weekdays: { shorthand: [stri...
{ "end_byte": 818, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitAliasFromIndirectFile.ts" }
TypeScript/tests/cases/compiler/genericCallInferenceWithGenericLocalFunction.ts_0_328
// @strict: true // @noEmit: true // https://github.com/microsoft/TypeScript/issues/43961 const createTransform = <I, O>(tr: (from: I) => O) => tr; function withP2<P>(p: P) { const m = <I,>(from: I) => ({ ...from, ...p }); return createTransform(m); } const addP2 = withP2({ foo: 1 }); const added2 = addP2({ bar...
{ "end_byte": 328, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericCallInferenceWithGenericLocalFunction.ts" }
TypeScript/tests/cases/compiler/invokingNonGenericMethodWithTypeArguments1.ts_0_68
class Foo { constructor() { this.foo<string>(); } }
{ "end_byte": 68, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/invokingNonGenericMethodWithTypeArguments1.ts" }
TypeScript/tests/cases/compiler/declarationEmitClassMemberWithComputedPropertyName.ts_0_867
// @target: esnext // @declaration: true // @emitDeclarationOnly: true const k1 = Symbol(); const k2 = 'foo' as const; const k3 = Symbol(); const k4 = 'prop' as const; class Foo { static [k1](): number { return 1; } [k1](): string { return ""; } static [k2]() { return 1; ...
{ "end_byte": 867, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitClassMemberWithComputedPropertyName.ts" }
TypeScript/tests/cases/compiler/complicatedPrivacy.ts_0_1657
// @target: es5 module m1 { export module m2 { export function f1(c1: C1) { } export function f2(c2: C2) { } export class C2 implements m3.i3 { public get p1(arg) { return new C1(); } public set p1(arg1: C1) { ...
{ "end_byte": 1657, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/complicatedPrivacy.ts" }
TypeScript/tests/cases/compiler/strictOptionalProperties1.ts_0_5311
// @strict: true // @exactOptionalPropertyTypes: true // @declaration: true function f1(obj: { a?: string, b?: string | undefined }) { let a = obj.a; // string | undefined let b = obj.b; // string | undefined obj.a = 'hello'; obj.b = 'hello'; obj.a = undefined; // Error obj.b = undefined; } ...
{ "end_byte": 5311, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/strictOptionalProperties1.ts" }
TypeScript/tests/cases/compiler/narrowingUnionToUnion.ts_0_6059
// @strict: true // @declaration: true type Falsy = false | 0 | 0n | '' | null | undefined; declare function isFalsy(value: unknown): value is Falsy; function fx1(x: string | number | undefined) { if (isFalsy(x)) { x; // "" | 0 | undefined } } function fx2<T>(x: T | undefined) { if (isFalsy(x))...
{ "end_byte": 6059, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowingUnionToUnion.ts" }
TypeScript/tests/cases/compiler/arrayConcat3.ts_0_283
// @strictFunctionTypes: true // TODO: remove lib hack when https://github.com/Microsoft/TypeScript/issues/20454 is fixed type Fn<T extends object> = <U extends T>(subj: U) => U function doStuff<T extends object, T1 extends T>(a: Array<Fn<T>>, b: Array<Fn<T1>>) { b.concat(a); }
{ "end_byte": 283, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arrayConcat3.ts" }
TypeScript/tests/cases/compiler/exportAlreadySeen.ts_0_372
module M { export export var x = 1; export export function f() { } export export module N { export export class C { } export export interface I { } } } declare module A { export export var x; export export function f() export export module N { export export class...
{ "end_byte": 372, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportAlreadySeen.ts" }
TypeScript/tests/cases/compiler/systemModuleConstEnums.ts_0_239
// @module: system declare function use(a: any); const enum TopLevelConstEnum { X } export function foo() { use(TopLevelConstEnum.X); use(M.NonTopLevelConstEnum.X); } module M { export const enum NonTopLevelConstEnum { X } }
{ "end_byte": 239, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/systemModuleConstEnums.ts" }
TypeScript/tests/cases/compiler/constraintPropagationThroughReturnTypes.ts_0_110
function g<T>(x: T): T { return x; } function f<S extends { foo: string }>(x: S) { var y = g(x); y; }
{ "end_byte": 110, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constraintPropagationThroughReturnTypes.ts" }
TypeScript/tests/cases/compiler/jsxElementClassTooManyParams.tsx_0_642
// @strict: true // @jsx: preserve namespace JSX { export interface Element {} export interface IntrinsicClassAttributes<TClass, TOther=never> { ref?: TClass; item?: TOther; } export interface ElementClass extends Element {} export interface ElementAttributesProperty { props: {}; } ...
{ "end_byte": 642, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsxElementClassTooManyParams.tsx" }
TypeScript/tests/cases/compiler/allowSyntheticDefaultImports1.ts_0_204
// @allowSyntheticDefaultImports: true // @module: commonjs // @Filename: a.ts import Namespace from "./b"; export var x = new Namespace.Foo(); // @Filename: b.d.ts export class Foo { member: string; }
{ "end_byte": 204, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/allowSyntheticDefaultImports1.ts" }
TypeScript/tests/cases/compiler/emptyTypeArgumentList.ts_0_124
function foo<T>() { } foo<>(); // https://github.com/microsoft/TypeScript/issues/33041 function noParams() {} noParams<>();
{ "end_byte": 124, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emptyTypeArgumentList.ts" }
TypeScript/tests/cases/compiler/generatorES6_1.ts_0_45
// @target: es6 function* foo() { yield }
{ "end_byte": 45, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/generatorES6_1.ts" }
TypeScript/tests/cases/compiler/exportedVariable1.ts_0_84
//@module: amd export var foo = {name: "Bill"}; var upper = foo.name.toUpperCase();
{ "end_byte": 84, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportedVariable1.ts" }
TypeScript/tests/cases/compiler/propertyAssignment.ts_2_316
var foo1: { new ():any; } var bar1: { x : number; } var foo2: { [index]; } // should be an error, used to be indexer, now it is a computed property var bar2: { x : number; } var foo3: { ():void; } var bar3: { x : number; } foo1 = bar1; // should be an error foo2 = bar2; foo3 = bar3; // should be an error
{ "end_byte": 316, "start_byte": 2, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/propertyAssignment.ts" }
TypeScript/tests/cases/compiler/allowJsCrossMonorepoPackage.ts_0_951
// @Filename: /node_modules/pkg/index.d.ts export declare function pkg(): "pkg"; // @Filename: /packages/shared/package.json { "name": "shared", "version": "1.0.0", "type": "module", "exports": "./index.js" } // @Filename: /packages/shared/utils.js export { pkg } from "pkg"; // @Filename: /packages/s...
{ "end_byte": 951, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/allowJsCrossMonorepoPackage.ts" }
TypeScript/tests/cases/compiler/genericContextualTypingSpecialization.ts_0_81
var b: number[]; b.reduce<number>((c, d) => c + d, 0); // should not error on '+'
{ "end_byte": 81, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericContextualTypingSpecialization.ts" }
TypeScript/tests/cases/compiler/blockScopedNamespaceDifferentFile.ts_0_423
// @target: es5 // @outFile: out.js // @module: amd // #15734 failed when test.ts comes before typings.d.ts // @Filename: test.ts namespace C { export class Name { static funcData = A.AA.func(); static someConst = A.AA.foo; constructor(parameters) {} } } // @Filename: typings.d.ts dec...
{ "end_byte": 423, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/blockScopedNamespaceDifferentFile.ts" }
TypeScript/tests/cases/compiler/stringMatchAll.ts_0_127
// @target: es2020 const matches = "matchAll".matchAll(/\w/g); const array = [...matches]; const { index, input } = array[0];
{ "end_byte": 127, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/stringMatchAll.ts" }
TypeScript/tests/cases/compiler/deprecatedCompilerOptions1.ts_0_414
// @typeScriptVersion: 5.0 // @filename: /foo/tsconfig.json { "compilerOptions": { "target": "ES3", "noImplicitUseStrict": true, "keyofStringsOnly": true, "suppressExcessPropertyErrors": true, "suppressImplicitAnyIndexErrors": true, "noStrictGenericChecks": true, ...
{ "end_byte": 414, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/deprecatedCompilerOptions1.ts" }
TypeScript/tests/cases/compiler/alwaysStrictModule5.ts_3_80
@alwaysStrict: true // @target: es6 // Targeting ES6 export const a = 1;
{ "end_byte": 80, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/alwaysStrictModule5.ts" }
TypeScript/tests/cases/compiler/mappedTypeOverArrayWithBareAnyRestCanBeUsedAsRestParam1.ts_0_280
// @strict: true // @noEmit: true // https://github.com/microsoft/TypeScript/issues/55932 type Replace<T extends [...any], A, B> = { [K in keyof T]: T[K] extends A ? B : T[K]; }; type ReplaceParams1<ARRAY extends [...any], A, B> = ( ...args: Replace<ARRAY, A, B> ) => any;
{ "end_byte": 280, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mappedTypeOverArrayWithBareAnyRestCanBeUsedAsRestParam1.ts" }
TypeScript/tests/cases/compiler/globalThisCapture.ts_0_153
// Add a lambda to ensure global 'this' capture is triggered (()=>this.window); var parts = []; // Ensure that the generated code is correct parts[0];
{ "end_byte": 153, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/globalThisCapture.ts" }
TypeScript/tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts_3_320
@target: es5 "use strict" function f0(a, [a, [b]], {b}) { } function f1([a, a]) { } function f2({b}, {b}) { } function f3([c, [c], [[c]]]) { } function f4({d, d: {d}}) { } function f5({e, e: {e}}, {e}, [d, e, [[e]]], ...e) { } function f6([f, ...f]) { } function f7(a, func = (a) => { return 1 }){ } // not error
{ "end_byte": 320, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts" }
TypeScript/tests/cases/compiler/bundledDtsLateExportRenaming.ts_0_545
// @module: commonjs // @declaration: true // @moduleResolution: node // @emitDeclarationOnly: true // @outFile: ./dist/out.d.ts // @Filename: index.ts export * from "./nested"; // @Filename: nested/base.ts import { B } from "./shared"; export function f() { return new B(); } // @Filename: nested/derived.ts imp...
{ "end_byte": 545, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/bundledDtsLateExportRenaming.ts" }
TypeScript/tests/cases/compiler/noImplicitReturnInConstructors.ts_0_73
// @noImplicitReturns: true class C { constructor() { return; } }
{ "end_byte": 73, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noImplicitReturnInConstructors.ts" }
TypeScript/tests/cases/compiler/escapedIdentifiers.ts_0_2544
// @allowUnusedLabels: true // @allowUnreachableCode: true /* 0 .. \u0030 9 .. \u0039 A .. \u0041 Z .. \u005a a .. \u0061 z .. \u00za */ // var decl var \u0061 = 1; a ++; \u0061 ++; var b = 1; b ++; \u0062 ++; // modules module moduleType1 { export var baz1: number; } module moduleTyp...
{ "end_byte": 2544, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/escapedIdentifiers.ts" }
TypeScript/tests/cases/compiler/taggedTemplateStringsHexadecimalEscapes.ts_0_68
function f(...args: any[]) { } f `\x0D${ "Interrupted CRLF" }\x0A`;
{ "end_byte": 68, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/taggedTemplateStringsHexadecimalEscapes.ts" }
TypeScript/tests/cases/compiler/methodInAmbientClass1.ts_4_57
declare class Foo { fn(): boolean { } }
{ "end_byte": 57, "start_byte": 4, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/methodInAmbientClass1.ts" }
TypeScript/tests/cases/compiler/unusedParameterProperty1.ts_0_134
//@noUnusedLocals:true //@noUnusedParameters:true class A { constructor(private used: string) { let foge = used; } }
{ "end_byte": 134, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedParameterProperty1.ts" }
TypeScript/tests/cases/compiler/contextualReturnTypeOfIIFE3.ts_0_232
// @lib: esnext // @noImplicitAny: true declare namespace app { var foo: { bar: { someFun: (arg: number) => void; }; }; } app.foo.bar = (function () { return { someFun(arg) {} }; })(); app.foo.bar.someFun(1);
{ "end_byte": 232, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualReturnTypeOfIIFE3.ts" }
TypeScript/tests/cases/compiler/externalModuleReferenceDoubleUnderscore1.ts_0_352
declare module 'timezonecomplete' { import basics = require("__timezonecomplete/basics"); export import TimeUnit = basics.TimeUnit; } declare module '__timezonecomplete/basics' { export enum TimeUnit { Second = 0, Minute = 1, Hour = 2, Day = 3, Week = 4, Mont...
{ "end_byte": 352, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/externalModuleReferenceDoubleUnderscore1.ts" }
TypeScript/tests/cases/compiler/controlFlowAutoAccessor1.ts_0_823
// @strict: true // @target: esnext // @declaration: true class Example { accessor test; constructor(test: number) { this.test = test; } getTest() { return this.test; } } class Example2 { accessor test; constructor(test: number | undefined) { this.test = test; } getTest() { if (t...
{ "end_byte": 823, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/controlFlowAutoAccessor1.ts" }
TypeScript/tests/cases/compiler/recursiveTypeComparison2.ts_0_1151
// Before fix this would cause compiler to hang (#1170) declare module Bacon { interface Event<T> { } interface Error<T> extends Event<T> { } interface Observable<T> { zip<U, V>(other: EventStream<U>, f: (a: T, b: U) => V): EventStream<V>; slidingWindow(max: number, min?: number): P...
{ "end_byte": 1151, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveTypeComparison2.ts" }
TypeScript/tests/cases/compiler/continueNotInIterationStatement2.ts_0_51
while (true) { function f() { continue; } }
{ "end_byte": 51, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/continueNotInIterationStatement2.ts" }
TypeScript/tests/cases/compiler/genericFunctionsAndConditionalInference.ts_0_1111
type Boxified<T> = { [P in keyof T]: { value: T[P]} }; declare function unboxify<T>(obj: Boxified<T>): T; function foo<U, V>(obj: { u: { value: U }, v: { value: V } }) { return unboxify(obj); } let qq = foo({ u: { value: 10 }, v: { value: 'hello'} }); // { u: U, v: V } but should be { u: number, v: string } //...
{ "end_byte": 1111, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericFunctionsAndConditionalInference.ts" }
TypeScript/tests/cases/compiler/importAliasWithDottedName.ts_0_159
module M { export var x = 1; export module N { export var y = 2; } } module A { import N = M.N; var r = N.y; var r2 = M.N.y; }
{ "end_byte": 159, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importAliasWithDottedName.ts" }
TypeScript/tests/cases/compiler/typeInfer1.ts_0_263
interface ITextWriter2 { Write(s:string):void; WriteLine(s:string):void; } var x: ITextWriter2 = { Write: function (s:string):void {}, WriteLine: function(s:string):void {} } var yyyyyyyy: ITextWriter2 = { Moo: function() { return "cow"; } }
{ "end_byte": 263, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeInfer1.ts" }
TypeScript/tests/cases/compiler/reactTransitiveImportHasValidDeclaration.ts_0_1098
// @declaration: true // @filename: node_modules/react/index.d.ts declare namespace React { export interface DetailedHTMLProps<T, U> {} export interface HTMLAttributes<T> {} } export = React; export as namespace React; // @filename: node_modules/create-emotion-styled/types/react/index.d.ts /// <reference types=...
{ "end_byte": 1098, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reactTransitiveImportHasValidDeclaration.ts" }
TypeScript/tests/cases/compiler/superWithGenerics.ts_0_141
declare class B<T> { m<U>(): B<U>; static g(): B<any>; } class D extends B<any> { constructor() { super(); } }
{ "end_byte": 141, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/superWithGenerics.ts" }
TypeScript/tests/cases/compiler/duplicateAnonymousInners1.ts_0_315
module Foo { class Helper { } class Inner {} // Inner should show up in intellisense export var Outer=0; } module Foo { // Should not be an error class Helper { } // Inner should not show up in intellisense // Outer should show up in intellisense }
{ "end_byte": 315, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateAnonymousInners1.ts" }
TypeScript/tests/cases/compiler/divergentAccessorsTypes2.ts_0_215
// @strict: true // @target: esnext class Test1<T> { get foo(): T { return null as any } set foo(s: T | undefined ) { } } const s = new Test1<string>(); s.foo = undefined; s.foo = "hello"; s.foo = 42;
{ "end_byte": 215, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/divergentAccessorsTypes2.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationStatements.ts_0_1252
// @sourcemap: true function f() { var y; var x = 0; for (var i = 0; i < 10; i++) { x += i; x *= 0; } if (x > 17) { x /= 9; } else { x += 10; x++; } var a = [ 1, 2, 3 ]; var obj = { z: 1, q: "hello" ...
{ "end_byte": 1252, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationStatements.ts" }
TypeScript/tests/cases/compiler/checkSuperCallBeforeThisAccessing2.ts_3_183
ass Based { } class Derived extends Based { public x: number; constructor() { this.x = 100; super(); this.x = 10; var that = this; } }
{ "end_byte": 183, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/checkSuperCallBeforeThisAccessing2.ts" }
TypeScript/tests/cases/compiler/superPropertyAccessInComputedPropertiesOfNestedType_ES5.ts_0_221
// @target: ES5 class A { foo() { return 1; } } class B extends A { foo() { return 2; } bar() { return class { [super.foo()]() { return 100; } } } }
{ "end_byte": 221, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/superPropertyAccessInComputedPropertiesOfNestedType_ES5.ts" }
TypeScript/tests/cases/compiler/globalFunctionAugmentationOverload.ts_0_228
// @filename: mod.d.ts declare function expect(spy: Function): void; declare module "mod" { class mod {} export = mod; } // @filename: mine.ts import "mod"; declare global { function expect(element: string): void; }
{ "end_byte": 228, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/globalFunctionAugmentationOverload.ts" }
TypeScript/tests/cases/compiler/controlFlowWithIncompleteTypes.ts_0_468
// Repro from #11000 declare var cond: boolean; function foo1() { let x: string | number | boolean = 0; while (cond) { if (typeof x === "string") { x = x.slice(); } else { x = "abc"; } } } function foo2() { let x: string | number | boolean = 0; ...
{ "end_byte": 468, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/controlFlowWithIncompleteTypes.ts" }
TypeScript/tests/cases/compiler/importedModuleAddToGlobal.ts_0_315
// Binding for an import statement in a typeref position is being added to the global scope // Shouldn't compile b.B is not defined in C module A { import b = B; import c = C; } module B { import a = A; export class B { } } module C { import a = A; function hello(): b.B { return null; } }
{ "end_byte": 315, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importedModuleAddToGlobal.ts" }
TypeScript/tests/cases/compiler/genericWithCallSignatureReturningSpecialization.ts_0_102
interface B<T> { f(): B<number>; (value: T): void; } var x: B<boolean>; x(true); // was error
{ "end_byte": 102, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericWithCallSignatureReturningSpecialization.ts" }
TypeScript/tests/cases/compiler/strictModeWordInImportDeclaration.ts_3_122
@target: ES6 "use strict" import * as package from "./1" import {foo as private} from "./1" import public from "./1"
{ "end_byte": 122, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/strictModeWordInImportDeclaration.ts" }
TypeScript/tests/cases/compiler/assignmentCompatFunctionsWithOptionalArgs.ts_0_269
function foo(x: { id: number; name?: string; }): void; foo({ id: 1234 }); // Ok foo({ id: 1234, name: "hello" }); // Ok foo({ id: 1234, name: false }); // Error, name of wrong type foo({ name: "hello" }); // Error, id required but missing
{ "end_byte": 269, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatFunctionsWithOptionalArgs.ts" }
TypeScript/tests/cases/compiler/unusedTypeParameters8.ts_0_123
//@noUnusedLocals:true //@noUnusedParameters:true // @fileName: a.ts class C<T> { } // @fileName: b.ts interface C<T> { }
{ "end_byte": 123, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedTypeParameters8.ts" }
TypeScript/tests/cases/compiler/declarationEmitDestructuring3.ts_0_104
// @declaration: true function bar([x, z, ...w]) { } function foo([x, ...y] = [1, "string", true]) { }
{ "end_byte": 104, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitDestructuring3.ts" }
TypeScript/tests/cases/compiler/reverseMappedTypeRecursiveInference.ts_0_275
// @strict: true type Foo<V> = { [K in keyof V]: Foo<V[K]>; } type Bar<V> = { [K in keyof V]: V[K] extends object ? Bar<V[K]> : string; } function test<V>(value: Foo<V>): V { console.log(value); return undefined as any; } const bar: Bar<any> = {}; test(bar);
{ "end_byte": 275, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reverseMappedTypeRecursiveInference.ts" }
TypeScript/tests/cases/compiler/assignmentCompatability7.ts_0_459
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 interfaceWithPublicAndOptional<T,U> { one: T; two?: U; }; var obj4: inte...
{ "end_byte": 459, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatability7.ts" }
TypeScript/tests/cases/compiler/conditionalExpressionNewLine10.ts_0_55
var v = a ? b ? d : e : c ? f : g;
{ "end_byte": 55, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/conditionalExpressionNewLine10.ts" }
TypeScript/tests/cases/compiler/superCallInsideClassDeclaration.ts_0_179
class A { } class C { } class B extends A { constructor() { class D extends C { constructor() { super(); } } } }
{ "end_byte": 179, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/superCallInsideClassDeclaration.ts" }
TypeScript/tests/cases/compiler/jsxChildrenArrayWrongType.tsx_0_504
// @jsx: react // @strict: true // @target: ES5 // @module: ESNext // @esModuleInterop: true // @skipLibCheck: true // @filename: index.tsx /// <reference path="/.lib/react18/react18.d.ts" /> /// <reference path="/.lib/react18/global.d.ts" /> // target is ES5, so no `Iterable` type is present. interface PropsType { ...
{ "end_byte": 504, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsxChildrenArrayWrongType.tsx" }
TypeScript/tests/cases/compiler/instantiatedBaseTypeConstraints.ts_0_140
interface Foo<T extends Foo<T, C>, C> { foo(bar: C): void; } class Bar implements Foo<Bar, string> { foo(bar: string): void { } }
{ "end_byte": 140, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/instantiatedBaseTypeConstraints.ts" }
TypeScript/tests/cases/compiler/declFileImportModuleWithExportAssignment.ts_0_652
// @module: commonjs // @declaration: true // @Filename: declFileImportModuleWithExportAssignment_0.ts module m2 { export interface connectModule { (res, req, next): void; } export interface connectExport { use: (mod: connectModule) => connectExport; listen: (port: number) => void; ...
{ "end_byte": 652, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileImportModuleWithExportAssignment.ts" }
TypeScript/tests/cases/compiler/checkTypePredicateForRedundantProperties.ts_0_79
function addProp2(x: any): x is { a: string; a: string; } { return true; }
{ "end_byte": 79, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/checkTypePredicateForRedundantProperties.ts" }
TypeScript/tests/cases/compiler/destructuredMaappedTypeIsNotImplicitlyAny.ts_0_306
// @noImplicitAny: true function foo<T extends string>(key: T, obj: { [_ in T]: number }) { const { [key]: bar } = obj; // Element implicitly has an 'any' type because type '{ [_ in T]: number; }' has no index signature. bar; // bar : any // Note: this does work: const lorem = obj[key]; }
{ "end_byte": 306, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/destructuredMaappedTypeIsNotImplicitlyAny.ts" }
TypeScript/tests/cases/compiler/capturedLetConstInLoop11_ES6.ts_0_184
// @target: ES6 for (;;) { let x = 1; () => x; } function foo() { for (;;) { const a = 0; switch(a) { case 0: return () => a; } } }
{ "end_byte": 184, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/capturedLetConstInLoop11_ES6.ts" }
TypeScript/tests/cases/compiler/inferentialTypingWithFunctionTypeNested.ts_0_157
declare function map<T, U>(x: T, f: () => { x: (s: T) => U }): U; declare function identity<V>(y: V): V; var s = map("", () => { return { x: identity }; });
{ "end_byte": 157, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inferentialTypingWithFunctionTypeNested.ts" }