_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/nestedSelf.ts_0_115
module M { export class C { public n = 42; public foo() { [1,2,3].map((x) => { return this.n * x; })} } }
{ "end_byte": 115, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nestedSelf.ts" }
TypeScript/tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts_0_725
// none of these function calls should be allowed var x = function () { return; }; var r1 = x<number>(); var y: any = x; var r2 = y<string>(); var c: Function; var r3 = c<number>(); // should be an error class C implements Function { prototype = null; length = 1; arguments = null; caller = () => { }; ...
{ "end_byte": 725, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts" }
TypeScript/tests/cases/compiler/identityRelationNeverTypes.ts_0_577
// @strict: true // @declaration: true // Repro from #47996 type Equals<A, B> = (<T>() => T extends B ? 1 : 0) extends (<T>() => T extends A ? 1 : 0) ? true : false; declare class State<TContext> { _context: TContext; _value: string; matches<TSV extends string>(stateValue: TSV): this is State<TContext> &...
{ "end_byte": 577, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/identityRelationNeverTypes.ts" }
TypeScript/tests/cases/compiler/declFileEmitDeclarationOnlyError1.ts_0_73
// @emitDeclarationOnly: true // @filename: hello.ts var hello = "yo!";
{ "end_byte": 73, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileEmitDeclarationOnlyError1.ts" }
TypeScript/tests/cases/compiler/collisionThisExpressionAndNameResolution.ts_0_390
// @lib: es5 var console : { log(message: any); } class Foo { x() { var _this = 10; // Local var. No this capture in x(), so no conflict. function inner() { console.log(_this); // Error as this doesnt not resolve to user defined _this return x => this; // New scope. So...
{ "end_byte": 390, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionThisExpressionAndNameResolution.ts" }
TypeScript/tests/cases/compiler/truthinessCallExpressionCoercion4.ts_0_187
// @checkJs: true // @allowJs: true // @strict: true // @noEmit: true // @filename: a.js function fn() {} if (typeof module === 'object' && module.exports) { module.exports = fn; }
{ "end_byte": 187, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/truthinessCallExpressionCoercion4.ts" }
TypeScript/tests/cases/compiler/recursiveGenericMethodCall.ts_0_110
interface Generator<T> { (): T; } function Generate<T>(func: Generator<T>): T { return Generate(func); }
{ "end_byte": 110, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveGenericMethodCall.ts" }
TypeScript/tests/cases/compiler/nodeResolution8.ts_0_235
// @module: commonjs // @moduleResolution: node // @filename: node_modules/a/ref.ts var x = 1; // @filename: node_modules/a/index.d.ts /// <reference path="ref.ts"/> export declare var y; // @filename: b.ts import y = require("a");
{ "end_byte": 235, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nodeResolution8.ts" }
TypeScript/tests/cases/compiler/constEnumMergingWithValues4.ts_0_118
//@module: amd //@filename: m1.ts module foo { const enum E { X } } module foo { var x = 1; } export = foo
{ "end_byte": 118, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constEnumMergingWithValues4.ts" }
TypeScript/tests/cases/compiler/staticClassMemberError.ts_0_154
class C { static s; public a() { s = 1; } } // just want to make sure this one doesn't crash the compiler function Foo(); class Foo { static bar; }
{ "end_byte": 154, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/staticClassMemberError.ts" }
TypeScript/tests/cases/compiler/libCompileChecks.ts_0_215
// @lib: esnext, dom // @target: esnext // @skipLibCheck: false // @skipDefaultLibCheck: false // This test is effectively the 'lib check' for all our .d.ts files because we use skipLibCheck // as false everywhere.
{ "end_byte": 215, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/libCompileChecks.ts" }
TypeScript/tests/cases/compiler/superPropertyElementNoUnusedLexicalThisCapture.ts_0_231
class A { x() {} } class B extends A { constructor() { super(); } foo() { return () => { super.x; } } bar() { return () => { super["x"]; } } }
{ "end_byte": 231, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/superPropertyElementNoUnusedLexicalThisCapture.ts" }
TypeScript/tests/cases/compiler/amdDeclarationEmitNoExtraDeclare.ts_0_500
// @declaration: true // @module: amd // @outFile: dist.js // @filename: Class.ts import { Configurable } from "./Configurable" export class HiddenClass {} export class ActualClass extends Configurable(HiddenClass) {} // @filename: Configurable.ts export type Constructor<T> = { new(...args: any[]): T; } export fu...
{ "end_byte": 500, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/amdDeclarationEmitNoExtraDeclare.ts" }
TypeScript/tests/cases/compiler/nestedGlobalNamespaceInClass.ts_0_59
// should not crash - from #35717 class C { global x }
{ "end_byte": 59, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nestedGlobalNamespaceInClass.ts" }
TypeScript/tests/cases/compiler/getterSetterNonAccessor.ts_0_209
function getFunc():any{return 0;} function setFunc(v){} Object.defineProperty({}, "0", <PropertyDescriptor>({ get: getFunc, set: setFunc, configurable: true }));
{ "end_byte": 209, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/getterSetterNonAccessor.ts" }
TypeScript/tests/cases/compiler/staticsNotInScopeInClodule.ts_0_90
class Clod { static x = 10; } module Clod { var p = x; // x isn't in scope here }
{ "end_byte": 90, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/staticsNotInScopeInClodule.ts" }
TypeScript/tests/cases/compiler/assertionFunctionsCanNarrowByDiscriminant.ts_0_575
// @strict: true interface Cat { type: 'cat'; canMeow: true; } interface Dog { type: 'dog'; canBark: true; } type Animal = Cat | Dog; declare function assertEqual<T>(value: any, type: T): asserts value is T; const animal = { type: 'cat', canMeow: true } as Animal; assertEqual(animal.type, 'cat' as c...
{ "end_byte": 575, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assertionFunctionsCanNarrowByDiscriminant.ts" }
TypeScript/tests/cases/compiler/declarationEmitClassPrivateConstructor.ts_0_490
// @target: es5 // @module: commonjs // @declaration: true interface PrivateInterface { } export class ExportedClass1 { private constructor(data: PrivateInterface) { } } export class ExportedClass2 { private constructor(private data: PrivateInterface) { } } export class ExportedClass3 { private construc...
{ "end_byte": 490, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitClassPrivateConstructor.ts" }
TypeScript/tests/cases/compiler/typeOfOnTypeArg.ts_0_77
var A = { '': 3 }; function fill<B extends typeof A>(f: B) { } fill(32);
{ "end_byte": 77, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeOfOnTypeArg.ts" }
TypeScript/tests/cases/compiler/commentsOnJSXExpressionsArePreserved.tsx_0_608
// @module: system,commonjs // @jsx: react,react-jsx,react-jsxdev,preserve // @moduleDetection: legacy,auto,force // file is intentionally not a module - this tests for a crash in the module/system transforms alongside the `react-jsx` and `react-jsxdev` outputs namespace JSX {} class Component { render() { ...
{ "end_byte": 608, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentsOnJSXExpressionsArePreserved.tsx" }
TypeScript/tests/cases/compiler/commonJsExportTypeDeclarationError.ts_0_384
// @esModuleInterop: true // @checkJs: true // @module: commonjs // @target: es5 // @outDir: ./out // @Filename: ./test.js module.exports = { message: "" } // @Filename: ./types1.ts import test from "./test"; export type test // @Filename: ./types2.ts import test from "./test"; export type test = // @Filename: ...
{ "end_byte": 384, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commonJsExportTypeDeclarationError.ts" }
TypeScript/tests/cases/compiler/nameCollisionsInPropertyAssignments.ts_0_36
var x = 1 var y = { x() { x++; } };
{ "end_byte": 36, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nameCollisionsInPropertyAssignments.ts" }
TypeScript/tests/cases/compiler/systemExportAssignment2.ts_0_162
// @target: es5 // @module: system // @filename: a.ts var a = 10; export = a; // Error: export = not allowed in ES6 // @filename: b.ts import * as a from "a";
{ "end_byte": 162, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/systemExportAssignment2.ts" }
TypeScript/tests/cases/compiler/continueLabel.ts_0_59
label1: for(var i = 0; i < 1; i++) { continue label1; }
{ "end_byte": 59, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/continueLabel.ts" }
TypeScript/tests/cases/compiler/collisionSuperAndLocalVarInConstructor.ts_0_366
var _super = 10; // No Error class Foo { constructor() { var _super = 10; // No error } } class b extends Foo { constructor() { super(); var _super = 10; // Should be error } } class c extends Foo { constructor() { super(); var x = () => { var _su...
{ "end_byte": 366, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionSuperAndLocalVarInConstructor.ts" }
TypeScript/tests/cases/compiler/avoidNarrowingUsingConstVariableFromBindingElementWithLiteralInitializer.ts_0_224
// @strict: true // @noEmit: true declare const foo: ["a", string, number] | ["b", string, boolean]; export function test(arg: { index?: number }) { const { index = 0 } = arg; if (foo[index] === "a") { foo; } }
{ "end_byte": 224, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/avoidNarrowingUsingConstVariableFromBindingElementWithLiteralInitializer.ts" }
TypeScript/tests/cases/compiler/moduleResolutionWithExtensions_withPaths.ts_0_802
// @filename: /tsconfig.json { "compilerOptions": { "outDir": "lib", "target": "ES6", "module": "ES6", "baseUrl": "/", "moduleResolution": "Node", "noImplicitAny": true, "traceResolution": true, "paths": { "foo/*": ["node_modules/foo/lib/*"] } } } // @filename: /node_modules/foo/lib/test.js expo...
{ "end_byte": 802, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolutionWithExtensions_withPaths.ts" }
TypeScript/tests/cases/compiler/generatorES6_3.ts_0_51
// @target: es6 var v = function*() { yield 0 }
{ "end_byte": 51, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/generatorES6_3.ts" }
TypeScript/tests/cases/compiler/arrayAugment.ts_0_138
interface Array<T> { split: (parts: number) => T[][]; } var x = ['']; var y = x.split(4); var y: string[][]; // Expect no error here
{ "end_byte": 138, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arrayAugment.ts" }
TypeScript/tests/cases/compiler/prettyContextNotDebugAssertion.ts_0_52
// @pretty: true // @filename: index.ts if (true) {
{ "end_byte": 52, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/prettyContextNotDebugAssertion.ts" }
TypeScript/tests/cases/compiler/mappedTypeNotMistakenlyHomomorphic.ts_0_555
enum ABC { A, B } type Gen<T extends ABC> = { v: T; } & ( { v: ABC.A, a: string, } | { v: ABC.B, b: string, } ) // Quick info: ??? // // type Gen2<T extends ABC> = { // v: string; // } // type Gen2<T extends ABC> = { [Property in keyof Gen<T>]: string; }; // 'a' and 'b' properties required...
{ "end_byte": 555, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mappedTypeNotMistakenlyHomomorphic.ts" }
TypeScript/tests/cases/compiler/enumPropertyAccessBeforeInitalisation.ts_0_65
enum E { A = A, B = E.B, C = E["C"], D = 1 + D }
{ "end_byte": 65, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumPropertyAccessBeforeInitalisation.ts" }
TypeScript/tests/cases/compiler/typePredicatesInUnion_noMatch.ts_0_214
interface A { pred(x: {}, y: {}): x is boolean; } interface B { pred(x: {}, y: {}): y is string; } type Or = A | B; function f(o: Or, x: {}, y: {}) { if (o.pred(x, y)) { x; y; } }
{ "end_byte": 214, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typePredicatesInUnion_noMatch.ts" }
TypeScript/tests/cases/compiler/deprecatedCompilerOptions3.ts_0_415
// @typeScriptVersion: 6.0 // @filename: /foo/tsconfig.json { "compilerOptions": { "target": "ES3", "noImplicitUseStrict": true, "keyofStringsOnly": true, "suppressExcessPropertyErrors": true, "suppressImplicitAnyIndexErrors": true, "noStrictGenericChecks": true, ...
{ "end_byte": 415, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/deprecatedCompilerOptions3.ts" }
TypeScript/tests/cases/compiler/undefinedAsDiscriminantWithUnknown.ts_0_248
// @strictNullChecks: true,false type S = | { type: 'string', value: string } | { type: 'number', value: number } | { type: 'unknown', value: unknown } | { value: undefined }; declare var s: S if (s.value !== undefined) { s; } else { s; }
{ "end_byte": 248, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/undefinedAsDiscriminantWithUnknown.ts" }
TypeScript/tests/cases/compiler/es5ExportDefaultClassDeclaration.ts_0_104
// @target: es5 // @module: commonjs // @declaration: true export default class C { method() { } }
{ "end_byte": 104, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es5ExportDefaultClassDeclaration.ts" }
TypeScript/tests/cases/compiler/declFileRegressionTests.ts_0_159
// @declaration: true // 'null' not converted to 'any' in d.ts // function types not piped through correctly var n = { w: null, x: '', y: () => { }, z: 32 };
{ "end_byte": 159, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileRegressionTests.ts" }
TypeScript/tests/cases/compiler/letDeclarations-useBeforeDefinition2.ts_0_100
// @target: ES6 // @outFile: out.js // @Filename: file1.ts l; // @Filename: file2.ts const l = 0;
{ "end_byte": 100, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/letDeclarations-useBeforeDefinition2.ts" }
TypeScript/tests/cases/compiler/controlFlowDestructuringVariablesInTryCatch.ts_0_294
// @strict: true declare function f1(): string; declare function f2(): [b: string]; declare function f3(): { c: string }; try { var a = f1(); var [b] = f2(); var { c } = f3(); var [d = 1] = []; var { e = 1 } = { }; } catch { console.error("error"); } a; b; c; d; e;
{ "end_byte": 294, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/controlFlowDestructuringVariablesInTryCatch.ts" }
TypeScript/tests/cases/compiler/asyncFunctionReturnType.ts_0_2638
// @target: ES6 async function fAsync() { // Without explicit type annotation, this is just an array. return [1, true]; } async function fAsyncExplicit(): Promise<[number, boolean]> { // This is contextually typed as a tuple. return [1, true]; } // https://github.com/Microsoft/TypeScript/issues/13128 ...
{ "end_byte": 2638, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/asyncFunctionReturnType.ts" }
TypeScript/tests/cases/compiler/duplicatePackage_withErrors.ts_0_591
// @noImplicitReferences: true // @Filename: /node_modules/a/index.d.ts export { x } from "x"; // @Filename: /node_modules/a/node_modules/x/index.d.ts export const x = 1 + 1; // @Filename: /node_modules/a/node_modules/x/package.json { "name": "x", "version": "1.2.3" } // @Filename: /node_modules/b/index.d.ts export...
{ "end_byte": 591, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicatePackage_withErrors.ts" }
TypeScript/tests/cases/compiler/privateInstanceVisibility.ts_0_450
module Test { export class Example { private someNumber: number; public doSomething() { var that = this; function innerFunction() { var num = that.someNumber; } } } ...
{ "end_byte": 450, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privateInstanceVisibility.ts" }
TypeScript/tests/cases/compiler/contextualTypeShouldBeLiteral.ts_0_1547
// @strict: true interface X { type: 'x'; value: string; method(): void; } interface Y { type: 'y'; value: 'none' | 'done'; method(): void; } function foo(bar: X | Y) { } foo({ type: 'y', value: 'done', method() { this; this.type; this.value; } }); int...
{ "end_byte": 1547, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTypeShouldBeLiteral.ts" }
TypeScript/tests/cases/compiler/es5-asyncFunctionLongObjectLiteral.ts_0_757
// @lib: es5,es2015.promise // @target: ES5 // the generated code from both should be similar const fooShort = async () => { return { a: await Promise.resolve(0), b: await Promise.resolve(1), c: await Promise.resolve(2), d: await Promise.resolve(3), e: await Promise.resolve...
{ "end_byte": 757, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es5-asyncFunctionLongObjectLiteral.ts" }
TypeScript/tests/cases/compiler/nullableFunctionError.ts_0_79
// @strictNullChecks: true null(); undefined(); let f: null | undefined; f();
{ "end_byte": 79, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nullableFunctionError.ts" }
TypeScript/tests/cases/compiler/exportAssignmentFunction.ts_0_231
//@module: amd // @Filename: exportAssignmentFunction_A.ts function foo() { return 0; } export = foo; // @Filename: exportAssignmentFunction_B.ts import fooFunc = require("exportAssignmentFunction_A"); var n: number = fooFunc();
{ "end_byte": 231, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportAssignmentFunction.ts" }
TypeScript/tests/cases/compiler/cannotInvokeNewOnErrorExpression.ts_0_56
module M { class ClassA {} } var t = new M.ClassA[];
{ "end_byte": 56, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/cannotInvokeNewOnErrorExpression.ts" }
TypeScript/tests/cases/compiler/declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.ts_0_1485
// @declaration: true // @lib: es6 // Note that both of the following have an `any` in their return type from where we bottom out the type printout // for having too many instances of the same symbol nesting. // Slightly simplified repro from https://github.com/microsoft/TypeScript/issues/30732 so it's easier to read...
{ "end_byte": 1485, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.ts" }
TypeScript/tests/cases/compiler/objectLiteralsAgainstUnionsOfArrays01.ts_0_118
interface Foo { bar: Bar | Bar[]; } interface Bar { prop: string; } let x: Foo[] = [ { bar: { prop: 100 } } ]
{ "end_byte": 118, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectLiteralsAgainstUnionsOfArrays01.ts" }
TypeScript/tests/cases/compiler/importNonExportedMember10.ts_0_192
// @esModuleInterop: false // @module: es2015 // @checkJs: true // @allowJs: true // @noEmit: true // @Filename: a.ts class Foo {} export = Foo; // @Filename: b.js import { Foo } from './a';
{ "end_byte": 192, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importNonExportedMember10.ts" }
TypeScript/tests/cases/compiler/inheritanceOfGenericConstructorMethod1.ts_0_221
class A<T> { } class B<T> extends A<T> {} var a = new A<Date>(); var b1 = new B(); // no error var b2: B<Date> = new B<Date>(); // no error var b3 = new B<Date>(); // error, could not select overload for 'new' expression
{ "end_byte": 221, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inheritanceOfGenericConstructorMethod1.ts" }
TypeScript/tests/cases/compiler/innerTypeArgumentInference.ts_0_108
interface Generator<T> { (): T; } function Generate<U>(func: Generator<U>): U { return Generate(func); }
{ "end_byte": 108, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/innerTypeArgumentInference.ts" }
TypeScript/tests/cases/compiler/genericIndexedAccessVarianceComparisonResultCorrect.ts_0_581
class A { x: string = 'A'; y: number = 0; } class B { x: string = 'B'; z: boolean = true; } type T<X extends { x: any }> = Pick<X, 'x'>; type C = T<A>; type D = T<B>; type C_extends_D = C extends D ? true : false; // true type PickA_extends_PickB = Pick<A, 'x'> exten...
{ "end_byte": 581, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericIndexedAccessVarianceComparisonResultCorrect.ts" }
TypeScript/tests/cases/compiler/baseConstraintOfDecorator.ts_0_702
export function classExtender<TFunction>(superClass: TFunction, _instanceModifier: (instance: any, args: any[]) => void): TFunction { return class decoratorFunc extends superClass { constructor(...args: any[]) { super(...args); _instanceModifier(this, args); } }; } class...
{ "end_byte": 702, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/baseConstraintOfDecorator.ts" }
TypeScript/tests/cases/compiler/signatureCombiningRestParameters1.ts_0_487
// @strict: true // @lib: esnext // @noEmit: true // https://github.com/microsoft/TypeScript/issues/58371 type T1 = "A" | "B"; type T2 = { C: [string]; D: [number]; }; declare const map: { [K in T1 | keyof T2]: (...args: K extends keyof T2 ? T2[K] : []) => unknown; }; declare const args: any; for (const [ke...
{ "end_byte": 487, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/signatureCombiningRestParameters1.ts" }
TypeScript/tests/cases/compiler/multiLineErrors.ts_0_218
var t = 32; function noReturn(): { n: string; y: number; } { var x = 4; var y = 10; } interface A1 { x: { y: number; }; } interface A2 { x: { y: string; }; } var t1: A1; var t2: A2; t1 = t2;
{ "end_byte": 218, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/multiLineErrors.ts" }
TypeScript/tests/cases/compiler/jsxFactoryMissingErrorInsideAClass.ts_0_168
//@jsx: react //@target: es6 //@module: commonjs //@reactNamespace: factory //@filename: test.tsx export class C { factory() { return <div></div>; } }
{ "end_byte": 168, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsxFactoryMissingErrorInsideAClass.ts" }
TypeScript/tests/cases/compiler/genericDefaults.ts_0_5594
// @declaration: true interface A { a: number; } interface B { b: number; } interface C { c: number; } interface D { d: number; } interface AB { a: number; b: number; } interface BC { b: number; c: number; } declare const a: A; declare const b: B; declare const c: C; declare const d: D; declare const ab: AB; declare c...
{ "end_byte": 5594, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericDefaults.ts" }
TypeScript/tests/cases/compiler/genericDefaults.ts_5595_10883
f14(a, b); f14(a, b, c); f14(a, b, d); // no inference, partially supplied f14<A>(); f14<A>(a); f14<A>(a, b); f14<A>(a, b, c); f14<A, B>(); f14<A, B>(a); f14<A, B>(a, b); f14<A, B>(a, b, c); // no inference fully supplied f14<A, B, D>(); f14<A, B, D>(a); f14<A, B, D>(a, b); f14<A, B, D>(a, b, d); // function with two ...
{ "end_byte": 10883, "start_byte": 5595, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericDefaults.ts" }
TypeScript/tests/cases/compiler/genericDefaults.ts_10884_11942
interface Base02Constructor { new <T = A>(a: T): Base02 & T; } declare const Base02: Base02Constructor; declare class Derived03 extends Base02 {} const Derived03c00 = new Derived03(ab); const Derived03c01 = Derived03c00.a; type DerivedProps = keyof Derived03; type t00<T = number> = { a: T; } const t00c00 = (<t00>x).a;...
{ "end_byte": 11942, "start_byte": 10884, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericDefaults.ts" }
TypeScript/tests/cases/compiler/privacyInterface.ts_0_4905
//@module: commonjs export module m1 { export class C1_public { private f1() { } } class C2_private { } export interface C3_public { (c1: C1_public); (c1: C2_private); (): C1_public; (c2: number): C2_private; new (c1: C1_public); ne...
{ "end_byte": 4905, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyInterface.ts" }
TypeScript/tests/cases/compiler/internalAliasUninitializedModuleInsideTopLevelModuleWithExport.ts_0_195
//@module: amd // @declaration: true export module a { export module b { export interface I { foo(); } } } export import b = a.b; export var x: b.I; x.foo();
{ "end_byte": 195, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/internalAliasUninitializedModuleInsideTopLevelModuleWithExport.ts" }
TypeScript/tests/cases/compiler/funduleExportedClassIsUsedBeforeDeclaration.ts_0_260
interface A { // interface before module declaration (): B.C; // uses defined below class in module } declare function B(): B.C; // function merged with module declare module B { export class C { // class defined in module } } new B.C();
{ "end_byte": 260, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/funduleExportedClassIsUsedBeforeDeclaration.ts" }
TypeScript/tests/cases/compiler/constEnums.ts_0_3070
const enum Enum1 { A0 = 100, } const enum Enum1 { // correct cases A, B, C = 10, D = A | B, E = A | 1, F = 1 | A, G = (1 & 1), H = ~(A | B), I = A >>> 1, J = 1 & A, K = ~(1 | 5), L = ~D, M = E << B, N = E << 1, O = E >> B, P = E >> 1, PQ = E **...
{ "end_byte": 3070, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constEnums.ts" }
TypeScript/tests/cases/compiler/intersectionWithConflictingPrivates.ts_0_1201
// @strict: true // @target: esnext // @useDefineForClassFields: false class A { private x: unknown; y?: string; } class B { private x: unknown; y?: string; } declare let ab: A & B; ab.y = 'hello'; ab = {}; function f1(node: A | B) { if (node instanceof A || node instanceof A) { node; // A } else { no...
{ "end_byte": 1201, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/intersectionWithConflictingPrivates.ts" }
TypeScript/tests/cases/compiler/unusedPrivateVariableInClass4.ts_0_183
//@noUnusedLocals:true //@noUnusedParameters:true class greeter { private x: string; private y: string; public z: string; public method1() { this.x; } }
{ "end_byte": 183, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedPrivateVariableInClass4.ts" }
TypeScript/tests/cases/compiler/contextualTypeBasedOnIntersectionWithAnyInTheMix5.ts_0_1264
// @strict: true // @noEmit: true type ComputedGetter<T> = (oldValue?: T) => T; type ComputedOptions = Record<string, ComputedGetter<any>>; type ExtractComputedReturns<T extends any> = { [key in keyof T]: T[key] extends (...args: any[]) => infer TReturn ? TReturn : never; }; interface ComponentOptionsBase<...
{ "end_byte": 1264, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTypeBasedOnIntersectionWithAnyInTheMix5.ts" }
TypeScript/tests/cases/compiler/deleteReadonlyInStrictNullChecks.ts_0_104
// @strictNullChecks: true interface Function { readonly name: string; } class Foo {} delete Foo.name;
{ "end_byte": 104, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/deleteReadonlyInStrictNullChecks.ts" }
TypeScript/tests/cases/compiler/infinitelyGenerativeInheritance1.ts_0_179
interface Stack<T> { pop(): T zip<S>(a: Stack<S>): Stack<{ x: T; y: S }> } interface MyStack<T> extends Stack<T> { zip<S>(a: Stack<S>): Stack<{ x: T; y: S }> }
{ "end_byte": 179, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/infinitelyGenerativeInheritance1.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationFor.ts_0_415
// @sourcemap: true for (var i = 0; i < 10; i++) { WScript.Echo("i: " + i); } for (i = 0; i < 10; i++) { WScript.Echo("i: " + i); } for (var j = 0; j < 10; ) { j++; if (j == 1) { continue; } } for (j = 0; j < 10;) { j++; } for (var k = 0;; k++) { } for (k = 0;; k++) { } for (; k < 10; k+...
{ "end_byte": 415, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationFor.ts" }
TypeScript/tests/cases/compiler/declarationEmitExpressionInExtends4.ts_0_235
// @declaration: true function getSomething() { return class D { } } class C extends getSomething()<number, string> { } class C2 extends SomeUndefinedFunction()<number, string> { } class C3 extends SomeUndefinedFunction { }
{ "end_byte": 235, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitExpressionInExtends4.ts" }
TypeScript/tests/cases/compiler/contextualTyping32.ts_0_112
function foo(param: {():number; (i:number):number; }[]) { }; foo([function(){return 1;}, function(){return 4}]);
{ "end_byte": 112, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTyping32.ts" }
TypeScript/tests/cases/compiler/destructuringInVariableDeclarations5.ts_0_90
// @target: es6 // @module: umd export let { toString } = 1; { let { toFixed } = 1; }
{ "end_byte": 90, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/destructuringInVariableDeclarations5.ts" }
TypeScript/tests/cases/compiler/relationComplexityError.ts_0_355
// @strict: true // @noEmit: true // Repro from #55630 type Digits = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'; type T1 = `${Digits}${Digits}${Digits}${Digits}` | undefined; type T2 = { a: string } | { b: number }; function f1(x: T1, y: T1 & T2) { x = y; } function f2(x: T1 | null, y: T1 & T2) {...
{ "end_byte": 355, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/relationComplexityError.ts" }
TypeScript/tests/cases/compiler/functionOverloads.ts_0_121
function foo(): string; function foo(bar: string): number; function foo(bar?: string): any { return "" }; var x = foo(5);
{ "end_byte": 121, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloads.ts" }
TypeScript/tests/cases/compiler/unusedImportDeclaration.ts_0_353
// @module: commonjs // @declaration: true // @Filename: unusedImportDeclaration_testerB.ts class TesterB { me: string; } export = TesterB; // @Filename: unusedImportDeclaration_testerA.ts import B = require("./unusedImportDeclaration_testerB"); var thingy: B = { me: "A" }; declare function foo(a: string): voi...
{ "end_byte": 353, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedImportDeclaration.ts" }
TypeScript/tests/cases/compiler/errorForwardReferenceForwadingConstructor.ts_0_227
// Error forward referencing derived class with forwarding constructor function f() { var d1 = new derived(); var d2 = new derived(4); } class base { constructor(public n: number) { } } class derived extends base { }
{ "end_byte": 227, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/errorForwardReferenceForwadingConstructor.ts" }
TypeScript/tests/cases/compiler/declarationEmitTransitiveImportOfHtmlDeclarationItem.ts_0_389
// @declaration: true // @allowArbitraryExtensions: true // @filename: foo.d.html.ts export declare class CustomHtmlRepresentationThing {} // @filename: reexporter.ts import { CustomHtmlRepresentationThing } from "./foo.html"; export function func() { return new CustomHtmlRepresentationThing(); } // @filename: i...
{ "end_byte": 389, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitTransitiveImportOfHtmlDeclarationItem.ts" }
TypeScript/tests/cases/compiler/classMemberInitializerWithLamdaScoping2.ts_0_616
// @lib: es5 // @Filename: classMemberInitializerWithLamdaScoping2_0.ts var field1: string; // @Filename: classMemberInitializerWithLamdaScoping2_1.ts declare var console: { log(msg?: any): void; }; class Test1 { constructor(private field1: string) { } messageHandler = () => { console.log(field...
{ "end_byte": 616, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classMemberInitializerWithLamdaScoping2.ts" }
TypeScript/tests/cases/compiler/declarationEmitScopeConsistency.ts_0_229
// @strict: true // @declaration: true // @filename: a.ts export interface A { a: number } export const f = (x: A) => x as A; // @filename: b.ts import { f } from "./a"; export interface A { other: number } export const g = f;
{ "end_byte": 229, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitScopeConsistency.ts" }
TypeScript/tests/cases/compiler/unusedLocalsInMethod1.ts_0_119
//@noUnusedLocals:true //@noUnusedParameters:true class greeter { public function1() { var x = 10; } }
{ "end_byte": 119, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedLocalsInMethod1.ts" }
TypeScript/tests/cases/compiler/moduleResolutionWithSuffixes_one_externalTSModule.ts_0_480
// moduleSuffixes has one entry and there's a matching package with TS files. // @fullEmitPaths: true // @filename: /tsconfig.json { "compilerOptions": { "outDir": "bin", "moduleResolution": "node", "traceResolution": true, "moduleSuffixes": [".ios"] } } // @filename: /node_modules/some-library/index.ios.ts ...
{ "end_byte": 480, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolutionWithSuffixes_one_externalTSModule.ts" }
TypeScript/tests/cases/compiler/nestedGenericSpreadInference.ts_0_266
// @strict: true declare function wrap<X>(x: X): { x: X }; declare function call<A extends unknown[], T>(x: { x: (...args: A) => T }, ...args: A): T; // This should be of type `number` - ideally, it also would not error. const leak = call(wrap(<T>(x: T) => x), 1);
{ "end_byte": 266, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nestedGenericSpreadInference.ts" }
TypeScript/tests/cases/compiler/narrowingInCaseClauseAfterCaseClauseWithReturn.ts_0_1021
// @strict: true // @noEmit: true // https://github.com/microsoft/TypeScript/issues/56352 function test1(arg: string | undefined) { if (!arg) throw new Error(); switch (true) { case arg.toUpperCase() === "A": return "A"; case arg.toUpperCase() === "B": case arg.toUpperCase() === "C": case ...
{ "end_byte": 1021, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowingInCaseClauseAfterCaseClauseWithReturn.ts" }
TypeScript/tests/cases/compiler/funcdecl.ts_0_1534
// @declaration: true function simpleFunc() { return "this is my simple func"; } var simpleFuncVar = simpleFunc; function anotherFuncNoReturn() { } var anotherFuncNoReturnVar = anotherFuncNoReturn; function withReturn() : string{ return "Hello"; } var withReturnVar = withReturn; function withParams(a : strin...
{ "end_byte": 1534, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/funcdecl.ts" }
TypeScript/tests/cases/compiler/bestCommonTypeWithOptionalProperties.ts_0_290
interface X { foo: string } interface Y extends X { bar?: number } interface Z extends X { bar: string } var x: X; var y: Y; var z: Z; // All these arrays should be X[] var b1 = [x, y, z]; var b2 = [x, z, y]; var b3 = [y, x, z]; var b4 = [y, z, x]; var b5 = [z, x, y]; var b6 = [z, y, x];
{ "end_byte": 290, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/bestCommonTypeWithOptionalProperties.ts" }
TypeScript/tests/cases/compiler/es6ExportDefaultExpression.ts_0_63
// @target: es6 // @declaration: true export default (1 + 2);
{ "end_byte": 63, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ExportDefaultExpression.ts" }
TypeScript/tests/cases/compiler/recursiveBaseCheck5.ts_0_121
interface I1<T> extends I2<string> { } interface I2<T> extends I1<T> { } class X<T, U> implements I2<T> { } (new X).blah;
{ "end_byte": 121, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveBaseCheck5.ts" }
TypeScript/tests/cases/compiler/es6ModuleEnumDeclaration.ts_0_545
// @target: ES6 export enum e1 { a, b, c } enum e2 { x, y, z } var x = e1.a; var y = e2.x; export module m1 { export enum e3 { a, b, c } enum e4 { x, y, z } var x1 = e1.a; var y1 = e2.x; var x2 = e3.a; var y2 = e4.x;...
{ "end_byte": 545, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ModuleEnumDeclaration.ts" }
TypeScript/tests/cases/compiler/undefinedInferentialTyping.ts_0_97
function f<T>(arr: T[], elemnt: T): T { return null; } var a = f([], 3); // should be number
{ "end_byte": 97, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/undefinedInferentialTyping.ts" }
TypeScript/tests/cases/compiler/collisionSuperAndNameResolution.ts_0_227
// @lib: es5 var console: { log(message: any); } var _super = 10; // No error class base { } class Foo extends base { x() { console.log(_super); // Error as this doesnt not resolve to user defined _super } }
{ "end_byte": 227, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionSuperAndNameResolution.ts" }
TypeScript/tests/cases/compiler/jsFileCompilationBindStrictModeErrors.ts_0_672
// @allowJs: true // @checkJs: true // @noEmit: true // @filename: a.js // @target: es6 "use strict"; var a = { a: "hello", // error b: 10, a: 10 // error }; var let = 10; // error delete a; // error try { } catch (eval) { // error } function arguments() { // error } with (a) { b = 10; } // @filename:...
{ "end_byte": 672, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationBindStrictModeErrors.ts" }
TypeScript/tests/cases/compiler/unparenthesizedConstructorTypeInUnionOrIntersection.ts_0_802
type U1 = string | new () => void; type U2 = string | new (foo: number) => void type U3 = | new () => number type U4 = | new (foo?: number) => void; type U5 = string | new (number: number, foo?: string) => void | number; type U6 = | string | new (...args: any[]) => void | number; type I1 = string & new () => voi...
{ "end_byte": 802, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unparenthesizedConstructorTypeInUnionOrIntersection.ts" }
TypeScript/tests/cases/compiler/null.ts_0_252
// @allowUnreachableCode: true var x=null; var y=3+x; var z=3+null; class C { } function f() { return null; return new C(); } function g() { return null; return 3; } interface I { x:any; y:number; } var w:I={x:null,y:3};
{ "end_byte": 252, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/null.ts" }
TypeScript/tests/cases/compiler/reversedRecusiveTypeInstantiation.ts_0_193
interface A<StringArgPos1, NumberArgPos2> { xPos1 : StringArgPos1 yPos2 : NumberArgPos2 zPos2Pos1 : A<NumberArgPos2, StringArgPos1> } var a : A<string, number> a.zPos2Pos1.xPos1 = 1
{ "end_byte": 193, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reversedRecusiveTypeInstantiation.ts" }
TypeScript/tests/cases/compiler/declarationEmitDefaultExport7.ts_0_73
// @declaration: true // @target: es6 class A {} export default new A();
{ "end_byte": 73, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitDefaultExport7.ts" }
TypeScript/tests/cases/compiler/vueLikeDataAndPropsInference2.ts_0_969
interface Instance { _instanceBrand: never } type DataDef<Data, Props> = (this: Readonly<Props> & Instance) => Data type PropsDefinition<T> = { [K in keyof T]: T[K] } interface Options< Data = object | ((this: Instance) => object), PropsDef = PropsDefinition<Record<string, any>> > { data?: Da...
{ "end_byte": 969, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/vueLikeDataAndPropsInference2.ts" }
TypeScript/tests/cases/compiler/mergedClassWithNamespacePrototype.ts_0_150
// @Filename: /a.d.ts declare class Foo {} // @Filename: /b.ts declare namespace Foo { namespace prototype { function f(): void; } }
{ "end_byte": 150, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mergedClassWithNamespacePrototype.ts" }
TypeScript/tests/cases/compiler/declarationMaps.ts_0_385
// @declaration: true // @declarationMap: true module m2 { export interface connectModule { (res, req, next): void; } export interface connectExport { use: (mod: connectModule) => connectExport; listen: (port: number) => void; } } var m2: { (): m2.connectExport; test1: ...
{ "end_byte": 385, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationMaps.ts" }
TypeScript/tests/cases/compiler/augmentedTypesModules3.ts_0_203
//// module then class module m3 { } class m3 { } // ok since the module is not instantiated module m3a { var y = 2; } class m3a { foo() { } } // error, class isn't ambient or declared before the module
{ "end_byte": 203, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/augmentedTypesModules3.ts" }