_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/thisInFunctionCall.ts_0_606
// @target: es2015 // @noImplicitThis: true class Test { data: number[] constructor() { this.data = [1, 2, 3] } finderRaw() { this.data.find(function (d) { return d === this.data.length }) } forEacherRaw() { this.data.forEach(function (d) { console.log(d === this.data.length)...
{ "end_byte": 606, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/thisInFunctionCall.ts" }
TypeScript/tests/cases/compiler/declarationEmitToDeclarationDirWithDeclarationOption.ts_0_212
// @declaration: true // @filename: /foo/tsconfig.json { "compilerOptions": { "declaration": true, "declarationDir": "out" } } // @filename: /foo/test.ts interface Foo { x: number; } export default Foo;
{ "end_byte": 212, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitToDeclarationDirWithDeclarationOption.ts" }
TypeScript/tests/cases/compiler/regExpWithSlashInCharClass.ts_0_135
var foo1 = "a/".replace(/.[/]/, ""); var foo2 = "a//".replace(/.[//]/g, ""); var foo3 = "a/".replace(/.[/no sleep /till/]/, "bugfix");
{ "end_byte": 135, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/regExpWithSlashInCharClass.ts" }
TypeScript/tests/cases/compiler/didYouMeanSuggestionErrors.ts_0_747
// @lib: es5 describe("my test suite", () => { it("should run", () => { const a = $(".thing"); }); }); suite("another suite", () => { test("everything else", () => { console.log(process.env); document.createElement("div"); const x = require("fs"); const y = Buffer.f...
{ "end_byte": 747, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/didYouMeanSuggestionErrors.ts" }
TypeScript/tests/cases/compiler/es6ModuleInternalImport.ts_0_363
// @target: ES6 export module m { export var a = 10; } export import a1 = m.a; import a2 = m.a; var x = a1 + a2; export module m1 { export import a3 = m.a; import a4 = m.a; var x = a1 + a2; var x2 = a3 + a4; } module m2 { export import a3 = m.a; import a4 = m.a; var x = a1 + a2; var ...
{ "end_byte": 363, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ModuleInternalImport.ts" }
TypeScript/tests/cases/compiler/contextuallyTypeGeneratorReturnTypeFromUnion.ts_0_409
// @strict: true // @noEmit: true // @lib: esnext // repro #51187 type Action = () => (Generator<string, string, string[]> | string) const test1: Action = function* () { const next = yield '' return next[0] } type Action2 = () => (AsyncGenerator<string, string, string[]> | string) const test2: Action2 = as...
{ "end_byte": 409, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextuallyTypeGeneratorReturnTypeFromUnion.ts" }
TypeScript/tests/cases/compiler/primitiveTypeAsClassName.ts_0_12
class any {}
{ "end_byte": 12, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/primitiveTypeAsClassName.ts" }
TypeScript/tests/cases/compiler/duplicatePackage.ts_0_1033
// @noImplicitReferences: true // @Filename: /node_modules/a/index.d.ts import X from "x"; export function a(x: X): void; // @Filename: /node_modules/a/node_modules/x/index.d.ts export default class X { private x: number; } // @Filename: /node_modules/a/node_modules/x/package.json { "name": "x", "version": "1.2....
{ "end_byte": 1033, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicatePackage.ts" }
TypeScript/tests/cases/compiler/collisionCodeGenModuleWithModuleReopening.ts_0_439
module m1 { export class m1 { } } var foo = new m1.m1(); module m1 { export class c1 { } var b = new c1(); var c = new m1(); } var foo2 = new m1.c1(); module m2 { export class c1 { } export var b10 = 10; var x = new c1(); } var foo3 = new m2.c1(); module m2 { export class m2...
{ "end_byte": 439, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionCodeGenModuleWithModuleReopening.ts" }
TypeScript/tests/cases/compiler/moduleResolution_explicitNodeModulesImport.ts_0_204
// @allowJs: true // @noImplicitReferences: true // @maxNodeModuleJsDepth: 1 // @Filename: /node_modules/foo/index.js exports.x = 0; // @Filename: /src/index.ts import { x } from "../node_modules/foo";
{ "end_byte": 204, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolution_explicitNodeModulesImport.ts" }
TypeScript/tests/cases/compiler/esModuleInterop.ts_0_373
// @esModuleInterop: true // @filename: hybrid/index.d.ts export function sayHello(): string; // @filename: path.d.ts declare const anything: any; export = anything; // @filename: fs.d.ts declare const anything: any; export = anything; // @filename: mjts.ts import { sayHello } from "./hybrid"; import path from "./path"...
{ "end_byte": 373, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/esModuleInterop.ts" }
TypeScript/tests/cases/compiler/augmentExportEquals5.ts_0_1916
// @module: amd // @filename: express.d.ts declare module Express { export interface Request { } export interface Response { } export interface Application { } } declare module "express" { function e(): e.Express; namespace e { interface IRoute { all(...handler: RequestHandler...
{ "end_byte": 1916, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/augmentExportEquals5.ts" }
TypeScript/tests/cases/compiler/commentOnArrayElement1.ts_3_107
nst array = [ /* element 1*/ 1 /* end of element 1 */, 2 /* end of element 2 */ ];
{ "end_byte": 107, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentOnArrayElement1.ts" }
TypeScript/tests/cases/compiler/ternaryExpressionSourceMap.ts_0_64
// @sourcemap: true var x = 1; var foo = x ? () => 0 : () => 0;
{ "end_byte": 64, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ternaryExpressionSourceMap.ts" }
TypeScript/tests/cases/compiler/modFunctionCrash.ts_0_139
declare module Q { function f(fn:()=>void); // typechecking the function type shouldnot crash the compiler } Q.f(function() {this;});
{ "end_byte": 139, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/modFunctionCrash.ts" }
TypeScript/tests/cases/compiler/jsxViaImport.2.tsx_0_514
//@jsx: preserve //@module: commonjs //@filename: component.d.ts declare module JSX { interface ElementAttributesProperty { props; } } declare module React { class Component<T, U> { } } declare module "BaseComponent" { export default class extends React.Component<any, {}> { } } //@filename: consumer.tsx /...
{ "end_byte": 514, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsxViaImport.2.tsx" }
TypeScript/tests/cases/compiler/asyncImportNestedYield.ts_0_90
// @lib: esnext async function* foo() { import((await import(yield "foo")).default); }
{ "end_byte": 90, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/asyncImportNestedYield.ts" }
TypeScript/tests/cases/compiler/typeVariableTypeGuards.ts_0_1460
// @strict: true // Repro from #14091 interface Foo { foo(): void } class A<P extends Partial<Foo>> { constructor(public props: Readonly<P>) {} doSomething() { this.props.foo && this.props.foo() } } // Repro from #14415 interface Banana { color: 'yellow'; } class Monkey<T extends Banan...
{ "end_byte": 1460, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeVariableTypeGuards.ts" }
TypeScript/tests/cases/compiler/hugeDeclarationOutputGetsTruncatedWithError.ts_0_320
// @declaration: true type props = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z"; type manyprops = `${props}${props}`; export const c = [null as any as {[K in manyprops]: {[K2 in manyprops]: `${K}.${K2}`}}][0];
{ "end_byte": 320, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/hugeDeclarationOutputGetsTruncatedWithError.ts" }
TypeScript/tests/cases/compiler/inheritSameNamePropertiesWithDifferentVisibility.ts_0_125
class C { public x: number; } class C2 { private x: number; } interface A extends C, C2 { // error y: string; }
{ "end_byte": 125, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inheritSameNamePropertiesWithDifferentVisibility.ts" }
TypeScript/tests/cases/compiler/staticMemberExportAccess.ts_0_422
class Sammy { foo() { return "hi"; } static bar() { return -1; } } module Sammy { export var x = 1; } interface JQueryStatic { sammy: Sammy; // class instance } var $: JQueryStatic; var instanceOfClassSammy: Sammy = new $.sammy(); // should be error var r1 = instanceOfClassSammy.foo(); // r1 is stri...
{ "end_byte": 422, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/staticMemberExportAccess.ts" }
TypeScript/tests/cases/compiler/classNameReferencesInStaticElements.ts_0_407
// @target: es2017 // @noTypesAndSymbols: true // https://github.com/microsoft/TypeScript/issues/54607 class Foo { static { console.log(this, Foo) } static x = () => { console.log(this, Foo) } static y = function(this: unknown) { console.log(this, Foo) } #x() { console.log(Foo); } x() { this.#x(); ...
{ "end_byte": 407, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classNameReferencesInStaticElements.ts" }
TypeScript/tests/cases/compiler/jsFileCompilationWithOutFileNameSameAsInputJsFile.ts_0_109
// @allowJs: true // @outFile: /b.js // @filename: /a.ts class c { } // @filename: /b.js function foo() { }
{ "end_byte": 109, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationWithOutFileNameSameAsInputJsFile.ts" }
TypeScript/tests/cases/compiler/aliasWithInterfaceExportAssignmentUsedInVarInitializer.ts_0_315
// @module: commonjs // @Filename: aliasWithInterfaceExportAssignmentUsedInVarInitializer_0.ts interface c { q3: number; } export = c; // @Filename: aliasWithInterfaceExportAssignmentUsedInVarInitializer_1.ts import moduleA = require("./aliasWithInterfaceExportAssignmentUsedInVarInitializer_0"); var d = b.q3;
{ "end_byte": 315, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/aliasWithInterfaceExportAssignmentUsedInVarInitializer.ts" }
TypeScript/tests/cases/compiler/commentsOnObjectLiteral2.ts_0_325
// @removeComments: false var Person = makeClass( { /** This is just another way to define a constructor. @constructs @param {string} name The name of the person. */ initialize: function(name) { this.name = name; } /* trailing comment 1*/, ...
{ "end_byte": 325, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentsOnObjectLiteral2.ts" }
TypeScript/tests/cases/compiler/genericDerivedTypeWithSpecializedBase2.ts_0_175
class A<T extends { length: number }> { x: T; } class B<U> extends A<string> { y: U; } var x: A<{ length: number; foo: number }>; var y: B<number>; x = y; // error
{ "end_byte": 175, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericDerivedTypeWithSpecializedBase2.ts" }
TypeScript/tests/cases/compiler/extension.ts_0_255
interface I { x; } interface I { y; } declare module M { export class C { public p:number; } } declare module M { export extension class C { public pe:string; } } var c=new M.C(); c.pe; c.p; var i:I; i.x; i.y;
{ "end_byte": 255, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/extension.ts" }
TypeScript/tests/cases/compiler/genericArrayPropertyAssignment.ts_0_96
function isEmpty(list: {length:number;}) { return list.length ===0; } isEmpty([]); // error
{ "end_byte": 96, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericArrayPropertyAssignment.ts" }
TypeScript/tests/cases/compiler/import_reference-exported-alias.ts_0_440
// @Filename: file1.ts module App { export module Services { export class UserServices { public getUserName(): string { return "Bill Gates"; } } } } import Mod = App; export = Mod; // @Filename: file2.ts // @module: amd import appJs = require("file1"); i...
{ "end_byte": 440, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/import_reference-exported-alias.ts" }
TypeScript/tests/cases/compiler/moduleResolution_automaticTypeDirectiveNames.ts_0_204
// @noImplicitReferences: true // @Filename: /node_modules/@types/.a/index.d.ts declare const a: number; // @Filename: /node_modules/@types/a/index.d.ts declare const a: string; // @Filename: /a.ts a;
{ "end_byte": 204, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolution_automaticTypeDirectiveNames.ts" }
TypeScript/tests/cases/compiler/importDeclarationInModuleDeclaration2.ts_0_118
// @allowJs: true // @noEmit: true // @checkJs: true // @filename: check.js function container() { import "fs"; }
{ "end_byte": 118, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importDeclarationInModuleDeclaration2.ts" }
TypeScript/tests/cases/compiler/satisfiesEmit.ts_0_109
// This import should not be elided in the emitted JS import a = require("foo"); const p = a satisfies bleh;
{ "end_byte": 109, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/satisfiesEmit.ts" }
TypeScript/tests/cases/compiler/narrowingIntersection.ts_0_570
// Somehow this being an intersection matters. type FooAndBaz = { foo: unknown } & { baz: unknown }; type Disjoint = | { readonly value: string; readonly err?: never; } | { readonly value?: never; readonly err: FooAndBaz; }; function test1(result: Disjoint): string { if (result.err) { throw result.err; ...
{ "end_byte": 570, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowingIntersection.ts" }
TypeScript/tests/cases/compiler/propertyAccess2.ts_0_29
var foo: number; foo.toBAZ();
{ "end_byte": 29, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/propertyAccess2.ts" }
TypeScript/tests/cases/compiler/noImplicitAnyParametersInModule.ts_3_1173
@noImplicitAny: true module M { // No implicit-'any' errors. function m_f1(): void { } // Implicit-'any' error for x. function m_f2(x): void { } // No implicit-'any' errors. function m_f3(x: any): void { } // Implicit-'any' errors for x, y, and z. function m_f4(x, y, z): void { } ...
{ "end_byte": 1173, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noImplicitAnyParametersInModule.ts" }
TypeScript/tests/cases/compiler/crashIntypeCheckInvocationExpression.ts_0_346
//@module: amd var nake; function doCompile<P0, P1, P2>(fileset: P0, moduleType: P1) { return undefined; } export var compileServer = task<number, number, any>(<P0, P1, P2>() => { var folder = path.join(), fileset = nake.fileSetSync<number, number, any>(folder) return doCompile<number, number, any>(...
{ "end_byte": 346, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/crashIntypeCheckInvocationExpression.ts" }
TypeScript/tests/cases/compiler/unusedLocalsAndObjectSpread2.ts_0_251
//@noUnusedLocals:true declare let props: any; const { children, // here! active: _a, // here! ...rest } = props; function foo() { const { children, active: _a, ...rest } = props; } export const asdf = 123;
{ "end_byte": 251, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedLocalsAndObjectSpread2.ts" }
TypeScript/tests/cases/compiler/multipleExports.ts_0_139
// @module: commonjs export module M { export var v = 0; export let x; } const x = 0; export module M { v; export {x}; }
{ "end_byte": 139, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/multipleExports.ts" }
TypeScript/tests/cases/compiler/recursiveExportAssignmentAndFindAliasedType1.ts_0_611
//@module: amd // @Filename: recursiveExportAssignmentAndFindAliasedType1_moduleDef.d.ts declare module "moduleC" { import self = require("moduleC"); export = self; } // @Filename: recursiveExportAssignmentAndFindAliasedType1_moduleB.ts class ClassB { } export = ClassB; // @Filename: recursiveExportAssignment...
{ "end_byte": 611, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveExportAssignmentAndFindAliasedType1.ts" }
TypeScript/tests/cases/compiler/classStaticPropertyTypeGuard.ts_0_280
// @strictNullChecks: true // @target: ES5 // Repro from #8923 class A { private static _a: string | undefined; public get a(): string { if (A._a) { return A._a; // is possibly null or undefined. } return A._a = 'helloworld'; } }
{ "end_byte": 280, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classStaticPropertyTypeGuard.ts" }
TypeScript/tests/cases/compiler/functionOverloads35.ts_0_141
function foo(bar:{a:number;}):number; function foo(bar:{a:string;}):string; function foo(bar:{a:any;}):any{ return bar } var x = foo({a:1});
{ "end_byte": 141, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloads35.ts" }
TypeScript/tests/cases/compiler/crashInResolveInterface.ts_0_359
// @Filename: file1.ts interface Q<T> { each(action: (item: T, index: number) => void): void; } var q1: Q<{ a: number; }>; var x = q1.each(x => c.log(x)); // @Filename: file2.ts ///<reference path='file1.ts'/> declare var c: C; interface C { count(countTitle?: string): void; } interface C { log(message?: a...
{ "end_byte": 359, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/crashInResolveInterface.ts" }
TypeScript/tests/cases/compiler/letDeclarations-validContexts.ts_0_1596
// @allowUnusedLabels: true // @allowUnreachableCode: true // @target: ES6 // Control flow statements with blocks if (true) { let l1 = 0; } else { let l2 = 0; } while (true) { let l3 = 0; } do { let l4 = 0; } while (true); var obj; with (obj) { let l5 = 0; } for (var i = 0; i < 10; i++) {...
{ "end_byte": 1596, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/letDeclarations-validContexts.ts" }
TypeScript/tests/cases/compiler/declFileImportChainInExportAssignment.ts_0_160
// @declaration: true // @module: commonjs module m { export module c { export class c { } } } import a = m.c; import b = a; export = b;
{ "end_byte": 160, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileImportChainInExportAssignment.ts" }
TypeScript/tests/cases/compiler/systemModule17.ts_0_497
// @module: system // @filename: f1.ts export class A {} export interface I {} // @filename: f2.ts var x = 1; interface I { } namespace N { export var x = 1; export interface I { } } import IX = N.x; import II = N.I; import { A, A as EA, I as EI } from "f1"; export {x}; export {x as x1}; export {I}; export {...
{ "end_byte": 497, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/systemModule17.ts" }
TypeScript/tests/cases/compiler/emitThisInObjectLiteralGetter.ts_0_98
// @target: es5 const example = { get foo() { return item => this.bar(item); } };
{ "end_byte": 98, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emitThisInObjectLiteralGetter.ts" }
TypeScript/tests/cases/compiler/parenthesisDoesNotBlockAliasSymbolCreation.ts_0_509
// @declaration: true export type InvalidKeys<K extends string|number|symbol> = { [P in K]? : never }; export type InvalidKeys2<K extends string|number|symbol> = ( { [P in K]? : never } ); export type A<T> = ( T & InvalidKeys<"a"> ); export type A2<T> = ( T & InvalidKeys2<"a"> ); export const a = null as...
{ "end_byte": 509, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parenthesisDoesNotBlockAliasSymbolCreation.ts" }
TypeScript/tests/cases/compiler/overloadBindingAcrossDeclarationBoundaries2.ts_0_658
// @Filename: overloadBindingAcrossDeclarationBoundaries_file0.ts interface Opt1 { p?: any; } interface Opt2 { q?: any; } interface Opt3 { r?: any; } interface Opt4 { s?: any; } interface A { a(o: Opt1): Opt1; a(o: Opt2): Opt2; (o: Opt1): Opt1; (o: Opt2): Opt2; new (o: Opt1): Opt1; ...
{ "end_byte": 658, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overloadBindingAcrossDeclarationBoundaries2.ts" }
TypeScript/tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES6.ts_0_314
// @target: ES6 "use strict"; function foo(a: number) { if (a === 10) { function foo() { } foo(); foo(10); // not ok } else { function foo() { } foo(); foo(10); // not ok } foo(10); foo(); // not ok } foo(10); foo(); // not ok - needs number
{ "end_byte": 314, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES6.ts" }
TypeScript/tests/cases/compiler/contextualTypeArrayReturnType.ts_0_348
interface IBookStyle { initialLeftPageTransforms?: (width: number) => NamedTransform[]; } interface NamedTransform { [name: string]: Transform3D; } interface Transform3D { cachedCss: string; } var style: IBookStyle = { initialLeftPageTransforms: (width: number) => { return [ {'ry'...
{ "end_byte": 348, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTypeArrayReturnType.ts" }
TypeScript/tests/cases/compiler/declFileCallSignatures.ts_0_1632
// @target: ES5 // @declaration: true // @removeComments: false // @module: commonjs // @Filename: declFileCallSignatures_0.ts export interface ICallSignature { /** This comment should appear for foo*/ (): string; } export interface ICallSignatureWithParameters { /** This is comment for function signature...
{ "end_byte": 1632, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileCallSignatures.ts" }
TypeScript/tests/cases/compiler/incompatibleAssignmentOfIdenticallyNamedTypes.ts_0_100
interface T { } declare const a: T; class Foo<T> { x: T; fn() { this.x = a; } }
{ "end_byte": 100, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/incompatibleAssignmentOfIdenticallyNamedTypes.ts" }
TypeScript/tests/cases/compiler/useBeforeDeclaration_superClass.ts_0_438
class C { x = 0; } class D extends C { // Not an error -- this will access the parent's initialized value for `x`, not the one on the child. old_x = this.x; x = 1; } // Test that it works on chains of classes class X { x = 0; } class Y extends X {} class Z extends Y { old_x = this.x; x = 1;...
{ "end_byte": 438, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/useBeforeDeclaration_superClass.ts" }
TypeScript/tests/cases/compiler/errorInfoForRelatedIndexTypesNoConstraintElaboration.ts_0_250
/// <reference path="/.lib/react16.d.ts" /> class I<T1 extends keyof JSX.IntrinsicElements, T2 extends keyof JSX.IntrinsicElements> { M() { let c1: JSX.IntrinsicElements[T1] = {}; const c2: JSX.IntrinsicElements[T2] = c1; } }
{ "end_byte": 250, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/errorInfoForRelatedIndexTypesNoConstraintElaboration.ts" }
TypeScript/tests/cases/compiler/expressionWithJSDocTypeArguments.ts_0_693
// @strict: true // Repro from #51802 function foo<T>(x: T): T { return x } class Bar<T> { constructor(public x: T) { } } // Errors expected on all of the following const WhatFoo = foo<?>; const HuhFoo = foo<string?>; const NopeFoo = foo<?string>; const ComeOnFoo = foo<?string?>; type TWhatFoo = typeof foo<?>; ty...
{ "end_byte": 693, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/expressionWithJSDocTypeArguments.ts" }
TypeScript/tests/cases/compiler/genericInference2.ts_4_651
declare module ko { export interface Observable<T> { (): T; (value: T): any; N: number; g: boolean; r: T; } export function observable<T>(value: T): Observable<T>; } var o = { name: ko.observable("Bob"), age: k...
{ "end_byte": 651, "start_byte": 4, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericInference2.ts" }
TypeScript/tests/cases/compiler/contextualSignatureInstatiationContravariance.ts_0_419
interface Animal { x } interface Giraffe extends Animal { y } interface Elephant extends Animal { y2 } var f2: <T extends Animal>(x: T, y: T) => void; var g2: (g: Giraffe, e: Elephant) => void; g2 = f2; // error because Giraffe and Elephant are disjoint types var h2: (g1: Giraffe, g2: Giraffe) => void; h2 = f2; // v...
{ "end_byte": 419, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualSignatureInstatiationContravariance.ts" }
TypeScript/tests/cases/compiler/noParameterReassignmentIIFEAnnotated.ts_0_277
// @allowJs: true // @checkJs: true // @noEmit: true // @filename: index.js self.importScripts = (function (importScripts) { /** * @param {...unknown} rest */ return function () { return importScripts.apply(this, arguments); }; })(importScripts);
{ "end_byte": 277, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noParameterReassignmentIIFEAnnotated.ts" }
TypeScript/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.ts_0_389
// @target: es5 // @module: commonjs // @declaration: true // @filename: es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.ts var a = 10; export default a; // @filename: es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts import defaultBinding, * as nameSpaceBinding from "./es6ImportDefaultBinding...
{ "end_byte": 389, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.ts" }
TypeScript/tests/cases/compiler/declaredExternalModuleWithExportAssignment.ts_0_362
declare module 'connect' { interface connectModule { (res, req, next): void; } interface connectExport { use: (mod: connectModule) => connectExport; listen: (port: number) => void; } var server: { (): connectExport; test1: connectModule; test2(): con...
{ "end_byte": 362, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declaredExternalModuleWithExportAssignment.ts" }
TypeScript/tests/cases/compiler/classExtendingQualifiedName2.ts_0_72
module M { export class C { } class D extends M.C { } }
{ "end_byte": 72, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classExtendingQualifiedName2.ts" }
TypeScript/tests/cases/compiler/doNotInferUnrelatedTypes.ts_0_174
// #16709 declare function dearray<T>(ara: ReadonlyArray<T>): T; type LiteralType = "foo" | "bar"; declare var alt: Array<LiteralType>; let foo: LiteralType = dearray(alt);
{ "end_byte": 174, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/doNotInferUnrelatedTypes.ts" }
TypeScript/tests/cases/compiler/inheritanceStaticMembersIncompatible.ts_0_78
class a { static x: string; } class b extends a { static x: number; }
{ "end_byte": 78, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inheritanceStaticMembersIncompatible.ts" }
TypeScript/tests/cases/compiler/typeParameterArgumentEquivalence4.ts_0_140
function foo<T,U>() { var x: (item) => U; var y: (item) => T; x = y; // Should be an error y = x; // Shound be an error }
{ "end_byte": 140, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeParameterArgumentEquivalence4.ts" }
TypeScript/tests/cases/compiler/typeofUnknownSymbol.ts_0_58
// previously gave no error here var x = typeof whatsthis
{ "end_byte": 58, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeofUnknownSymbol.ts" }
TypeScript/tests/cases/compiler/unusedTypeParameters_templateTag.ts_0_137
// @allowJs: true // @checkJs: true // @noEmit: true // @noUnusedParameters:true // @Filename: /a.js /** @template T */ function f() {}
{ "end_byte": 137, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedTypeParameters_templateTag.ts" }
TypeScript/tests/cases/compiler/commentsBeforeFunctionExpression1.ts_0_65
// @removeComments: false var v = { f: /**own f*/ (a) => 0 }
{ "end_byte": 65, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentsBeforeFunctionExpression1.ts" }
TypeScript/tests/cases/compiler/classWithEmptyTypeParameter.ts_0_13
class C<> { }
{ "end_byte": 13, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classWithEmptyTypeParameter.ts" }
TypeScript/tests/cases/compiler/nonnullAssertionPropegatesContextualType.ts_0_105
// @strict: true let rect2: SVGRectElement = document.querySelector('.svg-rectangle')!; // Error: Element
{ "end_byte": 105, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nonnullAssertionPropegatesContextualType.ts" }
TypeScript/tests/cases/compiler/declarationEmitBindingPatternsUnused.ts_0_3579
// @declaration: true // @target: esnext // @skipLibCheck: false type Named = { name: string } // Resons we can't remove aliases that are not used in the function signature: // 1.Causes duplicate identifier if we remove alias function duplicateIndetifiers({ name: alias, name: alias2 }: Named) { } function duplicate...
{ "end_byte": 3579, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitBindingPatternsUnused.ts" }
TypeScript/tests/cases/compiler/optionalParamReferencingOtherParams2.ts_0_76
var a = 1; function strange(x = a, y = b) { var b = ""; return y; }
{ "end_byte": 76, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/optionalParamReferencingOtherParams2.ts" }
TypeScript/tests/cases/compiler/noUncheckedIndexedAccessCompoundAssignments.ts_0_485
// @strict: true // @noUncheckedIndexedAccess: true // Each line should have one error // for a total of 12 errors stringMap.foo++; --stringMap.foo; stringMap.foo += 1; stringMap.foo *= 1; ++stringMap['foo']; stringMap['foo']--; ++stringMap[s]; stringMap[s]--; numberMap[32]++; numberMap[32] += 1; numberMap[n]++; numbe...
{ "end_byte": 485, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noUncheckedIndexedAccessCompoundAssignments.ts" }
TypeScript/tests/cases/compiler/sourceMapWithCaseSensitiveFileNamesAndOutDir.ts_0_383
// @outDir: testfiles // @sourcemap: true // @useCaseSensitiveFileNames: true // @Filename: testFiles/app.ts // Note in the out result we are using same folder name only different in casing // Since this is case sensitive, the folders are different and hence the relative paths in sourcemap shouldn't be just app.ts or a...
{ "end_byte": 383, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapWithCaseSensitiveFileNamesAndOutDir.ts" }
TypeScript/tests/cases/compiler/collisionCodeGenModuleWithMemberInterfaceConflict.ts_0_110
module m1 { export interface m1 { } export class m2 implements m1 { } } var foo = new m1.m2();
{ "end_byte": 110, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionCodeGenModuleWithMemberInterfaceConflict.ts" }
TypeScript/tests/cases/compiler/bigIntWithTargetES2016.ts_0_141
// @target: es2016 // @lib: esnext BigInt(1) ** BigInt(1); // should not error let num = BigInt(2); num **= BigInt(2); // should not error
{ "end_byte": 141, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/bigIntWithTargetES2016.ts" }
TypeScript/tests/cases/compiler/accessorParameterAccessibilityModifier.ts_0_84
// @target: es5 class C { set X(public v) { } static set X(public v2) { } }
{ "end_byte": 84, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/accessorParameterAccessibilityModifier.ts" }
TypeScript/tests/cases/compiler/mappedTypeMultiInference.ts_0_341
interface Style { flashy: any; } declare function mergeStyleSets<K extends string>( ...cssSets: { [P in K]?: Style }[]): { [P in K]: Style }; // Expected: // let x: { // a: Style; // b: Style; // } let x = mergeStyleSets( {}, { a: { flashy: true }, }, { b: { fla...
{ "end_byte": 341, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mappedTypeMultiInference.ts" }
TypeScript/tests/cases/compiler/es6-umd.ts_0_167
// @target: ES6 // @sourcemap: false // @declaration: false // @module: umd class A { constructor () { } public B() { return 42; } }
{ "end_byte": 167, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6-umd.ts" }
TypeScript/tests/cases/compiler/declarationFilesGeneratingTypeReferences.ts_0_239
// @declaration: true // @outFile: out.js // @filename: /a/node_modules/@types/jquery/index.d.ts interface JQuery { } // @filename: /a/app.ts /// <reference types="jquery" preserve="true" /> namespace Test { export var x: JQuery; }
{ "end_byte": 239, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationFilesGeneratingTypeReferences.ts" }
TypeScript/tests/cases/compiler/tooManyTypeParameters1.ts_0_169
function f<T>() { } f<string, string>(); var x = <T>() => {}; x<number,number>(); class C<T> {} var c = new C<Date,Date>(); interface I<T> {} var i: I<number,number>;
{ "end_byte": 169, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/tooManyTypeParameters1.ts" }
TypeScript/tests/cases/compiler/requireOfJsonFileNonRelativeWithoutExtensionResolvesToTs.ts_0_346
// @module: commonjs // @outdir: out/ // @allowJs: true // @fullEmitPaths: true // @resolveJsonModule: true // @Filename: /src/projects/file1.ts import f = require("f"); // should work to f.ts let fnumber: number = f; // @Filename: /src/node_modules/f.json { "a": true, "b": "hello" } // @Filename: /src/node_...
{ "end_byte": 346, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/requireOfJsonFileNonRelativeWithoutExtensionResolvesToTs.ts" }
TypeScript/tests/cases/compiler/inheritanceGrandParentPrivateMemberCollisionWithPublicMember.ts_0_111
class A { private myMethod() { } } class B extends A { } class C extends B { public myMethod() { } }
{ "end_byte": 111, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inheritanceGrandParentPrivateMemberCollisionWithPublicMember.ts" }
TypeScript/tests/cases/compiler/superCallInsideClassExpression.ts_0_185
class A { } class C { } class B extends A { constructor() { var D = class extends C { constructor() { super(); } } } }
{ "end_byte": 185, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/superCallInsideClassExpression.ts" }
TypeScript/tests/cases/compiler/doNotElaborateAssignabilityToTypeParameters.ts_0_241
// @lib: es2015 // @target: ES5 async function foo<T>(x: T): Promise<T> { let yaddable = await getXOrYadda(x); return yaddable; } interface Yadda { stuff: string, things: string, } declare function getXOrYadda<T>(x: T): T | Yadda;
{ "end_byte": 241, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/doNotElaborateAssignabilityToTypeParameters.ts" }
TypeScript/tests/cases/compiler/FunctionDeclaration7.ts_0_31
module M { function foo(); }
{ "end_byte": 31, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/FunctionDeclaration7.ts" }
TypeScript/tests/cases/compiler/reverseMappedTupleContext.ts_0_1150
// @strict: true // @noEmit: true // https://github.com/microsoft/TypeScript/issues/55382 declare function test1<T>(arg: { [K in keyof T]: T[K]; }): T; const result1 = test1(["foo", 42]); declare function test2<T extends readonly unknown[]>(arg: { [K in keyof T]: T[K]; }): T; const result2 = test2(["foo", 42]); ...
{ "end_byte": 1150, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reverseMappedTupleContext.ts" }
TypeScript/tests/cases/compiler/indexSignatureInOtherFile1.ts_0_763
// @target: es2015 // @Filename: other.ts interface Array1<T> { length: number; [n: number]: T; } interface ArrayConstructor1 { new(arrayLength?: number): Array1<any>; } declare var Array1: ArrayConstructor1; // iterable.d.ts interface Array1<T> { [Symbol.iterator](): IterableIterator<T>; } // symbol.wellkn...
{ "end_byte": 763, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/indexSignatureInOtherFile1.ts" }
TypeScript/tests/cases/compiler/declarationEmitRelativeModuleError.ts_0_115
declare module "b:block" { // <-- no error anymore } declare module "b:/block" { // <-- still an error }
{ "end_byte": 115, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitRelativeModuleError.ts" }
TypeScript/tests/cases/compiler/unusedParametersWithUnderscore.ts_0_285
//@noUnusedLocals:true //@noUnusedParameters:true function f(a, _b, c, ___, d,e___, _f) { } function f2({_a, __b}) { } function f3([_a, ,__b]) { } function f4(...arg) { } function f5(..._arg) { } function f6(arg?, _arg?) { } var f7 = _ => undefined; var f8 = function (_) { };
{ "end_byte": 285, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedParametersWithUnderscore.ts" }
TypeScript/tests/cases/compiler/commentOnArrayElement13.ts_3_34
nst array = [/* comment */];
{ "end_byte": 34, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentOnArrayElement13.ts" }
TypeScript/tests/cases/compiler/unspecializedConstraints.ts_0_4626
module ts { interface Map<T> { [index: string]: T; } interface Equals<T> { equals(other: T): boolean; } class Symbol { } class Type extends Symbol { equals(that: Type): boolean { if (this === that) return true; if (!(this.isObjectType() && t...
{ "end_byte": 4626, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unspecializedConstraints.ts" }
TypeScript/tests/cases/compiler/capturedParametersInInitializers2.ts_0_242
// @target: es5 function foo( y = class { static c = x; get [x]() {return x;} constructor() { x; } [z]() { return z; } }, x = 1, z = 2 ) { y.c } function foo2(y = class {[x] = x}, x = 1) { }
{ "end_byte": 242, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/capturedParametersInInitializers2.ts" }
TypeScript/tests/cases/compiler/declarationEmitNoNonRequiredParens.ts_0_179
// @declaration: true export enum Test { A, B, C } export type TestType = typeof Test; export const bar = null! as TestType[Extract<keyof TestType, string>][] satisfies any;
{ "end_byte": 179, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitNoNonRequiredParens.ts" }
TypeScript/tests/cases/compiler/nestedHomomorphicMappedTypesWithArrayConstraint1.ts_0_246
// @strict: true // @noEmit: true // Based on @types/sinon v10 type MatchArguments<T> = { [K in keyof T]: T[K]; }; interface SinonSpyCallApi<TArgs extends any[] = any[]> { calledWith(...args: Partial<MatchArguments<TArgs>>): boolean; }
{ "end_byte": 246, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nestedHomomorphicMappedTypesWithArrayConstraint1.ts" }
TypeScript/tests/cases/compiler/contextualTyping21.ts_0_53
var foo:{id:number;}[] = [{id:1}]; foo = [{id:1}, 1];
{ "end_byte": 53, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTyping21.ts" }
TypeScript/tests/cases/compiler/tsxDiscriminantPropertyInference.tsx_0_804
// @noImplicitAny: true // @strictNullChecks: true // @jsx: preserve // Repro from #41759 namespace JSX { export interface Element {} } type DiscriminatorTrue = { disc: true; cb: (x: string) => void; } type DiscriminatorFalse = { disc?: false; cb: (x: number) => void; } type Props = Discriminato...
{ "end_byte": 804, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/tsxDiscriminantPropertyInference.tsx" }
TypeScript/tests/cases/compiler/moduleNoneDynamicImport.ts_0_166
// @allowJs: true // @target: es2015,es2020 // @module: none // @outFile: /a.js // @filename: /a.ts const foo = import("./b"); // @filename: /b.js export default 1;
{ "end_byte": 166, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleNoneDynamicImport.ts" }
TypeScript/tests/cases/compiler/genericClasses2.ts_0_256
// @declaration: true interface Foo<T> { a: T; } class C<T> { public x: T; public y: Foo<T>; public z: Foo<number>; } var v1 : C<string>; var y = v1.x; // should be 'string' var w = v1.y.a; // should be 'string' var z = v1.z.a; // should be 'number'
{ "end_byte": 256, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericClasses2.ts" }
TypeScript/tests/cases/compiler/moduleAugmentationDoesNamespaceEnumMergeOfReexport.ts_0_439
// @filename: file.ts export namespace Root { // type-only NS export interface Foo { x: number; } } // @filename: reexport.ts export * from "./file"; // @filename: augment.ts import * as ns from "./reexport"; declare module "./reexport" { // Merging an enum into a type-only NS is OK export ...
{ "end_byte": 439, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleAugmentationDoesNamespaceEnumMergeOfReexport.ts" }
TypeScript/tests/cases/compiler/importShadowsGlobalName.ts_0_156
//@module: amd // @Filename:Foo.ts class Foo {} export = Foo; // @Filename: Bar.ts import Error = require('Foo'); class Bar extends Error {} export = Bar;
{ "end_byte": 156, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importShadowsGlobalName.ts" }