_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/exportAssignValueAndType.ts_0_212
//@module: commonjs declare module http { export interface Server { openPort: number; } } interface server { (): http.Server; startTime: Date; } var x = 5; var server = new Date(); export = server;
{ "end_byte": 212, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportAssignValueAndType.ts" }
TypeScript/tests/cases/compiler/optionalParamAssignmentCompat.ts_0_189
interface I1 { (p1: number, p2: string): void; } interface I2 { p1: I1; m1(p1?: string): I1; } var i2: I2; var c: I1 = i2.p1; // should be ok var d: I1 = i2.m1; // should error
{ "end_byte": 189, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/optionalParamAssignmentCompat.ts" }
TypeScript/tests/cases/compiler/exportStarNotElided.ts_0_284
// @filename: register.ts const r: any[] = []; export function register(data: any) { r.push(data); } // @filename: data1.ts import { register } from "./"; register("ok"); // @filename: index.ts export * from "./register"; export * from "./data1"; export * as aliased from "./data1";
{ "end_byte": 284, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportStarNotElided.ts" }
TypeScript/tests/cases/compiler/targetTypingOnFunctions.ts_0_128
var fu: (s: string) => string = function (s) { return s.toLowerCase() }; var zu = fu = function (s) { return s.toLowerCase() };
{ "end_byte": 128, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/targetTypingOnFunctions.ts" }
TypeScript/tests/cases/compiler/genericFunctionsWithOptionalParameters1.ts_0_244
interface Utils { fold<T, S>(c?: Array<T>, folder?: (s: S, t: T) => T, init?: S): T; } var utils: Utils; utils.fold(); // no error utils.fold(null); // no error utils.fold(null, null); // no error utils.fold(null, null, null); // no error
{ "end_byte": 244, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericFunctionsWithOptionalParameters1.ts" }
TypeScript/tests/cases/compiler/errorsOnUnionsOfOverlappingObjects01.ts_0_842
interface Foo { a: string; b: number; }; interface Bar { b: string; } interface Other { totallyUnrelatedProperty: number; } export let x = { a: '', b: '' }; declare function f(x: Foo | Other): any; f(x); f({ a: '', b: '' }) declare function g(x: Bar | Other): any; g(x); g({ a: '', b: '' }) decla...
{ "end_byte": 842, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/errorsOnUnionsOfOverlappingObjects01.ts" }
TypeScript/tests/cases/compiler/generatorES6_4.ts_0_60
// @target: es6 var v = { *foo() { yield 0 } }
{ "end_byte": 60, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/generatorES6_4.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationDestructuringForOfArrayBindingPattern.ts_0_2561
// @lib: es5 // @sourcemap: true declare var console: { log(msg: any): void; } type Robot = [number, string, string]; type MultiSkilledRobot = [string, [string, string]]; let robotA: Robot = [1, "mower", "mowing"]; let robotB: Robot = [2, "trimmer", "trimming"]; let robots = [robotA, robotB]; function getRobots() ...
{ "end_byte": 2561, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationDestructuringForOfArrayBindingPattern.ts" }
TypeScript/tests/cases/compiler/inDoesNotOperateOnPrimitiveTypes.ts_0_2183
const validHasKey = <T extends object>( thing: T, key: string, ): boolean => { return key in thing; // Ok }; const alsoValidHasKey = <T>( thing: T, key: string, ): boolean => { return key in thing; // Ok (as T may be instantiated with a valid type) }; function invalidHasKey<T extends string | number>( t...
{ "end_byte": 2183, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inDoesNotOperateOnPrimitiveTypes.ts" }
TypeScript/tests/cases/compiler/argumentsReferenceInConstructor5_Js.ts_0_329
// @declaration: true // @allowJs: true // @emitDeclarationOnly: true // @filename: /a.js const bar = { arguments: {} } class A { /** * Constructor * * @param {object} [foo={}] */ constructor(foo = {}) { /** * @type object */ this.foo = foo; /** * @type object */ this.bar = bar.argumen...
{ "end_byte": 329, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/argumentsReferenceInConstructor5_Js.ts" }
TypeScript/tests/cases/compiler/innerFunc.ts_0_193
function salt() { function pepper() { return 5;} return pepper(); } module M { export function tungsten() { function oxygen() { return 6; }; return oxygen(); } }
{ "end_byte": 193, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/innerFunc.ts" }
TypeScript/tests/cases/compiler/instantiateContextualTypes.ts_0_3754
// @strict: true // @target: es6 // #6611 export interface A<a> { value: a; } function fn<a>(values: A<a>, value: a) : void { } declare let handlers: A<(value: number) => void>; fn(handlers, value => alert(value)); // #21382 interface BaseProps<T> { initialValues: T; nextValues: (cur: T) => T; } declare c...
{ "end_byte": 3754, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/instantiateContextualTypes.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationExportAssignmentCommonjs.ts_0_77
//@module: commonjs // @sourcemap: true class a { public c; } export = a;
{ "end_byte": 77, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationExportAssignmentCommonjs.ts" }
TypeScript/tests/cases/compiler/internalAliasInitializedModuleInsideTopLevelModuleWithoutExport.ts_0_167
//@module: amd // @declaration: true export module a { export module b { export class c { } } } import b = a.b; export var x: b.c = new b.c();
{ "end_byte": 167, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/internalAliasInitializedModuleInsideTopLevelModuleWithoutExport.ts" }
TypeScript/tests/cases/compiler/conditionalExpressionNewLine9.ts_0_47
var v = a ? b ? d : e : c ? f : g;
{ "end_byte": 47, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/conditionalExpressionNewLine9.ts" }
TypeScript/tests/cases/compiler/contextualTupleTypeParameterReadonly.ts_0_383
// @strict: true declare function each<T extends ReadonlyArray<any>>(cases: ReadonlyArray<T>): (fn: (...args: T) => any) => void; const cases = [ [1, '1'], [2, '2'], ] as const; const eacher = each(cases); eacher((a, b) => { a; b; }); // TODO: https://github.com/microsoft/TypeScript/issues/53255 ea...
{ "end_byte": 383, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTupleTypeParameterReadonly.ts" }
TypeScript/tests/cases/compiler/es5-souremap-amd.ts_0_143
// @target: ES5 // @sourcemap: true // @module: amd class A { constructor () { } public B() { return 42; } }
{ "end_byte": 143, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es5-souremap-amd.ts" }
TypeScript/tests/cases/compiler/defaultParameterAddsUndefinedWithStrictNullChecks.ts_0_1419
// @strictNullChecks: true // @declaration: true function f(addUndefined1 = "J", addUndefined2?: number) { return addUndefined1.length + (addUndefined2 || 0); } function g(addUndefined = "J", addDefined: number) { return addUndefined.length + addDefined; } let total = f() + f('a', 1) + f('b') + f(undefined, 2);...
{ "end_byte": 1419, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/defaultParameterAddsUndefinedWithStrictNullChecks.ts" }
TypeScript/tests/cases/compiler/typeOfEnumAndVarRedeclarations.ts_0_317
enum E { a } enum E { b = 1 } var x = E; var x: { readonly a: E; readonly b: E; readonly [x: number]: string; }; // Shouldnt error var y = E; var y: { readonly a: E; readonly b: E; readonly [x: number]: string; readonly [x: number]: string } // two errors: the types are not identical and duplicate signatures
{ "end_byte": 317, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeOfEnumAndVarRedeclarations.ts" }
TypeScript/tests/cases/compiler/deprecatedCompilerOptions4.ts_0_451
// @typeScriptVersion: 5.5 // @filename: /foo/tsconfig.json { "compilerOptions": { "target": "ES3", "noImplicitUseStrict": true, "keyofStringsOnly": true, "suppressExcessPropertyErrors": true, "suppressImplicitAnyIndexErrors": true, "noStrictGenericChecks": true, ...
{ "end_byte": 451, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/deprecatedCompilerOptions4.ts" }
TypeScript/tests/cases/compiler/doubleUnderscoreMappedTypes.ts_0_517
interface Properties { property1: string; __property2: string; } // As expected, I can make an object satisfying this interface const ok: Properties = { property1: "", __property2: "" }; // As expected, "__property2" is indeed a key of the type type Keys = keyof Properties; const k: Keys = "__property...
{ "end_byte": 517, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/doubleUnderscoreMappedTypes.ts" }
TypeScript/tests/cases/compiler/genericCallbacksAndClassHierarchy.ts_0_559
module M { export interface I<T> { subscribe(callback: (newValue: T) => void ): any; } export class C1<T> { public value: I<T>; } export class A<T> { public dummy: any; } export class B<T> extends C1<A<T>> { } export class D<T> { _subscribe(viewModel: B<T>...
{ "end_byte": 559, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericCallbacksAndClassHierarchy.ts" }
TypeScript/tests/cases/compiler/assignmentCompatability2.ts_0_325
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:{};; export var __val__aa = aa; } __test2__.__val__aa = __test1__.__val_...
{ "end_byte": 325, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatability2.ts" }
TypeScript/tests/cases/compiler/emitPostComments.ts_0_259
// @removeComments: false var y = 10; /** * @name Foo * @class */ /**#@+ * @memberOf Foo# * @field */ /** * @name bar * @type Object[] */ /**#@-*/ /** * @name Foo2 * @class */ /**#@+ * @memberOf Foo2# * @field */ /** * @name bar * @type Object[] */ /**#@-*/
{ "end_byte": 259, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emitPostComments.ts" }
TypeScript/tests/cases/compiler/unusedLocalProperty.ts_0_240
// @lib: es5 // @noUnusedLocals:true declare var console: { log(msg: any): void; } class Animal { constructor(private species: string) { } printSpecies() { let { species } = this; console.log(species); } }
{ "end_byte": 240, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedLocalProperty.ts" }
TypeScript/tests/cases/compiler/typeInferenceTypePredicate2.ts_0_120
[true, true, false, null] .filter((thing): thing is boolean => thing !== null) .map(thing => thing.toString());
{ "end_byte": 120, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeInferenceTypePredicate2.ts" }
TypeScript/tests/cases/compiler/super1.ts_0_890
// Case 1 class Base1 { public foo() { return "base"; } } class Sub1 extends Base1 { public bar() { return "base"; } } class SubSub1 extends Sub1 { public bar() { return super.super.foo; } } // Case 2 class Base2 { public foo() { return "base"; } } cla...
{ "end_byte": 890, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/super1.ts" }
TypeScript/tests/cases/compiler/declarationEmitEnumReferenceViaImportEquals.ts_0_745
// @strict: true // @declaration: true // @filename: translation.ts export interface Translation { translationKey: Translation.TranslationKeyEnum; } export namespace Translation { export type TranslationKeyEnum = 'translation1' | 'translation2'; export const TranslationKeyEnum = { Translation1: 'translation...
{ "end_byte": 745, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitEnumReferenceViaImportEquals.ts" }
TypeScript/tests/cases/compiler/jsxFragmentWrongType.tsx_0_381
// @jsx: react // @strict: true // @skipLibCheck: true // @target: ES2017 // @module: ESNext // @esModuleInterop: true // @filename: a.tsx /// <reference path="/.lib/react18/react18.d.ts" /> /// <reference path="/.lib/react18/global.d.ts" /> const test = () => "asd"; const jsxWithJsxFragment = <>{test}</>; const jsx...
{ "end_byte": 381, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsxFragmentWrongType.tsx" }
TypeScript/tests/cases/compiler/declarationEmitArrowFunctionNoRenaming.ts_0_600
// @strict: true // @declaration: true export type Brand< Base, Branding, ReservedName extends string = "__type__" > = Base & { [K in ReservedName]: Branding } & { __witness__: Base }; export type BoundedInteger< LowerBound extends number, UpperBound extends number > = Brand<number, "BoundedInteger">; expo...
{ "end_byte": 600, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitArrowFunctionNoRenaming.ts" }
TypeScript/tests/cases/compiler/accessorWithoutBody1.ts_0_37
// @target: ES5 var v = { get foo() }
{ "end_byte": 37, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/accessorWithoutBody1.ts" }
TypeScript/tests/cases/compiler/bom-utf8.ts_3_13
r x=10;
{ "end_byte": 13, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/bom-utf8.ts" }
TypeScript/tests/cases/compiler/assertInWrapSomeTypeParameter.ts_0_88
class C<T extends C<T>> { foo<U extends C<C<T>>(x: U) { return null; } }
{ "end_byte": 88, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assertInWrapSomeTypeParameter.ts" }
TypeScript/tests/cases/compiler/objectRestSpread.ts_0_524
// @target: es2017 // @lib: es2018 // @noTypesAndSymbols: true let obj = {}; ({...obj}); let { prop = { ...obj }, more = { ...obj } = { ...obj }, ['' + 'other']: other = { ...obj }, yetAnother: {nested: { ['nested' + 'prop']: nestedProp = { ...obj }, ...nestedRest } = { ...obj }} = { ...obj }, fn =...
{ "end_byte": 524, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectRestSpread.ts" }
TypeScript/tests/cases/compiler/genericArrayExtenstions.ts_0_171
export declare class ObservableArray<T> implements Array<T> { // MS.Entertainment.ObservableArray concat<U extends T[]>(...items: U[]): T[]; concat(...items: T[]): T[]; }
{ "end_byte": 171, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericArrayExtenstions.ts" }
TypeScript/tests/cases/compiler/continueInIterationStatement2.ts_0_32
do { continue; } while (true);
{ "end_byte": 32, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/continueInIterationStatement2.ts" }
TypeScript/tests/cases/compiler/typeParameterCompatibilityAccrossDeclarations.ts_0_317
//@module: amd var a = { x: function <T>(y: T): T { return null; } } var a2 = { x: function (y: any): any { return null; } } export interface I { x<T>(y: T): T; } export interface I2 { x(y: any): any; } var i: I; var i2: I2; a = i; // error i = a; // error a2 = i2; // no error i2 = a2; // no error
{ "end_byte": 317, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeParameterCompatibilityAccrossDeclarations.ts" }
TypeScript/tests/cases/compiler/typeReferenceDirectives11.ts_0_371
// @noImplicitReferences: true // @declaration: true // @typeRoots: /types // @traceResolution: true // @types: lib // @outFile: output.js // @currentDirectory: / // @filename: /types/lib/index.d.ts interface Lib { x } // @filename: /mod1.ts export function foo(): Lib { return {x: 1} } // @filename: /mod2.ts imp...
{ "end_byte": 371, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeReferenceDirectives11.ts" }
TypeScript/tests/cases/compiler/divergentAccessorsTypes7.ts_0_619
class Test<S> { constructor() {} set value(value: string | ((item: S) => string)) {} get value(): string { return null!; } // -- Replacing the getter such that the getter/setter types match, removes the error: // get value(): string | ((item: S) => string) { // return null!; ...
{ "end_byte": 619, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/divergentAccessorsTypes7.ts" }
TypeScript/tests/cases/compiler/abstractPropertyInConstructor.ts_0_2060
abstract class AbstractClass { constructor(str: string, other: AbstractClass) { this.method(parseInt(str)); let val = this.prop.toLowerCase(); if (!str) { this.prop = "Hello World"; } this.cb(str); // OK, reference is inside function const innerF...
{ "end_byte": 2060, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/abstractPropertyInConstructor.ts" }
TypeScript/tests/cases/compiler/ExportAssignment8.ts_0_31
export = B; export class C { }
{ "end_byte": 31, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ExportAssignment8.ts" }
TypeScript/tests/cases/compiler/constEnumMergingWithValues3.ts_0_101
//@module: amd //@filename: m1.ts enum foo { A } module foo { const enum E { X } } export = foo
{ "end_byte": 101, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constEnumMergingWithValues3.ts" }
TypeScript/tests/cases/compiler/checkSuperCallBeforeThisAccessing7.ts_3_153
ass Base { constructor(func: ()=>Base) { } } class Super extends Base { constructor() { super((() => this)); // No error } }
{ "end_byte": 153, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/checkSuperCallBeforeThisAccessing7.ts" }
TypeScript/tests/cases/compiler/inOperatorWithGeneric.ts_0_72
class C<T> { foo(x:T) { for (var p in x) { } } }
{ "end_byte": 72, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inOperatorWithGeneric.ts" }
TypeScript/tests/cases/compiler/truthinessCallExpressionCoercion3.ts_0_320
// @strictNullChecks: true // @lib: esnext,dom // from #41640, based on an example in ant-design interface I { always(): void } function f(result: unknown) { if ((result as I).always) { return result } } function g(result: unknown) { if (((result as I)).always) { return result } }
{ "end_byte": 320, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/truthinessCallExpressionCoercion3.ts" }
TypeScript/tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts_0_86
var tt1 = (a, (b, c)) => a+b+c; var tt2 = ((a), b, c) => a+b+c; var tt3 = ((a)) => a;
{ "end_byte": 86, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts" }
TypeScript/tests/cases/compiler/modifierOnParameter1.ts_0_41
class C { constructor(declare p) { } }
{ "end_byte": 41, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/modifierOnParameter1.ts" }
TypeScript/tests/cases/compiler/typePredicatesInUnion2.ts_0_186
declare function isString(x: any): x is string; declare function isNumber(x: any): x is number; declare function f(p: typeof isString | typeof isNumber): void; f(isString); f(isNumber);
{ "end_byte": 186, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typePredicatesInUnion2.ts" }
TypeScript/tests/cases/compiler/inOperator.ts_0_109
var a=[]; for (var x in a) {} if (3 in a) {} var b = '' in 0; var c: any; var y: number; if (y in c) { }
{ "end_byte": 109, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inOperator.ts" }
TypeScript/tests/cases/compiler/ipromise4.ts_0_999
declare module Windows.Foundation { export interface IPromise<T> { then<U>(success?: (value: T) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void ): Windows.Foundation.IPromise<U>; then<U>(success?: (value: T) => IPromise<U>, error?: (error: any) => U, progress?...
{ "end_byte": 999, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ipromise4.ts" }
TypeScript/tests/cases/compiler/objectBindingPatternContextuallyTypesArgument.ts_0_99
declare function id<T>(x: T): T; const { f = (x: string) => x.length } = id({ f: x => x.charAt });
{ "end_byte": 99, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectBindingPatternContextuallyTypesArgument.ts" }
TypeScript/tests/cases/compiler/typeRootsFromNodeModulesInParentDirectory.ts_0_278
// @noImplicitReferences: true // @traceResolution: true // @currentDirectory: /src // @Filename: /node_modules/@types/foo/index.d.ts declare module "xyz" { export const x: number; } // @Filename: /src/a.ts import { x } from "xyz"; x; // @Filename: /src/tsconfig.json {}
{ "end_byte": 278, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeRootsFromNodeModulesInParentDirectory.ts" }
TypeScript/tests/cases/compiler/moduleAugmentationInDependency.ts_0_114
// @filename: /node_modules/A/index.d.ts declare module "ext" { } export {}; // @filename: /src/app.ts import "A"
{ "end_byte": 114, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleAugmentationInDependency.ts" }
TypeScript/tests/cases/compiler/extendingSetWithCheckJs.ts_0_372
// @allowJs: true // @checkJs: true // @noEmit: true // @lib: es2017 class MySet extends Set { constructor() { super(); } } class MyWeakSet extends WeakSet { constructor() { super(); } } class MyMap extends Map { constructor() { super(); } } class MyWeakMap extends We...
{ "end_byte": 372, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/extendingSetWithCheckJs.ts" }
TypeScript/tests/cases/compiler/functionOverloads15.ts_0_155
function foo(foo:{a:string; b:number;}):string; function foo(foo:{a:string; b:number;}):number; function foo(foo:{a:string; b?:number;}):any { return "" }
{ "end_byte": 155, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloads15.ts" }
TypeScript/tests/cases/compiler/superInConstructorParam1.ts_0_114
class B { public foo(): number { return 0; } } class C extends B { constructor(a = super.foo()) { } }
{ "end_byte": 114, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/superInConstructorParam1.ts" }
TypeScript/tests/cases/compiler/useBeforeDeclaration_classDecorators.2.ts_0_1812
// @target: esnext // @noEmit: true // @noTypesAndSymbols: true // @experimentalDecorators: * declare const dec: any; // ok @dec(() => C1) class C1 { } // error @dec(C2) class C2 { } // error @dec((() => C3)()) class C3 { } // ok class C4 { @dec(() => C4) static method() {} @dec(() => C4) static get w() { ...
{ "end_byte": 1812, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/useBeforeDeclaration_classDecorators.2.ts" }
TypeScript/tests/cases/compiler/overloadCallTest.ts_0_246
class foo { constructor() { function bar(): string; function bar(s:string); function bar(foo?: string) { return "foo" }; var test = bar("test"); var goo = bar(); goo = bar("test"); } }
{ "end_byte": 246, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overloadCallTest.ts" }
TypeScript/tests/cases/compiler/generatorTransformFinalLabel.ts_0_179
// @target: es5 // @lib: es5,es6 // @noEmitHelpers: true async function test(skip: boolean) { if (!skip) { await 1 } else { throw Error('test') } }
{ "end_byte": 179, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/generatorTransformFinalLabel.ts" }
TypeScript/tests/cases/compiler/awaitedTypeCrash.ts_0_156
// @target: esnext // https://github.com/microsoft/TypeScript/issues/51984 async function* f<T extends Promise<never>>(): AsyncGenerator<T, void, void> { }
{ "end_byte": 156, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/awaitedTypeCrash.ts" }
TypeScript/tests/cases/compiler/inheritanceStaticPropertyOverridingAccessor.ts_0_204
// @allowUnreachableCode: true class a { static get x(): () => string { return null;; } static set x(aValue: () => string) { } } class b extends a { static x: () => string; }
{ "end_byte": 204, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inheritanceStaticPropertyOverridingAccessor.ts" }
TypeScript/tests/cases/compiler/letDeclarations-scopes-duplicates.ts_0_798
// @target: ES6 // Errors: redeclaration let var1 = 0; let var1 = 0; // error let var2 = 0; const var2 = 0; const var3 = 0; let var3 = 0; const var4 = 0; const var4 = 0; var var5 = 0; let var5 = 0; let var6 = 0; var var6 = 0; { let var7 = 0; let var7 = 0; { let var8 = 0; const var8 = ...
{ "end_byte": 798, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/letDeclarations-scopes-duplicates.ts" }
TypeScript/tests/cases/compiler/reExportUndefined2.ts_0_179
// @module: commonjs // @filename: a.ts var undefined; export { undefined }; // @filename: b.ts import { undefined } from "./a"; declare function use(a: number); use(undefined);
{ "end_byte": 179, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reExportUndefined2.ts" }
TypeScript/tests/cases/compiler/extendBaseClassBeforeItsDeclared.ts_0_82
class derived extends base { } class base { constructor (public n: number) { } }
{ "end_byte": 82, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/extendBaseClassBeforeItsDeclared.ts" }
TypeScript/tests/cases/compiler/doNotemitTripleSlashComments.ts_3_557
@removeComments: true // @Filename: file0.ts /// <reference path="file1.ts" /> /// <reference path="file2.ts" /> /// <amd-dependency path="/js/libs/hgn.js!app/templates/home" name="compiler"/> var x = 10; /// <reference path="file1.ts" /> var y = "hello"; /// <reference path="file2.ts" /> // @Filename: file1.ts /...
{ "end_byte": 557, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/doNotemitTripleSlashComments.ts" }
TypeScript/tests/cases/compiler/intersectionOfMixinConstructorTypeAndNonConstructorType.ts_0_92
// Repro for #17388 declare let x: {foo: undefined} & {new(...args: any[]): any}; new x();
{ "end_byte": 92, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/intersectionOfMixinConstructorTypeAndNonConstructorType.ts" }
TypeScript/tests/cases/compiler/emitPinnedCommentsOnTopOfFile.ts_3_75
@removeComments: true /*! multi line comment */ var x = 10;
{ "end_byte": 75, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emitPinnedCommentsOnTopOfFile.ts" }
TypeScript/tests/cases/compiler/identicalGenericConditionalsWithInferRelated.ts_0_808
function f<X>(arg: X) { type Cond1 = X extends [infer A] ? A : never; type Cond2 = X extends [infer A] ? A : never; let x: Cond1 = null as any; let y: Cond2 = null as any; x = y; // is err, should be ok y = x; // is err, should be ok } // repro from https://github.com/microsoft/TypeScript/issu...
{ "end_byte": 808, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/identicalGenericConditionalsWithInferRelated.ts" }
TypeScript/tests/cases/compiler/declarationEmitFBoundedTypeParams.ts_0_151
// @declaration: true // Repro from #6040 function append<a, b extends a>(result: a[], value: b): a[] { result.push(value); return result; }
{ "end_byte": 151, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitFBoundedTypeParams.ts" }
TypeScript/tests/cases/compiler/argumentsObjectIterator03_ES5.ts_0_165
//@target: ES5 function asReversedTuple(a: number, b: string, c: boolean): [boolean, string, number] { let [x, y, z] = arguments; return [z, y, x]; }
{ "end_byte": 165, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/argumentsObjectIterator03_ES5.ts" }
TypeScript/tests/cases/compiler/enumLiteralAssignableToEnumInsideUnion.ts_0_683
module X { export enum Foo { A, B } } module Y { export enum Foo { A, B } } module Z { export enum Foo { A = 1 << 1, B = 1 << 2, } } module Ka { export enum Foo { A = 1 << 10, B = 1 << 11, } } const e0: X.Foo | boolean = Y.Foo.A; // ok cons...
{ "end_byte": 683, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumLiteralAssignableToEnumInsideUnion.ts" }
TypeScript/tests/cases/compiler/functionOverloads44.ts_0_541
interface Animal { animal } interface Dog extends Animal { dog } interface Cat extends Animal { cat } function foo1(bar: { a:number }[]): Dog; function foo1(bar: { a:string }[]): Animal; function foo1([x]: { a:number | string }[]): Dog { return undefined; } function foo2(bar: { a:number }[]): Cat; function foo2(b...
{ "end_byte": 541, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloads44.ts" }
TypeScript/tests/cases/compiler/checkJsdocTypeTagOnExportAssignment8.ts_0_259
// @allowJs: true // @checkJs: true // @outDir: ./out // @filename: checkJsdocTypeTagOnExportAssignment8.js // @Filename: a.js /** * @typedef Foo * @property {string} a * @property {'b'} b */ /** @type {Foo} */ export default { a: 'a', b: 'b' }
{ "end_byte": 259, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/checkJsdocTypeTagOnExportAssignment8.ts" }
TypeScript/tests/cases/compiler/privatePropertyInUnion.ts_0_342
// @strict: true // Repro from #38236 type Type = string | object; class SyncableObject { private foo: unknown; } interface SyncableRef<T extends ISyncableObject> {} interface ISyncableObject<T = object> extends SyncableObject {} type __ValueDescriptorType<T extends string | object> = T extends ISyncableObject ...
{ "end_byte": 342, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privatePropertyInUnion.ts" }
TypeScript/tests/cases/compiler/typeArgInference2WithError.ts_0_126
interface Item { name: string; } declare function foo<T extends Item>(x?: T, y?: T): T; var z7 = foo("abc", 5); // Error
{ "end_byte": 126, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeArgInference2WithError.ts" }
TypeScript/tests/cases/compiler/alwaysStrict.ts_0_64
// @alwaysStrict: true function f() { var arguments = []; }
{ "end_byte": 64, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/alwaysStrict.ts" }
TypeScript/tests/cases/compiler/typeOfSuperCall.ts_0_91
class C { } class D extends C { constructor() { var x: void = super(); } }
{ "end_byte": 91, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeOfSuperCall.ts" }
TypeScript/tests/cases/compiler/moduleResolution_relativeImportJsFile.ts_0_127
// @noImplicitReferences: true // @Filename: /src/b.js export const x = 0; // @Filename: /src/a.ts import * as b from "./b";
{ "end_byte": 127, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolution_relativeImportJsFile.ts" }
TypeScript/tests/cases/compiler/classImplementsPrimitive.ts_0_132
// classes cannot implement primitives class C implements number { } class C2 implements string { } class C3 implements boolean { }
{ "end_byte": 132, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classImplementsPrimitive.ts" }
TypeScript/tests/cases/compiler/controlFlowFavorAssertedTypeThroughTypePredicate.ts_0_765
// @noEmit: true // @strict: true // repro 49988#issuecomment-1192016929 declare function isObject1(value: unknown): value is Record<string, unknown>; declare const obj1: {}; if (isObject1(obj1)) { obj1; obj1['attr']; } // check type after conditional block obj1; declare const obj2: {} | undefined; if (isOb...
{ "end_byte": 765, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/controlFlowFavorAssertedTypeThroughTypePredicate.ts" }
TypeScript/tests/cases/compiler/declarationEmitInvalidExport.ts_0_104
// @declaration: true if (false) { export var myClass = 0; } export type MyClass = typeof myClass; }
{ "end_byte": 104, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitInvalidExport.ts" }
TypeScript/tests/cases/compiler/optionalParamterAndVariableDeclaration.ts_0_92
class C { constructor(options?: number) { var options = (options || 0); } }
{ "end_byte": 92, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/optionalParamterAndVariableDeclaration.ts" }
TypeScript/tests/cases/compiler/unusedClassesinModule1.ts_0_132
//@noUnusedLocals:true //@noUnusedParameters:true module A { class Calculator { public handelChar() { } } }
{ "end_byte": 132, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedClassesinModule1.ts" }
TypeScript/tests/cases/compiler/primitiveTypeAsInterfaceNameGeneric.ts_0_22
interface number<T> {}
{ "end_byte": 22, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/primitiveTypeAsInterfaceNameGeneric.ts" }
TypeScript/tests/cases/compiler/declarationEmitTypeAliasWithTypeParameters4.ts_3_161
@declaration: true type Foo<T, Y> = { foo<U, J>(): Foo<U, J> }; type SubFoo<R> = Foo<string, R>; function foo() { return {} as SubFoo<number>; }
{ "end_byte": 161, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitTypeAliasWithTypeParameters4.ts" }
TypeScript/tests/cases/compiler/dynamicImportEvaluateSpecifier.ts_0_390
// @lib: es2019 // @target: es2019 // @module: commonjs // https://github.com/microsoft/TypeScript/issues/48285 let i = 0; import(String(i++)); import(String(i++)); const getPath = async () => { /* in reality this would do some async FS operation, or a web request */ return "/root/my/cool/path"; }; const someFunct...
{ "end_byte": 390, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/dynamicImportEvaluateSpecifier.ts" }
TypeScript/tests/cases/compiler/outModuleConcatUnspecifiedModuleKind.ts_0_125
// @target: ES5 // @outFile: out.js // @Filename: a.ts export class A { } // module // @Filename: b.ts var x = 0; // global
{ "end_byte": 125, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/outModuleConcatUnspecifiedModuleKind.ts" }
TypeScript/tests/cases/compiler/classStaticInitializersUsePropertiesBeforeDeclaration.ts_1_234
class Foo { static enumMember = Enum.A; static objLiteralMember = ObjLiteral.A; static namespaceMember = Namespace.A; } enum Enum { A } const ObjLiteral = { A: 0 }; namespace Namespace { export let A = 0 }
{ "end_byte": 234, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classStaticInitializersUsePropertiesBeforeDeclaration.ts" }
TypeScript/tests/cases/compiler/intTypeCheck.ts_0_4434
interface i1 { //Property Signatures p; p1?; p2?: string; p3(); p4? (); p5? (): void; p6(pa1): void; p7? (pa1, pa2): void; } interface i2 { //Call Signatures (); (): number; (p); (p1: string); (p2?: string); (...p3: any[]); (p4: string, p5?: string); ...
{ "end_byte": 4434, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/intTypeCheck.ts" }
TypeScript/tests/cases/compiler/functionMergedWithModule.ts_0_168
function foo(title: string) { var x = 10; } module foo.Bar { export function f() { } } module foo.Baz { export function g() { Bar.f(); } }
{ "end_byte": 168, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionMergedWithModule.ts" }
TypeScript/tests/cases/compiler/forInStatement3.ts_0_62
function F<T>() { var expr: T; for (var a in expr) { } }
{ "end_byte": 62, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/forInStatement3.ts" }
TypeScript/tests/cases/compiler/arrayFlatNoCrashInferenceDeclarations.ts_0_127
// @strict: true // @lib: es2020 // @declaration: true function foo<T>(arr: T[], depth: number) { return arr.flat(depth); }
{ "end_byte": 127, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arrayFlatNoCrashInferenceDeclarations.ts" }
TypeScript/tests/cases/compiler/ambientModuleWithTemplateLiterals.ts_0_285
declare module Foo { enum Bar { a = `1`, b = '2', c = '3' } export const a = 'string'; export const b = `template`; export const c = Bar.a; export const d = Bar['b']; export const e = Bar[`c`]; } Foo.a; Foo.b; Foo.c; Foo.d; Foo.e;
{ "end_byte": 285, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ambientModuleWithTemplateLiterals.ts" }
TypeScript/tests/cases/compiler/decoratorMetadataElidedImportOnDeclare.ts_0_372
// @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) {} class Test { ...
{ "end_byte": 372, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/decoratorMetadataElidedImportOnDeclare.ts" }
TypeScript/tests/cases/compiler/impliedNodeFormatInterop1.ts_0_619
// @module: es2020 // @moduleResolution: node10 // @esModuleInterop: true // @Filename: /node_modules/highlight.js/package.json { "name": "highlight.js", "type": "commonjs", "types": "index.d.ts" } // @Filename: /node_modules/highlight.js/index.d.ts declare module "highlight.js" { export interface HighlightAP...
{ "end_byte": 619, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/impliedNodeFormatInterop1.ts" }
TypeScript/tests/cases/compiler/constructorParametersThatShadowExternalNamesInVariableDeclarations.ts_0_154
var x = 1; class A { private a = x; constructor(x: number) { } } class B { private a = x; constructor() { var x = ""; } }
{ "end_byte": 154, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constructorParametersThatShadowExternalNamesInVariableDeclarations.ts" }
TypeScript/tests/cases/compiler/collisionRestParameterArrowFunctions.ts_0_288
var f1 = (_i: number, ...restParameters) => { //_i is error var _i = 10; // no error } var f1NoError = (_i: number) => { // no error var _i = 10; // no error } var f2 = (...restParameters) => { var _i = 10; // No Error } var f2NoError = () => { var _i = 10; // no error }
{ "end_byte": 288, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionRestParameterArrowFunctions.ts" }
TypeScript/tests/cases/compiler/targetTypeTest1.ts_0_1506
declare class Point { constructor(x: number, y: number); public x: number; public y: number; public add(dx: number, dy: number): Point; static origin: Point; } // Type provided by extern declaration // Because Point is a constructor function, this is inferred // to be Point and return ty...
{ "end_byte": 1506, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/targetTypeTest1.ts" }
TypeScript/tests/cases/compiler/classExtendsInterfaceInExpression.ts_0_108
interface A {} function factory(a: any): {new(): Object} { return null; } class C extends factory(A) {}
{ "end_byte": 108, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classExtendsInterfaceInExpression.ts" }
TypeScript/tests/cases/compiler/errorMessagesIntersectionTypes02.ts_0_238
interface Foo { fooProp: "hello" | "world"; } interface Bar { barProp: string; } interface FooBar extends Foo, Bar { } declare function mixBar<T>(obj: T): T & Bar; let fooBar: FooBar = mixBar({ fooProp: "frizzlebizzle" });
{ "end_byte": 238, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/errorMessagesIntersectionTypes02.ts" }