_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/importsInAmbientModules1.ts_0_143
// @module: amd // @filename: external.d.ts export var x: number // @filename: main.ts declare module "M" { import {x} from "external" }
{ "end_byte": 143, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importsInAmbientModules1.ts" }
TypeScript/tests/cases/compiler/lastPropertyInLiteralWins.ts_0_362
interface Thing { thunk: (str: string) => void; } function test(thing: Thing) { thing.thunk("str"); } test({ // Should error, as last one wins, and is wrong type thunk: (str: string) => {}, thunk: (num: number) => {} }); test({ // Should be OK. Last 'thunk' is of correct type thunk: (num: number) ...
{ "end_byte": 362, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/lastPropertyInLiteralWins.ts" }
TypeScript/tests/cases/compiler/requireOfJsonFileWithAmd.ts_0_310
// @module: amd // @outdir: out/ // @allowJs: true // @fullEmitPaths: true // @resolveJsonModule: true // @Filename: file1.ts import b1 = require('./b'); let x = b1.a; import b2 = require('./b.json'); if (x) { let b = b2.b; x = (b1.b === b); } // @Filename: b.json { "a": true, "b": "hello" }
{ "end_byte": 310, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/requireOfJsonFileWithAmd.ts" }
TypeScript/tests/cases/compiler/commentOnExpressionStatement1.ts_0_45
// @removeComments: false 1 + 1; // Comment.
{ "end_byte": 45, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentOnExpressionStatement1.ts" }
TypeScript/tests/cases/compiler/destructureComputedProperty.ts_0_266
declare const ab: { n: number } | { n: string }; const nameN = "n"; const { [nameN]: n } = ab; class C { private p: number; } const nameP = "p"; const { "p": p0 } = new C(); const { ["p"]: p1 } = new C(); const { [nameP]: p2 } = new C(); const { p: p3 } = new C();
{ "end_byte": 266, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/destructureComputedProperty.ts" }
TypeScript/tests/cases/compiler/moduleAugmentationInAmbientModule5.ts_0_358
// @module: commonjs // @declaration: true // @filename: array.d.ts declare module "A" { class A { x: number; } } declare module "array" { import {A} from "A"; global { interface Array<T> { getA(): A; } } } // @filename: f.ts /// <reference path="array.d.ts"/> import "arra...
{ "end_byte": 358, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleAugmentationInAmbientModule5.ts" }
TypeScript/tests/cases/compiler/correlatedUnions.ts_0_6687
// @strict: true // @declaration: true // Various repros from #30581 type RecordMap = { n: number, s: string, b: boolean }; type UnionRecord<K extends keyof RecordMap = keyof RecordMap> = { [P in K]: { kind: P, v: RecordMap[P], f: (v: RecordMap[P]) => void }}[K]; function processRecord<K extends keyof Re...
{ "end_byte": 6687, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/correlatedUnions.ts" }
TypeScript/tests/cases/compiler/correlatedUnions.ts_6689_7135
function getConfigOrDefault<T extends keyof Config>( userConfig: Partial<Config>, key: T, defaultValue: Config[T] ): Config[T] { const userValue = userConfig[key]; const assertedCheck = userValue ? userValue! : defaultValue; return assertedCheck; } // repro from #47523 type Foo1 = { x: number; y: str...
{ "end_byte": 7135, "start_byte": 6689, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/correlatedUnions.ts" }
TypeScript/tests/cases/compiler/deepComparisons.ts_0_937
function f1<T, K1 extends keyof T, K2 extends keyof T[K1]>() { let v1: Extract<T, string> = 0 as any as T; // Error let v2: Extract<T[K1], string> = 0 as any as T[K1]; // Error let v3: Extract<T[K1][K2], string> = 0 as any as T[K1][K2]; // No error } type Foo<T> = { x: Foo<T> }; type Bar<T> = { x: Bar<T...
{ "end_byte": 937, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/deepComparisons.ts" }
TypeScript/tests/cases/compiler/badArraySyntax.ts_0_178
class Z { public x = ""; } var a1: Z[] = []; var a2 = new Z[]; var a3 = new Z[](); var a4: Z[] = new Z[]; var a5: Z[] = new Z[](); var a6: Z[][] = new Z [ ] [ ];
{ "end_byte": 178, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/badArraySyntax.ts" }
TypeScript/tests/cases/compiler/reachabilityChecks1.ts_0_825
// @allowUnreachableCode: false // @preserveConstEnums: true while (true); var x = 1; module A { while (true); let x; } module A1 { do {} while(true); module A { interface F {} } } module A2 { while (true); module A { var x = 1; } } module A3 { while (true); ...
{ "end_byte": 825, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reachabilityChecks1.ts" }
TypeScript/tests/cases/compiler/nonInferrableTypePropagation3.ts_0_423
// @strict: true // @noEmit: true // Repro from #53748 declare type Callback<Args extends any[], Out, R> = (...args: Args) => (data: Out) => R; declare function factory<Out>(): <Args extends any[], R>(callback: Callback<Args, Out, R>) => (...args: Args) => R; const make = factory<{id: string, age: number}[]>(); con...
{ "end_byte": 423, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nonInferrableTypePropagation3.ts" }
TypeScript/tests/cases/compiler/aliasInstantiationExpressionGenericIntersectionNoCrash1.ts_0_193
// @strict: true class ErrImpl<E> { e!: E; } declare const Err: typeof ErrImpl & (<T>() => T); type ErrAlias<U> = typeof Err<U>; declare const e: ErrAlias<number>; e as ErrAlias<string>;
{ "end_byte": 193, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/aliasInstantiationExpressionGenericIntersectionNoCrash1.ts" }
TypeScript/tests/cases/compiler/commonSourceDir5.ts_0_367
// @outFile: concat.js // @module: amd // @moduleResolution: node // @Filename: A:/bar.ts import {z} from "./foo"; export var x = z + z; // @Filename: A:/foo.ts import {pi} from "B:/baz"; export var i = Math.sqrt(-1); export var z = pi * pi; // @Filename: B:/baz.ts import {x} from "A:/bar"; import {i} from "A:/foo";...
{ "end_byte": 367, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commonSourceDir5.ts" }
TypeScript/tests/cases/compiler/2dArrays.ts_0_218
class Cell { } class Ship { isSunk: boolean; } class Board { ships: Ship[]; cells: Cell[]; private allShipsSunk() { return this.ships.every(function (val) { return val.isSunk; }); } }
{ "end_byte": 218, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/2dArrays.ts" }
TypeScript/tests/cases/compiler/es5-importHelpersAsyncFunctions.ts_0_829
// @lib: es5,es2015.promise // @importHelpers: true // @target: es5 // @module: commonjs // @moduleResolution: classic // @filename: external.ts export async function foo() { } // @filename: script.ts async function foo() { } // @filename: tslib.d.ts export declare function __extends(d: Function, b: Function): void; ...
{ "end_byte": 829, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es5-importHelpersAsyncFunctions.ts" }
TypeScript/tests/cases/compiler/newLineFlagWithLF.ts_0_31
// @newline: LF var x=1; x=2;
{ "end_byte": 31, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/newLineFlagWithLF.ts" }
TypeScript/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts1.ts_0_674
// @module: commonjs // @declaration: true // @target: ES5 // @filename: server.ts class a { } export default a; // @filename: client.ts import defaultBinding1, { } from "./server"; export var x1 = new defaultBinding1(); import defaultBinding2, { a } from "./server"; export var x2 = new defaultBinding2(); import defa...
{ "end_byte": 674, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts1.ts" }
TypeScript/tests/cases/compiler/importDeclRefereingExternalModuleWithNoResolve.ts_0_126
// @noresolve: true import b = require("externalModule"); declare module "m1" { import im2 = require("externalModule"); }
{ "end_byte": 126, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importDeclRefereingExternalModuleWithNoResolve.ts" }
TypeScript/tests/cases/compiler/lambdaParameterWithTupleArgsHasCorrectAssignability.ts_0_604
// @strict: true type MyTupleItem = {}; type MyTuple = [MyTupleItem, ...MyTupleItem[]]; type GenericFunction<T extends MyTuple> = (...fromArgs: T) => void; class GenericClass<T extends MyTuple> { from: GenericFunction<T> | undefined; } function createClass<T extends MyTuple>(f: GenericFunction<T>): GenericClass<...
{ "end_byte": 604, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/lambdaParameterWithTupleArgsHasCorrectAssignability.ts" }
TypeScript/tests/cases/compiler/enumLiteralUnionNotWidened.ts_0_554
// repro from #22093 enum A { one = "one", two = "two" }; enum B { foo = "foo", bar = "bar" }; type C = A | B.foo; type D = A | "foo"; class List<T> { private readonly items: T[] = []; } function asList<T>(arg: T): List<T> { return new List(); } // TypeScript incorrectly infers the return type of "asList(x)" to be...
{ "end_byte": 554, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumLiteralUnionNotWidened.ts" }
TypeScript/tests/cases/compiler/mergedModuleDeclarationCodeGen5.ts_0_438
module M.buz.plop { export function doom() { } export function M() { } } module M.buz.plop { function gunk() { } function buz() { } export class fudge { } export enum plop { } // Emit these references as follows var v1 = gunk; // gunk var v2 = buz; // buz export var v3 = doom; /...
{ "end_byte": 438, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mergedModuleDeclarationCodeGen5.ts" }
TypeScript/tests/cases/compiler/moduleClassArrayCodeGenTest.ts_0_137
// Invalid code gen for Array of Module class module M { export class A { } class B{ } } var t: M.A[] = []; var t2: M.B[] = [];
{ "end_byte": 137, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleClassArrayCodeGenTest.ts" }
TypeScript/tests/cases/compiler/mappedTypeUnionConstrainTupleTreatedAsArrayLike.ts_0_490
// @noEmit: true // @strict: true type HomomorphicMappedType<T> = { [P in keyof T]: T[P] extends string ? boolean : null } function test1<T extends [number] | [string]>(args: T) { const arr: any[] = [] as HomomorphicMappedType<T> const arr2: readonly any[] = [] as HomomorphicMappedType<T> } function test2<T exte...
{ "end_byte": 490, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mappedTypeUnionConstrainTupleTreatedAsArrayLike.ts" }
TypeScript/tests/cases/compiler/metadataOfClassFromModule.ts_0_254
// @experimentalDecorators: true // @emitDecoratorMetadata: true // @target: es5 module MyModule { export function inject(target: any, key: string): void { } export class Leg { } export class Person { @inject leftLeg: Leg; } }
{ "end_byte": 254, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/metadataOfClassFromModule.ts" }
TypeScript/tests/cases/compiler/typeofEnum.ts_0_51
enum E { e1, e2 } var e1: typeof E; e1.e1;
{ "end_byte": 51, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeofEnum.ts" }
TypeScript/tests/cases/compiler/restParamAsOptional.ts_0_48
function f(...x?) { } function f2(...x = []) { }
{ "end_byte": 48, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/restParamAsOptional.ts" }
TypeScript/tests/cases/compiler/functionOverloads19.ts_0_107
function foo(bar:{b:string;}); function foo(bar:{a:string;}); function foo(bar:{a:any;}) { return {a:""} }
{ "end_byte": 107, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloads19.ts" }
TypeScript/tests/cases/compiler/es5ModuleWithModuleGenCommonjs.ts_0_133
// @target: ES5 // @module: commonjs export class A { constructor () { } public B() { return 42; } }
{ "end_byte": 133, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es5ModuleWithModuleGenCommonjs.ts" }
TypeScript/tests/cases/compiler/unknownSymbols2.ts_0_448
module M { var x: asdf; var y = x + asdf; var z = <asdf>x; // should be an error if (asdf) { } else if (qwerty) { } try { } catch (asdf) { // no error } switch (asdf) { case qwerty: break; default: break; } var a = () => ...
{ "end_byte": 448, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unknownSymbols2.ts" }
TypeScript/tests/cases/compiler/moduleAsBaseType.ts_0_84
module M {} class C extends M {} interface I extends M { } class C2 implements M { }
{ "end_byte": 84, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleAsBaseType.ts" }
TypeScript/tests/cases/compiler/recursiveConditionalCrash1.ts_0_106
type C1<T> = [T extends string ? C1<T> : never][0]; type C2<T> = [T extends string ? [C2<T>] : never][0];
{ "end_byte": 106, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveConditionalCrash1.ts" }
TypeScript/tests/cases/compiler/mismatchedClassConstructorVariable.ts_0_41
var baz: foo; class baz { } class foo { }
{ "end_byte": 41, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mismatchedClassConstructorVariable.ts" }
TypeScript/tests/cases/compiler/asiReturn.ts_3_104
This should be an error for using a return outside a function, but ASI should work properly return
{ "end_byte": 104, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/asiReturn.ts" }
TypeScript/tests/cases/compiler/reExportGlobalDeclaration4.ts_0_255
// @module: commonjs // @filename: file1.d.ts declare class Cls1 { x: number } declare class Cls2 { x: number } // @filename: file2.ts export {Cls1, Cls1 as CCls1}; export {Cls2, Cls2 as CCls2}; export {Cls1 as CCCls1}; export {Cls2 as CCCls2};
{ "end_byte": 255, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reExportGlobalDeclaration4.ts" }
TypeScript/tests/cases/compiler/instanceAndStaticDeclarations1.ts_0_337
// from spec class Point { constructor(public x: number, public y: number) { } public distance(p: Point) { var dx = this.x - p.x; var dy = this.y - p.y; return Math.sqrt(dx * dx + dy * dy); } static origin = new Point(0, 0); static distance(p1: Point, p2: Point) { return p1....
{ "end_byte": 337, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/instanceAndStaticDeclarations1.ts" }
TypeScript/tests/cases/compiler/declFileExportAssignmentOfGenericInterface.ts_0_313
//@module: amd // @declaration: true // @Filename: declFileExportAssignmentOfGenericInterface_0.ts interface Foo<T> { a: string; } export = Foo; // @Filename: declFileExportAssignmentOfGenericInterface_1.ts import a = require('declFileExportAssignmentOfGenericInterface_0'); export var x: a<a<string>>; x.a;
{ "end_byte": 313, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileExportAssignmentOfGenericInterface.ts" }
TypeScript/tests/cases/compiler/simpleRecursionWithBaseCase4.ts_0_312
// @checkJs: true // @noEmit: true // @strict: false var fn2 = function(name) { fn2 = compose(this, 0, 1) return fn2(name) function compose(child, level, find) { if (child === find) { return level } return compose(child, level + 1, find) } } var d = fn2(1); // d: any d.redefined();
{ "end_byte": 312, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/simpleRecursionWithBaseCase4.ts" }
TypeScript/tests/cases/compiler/inheritanceStaticFunctionOverridingInstanceProperty.ts_0_98
class a { x: string; } class b extends a { static x() { return new b().x; } }
{ "end_byte": 98, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inheritanceStaticFunctionOverridingInstanceProperty.ts" }
TypeScript/tests/cases/compiler/jsxNamespaceGlobalReexport.tsx_0_2976
// @strict: true // @jsx: react-jsx // @jsxImportSource: preact // @types: preact/jsx-runtime // @filename: /node_modules/preact/index.d.ts type Defaultize<Props, Defaults> = // Distribute over unions Props extends any // Make any properties included in Default optional ? Partial<Pick<Props, Extract<keyof Props, ke...
{ "end_byte": 2976, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsxNamespaceGlobalReexport.tsx" }
TypeScript/tests/cases/compiler/nestedRecursiveLambda.ts_0_98
function f(a:any) { void (r =>(r => r)); } f((r =>(r => r))); void(r =>(r => r)); [(r =>(r => r))]
{ "end_byte": 98, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nestedRecursiveLambda.ts" }
TypeScript/tests/cases/compiler/checkJsdocTypeTagOnExportAssignment4.ts_0_201
// @allowJs: true // @checkJs: true // @outDir: ./out // @filename: checkJsdocTypeTagOnExportAssignment4.js // @Filename: a.js /** * @typedef {number} Foo */ /** @type {Foo} */ export default "";
{ "end_byte": 201, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/checkJsdocTypeTagOnExportAssignment4.ts" }
TypeScript/tests/cases/compiler/unusedTypeParameterInMethod5.ts_0_101
//@noUnusedLocals:true //@noUnusedParameters:true class A { public f1 = function<X>() { } }
{ "end_byte": 101, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedTypeParameterInMethod5.ts" }
TypeScript/tests/cases/compiler/assignmentCompatability37.ts_0_357
module __test1__ { export interface interfaceWithPublicAndOptional<T,U> { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional<number,string> = { one: 1 };; export var __val__obj4 = obj4; } module __test2__ { export var aa:{ new <Tnumber>(param: Tnumber); };; export var __val__aa = aa; } __test...
{ "end_byte": 357, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatability37.ts" }
TypeScript/tests/cases/compiler/jsFileCompilationNoErrorWithoutDeclarationsWithJsFileReferenceWithOut.ts_0_239
// @allowJs: true // @outFile: out.js // @filename: a.ts class c { } // @filename: b.ts /// <reference path="c.js"/> //no error on above reference since not emitting declarations function foo() { } // @filename: c.js function bar() { }
{ "end_byte": 239, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationNoErrorWithoutDeclarationsWithJsFileReferenceWithOut.ts" }
TypeScript/tests/cases/compiler/functionWithDefaultParameterWithNoStatements13.ts_0_75
var v: any[]; function foo(a = [1 + 1]) { } function bar(a = [1 + 1]) { }
{ "end_byte": 75, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionWithDefaultParameterWithNoStatements13.ts" }
TypeScript/tests/cases/compiler/inferredRestTypeFixedOnce.ts_0_104
function wrap<Args extends unknown[]>(_: (...args: Args) => void) {} wrap(({ cancelable } = {}) => {});
{ "end_byte": 104, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inferredRestTypeFixedOnce.ts" }
TypeScript/tests/cases/compiler/memberOverride.ts_0_235
// An object initialiser accepts the first definition for the same property with a different type signature // Should compile, since the second declaration of a overrides the first var x = { a: "", a: 5 } var n: number = x.a;
{ "end_byte": 235, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/memberOverride.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern3.ts_0_1814
// @lib: es5 // @sourcemap: true declare var console: { log(msg: any): void; } type Robot = [number, string, string]; type MultiSkilledRobot = [string, [string, string]]; var robotA: Robot = [1, "mower", "mowing"]; var robotB: Robot = [2, "trimmer", "trimming"]; var multiRobotA: MultiSkilledRobot = ["mower", ["mow...
{ "end_byte": 1814, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern3.ts" }
TypeScript/tests/cases/compiler/badArrayIndex.ts_0_23
var results = number[];
{ "end_byte": 23, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/badArrayIndex.ts" }
TypeScript/tests/cases/compiler/es5-amd.ts_0_167
// @target: ES5 // @sourcemap: false // @declaration: false // @module: amd class A { constructor () { } public B() { return 42; } }
{ "end_byte": 167, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es5-amd.ts" }
TypeScript/tests/cases/compiler/inexistentPropertyInsideToStringType.ts_0_121
// @checkJs: true // @noEmit: true // @Filename: index.js function toString() { this.yadda this.someValue = ""; }
{ "end_byte": 121, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inexistentPropertyInsideToStringType.ts" }
TypeScript/tests/cases/compiler/moduleAndInterfaceSharingName2.ts_0_140
module X { export module Y { export interface Z { } } export interface Y { } } var z: X.Y.Z = null; var z2: X.Y<string>;
{ "end_byte": 140, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleAndInterfaceSharingName2.ts" }
TypeScript/tests/cases/compiler/exportAssignmentOfDeclaredExternalModule.ts_0_720
// @module: commonjs // @Filename: exportAssignmentOfDeclaredExternalModule_0.ts interface Sammy { new (): any; // a constructor signature (): number; // a 0 arg call signature } export = Sammy; // @Filename: exportAssignmentOfDeclaredExternalModule_1.ts ///<reference path='exportAssignmentOfDeclaredEx...
{ "end_byte": 720, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportAssignmentOfDeclaredExternalModule.ts" }
TypeScript/tests/cases/compiler/blockScopedBindingsInDownlevelGenerator.ts_0_139
// @target: es5 // @downlevelIteration: true // @lib: es2015 function* a() { for (const i of [1,2,3]) { (() => i)() yield i } }
{ "end_byte": 139, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/blockScopedBindingsInDownlevelGenerator.ts" }
TypeScript/tests/cases/compiler/unionOfFunctionAndSignatureIsCallable.ts_0_308
function f1(c1: Function, c2: () => object, callable: typeof c1 | typeof c2) { const a = c1(); const b = c2(); const c = callable(); } function f2(fetcherParams: object | (() => object)) { const data = typeof fetcherParams === 'function' ? fetcherParams() : fetcherParams }
{ "end_byte": 308, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unionOfFunctionAndSignatureIsCallable.ts" }
TypeScript/tests/cases/compiler/unusedTypeParameterInInterface2.ts_0_109
//@noUnusedLocals:true //@noUnusedParameters:true interface int<T, U, V> { f1(a: T): string; c: V; }
{ "end_byte": 109, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedTypeParameterInInterface2.ts" }
TypeScript/tests/cases/compiler/functionOverloadImplementationOfWrongName.ts_0_55
function foo(x); function foo(x, y); function bar() { }
{ "end_byte": 55, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloadImplementationOfWrongName.ts" }
TypeScript/tests/cases/compiler/emptyMemberAccess.ts_0_43
function getObj() { ().toString(); }
{ "end_byte": 43, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emptyMemberAccess.ts" }
TypeScript/tests/cases/compiler/functionOverloadImplementationOfWrongName2.ts_0_55
function foo(x); function bar() { } function foo(x, y);
{ "end_byte": 55, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloadImplementationOfWrongName2.ts" }
TypeScript/tests/cases/compiler/arrowFunctionWithObjectLiteralBody3.ts_0_36
// @target: es6 var v = a => <any>{}
{ "end_byte": 36, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arrowFunctionWithObjectLiteralBody3.ts" }
TypeScript/tests/cases/compiler/awaitExpressionInnerCommentEmit.ts_0_120
// @target: esnext async function foo() { /*comment1*/ await 1; await /*comment2*/ 2; await 3 /*comment3*/ }
{ "end_byte": 120, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/awaitExpressionInnerCommentEmit.ts" }
TypeScript/tests/cases/compiler/modulePreserve2.ts_0_581
// @module: preserve // @target: esnext // @strict: true // @checkJs: true // @traceResolution: true // @noEmit: true // @Filename: /node_modules/dep/package.json { "name": "dep", "exports": { "import": "./import.mjs", "require": "./require.js" } } // @Filename: /node_modules/dep/import.d.mts export con...
{ "end_byte": 581, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/modulePreserve2.ts" }
TypeScript/tests/cases/compiler/unusedImports10.ts_0_171
//@noUnusedLocals:true //@noUnusedParameters:true module A { export class Calculator { public handelChar() { } } } module B { import a = A; }
{ "end_byte": 171, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedImports10.ts" }
TypeScript/tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt4.ts_3_195
dule Z.M { export function bar() { return ""; } } module A.M { interface M { } import M = Z.M; export function bar() { } M.bar(); // Should call Z.M.bar }
{ "end_byte": 195, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt4.ts" }
TypeScript/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5.ts_0_962
// @target: es5 // @module: commonjs // @declaration: true // @filename: es6ImportDefaultBindingFollowedWithNamedImportInEs5_0.ts export var a = 10; export var x = a; export var m = a; // @filename: es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts import defaultBinding1, { } from "./es6ImportDefaultBindingFol...
{ "end_byte": 962, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5.ts" }
TypeScript/tests/cases/compiler/crashIntypeCheckObjectCreationExpression.ts_0_231
//@module: amd export class BuildWorkspaceService { public injectRequestService<P0, P1, P2>(service: P0) { this.injectBuildService<number>(new X(service)); } public injectBuildService<P0>(service: P0) { } }
{ "end_byte": 231, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/crashIntypeCheckObjectCreationExpression.ts" }
TypeScript/tests/cases/compiler/checkJsFiles5.ts_0_112
// @allowJs: true // @checkJs: true // @noEmit: true // @fileName: a.js // @ts-nocheck var x = "string"; x = 0;
{ "end_byte": 112, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/checkJsFiles5.ts" }
TypeScript/tests/cases/compiler/sourceMap-StringLiteralWithNewLine.ts_0_258
// @lib: es5 // @target: ES5 // @sourcemap: true interface Document { } interface Window { document: Document; } declare var window: Window; module Foo { var x = "test1"; var y = "test 2\ isn't this a lot of fun"; var z = window.document; }
{ "end_byte": 258, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMap-StringLiteralWithNewLine.ts" }
TypeScript/tests/cases/compiler/es6ClassTest.ts_0_1378
class Bar { public goo: number; public prop1(x) { return x; } constructor (n) { } } // new-style class class Foo extends Bar { foo:number; gar = 0; zoo:string = "zoo"; x: any; bar() { return 0; } private boo(); private boo(x?) { return x; } static statVal = 0; constructor(); ...
{ "end_byte": 1378, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ClassTest.ts" }
TypeScript/tests/cases/compiler/noUsedBeforeDefinedErrorInAmbientContext1.ts_3_91
@filename: test.d.ts declare var S: typeof A; // no error declare const A: number;
{ "end_byte": 91, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noUsedBeforeDefinedErrorInAmbientContext1.ts" }
TypeScript/tests/cases/compiler/nonNullReferenceMatching.ts_0_1338
// @strict: true type ElementRef = (element: HTMLElement | null) => void; type ThumbProps = { elementRef?: ElementRef; } type ComponentProps = { thumbYProps?: ThumbProps; thumbXProps: ThumbProps; } class Component { props!: ComponentProps; public thumbYElementRef = (ref: HTMLElement | null) => { ...
{ "end_byte": 1338, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nonNullReferenceMatching.ts" }
TypeScript/tests/cases/compiler/moduleResolutionWithExtensions_withAmbientPresent.ts_0_344
// @noImplicitReferences: true // @traceResolution: true // Allowjs is false, but this should *not* warn about the unused 'index.js' // @Filename: /node_modules/js/index.js // @Filename: /declarations.d.ts declare module "js" { export const x = 0; } // @Filename: /a.ts /// <reference path="declarations.d.ts" /> ...
{ "end_byte": 344, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolutionWithExtensions_withAmbientPresent.ts" }
TypeScript/tests/cases/compiler/exportAssignmentVariable.ts_0_205
// @module: commonjs // @Filename: exportAssignmentVariable_A.ts var x = 0; export = x; // @Filename: exportAssignmentVariable_B.ts import y = require("./exportAssignmentVariable_A"); var n: number = y;
{ "end_byte": 205, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportAssignmentVariable.ts" }
TypeScript/tests/cases/compiler/genericChainedCalls.ts_0_395
interface I1<T> { func<U>(callback: (value: T) => U): I1<T>; } declare var v1: I1<number>; var r1 = v1.func(num => num.toString()) .func(str => str.length) // error, number doesn't have a length .func(num => num.toString()) var s1 = v1.func(num => num.toString()) var s2 = s1.func(str =...
{ "end_byte": 395, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericChainedCalls.ts" }
TypeScript/tests/cases/compiler/emitMethodCalledNew.ts_0_251
// @declaration: true // https://github.com/microsoft/TypeScript/issues/55075 export const a = { new(x: number) { return x + 1 } } export const b = { "new"(x: number) { return x + 1 } } export const c = { ["new"](x: number) { return x + 1 } }
{ "end_byte": 251, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emitMethodCalledNew.ts" }
TypeScript/tests/cases/compiler/exportDefaultInterfaceClassAndFunctionOverloads.ts_0_260
export default function foo(value: number): number export default function foo(value: string): string export default function foo(value: string | number): string | number { return 1 } declare class Foo {} export default Foo export default interface Bar {}
{ "end_byte": 260, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportDefaultInterfaceClassAndFunctionOverloads.ts" }
TypeScript/tests/cases/compiler/contextualComputedNonBindablePropertyType.ts_0_783
// @noEmit: true // @strict: true // repro #51906 declare function testD(): "d"; declare function forceMatch<T>(matched: { [key in keyof T]: key; }): void; forceMatch({ [testD()]: "d", }); declare function forceMatch2<T>(matched: { [key in keyof T]: ({ key }: { key: key }) => void; }): void; forceMatch2({ ...
{ "end_byte": 783, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualComputedNonBindablePropertyType.ts" }
TypeScript/tests/cases/compiler/spuriousCircularityOnTypeImport.ts_0_676
// @strict: true // @filename: types.ts export type SelectorMap<T extends Record<string, (...params: unknown[]) => unknown>> = { [key in keyof T]: T[key]; }; // @filename: index.ts export type SelectorMap<T extends Record<string, (...params: unknown[]) => unknown>> = { [key in keyof T]: T[key]; }; export dec...
{ "end_byte": 676, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/spuriousCircularityOnTypeImport.ts" }
TypeScript/tests/cases/compiler/importTypeWithUnparenthesizedGenericFunctionParsed.ts_0_100
export declare const fail1: import("module").Modifier<<T>(x: T) => T>; // shouldn't be a parse error
{ "end_byte": 100, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importTypeWithUnparenthesizedGenericFunctionParsed.ts" }
TypeScript/tests/cases/compiler/contravariantTypeAliasInference.ts_0_377
// @strict: true type Func1<T> = (x: T) => void; type Func2<T> = ((x: T) => void) | undefined; declare let f1: Func1<string>; declare let f2: Func1<"a">; declare function foo<T>(f1: Func1<T>, f2: Func1<T>): void; foo(f1, f2); declare let g1: Func2<string>; declare let g2: Func2<"a">; declare function bar<T>(g1: F...
{ "end_byte": 377, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contravariantTypeAliasInference.ts" }
TypeScript/tests/cases/compiler/superAccessInFatArrow1.ts_0_254
module test { export class A { foo() { } } export class B extends A { bar(callback: () => void ) { } runme() { this.bar(() => { super.foo(); }); } } }
{ "end_byte": 254, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/superAccessInFatArrow1.ts" }
TypeScript/tests/cases/compiler/asyncFunctionWithForStatementNoInitializer.ts_0_311
async function test1() { let i = 0 let limit = 10 for (; i < limit; ++i) { } } async function test2() { let i = 0 let limit = 10 for (i = 1; i < limit; ++i) { } } async function test3() { let i = 0 for (;; ++i) { } } async function test4() { for (;;) { } }
{ "end_byte": 311, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/asyncFunctionWithForStatementNoInitializer.ts" }
TypeScript/tests/cases/compiler/literalTypeNameAssertionNotTriggered.ts_0_176
// @Filename: /a.ts import x = require("something"); export { x }; // @Filename: /b.ts import a = require('./a'); declare function f<T>(obj: T, key: keyof T): void; f(a, "");
{ "end_byte": 176, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/literalTypeNameAssertionNotTriggered.ts" }
TypeScript/tests/cases/compiler/cacheResolutions.ts_0_208
// @module: amd // @importHelpers: true // @traceResolution: true // @filename: /a/b/c/app.ts export let x = 1; // @filename: /a/b/c/lib1.ts export let x = 1; // @filename: /a/b/c/lib2.ts export let x = 1;
{ "end_byte": 208, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/cacheResolutions.ts" }
TypeScript/tests/cases/compiler/allowSyntheticDefaultImports10.ts_0_222
// @allowSyntheticDefaultImports: true // @module: commonjs // @Filename: b.d.ts export function foo(); export function bar(); // @Filename: a.ts import Foo = require("./b"); Foo.default.bar(); Foo.default.default.foo();
{ "end_byte": 222, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/allowSyntheticDefaultImports10.ts" }
TypeScript/tests/cases/compiler/importShouldNotBeElidedInDeclarationEmit.ts_0_258
// @declaration: true // @filename: node_modules/umd.d.ts export as namespace UMD; export type Thing = { a: number; } export declare function makeThing(): Thing; // @filename: index.ts import { makeThing } from "umd"; export const thing = makeThing();
{ "end_byte": 258, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importShouldNotBeElidedInDeclarationEmit.ts" }
TypeScript/tests/cases/compiler/conditionalExpressionNewLine5.ts_0_21
var v = a ? b : c;
{ "end_byte": 21, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/conditionalExpressionNewLine5.ts" }
TypeScript/tests/cases/compiler/exportAssignmentImportMergeNoCrash.ts_0_145
// @filename: assignment.ts export default { foo: 12 }; // @filename: user.ts import Obj from "./assignment"; export const Obj = void Obj;
{ "end_byte": 145, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportAssignmentImportMergeNoCrash.ts" }
TypeScript/tests/cases/compiler/unionExcessPropsWithPartialMember.ts_0_262
// @strict: true interface A { unused?: string; x: string; } interface B { x: string; y: string; } declare var ab: A | B; declare var a: A; ab = {...a, y: (null as any as string | undefined)}; // Should be allowed, since `y` is missing on `A`
{ "end_byte": 262, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unionExcessPropsWithPartialMember.ts" }
TypeScript/tests/cases/compiler/properties.ts_0_198
// @target: ES5 // @sourcemap: true // @declaration: true class MyClass { public get Count(): number { return 42; } public set Count(value: number) { // } }
{ "end_byte": 198, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/properties.ts" }
TypeScript/tests/cases/compiler/tsconfigMapOptionsAreCaseInsensitive.ts_0_227
// @filename: tsconfig.json { "compilerOptions": { "module": "AmD" } } // @filename: other.ts export default 42; // @filename: index.ts import Answer from "./other.js"; const x = 10 + Answer; export { x };
{ "end_byte": 227, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/tsconfigMapOptionsAreCaseInsensitive.ts" }
TypeScript/tests/cases/compiler/cloduleStaticMembers.ts_0_156
class Clod { private static x = 10; public static y = 10; } module Clod { var p = Clod.x; var q = x; var s = Clod.y; var t = y; }
{ "end_byte": 156, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/cloduleStaticMembers.ts" }
TypeScript/tests/cases/compiler/protectedMembersThisParameter.ts_0_1838
class Message { protected secret(): void {} } class MessageWrapper { message: Message = new Message(); wrap<T>() { let m = this.message; let f = function(this: T) { m.secret(); // should error } } } class A { protected a() {} } class B extends A { protected b() {} } class C extends A { ...
{ "end_byte": 1838, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/protectedMembersThisParameter.ts" }
TypeScript/tests/cases/compiler/unusedTypeParameters1.ts_0_85
//@noUnusedLocals:true //@noUnusedParameters:true class greeter<typeparameter1> { }
{ "end_byte": 85, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedTypeParameters1.ts" }
TypeScript/tests/cases/compiler/decoratorMetadataElidedImport.ts_0_456
// @target: es2020 // @module: commonjs, esnext // @strict: true // @experimentalDecorators: true // @emitDecoratorMetadata: true // @filename: observable.d.ts export declare class Observable<T> {} // @filename: index.ts import { Observable } from './observable'; function whatever(a: any, b: any, c: any) {} class T...
{ "end_byte": 456, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/decoratorMetadataElidedImport.ts" }
TypeScript/tests/cases/compiler/unusedClassesinNamespace3.ts_0_157
//@noUnusedLocals:true //@noUnusedParameters:true namespace Validation { class c1 { } export class c2 { } export let a = new c1(); }
{ "end_byte": 157, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedClassesinNamespace3.ts" }
TypeScript/tests/cases/compiler/noImplicitReturnsWithProtectedBlocks1.ts_0_214
// @noImplicitReturns: true declare function log(s: string): void; declare function get(): number; function main1() : number { try { return get(); } finally { log("in finally"); } }
{ "end_byte": 214, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noImplicitReturnsWithProtectedBlocks1.ts" }
TypeScript/tests/cases/compiler/sourceMap-InterfacePrecedingVariableDeclaration1.ts_0_62
// @target: ES5 // @sourcemap: true interface I {} var x = 0;
{ "end_byte": 62, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMap-InterfacePrecedingVariableDeclaration1.ts" }
TypeScript/tests/cases/compiler/moduleAugmentationDeclarationEmit2.ts_0_762
// @module: commonjs // @declaration: true // @filename: map.ts import { Observable } from "./observable" (<any>Observable.prototype).map = function() { } declare module "./observable" { interface Observable<T> { map<U>(proj: (e:T) => U): Observable<U> } namespace Observable { let someAno...
{ "end_byte": 762, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleAugmentationDeclarationEmit2.ts" }