_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/narrowRefinedConstLikeParameterBIndingElementNameInInnerScope.ts_0_181
// @strict: true // @noEmit: true function ff({ a, b }: { a: string | undefined, b: () => void }) { if (a !== undefined) { b = () => { const x: string = a; } } }
{ "end_byte": 181, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowRefinedConstLikeParameterBIndingElementNameInInnerScope.ts" }
TypeScript/tests/cases/compiler/templateLiteralEscapeSequence.ts_0_2062
declare function tag(template: TemplateStringsArray, ...substitutions: any[]): string; `\u`; `\u0`; `\u00`; `\u000`; `\u0000`; `\u{}`; `\u{ffffff}`; `\x`; `\x0`; `\x00`; `${0}\u`; `${0}\u0`; `${0}\u00`; `${0}\u000`; `${0}\u0000`; `${0}\u{}`; `${0}\u{ffffff}`; `${0}\x`; `${0}\x0`; `${0}\x00`; `\u${0}`; `\u0${0}`; `\u00...
{ "end_byte": 2062, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/templateLiteralEscapeSequence.ts" }
TypeScript/tests/cases/compiler/staticAsIdentifier.ts_0_306
class C1 { static static [x: string]: string; } class C2 { static static m() {} } class C3 { static static p: string; } class C4 { static static foo() {} } class C5 { static static } class C6 { static static } class C7 extends C6 { static override static }
{ "end_byte": 306, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/staticAsIdentifier.ts" }
TypeScript/tests/cases/compiler/doNotEmitTripleSlashCommentsInEmptyFile.ts_3_247
@removeComments: true // @Filename: file0.ts // @Filename: file1.ts // @Filename: file2.ts /// <reference path="file0.ts" /> /// <reference path="file1.ts" /> /// <amd-dependency path="/js/libs/hgn.js!app/templates/home" name="compiler"/>
{ "end_byte": 247, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/doNotEmitTripleSlashCommentsInEmptyFile.ts" }
TypeScript/tests/cases/compiler/constructorPropertyJs.ts_0_207
// @allowJs: true // @checkJs: true // @declaration: true // @emitDeclarationOnly: true // @filename: /a.js class C { /** * @param {any} a */ foo(a) { this.constructor = a; } }
{ "end_byte": 207, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constructorPropertyJs.ts" }
TypeScript/tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts_0_134
//@noUnusedLocals:true //@noUnusedParameters:true class Dummy { public greeter(person: string) { var unused = 20; } }
{ "end_byte": 134, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts" }
TypeScript/tests/cases/compiler/anyAsReturnTypeForNewOnCall.ts_0_98
function Point(x, y) { this.x = x; this.y = y; } var o = new Point(3, 4); var xx = o.x;
{ "end_byte": 98, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/anyAsReturnTypeForNewOnCall.ts" }
TypeScript/tests/cases/compiler/errorForUsingPropertyOfTypeAsType03.ts_0_570
namespace Test1 { enum Color { Red, Green, Blue } type C1 = Color; type C2 = typeof Color; let a1: Color.Red.toString; let a2: Color.Red["toString"]; let a3: Color["Red"]["toString"]; //let b1: (typeof Color).Red.toString; //let b2: (typeof Color).Red["toSt...
{ "end_byte": 570, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/errorForUsingPropertyOfTypeAsType03.ts" }
TypeScript/tests/cases/compiler/publicGetterProtectedSetterFromThisParameter.ts_0_599
// @target: ES5 class A { get x() { return 0; } protected set x(v: number) { } public get y() { return 0; } protected set y(v: number) { } } class B { get q() { return 0; } protected set q(v: number) { } protected get u() { return 0; } protected set u(v: number) { } foo(this: A, a: A, b: B) { ...
{ "end_byte": 599, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/publicGetterProtectedSetterFromThisParameter.ts" }
TypeScript/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision.ts_0_453
// @noemithelpers: true // @experimentaldecorators: true // @emitdecoratormetadata: true // @target: es5 // @module: commonjs // @filename: db.ts export class db { public doSomething() { } } // @filename: service.ts import {db} from './db'; function someDecorator(target) { return target; } @someDecorator c...
{ "end_byte": 453, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision.ts" }
TypeScript/tests/cases/compiler/collisionArgumentsInType.ts_0_726
var v1: (i: number, ...arguments) => void; // no error - no code gen var v12: (arguments: number, ...restParameters) => void; // no error - no code gen var v2: { (arguments: number, ...restParameters); // no error - no code gen new (arguments: number, ...restParameters); // no error - no code gen foo(argume...
{ "end_byte": 726, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionArgumentsInType.ts" }
TypeScript/tests/cases/compiler/typeParameterExtendingUnion2.ts_0_207
class Animal { run() { } } class Cat extends Animal { meow } class Dog extends Animal { woof } function run(a: Cat | Dog) { a.run(); } function f<T extends Cat | Dog>(a: T) { a.run(); run(a); }
{ "end_byte": 207, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeParameterExtendingUnion2.ts" }
TypeScript/tests/cases/compiler/es6ExportAssignment4.ts_0_173
// @target: es6 // @filename: modules.d.ts declare module "a" { var a: number; export = a; // OK, in ambient context } // @filename: b.ts import * as a from "a";
{ "end_byte": 173, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ExportAssignment4.ts" }
TypeScript/tests/cases/compiler/classExpressionWithStaticProperties1.ts_0_82
var v = class C { static a = 1; static b = 2; static c = C.a + C.b; };
{ "end_byte": 82, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classExpressionWithStaticProperties1.ts" }
TypeScript/tests/cases/compiler/infinitelyExpandingTypes5.ts_0_290
interface Query<T> { foo(x: T): Query<T[]>; } interface Enumerator<T> { (action: (item: T, index: number) => boolean): boolean; } function from<T>(array: T[]): Query<T>; function from<T>(enumerator: Enumerator<T>): Query<T>; function from(arg: any): any { return undefined; }
{ "end_byte": 290, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/infinitelyExpandingTypes5.ts" }
TypeScript/tests/cases/compiler/requireOfJsonFileWithModuleNodeResolutionEmitUndefined.ts_0_208
// @moduleResolution: node // @outdir: out/ // @fullEmitPaths: true // @resolveJsonModule: true // @Filename: file1.ts import * as b from './b.json'; // @Filename: b.json { "a": true, "b": "hello" }
{ "end_byte": 208, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/requireOfJsonFileWithModuleNodeResolutionEmitUndefined.ts" }
TypeScript/tests/cases/compiler/arrayCast.ts_0_320
// Should fail. Even though the array is contextually typed with { id: number }[], it still // has type { foo: string }[], which is not assignable to { id: number }[]. <{ id: number; }[]>[{ foo: "s" }]; // Should succeed, as the {} element causes the type of the array to be {}[] <{ id: number; }[]>[{ foo: "s" }, {}];
{ "end_byte": 320, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arrayCast.ts" }
TypeScript/tests/cases/compiler/breakTarget5.ts_0_119
// @allowUnusedLabels: true target: while (true) { function f() { while (true) { break target; } } }
{ "end_byte": 119, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/breakTarget5.ts" }
TypeScript/tests/cases/compiler/defaultIndexProps2.ts_0_143
class Foo { public v = "Yo"; } var f = new Foo(); // WScript.Echo(f[0]); var o = {v:"Yo2"}; // WScript.Echo(o[0]); 1[0]; var q = "s"[0];
{ "end_byte": 143, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/defaultIndexProps2.ts" }
TypeScript/tests/cases/compiler/typeGuardNarrowsIndexedAccessOfKnownProperty2.ts_0_147
// @strict: true const foo: { key?: number } = {}; const key = 'key' as const; if (foo[key]) { foo[key]; // number foo.key; // number }
{ "end_byte": 147, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeGuardNarrowsIndexedAccessOfKnownProperty2.ts" }
TypeScript/tests/cases/compiler/moduleResolutionAsTypeReferenceDirective.ts_0_362
// @noImplicitReferences: true // @typeRoots: /typings // @types: phaser // @traceResolution: true // @currentDirectory: / // @Filename: /typings/phaser/types/phaser.d.ts export const a2: number; // @Filename: /typings/phaser/package.json { "name": "phaser", "version": "1.2.3", "types": "types/phaser.d.ts" } // @Fi...
{ "end_byte": 362, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolutionAsTypeReferenceDirective.ts" }
TypeScript/tests/cases/compiler/internalImportUnInstantiatedModuleMergedWithClassNotReferencingInstance.ts_0_128
class A { aProp: string; } module A { export interface X { s: string } } module B { var A = 1; import Y = A; }
{ "end_byte": 128, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/internalImportUnInstantiatedModuleMergedWithClassNotReferencingInstance.ts" }
TypeScript/tests/cases/compiler/asiInES6Classes.ts_0_109
class Foo { defaults = { done: false } bar() { return 3; } }
{ "end_byte": 109, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/asiInES6Classes.ts" }
TypeScript/tests/cases/compiler/classImplementsClass1.ts_0_36
class A { } class C implements A { }
{ "end_byte": 36, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classImplementsClass1.ts" }
TypeScript/tests/cases/compiler/multipleClassPropertyModifiers.ts_0_101
class C { public static p1; static public p2; private static p3; static private p4; }
{ "end_byte": 101, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/multipleClassPropertyModifiers.ts" }
TypeScript/tests/cases/compiler/classMemberInitializerScoping2.ts_0_132
// @target: es2017,esnext // @useDefineForClassFields: true,false const x = 1 class C { p = x constructor(x: string) { } }
{ "end_byte": 132, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classMemberInitializerScoping2.ts" }
TypeScript/tests/cases/compiler/exportEqualsClassRedeclarationError.ts_0_221
// @target: es6 // @module: commonjs class SomeClass { static get someProp(): number { return 0; } static set someProp(value: number) {} static set someProp(value: number) {} } export = SomeClass;
{ "end_byte": 221, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportEqualsClassRedeclarationError.ts" }
TypeScript/tests/cases/compiler/genericTypeAssertions6.ts_0_441
class A<T,U> { constructor(x) { var y = <T>x; var z = <U>x; } f(x: T, y: U) { x = <T>y; y = <U>x; } } class B<T extends Date, U extends Date> extends A<T, U> { g(x: T) { var a: Date = x; var b = <Date>x; var c = <T>new Date(); var d =...
{ "end_byte": 441, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericTypeAssertions6.ts" }
TypeScript/tests/cases/compiler/downlevelLetConst19.ts_0_214
'use strict' declare function use(a: any); var x; function a() { { let x; use(x); function b() { { let x; use(x); } use(x); } } use(x) } use(x)
{ "end_byte": 214, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/downlevelLetConst19.ts" }
TypeScript/tests/cases/compiler/genericCloduleInModule.ts_0_169
module A { export class B<T> { foo() { } static bar() { } } export module B { export var x = 1; } } var b: A.B<number>; b.foo();
{ "end_byte": 169, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericCloduleInModule.ts" }
TypeScript/tests/cases/compiler/decoratorMetadataOnInferredType.ts_0_351
// @noemithelpers: true // @experimentaldecorators: true // @emitdecoratormetadata: true // @target: es5 // @module: commonjs declare var console: { log(msg: string): void; }; class A { constructor() { console.log('new A'); } } function decorator(target: Object, propertyKey: string) { } export class B { ...
{ "end_byte": 351, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/decoratorMetadataOnInferredType.ts" }
TypeScript/tests/cases/compiler/discriminateWithOptionalProperty3.ts_0_1134
// @strict: true // @exactOptionalPropertyTypes: true, false // @lib: esnext // @noEmit: true // https://github.com/microsoft/TypeScript/issues/55532#issuecomment-1694744665 type Maybe<T> = null | undefined | T; declare class GraphQLError extends Error { originalError: Error; } interface ExecutionArgs { variabl...
{ "end_byte": 1134, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/discriminateWithOptionalProperty3.ts" }
TypeScript/tests/cases/compiler/recursiveConditionalTypes.ts_0_4940
// @strict: true // @declaration: true // @target: esnext // Awaiting promises type __Awaited<T> = T extends null | undefined ? T : T extends PromiseLike<infer U> ? __Awaited<U> : T; type MyPromise<T> = { then<U>(f: ((value: T) => U | PromiseLike<U>) | null | undefined): MyPromise<U>; } type Infinit...
{ "end_byte": 4940, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveConditionalTypes.ts" }
TypeScript/tests/cases/compiler/circularContextualReturnType.ts_0_114
// @strict: true // Repro from #17711 Object.freeze({ foo() { return Object.freeze('a'); }, });
{ "end_byte": 114, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/circularContextualReturnType.ts" }
TypeScript/tests/cases/compiler/functionOverloads36.ts_0_145
function foo(bar:{a:number;}):number; function foo(bar:{a:string;}):string; function foo(bar:{a:any;}):any{ return bar } var x = foo({a:'foo'});
{ "end_byte": 145, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloads36.ts" }
TypeScript/tests/cases/compiler/localRequireFunction.ts_0_184
// @module: commonjs // @allowJs: true // @outDir: ./out/ // @filename: app.js function require(a) { return a; } const fs = require("fs"); const text = fs.readFileSync("/a/b/c");
{ "end_byte": 184, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/localRequireFunction.ts" }
TypeScript/tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithExport.ts_0_1984
// @module: commonjs // @declaration: true // @Filename: privacyTopLevelAmbientExternalModuleImportWithExport_require.ts // Public elements export class c_public { foo: string; } // @Filename: privacyTopLevelAmbientExternalModuleImportWithExport_require1.ts export class c_public { bar: string; } // @Filename:...
{ "end_byte": 1984, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithExport.ts" }
TypeScript/tests/cases/compiler/systemModule14.ts_0_145
// @module: system // @isolatedModules: true function foo() { return a; } import {a} from "foo"; export {foo} var x = 1; export {foo as b}
{ "end_byte": 145, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/systemModule14.ts" }
TypeScript/tests/cases/compiler/narrowingTypeofObject.ts_0_235
// @strict: true interface F { (): string } function test(x: number & { _foo: string }) { if (typeof x === 'object') { x; } } function f1(x: F & { foo: number }) { if (typeof x !== "object") { x; } }
{ "end_byte": 235, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowingTypeofObject.ts" }
TypeScript/tests/cases/compiler/jsFileCompilationWithOut.ts_0_108
// @allowJs: true // @outFile: out.js // @filename: a.ts class c { } // @filename: b.js function foo() { }
{ "end_byte": 108, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationWithOut.ts" }
TypeScript/tests/cases/compiler/enumWithPrimitiveName.ts_0_44
enum string { } enum number { } enum any { }
{ "end_byte": 44, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumWithPrimitiveName.ts" }
TypeScript/tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES5.ts_0_415
// @target: ES5 "use strict"; function foo(a: number) { if (a === 1) { function foo() { } // Error to declare function in block scope foo(); foo(10); // not ok } else { function foo() { } // Error to declare function in block scope foo(); foo(10); // not ok ...
{ "end_byte": 415, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES5.ts" }
TypeScript/tests/cases/compiler/functionTypeArgumentAssignmentCompat.ts_0_122
var f : { <T>(x:T): T; } var g : { <S>() : S[]; } = () => []; f = g; var s = f("str").toUpperCase(); console.log(s);
{ "end_byte": 122, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionTypeArgumentAssignmentCompat.ts" }
TypeScript/tests/cases/compiler/declFileTypeAnnotationBuiltInType.ts_0_487
// @target: ES5 // @declaration: true // string function foo(): string { return ""; } function foo2() { return ""; } // number function foo3(): number { return 10; } function foo4() { return 10; } // boolean function foo5(): boolean { return true; } function foo6() { return false; } // void ...
{ "end_byte": 487, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileTypeAnnotationBuiltInType.ts" }
TypeScript/tests/cases/compiler/importElisionExportNonExportAndDefault.ts_0_319
// @target: esnext // @module: esnext // @filename: main.ts import MyFunction from "./MyComponent"; MyFunction({msg: "Hello World"}); // @filename: MyComponent.ts interface MyFunction { msg: string; } export const MyFunction = ({ msg }: MyFunction) => console.log(`Got message "${msg}"`); export default MyFunction;
{ "end_byte": 319, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importElisionExportNonExportAndDefault.ts" }
TypeScript/tests/cases/compiler/esModuleInteropWithExportStar.ts_0_219
// @esModuleInterop: true // @target: es5 // @filename: fs.d.ts export const x: number; // @filename: mjts.ts import * as fs from "./fs"; fs; export * from "./fs"; export {x} from "./fs"; export {x as y} from "./fs";
{ "end_byte": 219, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/esModuleInteropWithExportStar.ts" }
TypeScript/tests/cases/compiler/commentsOnObjectLiteral1.ts_0_99
// @removeComments: false var Person = makeClass( /** @scope Person */ { } );
{ "end_byte": 99, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentsOnObjectLiteral1.ts" }
TypeScript/tests/cases/compiler/cloduleAndTypeParameters.ts_0_142
class Foo<T extends Foo.Bar> { constructor() { } } module Foo { export interface Bar { bar(): void; } export class Baz { } }
{ "end_byte": 142, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/cloduleAndTypeParameters.ts" }
TypeScript/tests/cases/compiler/objectCreate-errors.ts_0_430
// @strictNullChecks: true var e1 = Object.create(1); // Error var e2 = Object.create("string"); // Error var e3 = Object.create(false); // Error var e4 = Object.create(undefined); // Error var e5 = Object.create(1, {}); // Error var e6 = Object.create("string", {}); ...
{ "end_byte": 430, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectCreate-errors.ts" }
TypeScript/tests/cases/compiler/taggedPrimitiveNarrowing.ts_0_461
// @strict: true // @declaration: true type Hash = string & { __hash: true }; function getHashLength(hash: Hash): number { if (typeof hash !== "string") { throw new Error("This doesn't look like a hash"); } return hash.length; } function getHashLength2<T extends { __tag__: unknown}>(hash: string ...
{ "end_byte": 461, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/taggedPrimitiveNarrowing.ts" }
TypeScript/tests/cases/compiler/importDeclarationInModuleDeclaration1.ts_0_59
module m2 { import m3 = require("use_glo_M1_public"); }
{ "end_byte": 59, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importDeclarationInModuleDeclaration1.ts" }
TypeScript/tests/cases/compiler/propertyAccess1.ts_0_46
var foo: { a: number; }; foo.a = 4; foo.b = 5;
{ "end_byte": 46, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/propertyAccess1.ts" }
TypeScript/tests/cases/compiler/spreadInvalidArgumentType.ts_0_1662
enum E { v1, v2 }; function f<T extends { b: string }>(p1: T, p2: T[]) { var t: T; var i: T["b"]; var k: keyof T; var mapped_generic: {[P in keyof T]: T[P]}; var mapped: {[P in "b"]: T[P]}; var union_generic: T | { a: number }; var union_primitive: { a: number } | number; var inters...
{ "end_byte": 1662, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/spreadInvalidArgumentType.ts" }
TypeScript/tests/cases/compiler/assignmentCompatability18.ts_0_338
module __test1__ { export interface interfaceWithPublicAndOptional<T,U> { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional<number,string> = { one: 1 };; export var __val__obj4 = obj4; } module __test2__ { export var obj = {one: [1]}; export var __val__obj = obj; } __test2__.__val__obj = __t...
{ "end_byte": 338, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatability18.ts" }
TypeScript/tests/cases/compiler/recursiveExportAssignmentAndFindAliasedType2.ts_0_697
//@module: amd // @Filename: recursiveExportAssignmentAndFindAliasedType2_moduleDef.d.ts declare module "moduleC" { import self = require("moduleD"); export = self; } declare module "moduleD" { import self = require("moduleC"); export = self; } // @Filename: recursiveExportAssignmentAndFindAliasedType2...
{ "end_byte": 697, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveExportAssignmentAndFindAliasedType2.ts" }
TypeScript/tests/cases/compiler/ClassDeclarationWithInvalidConstOnPropertyDeclaration.ts_0_45
class AtomicNumbers { static const H = 1; }
{ "end_byte": 45, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ClassDeclarationWithInvalidConstOnPropertyDeclaration.ts" }
TypeScript/tests/cases/compiler/promiseIdentity2.ts_0_444
export interface IPromise<T, V> { then<U, W>(callback: (x: T) => IPromise<U, W>): IPromise<U, W>; } export interface Promise<T, V> { then<U, W>(callback: (x: T) => Promise<T, U>): Promise<T, W>; } // error because T is string in the first declaration, and T is boolean in the second // Return type and callback ...
{ "end_byte": 444, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/promiseIdentity2.ts" }
TypeScript/tests/cases/compiler/interfaceDeclaration4.ts_0_701
// Import this module when test harness supports external modules. Also remove the internal module below. // import Foo = require("interfaceDeclaration5") module Foo { export interface I1 { item: string; } export class C1 { } } class C1 implements Foo.I1 { public item:string; } // Allowed interface I2 extend...
{ "end_byte": 701, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/interfaceDeclaration4.ts" }
TypeScript/tests/cases/compiler/externalModuleQualification.ts_0_244
//@module: commonjs export var ID = "test"; export class DiffEditor<A, B, C> { private previousDiffAction: NavigateAction; constructor(id: string = ID) { } } class NavigateAction { f(editor: DiffEditor<any, any, any>) { } }
{ "end_byte": 244, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/externalModuleQualification.ts" }
TypeScript/tests/cases/compiler/functionCall8.ts_0_74
function foo(a?:string){} foo('foo'); foo('foo', 'bar'); foo(4); foo();
{ "end_byte": 74, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionCall8.ts" }
TypeScript/tests/cases/compiler/inheritanceMemberFuncOverridingMethod.ts_0_108
class a { x() { return "10"; } } class b extends a { x() { return "20"; } }
{ "end_byte": 108, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inheritanceMemberFuncOverridingMethod.ts" }
TypeScript/tests/cases/compiler/exportImportCanSubstituteConstEnumForValue.ts_0_1393
// @module: amd // @declaration: true // @target: es5 module MsPortalFx.ViewModels.Dialogs { export const enum DialogResult { Abort, Cancel, Ignore, No, Ok, Retry, Yes, } export interface DialogResultCallback { (result: MsPortalFx.ViewModels....
{ "end_byte": 1393, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportImportCanSubstituteConstEnumForValue.ts" }
TypeScript/tests/cases/compiler/fixingTypeParametersRepeatedly3.ts_0_448
interface Base { baseProp; } interface Derived extends Base { toBase?(): Base; } var derived: Derived; declare function foo<T>(x: T, func: (p: T) => T): T; var result = foo(derived, d => d.toBase()); // bar should type check just like foo. // result2 should have the same type as result declare function bar<T...
{ "end_byte": 448, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/fixingTypeParametersRepeatedly3.ts" }
TypeScript/tests/cases/compiler/jsFileMethodOverloads2.ts_0_803
// @allowJs: true // @outDir: dist/ // @declaration: true // @filename: jsFileMethodOverloads2.js // Also works if all @overload tags are combined in one comment. /** * @template T */ class Example { /** * @param {T} value */ constructor(value) { this.value = value; } /** * @overload * @pa...
{ "end_byte": 803, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileMethodOverloads2.ts" }
TypeScript/tests/cases/compiler/collisionExportsRequireAndClass.ts_0_515
//@module: amd //@filename: collisionExportsRequireAndClass_externalmodule.ts export class require { } export class exports { } module m1 { class require { } class exports { } } module m2 { export class require { } export class exports { } } //@filename: collisionExportsRequireAndClass_...
{ "end_byte": 515, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionExportsRequireAndClass.ts" }
TypeScript/tests/cases/compiler/constructorStaticParamName.ts_0_124
// static as constructor parameter name should only give error if 'use strict' class test { constructor (static) { } }
{ "end_byte": 124, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constructorStaticParamName.ts" }
TypeScript/tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts_0_343
function foo<T, U>(x:T, y:U, f: (v: T) => U) { var r1 = f<number>(1); var r2 = f(1); var r3 = f<any>(null); var r4 = f(null); var r11 = f(x); var r21 = f<number>(x); var r31 = f<any>(null); var r41 = f(null); var r12 = f(y); var r22 = f<number>(y); var r32 = f<any>(null); ...
{ "end_byte": 343, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts" }
TypeScript/tests/cases/compiler/recursiveClassBaseType.ts_0_386
// @strict: true // @declaration: true // Repro from #44281 declare const p: <T>(fn: () => T) => T; declare const Base: <T>(val: T) => { new(): T }; class C extends Base({ x: p<C[]>(() => []) }) { } // Repro from #44359 abstract class Base1 { abstract root(): Derived1; } class Derived1 extends class extends ...
{ "end_byte": 386, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveClassBaseType.ts" }
TypeScript/tests/cases/compiler/jsdocInTypeScript.ts_0_1391
// @lib: es2015 // @traceResolution: true // JSDoc typedef tags are not bound TypeScript files. /** @typedef {function} T */ declare const x: T; class T { prop: number; } x.prop; // Just to be sure that @property has no impact either. /** * @typedef {Object} MyType * @property {string} yes */ declare const m...
{ "end_byte": 1391, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsdocInTypeScript.ts" }
TypeScript/tests/cases/compiler/optionsSourcemapInlineSourcesMapRoot.ts_0_75
// @sourcemap: true // @inlineSources: true // @mapRoot: local var a = 10;
{ "end_byte": 75, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/optionsSourcemapInlineSourcesMapRoot.ts" }
TypeScript/tests/cases/compiler/genericCallWithoutArgs.ts_0_51
function f<X, Y>(x: X, y: Y) { } f<number,string>.
{ "end_byte": 51, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericCallWithoutArgs.ts" }
TypeScript/tests/cases/compiler/nonexistentPropertyUnavailableOnPromisedType.ts_0_56
function f(x: Promise<number>) { x.toLowerCase(); }
{ "end_byte": 56, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nonexistentPropertyUnavailableOnPromisedType.ts" }
TypeScript/tests/cases/compiler/binaryArithmatic3.ts_0_30
var v = undefined | undefined;
{ "end_byte": 30, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/binaryArithmatic3.ts" }
TypeScript/tests/cases/compiler/intersectionsAndOptionalProperties2.ts_0_907
// @strict: true // @exactOptionalPropertyTypes: true, false // @noEmit: true // https://github.com/microsoft/TypeScript/issues/58174 type A_Primitive = { disabled?: boolean; }; type B_Primitive = { disabled?: boolean | undefined; }; type C_Primitive = { disabled?: boolean; }; declare const ab_primitive: A_P...
{ "end_byte": 907, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/intersectionsAndOptionalProperties2.ts" }
TypeScript/tests/cases/compiler/returnTypeInferenceNotTooBroad.ts_0_512
type Signs = { kind: 'a'; a: 3; } | { kind: 'b'; b: 2; } | { kind: 'c'; c: 1; }; interface Opts<T> { low?: number; sign?: T } interface Wrapper<T> { } declare function sepsis<T extends Signs>(opts: Opts<T>): Wrapper<T>; declare function unwrap<T>(w: Wrapper<T>): T; export const y = sepsis({ low: 1, sign: { kind...
{ "end_byte": 512, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/returnTypeInferenceNotTooBroad.ts" }
TypeScript/tests/cases/compiler/defineVariables_useDefineForClassFields.ts_0_98
// @target: ESNext // @useDefineForClassFields: true const a = () => b() const b = () => null a()
{ "end_byte": 98, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/defineVariables_useDefineForClassFields.ts" }
TypeScript/tests/cases/compiler/typeofExternalModules.ts_0_402
// @module: commonjs // @Filename: typeofExternalModules_external.ts export class C { } // @Filename: typeofExternalModules_exportAssign.ts class D { } export = D; // @Filename: typeofExternalModules_core.ts import ext = require('./typeofExternalModules_external'); import exp = require('./typeofExternalModules_export...
{ "end_byte": 402, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeofExternalModules.ts" }
TypeScript/tests/cases/compiler/pathMappingBasedModuleResolution5_node.ts_0_955
// @module: commonjs // @traceResolution: true // paths is defined in tsconfig.json // @filename: c:/root/tsconfig.json { "compilerOptions": { "baseUrl": ".", "paths": { "*": [ "*", "generated/*" ], "components/*": [ ...
{ "end_byte": 955, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/pathMappingBasedModuleResolution5_node.ts" }
TypeScript/tests/cases/compiler/interfaceWithOptionalProperty.ts_0_54
// @declaration: true interface I { x?: number; }
{ "end_byte": 54, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/interfaceWithOptionalProperty.ts" }
TypeScript/tests/cases/compiler/augmentExportEquals6.ts_0_473
// @module: amd // @filename: file1.ts class foo {} namespace foo { export class A {} export namespace B { export let a; } } export = foo; // @filename: file2.ts import x = require("./file1"); x.B.b = 1; // OK - './file1' is a namespace declare module "./file1" { interface A { a: number } namespace ...
{ "end_byte": 473, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/augmentExportEquals6.ts" }
TypeScript/tests/cases/compiler/superInCatchBlock1.ts_0_103
class A { m(): void { } } class B extends A { m() { try { } catch (e) { super.m(); } } }
{ "end_byte": 103, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/superInCatchBlock1.ts" }
TypeScript/tests/cases/compiler/commentOnArrayElement2.ts_3_103
nst array = [ /* element 1*/ 1 /* end of element 1 */, 2 /* end of element 2 */ ];
{ "end_byte": 103, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentOnArrayElement2.ts" }
TypeScript/tests/cases/compiler/genericNumberIndex.ts_0_37
type X<I extends number> = ['a'][I];
{ "end_byte": 37, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericNumberIndex.ts" }
TypeScript/tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts_0_480
interface I { value: string; toString: (t: string) => string; } function f2(args: I) { } f2({ hello: 1 }) // error f2({ value: '' }) // missing toString satisfied by Object's member f2({ value: '', what: 1 }) // missing toString satisfied by Object's member f2({ toString: (s) => s }) // error, missing proper...
{ "end_byte": 480, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts" }
TypeScript/tests/cases/compiler/commentOnArrayElement10.ts_3_37
nst array = [,, /* comment */];
{ "end_byte": 37, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentOnArrayElement10.ts" }
TypeScript/tests/cases/compiler/capturedParametersInInitializers1.ts_0_834
// @target: es6 // ok - usage is deferred function foo1(y = class {c = x}, x = 1) { new y().c; } // ok - used in file function foo2(y = function(x: typeof z) {}, z = 1) { } // ok -used in type let a; function foo3(y = { x: <typeof z>a }, z = 1) { } // error - used before declaration function foo4(y = {...
{ "end_byte": 834, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/capturedParametersInInitializers1.ts" }
TypeScript/tests/cases/compiler/contextualTyping22.ts_0_80
var foo:(a:number)=>number = function(a){return a}; foo = function(b){return b};
{ "end_byte": 80, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTyping22.ts" }
TypeScript/tests/cases/compiler/genericClasses1.ts_0_114
// @declaration: true class C<T> { public x: T; } var v1 = new C<string>(); var y = v1.x; // should be 'string'
{ "end_byte": 114, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericClasses1.ts" }
TypeScript/tests/cases/compiler/subtypeRelationForNever.ts_0_370
function fail(message: string) : never { throw new Error(message); } function withFew<a, r>(values: a[], haveFew: (values: a[]) => r, haveNone: (reason: string) => r): r { return values.length > 0 ? haveFew(values) : haveNone('No values.'); } function id<a>(value: a) : a { return value; } const result = withFew([1,...
{ "end_byte": 370, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/subtypeRelationForNever.ts" }
TypeScript/tests/cases/compiler/importHelpersBundler.ts_0_1067
// @importHelpers: true // @target: es2017 // @module: esnext // @moduleResolution: bundler // @Filename: /node_modules/tslib/package.json { "name": "tslib", "main": "tslib.js", "module": "tslib.es6.js", "jsnext:main": "tslib.es6.js", "typings": "tslib.d.ts", "exports": { ".": { "module": {...
{ "end_byte": 1067, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importHelpersBundler.ts" }
TypeScript/tests/cases/compiler/declFileTypeAnnotationVisibilityErrorReturnTypeOfFunction.ts_0_985
// @target: ES5 // @module: commonjs // @declaration: true module m { class private1 { } export class public1 { } // Directly using names from this module function foo1(): private1 { return; } function foo2() { return new private1(); } export function foo3(): ...
{ "end_byte": 985, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileTypeAnnotationVisibilityErrorReturnTypeOfFunction.ts" }
TypeScript/tests/cases/compiler/genericArray0.ts_0_99
// @declaration: true var x:number[]; var y = x; function map<U>() { var ys: U[] = []; }
{ "end_byte": 99, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericArray0.ts" }
TypeScript/tests/cases/compiler/collisionExportsRequireAndAmbientFunction.ts_0_320
//@module: amd export declare function exports(): number; export declare function require(): string[]; declare module m1 { function exports(): string; function require(): number; } module m2 { export declare function exports(): string; export declare function require(): string[]; var a = 10; }
{ "end_byte": 320, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionExportsRequireAndAmbientFunction.ts" }
TypeScript/tests/cases/compiler/noImplicitReturnsWithoutReturnExpression.ts_0_392
// @noImplicitReturns: true function isMissingReturnExpression(): number { return; } function isMissingReturnExpression2(): any { return; } function isMissingReturnExpression3(): number|void { return; } function isMissingReturnExpression4(): void { return; } function isMissingReturnExpression5(x) { ...
{ "end_byte": 392, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noImplicitReturnsWithoutReturnExpression.ts" }
TypeScript/tests/cases/compiler/jsxLocalNamespaceIndexSignatureNoCrash.tsx_0_338
// @jsx: react // @jsxFactory: X.jsx // @filename: index.tsx export class X { static jsx() { return document.createElement('p'); } } export namespace X { export namespace JSX { export type IntrinsicElements = { [other: string]: any; }; } } function A() { return...
{ "end_byte": 338, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsxLocalNamespaceIndexSignatureNoCrash.tsx" }
TypeScript/tests/cases/compiler/asyncFunctionTempVariableScoping.ts_0_137
// @target: es5 // @lib: es2015 // https://github.com/Microsoft/TypeScript/issues/19187 async ({ foo, bar, ...rest }) => bar(await foo);
{ "end_byte": 137, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/asyncFunctionTempVariableScoping.ts" }
TypeScript/tests/cases/compiler/circularlyReferentialInterfaceAccessNoCrash.ts_0_171
type Mxs = Mx<'list', Mxs['p1']>; interface Mx<T, K> { p1: T; p2: K; } type ArrElem = ['list', ArrElem[number][0]][]; type TupleElem = [['list', TupleElem[0][0]]];
{ "end_byte": 171, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/circularlyReferentialInterfaceAccessNoCrash.ts" }
TypeScript/tests/cases/compiler/overloadsWithinClasses.ts_0_337
class foo { static fnOverload( ) {} static fnOverload(foo: string){ } // error } class bar { static fnOverload( ); static fnOverload(foo?: string){ } // no error } class X { public attr(name:string):string; public attr(name:string, value:string):X; public attr(first:any, second?:a...
{ "end_byte": 337, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overloadsWithinClasses.ts" }
TypeScript/tests/cases/compiler/importHelpersNoHelpersForAsyncGenerators.ts_0_304
// @importHelpers: true // @target: es5 // @module: commonjs // @lib: esnext // @moduleResolution: classic // @experimentalDecorators: true // @emitDecoratorMetadata: true // @filename: main.ts export async function * f() { await 1; yield 2; yield* [3]; } // @filename: tslib.d.ts export {}
{ "end_byte": 304, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importHelpersNoHelpersForAsyncGenerators.ts" }
TypeScript/tests/cases/compiler/downlevelLetConst9.ts_0_13
let a: number
{ "end_byte": 13, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/downlevelLetConst9.ts" }