_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/genericTypeWithMultipleBases3.ts_0_167
interface IA<T> { foo(x: T): T; } interface IB<T> { bar(x: T): T; } interface IC<T> extends IA<T>, IB<T> { } var c: IC<number>; var x = c.foo; var y = c.bar;
{ "end_byte": 167, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericTypeWithMultipleBases3.ts" }
TypeScript/tests/cases/compiler/useStrictLikePrologueString01.ts_0_84
//@target: commonjs //@target: es5 "hey!" " use strict " export function f() { }
{ "end_byte": 84, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/useStrictLikePrologueString01.ts" }
TypeScript/tests/cases/compiler/recursiveTypeParameterReferenceError1.ts_0_216
class X<T> { } interface Foo<T> { z: Foo<X<T>>; // error } var f: Foo<number>; var r = f.z; class C2<T> { x: T; } interface Foo2<T> { ofC4: C2<{ x: T }> // ok } var f2: Foo2<number>; var r2 = f2.ofC4;
{ "end_byte": 216, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveTypeParameterReferenceError1.ts" }
TypeScript/tests/cases/compiler/optionalParamArgsTest.ts_0_2719
// Optional parameter and default argument tests // Key: // Cx - "Class x" // My - "Method x" // Az - "Argument z" // E.g., C1M1A1 = "Class 1, Method 1, Argument 1" interface I1 { C1M1():number; C1M2(C1M2A1:number):number; C1M3(C1M3A1?:number,C1M3A2?:number):number; C1M4(C1M4A1:number,C1M4A2?:number):...
{ "end_byte": 2719, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/optionalParamArgsTest.ts" }
TypeScript/tests/cases/compiler/umdDependencyComment2.ts_0_82
//@module: umd ///<amd-dependency path='bar'/> import m1 = require("m2") m1.f();
{ "end_byte": 82, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/umdDependencyComment2.ts" }
TypeScript/tests/cases/compiler/debugger.ts_0_44
debugger; function foo() { debugger; }
{ "end_byte": 44, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/debugger.ts" }
TypeScript/tests/cases/compiler/inheritanceStaticAccessorOverridingMethod.ts_0_168
class a { static x() { return "20"; } } class b extends a { static get x() { return "20"; } static set x(aValue: string) { } }
{ "end_byte": 168, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inheritanceStaticAccessorOverridingMethod.ts" }
TypeScript/tests/cases/compiler/declFileGenericType.ts_0_898
//@module: commonjs // @declaration: true export module C { export class A<T>{ } export class B { } export function F<T>(x: T): A<B> { return null; } export function F2<T>(x: T): C.A<C.B> { return null; } export function F3<T>(x: T): C.A<C.B>[] { return null; } export function F4<T extends ...
{ "end_byte": 898, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileGenericType.ts" }
TypeScript/tests/cases/compiler/letDeclarations-es5-1.ts_0_174
// @target: ES5 let l1; let l2: number; let l3, l4, l5 :string, l6; let l7 = false; let l8: number = 23; let l9 = 0, l10 :string = "", l11 = null;
{ "end_byte": 174, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/letDeclarations-es5-1.ts" }
TypeScript/tests/cases/compiler/badThisBinding.ts_0_192
declare function foo(a:any): any; declare function bar(a:any): any; class Greeter { constructor() { foo(() => { bar(() => { var x = this; }); }); } }
{ "end_byte": 192, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/badThisBinding.ts" }
TypeScript/tests/cases/compiler/mergedInterfaceFromMultipleFiles1.ts_0_417
// @Filename: mergedInterfaceFromMultipleFiles1_0.ts interface I { foo(): string; } interface C extends I { a(): number; } // @Filename: mergedInterfaceFromMultipleFiles1_1.ts /// <reference path='mergedInterfaceFromMultipleFiles1_0.ts'/> interface D { bar(): number; } interface C extends D { b(): Date; } var c...
{ "end_byte": 417, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mergedInterfaceFromMultipleFiles1.ts" }
TypeScript/tests/cases/compiler/assignmentCompatInterfaceWithStringIndexSignature.ts_0_193
interface IHandler { (e): boolean; } interface IHandlerMap { [type: string]: IHandler; } class Foo { public Boz(): void { } } function Biz(map: IHandlerMap) { } Biz(new Foo());
{ "end_byte": 193, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatInterfaceWithStringIndexSignature.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationVarInDownLevelGenerator.ts_0_125
// @sourcemap: true // @downlevelIteration: true // @noEmitHelpers: true // @lib: es2015 function * f() { var x = 1, y; }
{ "end_byte": 125, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationVarInDownLevelGenerator.ts" }
TypeScript/tests/cases/compiler/commentOnClassAccessor2.ts_0_112
class C { /** * Getter. */ get bar(): number { return 1;} /** * Setter. */ set bar(v) { } }
{ "end_byte": 112, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentOnClassAccessor2.ts" }
TypeScript/tests/cases/compiler/APISample_parseConfig.ts_0_1467
// @module: commonjs // @skipLibCheck: true // @noImplicitAny:true // @strictNullChecks:true // @noTypesAndSymbols: true // @filename: node_modules/typescript/package.json { "name": "typescript", "types": "/.ts/typescript.d.ts" } // @filename: APISample_parseConfig.ts /* * Note: This test is a public API sam...
{ "end_byte": 1467, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/APISample_parseConfig.ts" }
TypeScript/tests/cases/compiler/missingRequiredDeclare.d.ts_0_10
var x = 1;
{ "end_byte": 10, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/missingRequiredDeclare.d.ts" }
TypeScript/tests/cases/compiler/sigantureIsSubTypeIfTheyAreIdentical.ts_0_213
interface ICache { get<T>(key: string): T; } class CacheService implements ICache { // Should not error that property type of get are incomaptible get<T>(key: string): T { return undefined; } }
{ "end_byte": 213, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sigantureIsSubTypeIfTheyAreIdentical.ts" }
TypeScript/tests/cases/compiler/declarationEmitPartialNodeReuseTypeOf.ts_0_523
// @strict: true // @declaration: true // @target: es2020 // @filename: a.ts export const nImported = "nImported" export const nNotImported = "nNotImported" const nPrivate = "private" export const o = (p1: typeof nImported, p2: typeof nNotImported, p3: typeof nPrivate) => null! as { foo: typeof nImported, bar: typeof ...
{ "end_byte": 523, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitPartialNodeReuseTypeOf.ts" }
TypeScript/tests/cases/compiler/alwaysStrictNoImplicitUseStrict.ts_0_147
// @module: commonjs // @alwaysStrict: true // @noImplicitUseStrict: true module M { export function f() { var arguments = []; } }
{ "end_byte": 147, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/alwaysStrictNoImplicitUseStrict.ts" }
TypeScript/tests/cases/compiler/functionDeclarationWithResolutionOfTypeOfSameName01.ts_3_46
terface f { } function f() { <f>f; }
{ "end_byte": 46, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionDeclarationWithResolutionOfTypeOfSameName01.ts" }
TypeScript/tests/cases/compiler/unreachableJavascriptUnchecked.ts_0_136
// @Filename: unreachable.js // @allowJs: true // @checkJs: false // @outDir: out function unreachable() { return 1; return 2; }
{ "end_byte": 136, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unreachableJavascriptUnchecked.ts" }
TypeScript/tests/cases/compiler/thisInConstructorParameter1.ts_0_59
class Foo { public y; constructor(x = this.y) { } }
{ "end_byte": 59, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/thisInConstructorParameter1.ts" }
TypeScript/tests/cases/compiler/builtinIterator.ts_0_1502
// @target: esnext // @strict: true const iterator = Iterator.from([0, 1, 2]); const mapped = iterator.map(String); const filtered = iterator.filter(x => x > 0); function isZero(x: number): x is 0 { return x === 0; } const zero = iterator.filter(isZero); const iteratorFromBare = Iterator.from({ next() { re...
{ "end_byte": 1502, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/builtinIterator.ts" }
TypeScript/tests/cases/compiler/narrowingConstrainedTypeParameter.ts_0_371
// @strictNullChecks: true // Repro from #10811 interface Pet { name: string; } function isPet(pet: any): pet is Pet { return typeof pet.name === "string"; } export function speak<TPet extends Pet>(pet: TPet, voice: (pet: TPet) => string): string { if (!isPet(pet)) { throw new Error("Expected \"...
{ "end_byte": 371, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowingConstrainedTypeParameter.ts" }
TypeScript/tests/cases/compiler/arityErrorRelatedSpanBindingPattern.ts_0_93
function foo(a, b, {c}): void {} function bar(a, b, [c]): void {} foo("", 0); bar("", 0);
{ "end_byte": 93, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arityErrorRelatedSpanBindingPattern.ts" }
TypeScript/tests/cases/compiler/superCallInNonStaticMethod.ts_0_1004
class Doing { public instanceMethod() { } } class Other extends Doing { // in instance method public instanceMethod() { super.instanceMethod(); } // in a lambda inside a instance method public lambdaInsideAnInstanceMethod() { () => { super.instanceMethod(); ...
{ "end_byte": 1004, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/superCallInNonStaticMethod.ts" }
TypeScript/tests/cases/compiler/duplicateIdentifierComputedName.ts_0_50
class C { ["a"]: string; ["a"]: string; }
{ "end_byte": 50, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateIdentifierComputedName.ts" }
TypeScript/tests/cases/compiler/errorsInGenericTypeReference.ts_1_1944
interface IFoo<T> { } class Foo<T> { } // in call type arguments class testClass1 { method<T>(): void { } } var tc1 = new testClass1(); tc1.method<{ x: V }>(); // error: could not find symbol V // in constructor type arguments class testClass2<T> { } var tc2 = new testClass2<{ x: V }>(); // error: could not fi...
{ "end_byte": 1944, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/errorsInGenericTypeReference.ts" }
TypeScript/tests/cases/compiler/declarationEmitDuplicateParameterDestructuring.ts_0_216
// @declaration: true // @emitDeclarationOnly: true export const fn1 = ({ prop: a, prop: b }: { prop: number }) => a + b; export const fn2 = ({ prop: a }: { prop: number }, { prop: b }: { prop: number }) => a + b;
{ "end_byte": 216, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitDuplicateParameterDestructuring.ts" }
TypeScript/tests/cases/compiler/overloadOnConstDuplicateOverloads1.ts_0_242
function foo(a: 'hi', x: string); function foo(a: 'hi', x: string); function foo(a: any, x: any) { } function foo2(a: 'hi', x: string); function foo2(a: 'hi', x: string); function foo2(a: string, x: string); function foo2(a: any, x: any) { }
{ "end_byte": 242, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overloadOnConstDuplicateOverloads1.ts" }
TypeScript/tests/cases/compiler/declarationEmitCastReusesTypeNode4.ts_0_1277
// @strict: true // @strictNullChecks: true,false // @allowJs: true // @checkJs: true // @emitDeclarationOnly: true // @declaration: true // @noTypesAndSymbols: true // @filename: input.js /** * @typedef {{ } & { name?: string }} P */ const something = /** @type {*} */(null); export let vLet = /** @type {P} */(some...
{ "end_byte": 1277, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitCastReusesTypeNode4.ts" }
TypeScript/tests/cases/compiler/tryStatementInternalComments.ts_0_174
/*1*/ try /*2*/ { /*3*/ /*4*/ throw /*5*/ "no" /*6*/; /*7*/} /*8*/ catch /*9*/ ( /*10*/ e /*11*/ ) /*12*/ { /*13*/ /*14*/} /*15*/ finally /*16*/ { /*17*/ /*18*/} /*19*/
{ "end_byte": 174, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/tryStatementInternalComments.ts" }
TypeScript/tests/cases/compiler/moduleResolution_packageJson_yesAtPackageRoot_fakeScopedPackage.ts_0_460
// @noImplicitReferences: true // @traceResolution: true // Copy of `moduleResolution_packageJson_notAtPackageRoot` with `foo/@bar` instead of `foo/bar`. Should behave identically. // @Filename: /node_modules/foo/@bar/index.js not read // @Filename: /node_modules/foo/package.json { "name": "foo", "version": "1.2.3",...
{ "end_byte": 460, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolution_packageJson_yesAtPackageRoot_fakeScopedPackage.ts" }
TypeScript/tests/cases/compiler/ramdaToolsNoInfinite2.ts_0_6017
// @strict: true declare module "Any/Kind" { import { Extends } from "Any/Extends"; import { List } from "List/List"; export type Kind<A extends any> = Extends<A, Function> extends 1 ? 'function' : Extends<A, List> extends 1 ? 'array' : Extends<A, object> extends 1 ? 'object' : Extends<A, string> extends 1...
{ "end_byte": 6017, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ramdaToolsNoInfinite2.ts" }
TypeScript/tests/cases/compiler/ramdaToolsNoInfinite2.ts_6018_12042
declare module "Object/NonNullable" { import { MergeFlat } from "Object/Merge"; import { NonNullable as UNonNullable } from "Union/NonNullable"; import { Depth } from "Object/_Internal"; import { Pick } from "Object/Pick"; import { Key } from "Any/Key"; import { Implements } from "Any/Implements...
{ "end_byte": 12042, "start_byte": 6018, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ramdaToolsNoInfinite2.ts" }
TypeScript/tests/cases/compiler/ramdaToolsNoInfinite2.ts_12043_15379
declare module "List/Drop" { import { Tail } from "List/Tail"; import { Cast } from "Any/Cast"; import { IterationOf } from "Iteration/IterationOf"; import { Iteration } from "Iteration/Iteration"; import { Number } from "Number/Number"; import { Way } from "Iteration/_Internal"; import { Li...
{ "end_byte": 15379, "start_byte": 12043, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ramdaToolsNoInfinite2.ts" }
TypeScript/tests/cases/compiler/ramdaToolsNoInfinite2.ts_15380_20762
declare module "Iteration/IterationOf" { import { Number } from "Number/Number"; export type IterationMap = { '-40': ['__', '-39', '-40', -40, '-']; '-39': ['-40', '-38', '-39', -39, '-']; '-38': ['-39', '-37', '-38', -38, '-']; '-37': ['-38', '-36', '-37', -37, '-']; '-...
{ "end_byte": 20762, "start_byte": 15380, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ramdaToolsNoInfinite2.ts" }
TypeScript/tests/cases/compiler/ramdaToolsNoInfinite2.ts_20763_22873
declare module "Function/Function" { import { List } from "List/List"; export interface Function<P extends List = any, R extends any = any> { (...args: P): R; } } declare module "Any/Extends" { export type Extends<A1 extends any, A2 extends any> = [A1] extends [never] ? 0 : A1 extends A2 ? 1 : ...
{ "end_byte": 22873, "start_byte": 20763, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ramdaToolsNoInfinite2.ts" }
TypeScript/tests/cases/compiler/badOverloadError.ts_0_77
function method() { var dictionary = <{ [index: string]: string; }>{}; }
{ "end_byte": 77, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/badOverloadError.ts" }
TypeScript/tests/cases/compiler/commentBeforeStaticMethod1.ts_0_94
class C { /** * Returns bar */ public static foo(): string { return "bar"; } }
{ "end_byte": 94, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentBeforeStaticMethod1.ts" }
TypeScript/tests/cases/compiler/numberVsBigIntOperations.ts_0_3810
// @target: esnext // Cannot mix bigints and numbers let bigInt = 1n, num = 2; bigInt = 1n; bigInt = 2; num = 1n; num = 2; bigInt += 1n; bigInt += 2; num += 1n; num += 2; bigInt -= 1n; bigInt -= 2; num -= 1n; num -= 2; bigInt *= 1n; bigInt *= 2; num *= 1n; num *= 2; bigInt /= 1n; bigInt /= 2; num /= 1n; num /= 2; bigI...
{ "end_byte": 3810, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/numberVsBigIntOperations.ts" }
TypeScript/tests/cases/compiler/declarationEmitVarInElidedBlock.ts_0_95
// @declaration: true // @emitDeclarationOnly: true { var a = ""; } export let b: typeof a;
{ "end_byte": 95, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitVarInElidedBlock.ts" }
TypeScript/tests/cases/compiler/declarationEmitReusesLambdaParameterNodes.ts_0_437
// @strict: true // @declaration: true // @module: nodenext // @filename: node_modules/react-select/index.d.ts export type Whatever = {x: string, y: number}; export type Props<T, TThing = Whatever> = Omit<TThing, "y"> & Partial<TThing> & T; // @filename: index.ts import { Props } from "react-select"; export const Cus...
{ "end_byte": 437, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitReusesLambdaParameterNodes.ts" }
TypeScript/tests/cases/compiler/constDeclarations-ambient-errors.ts_0_261
// @target: ES6 // error: no intialization expected in ambient declarations declare const c1: boolean = true; declare const c2: number = 0; declare const c3 = null, c4 :string = "", c5: any = 0; declare module M { const c6 = 0; const c7: number = 7; }
{ "end_byte": 261, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constDeclarations-ambient-errors.ts" }
TypeScript/tests/cases/compiler/classInheritence.ts_0_43
class B extends A { } class A extends A { }
{ "end_byte": 43, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classInheritence.ts" }
TypeScript/tests/cases/compiler/numericIndexerTyping2.ts_0_258
class I { [x: string]: Date } class I2 extends I { } var i: I; var r: string = i[1]; // error: numeric indexer returns the type of the string indexer var i2: I2; var r2: string = i2[1]; // error: numeric indexer returns the type of the string indexere
{ "end_byte": 258, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/numericIndexerTyping2.ts" }
TypeScript/tests/cases/compiler/distributiveConditionalTypeNeverIntersection1.ts_0_330
// @strict: true // @noEmit: true // https://github.com/microsoft/TypeScript/issues/57343 type IsNumber<T> = T extends number ? true : false; type Conflicted = { x: true } & { x: false }; type Ex1 = IsNumber<Conflicted>; // never type Ex2 = IsNumber<"OEEE" | Conflicted>; // false type Ex3 = IsNumber<1 | Conflicted>...
{ "end_byte": 330, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/distributiveConditionalTypeNeverIntersection1.ts" }
TypeScript/tests/cases/compiler/sideEffectImports4.ts_0_678
// @noUncheckedSideEffectImports: true,false // @strict: true // @noImplicitReferences: true // @module: esnext // @moduleResolution: bundler // @moduleDetection: force // @allowJs: true // @checkJs: true // @filename: node_modules/server-only/package.json { "name": "server-only", "version": "0.0.1", "main": "in...
{ "end_byte": 678, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sideEffectImports4.ts" }
TypeScript/tests/cases/compiler/duplicateObjectLiteralProperty_computedName3.ts_0_429
// @filename: a.ts export const n = 1; export const s = "s"; export enum E1 { A = "ENUM_KEY" } export enum E2 { B } // @filename: b.ts import * as keys from "./a"; const t1 = { [keys.n]: 1, [keys.n]: 1, // duplicate } const t2 = { [keys.s]: 1, [keys.s]: 1, // duplicate } const t3 = { [keys.E1.A]...
{ "end_byte": 429, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateObjectLiteralProperty_computedName3.ts" }
TypeScript/tests/cases/compiler/voidReturnIndexUnionInference.ts_0_614
// @strict: true // repro from https://github.com/Microsoft/TypeScript/issues/25274 export function safeInvoke<A1, R>( func: ((arg1: A1) => R) | null | undefined, arg1: A1 ): R | undefined { if (func) { return func(arg1); } else { return undefined; } } interface Props { onFoo?(v...
{ "end_byte": 614, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/voidReturnIndexUnionInference.ts" }
TypeScript/tests/cases/compiler/moduleResolutionWithSuffixes_one_externalModule.ts_0_798
// moduleSuffixes has one entry and there's a matching package. // @fullEmitPaths: true // @filename: /tsconfig.json { "compilerOptions": { "allowJs": true, "checkJs": false, "outDir": "bin", "moduleResolution": "node", "traceResolution": true, "moduleSuffixes": [".ios"] } } // @filename: /node_modules/s...
{ "end_byte": 798, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolutionWithSuffixes_one_externalModule.ts" }
TypeScript/tests/cases/compiler/moduleResolutionWithExtensions_notSupported2.ts_0_211
// @noImplicitReferences: true // @allowJs: true // @traceResolution: true // Test the error message if we have `--allowJs` but not `--jsx`. // @Filename: /jsx.jsx // @Filename: /a.ts import jsx from "./jsx";
{ "end_byte": 211, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolutionWithExtensions_notSupported2.ts" }
TypeScript/tests/cases/compiler/contextualTyping41.ts_0_73
var foo = <{():number; (i:number):number; }> (function(){return "err";});
{ "end_byte": 73, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTyping41.ts" }
TypeScript/tests/cases/compiler/classCannotExtendVar.ts_0_56
var Markup; class Markup { constructor() { } }
{ "end_byte": 56, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classCannotExtendVar.ts" }
TypeScript/tests/cases/compiler/unionTypeParameterInference.ts_0_189
// Regression test for #5861 interface Foo<T> { prop: T; } declare function lift<U>(value: U | Foo<U>): Foo<U>; function unlift<U>(value: U | Foo<U>): U { return lift(value).prop; }
{ "end_byte": 189, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unionTypeParameterInference.ts" }
TypeScript/tests/cases/compiler/classExpressionTest1.ts_0_195
function M() { class C<X> { f<T>() { var t: T; var x: X; return { t, x }; } } var v = new C<number>(); return v.f<string>(); }
{ "end_byte": 195, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classExpressionTest1.ts" }
TypeScript/tests/cases/compiler/strictOptionalProperties4.ts_0_317
// @strictNullChecks: true // @exactOptionalPropertyTypes: true // @allowJs: true // @checkJs: true // @noEmit: true // @filename: a.js /** * @typedef Foo * @property {number} [foo] */ const x = /** @type {Foo} */ ({}); x.foo; // number | undefined const y = /** @type {Required<Foo>} */ ({}); y.foo; // number
{ "end_byte": 317, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/strictOptionalProperties4.ts" }
TypeScript/tests/cases/compiler/commentOnImportStatement3.ts_0_114
// @module: commonjs // @removeComments: false /* copyright */ /* not copyright */ import foo = require('./foo');
{ "end_byte": 114, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentOnImportStatement3.ts" }
TypeScript/tests/cases/compiler/spliceTuples.ts_0_518
declare const sb: [string, boolean]; let k1: [number, string, boolean]; k1 = [1, ...sb]; let k2: [number, string, boolean, number]; k2 = [1, ...sb, 1]; declare const sb_: [string, ...boolean[]]; let k3: [number, string, ...boolean[]]; k3 = [1, ...sb_]; declare const sbb_: [string, boolean, ...boolean[]]; let k4: ...
{ "end_byte": 518, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/spliceTuples.ts" }
TypeScript/tests/cases/compiler/spreadObjectPermutations.ts_0_657
// @strict: true // @exactOptionalPropertyTypes: false, true declare const a: { x: string | number }; declare const b: { x?: string | number }; declare const c: { x?: string | number | undefined }; const v_a = { ...a }; const v_b = { ...b }; const v_c = { ...c }; const v_ab = { ...a, ...b }; const v_ac = { ...a, ......
{ "end_byte": 657, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/spreadObjectPermutations.ts" }
TypeScript/tests/cases/compiler/overloadingOnConstantsInImplementation.ts_0_101
function foo(a: 'hi', x: string); function foo(a: 'hi', x: string); function foo(a: 'hi', x: any) { }
{ "end_byte": 101, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overloadingOnConstantsInImplementation.ts" }
TypeScript/tests/cases/compiler/declarationEmitPrefersPathKindBasedOnBundling.ts_0_411
// @declaration: true // @target: es5 // @baseUrl: . // @outDir: ./dist // @rootDir: ./src // @filename: src/lib/operators/scalar.ts export interface Scalar { (): string; value: number; } export function scalar(value: string): Scalar { return null as any; } // @filename: src/settings/spacing.ts import { scalar } fr...
{ "end_byte": 411, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitPrefersPathKindBasedOnBundling.ts" }
TypeScript/tests/cases/compiler/dataViewConstructor.ts_0_49
new DataView(new Uint8Array(32)); // should error
{ "end_byte": 49, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/dataViewConstructor.ts" }
TypeScript/tests/cases/compiler/enumNoInitializerFollowsNonLiteralInitializer.ts_0_501
// @isolatedModules: true // @noTypesAndSymbols: true // @filename: ./helpers.ts export const foo = 2; // @filename: ./bad.ts import { foo } from "./helpers"; enum A { a = foo, b, c = 10, d = (c)! satisfies number as any, e, } // @filename: ./good.ts import { foo } from "./helpers"; enum A { ...
{ "end_byte": 501, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumNoInitializerFollowsNonLiteralInitializer.ts" }
TypeScript/tests/cases/compiler/allowSyntheticDefaultImports4.ts_0_203
// @allowSyntheticDefaultImports: true // @module: commonjs // @Filename: b.d.ts declare class Foo { member: string; } export = Foo; // @Filename: a.ts import Foo from "./b"; export var x = new Foo();
{ "end_byte": 203, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/allowSyntheticDefaultImports4.ts" }
TypeScript/tests/cases/compiler/constructorArgsErrors3.ts_0_64
class foo { constructor (public public a: number) { } }
{ "end_byte": 64, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constructorArgsErrors3.ts" }
TypeScript/tests/cases/compiler/superWithGenericSpecialization.ts_0_234
class C<T> { x: T; } class D<T> extends C<string> { y: T; constructor() { super(); // uses the type parameter type of the base class, ie string } } var d: D<number>; var r: string = d.x; var r2: number = d.y;
{ "end_byte": 234, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/superWithGenericSpecialization.ts" }
TypeScript/tests/cases/compiler/strictNullEmptyDestructuring.ts_0_380
// @strictNullChecks: true // Repro from #20873 let [] = null; let { } = null; ({} = null); let { } = undefined; ({} = undefined); let { } = Math.random() ? {} : null; ({} = Math.random() ? {} : null); let { } = Math.random() ? {} : undefined; ({} = Math.random() ? {} : undefined); let { } = Math.random() ? ...
{ "end_byte": 380, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/strictNullEmptyDestructuring.ts" }
TypeScript/tests/cases/compiler/library_StringSlice.ts_0_145
// String.prototype.slice can have zero, one, or two arguments String.prototype.slice(); String.prototype.slice(0); String.prototype.slice(0,1);
{ "end_byte": 145, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/library_StringSlice.ts" }
TypeScript/tests/cases/compiler/contextualTyping10.ts_0_59
class foo { public bar:{id:number;}[] = [{id:1}, {id:2}]; }
{ "end_byte": 59, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTyping10.ts" }
TypeScript/tests/cases/compiler/privacyLocalInternalReferenceImportWithExport.ts_0_6865
//@module: commonjs //@declaration: true // private elements module m_private { export class c_private { } export enum e_private { Happy, Grumpy } export function f_private() { return new c_private(); } export var v_private = new c_private(); export interface i_pr...
{ "end_byte": 6865, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyLocalInternalReferenceImportWithExport.ts" }
TypeScript/tests/cases/compiler/ParameterList7.ts_0_132
class C1 { constructor(public p1:string); // ERROR constructor(private p2:number); // ERROR constructor(public p3:any) {} // OK }
{ "end_byte": 132, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ParameterList7.ts" }
TypeScript/tests/cases/compiler/setterBeforeGetter.ts_0_236
class Foo { private _bar: { a: string; }; // should not be an error to order them this way set bar(thing: { a: string; }) { this._bar = thing; } get bar(): { a: string; } { return this._bar; } }
{ "end_byte": 236, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/setterBeforeGetter.ts" }
TypeScript/tests/cases/compiler/functionWithDefaultParameterWithNoStatements9.ts_0_68
function foo(a = console.log) { } function bar(a = console.log) { }
{ "end_byte": 68, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionWithDefaultParameterWithNoStatements9.ts" }
TypeScript/tests/cases/compiler/quickIntersectionCheckCorrectlyCachesErrors.ts_0_424
// @jsx: react // @filename: quickIntersectionCheckCorrectlyCachesErrors.tsx interface F<P> { (props: P & { children?: boolean }): void; propTypes: { [K in keyof P]: null extends P ? K : K }; } declare function g(C: F<unknown>): string; export function wu<CP extends { o: object }>(CC: F<CP>) { class WU { ...
{ "end_byte": 424, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/quickIntersectionCheckCorrectlyCachesErrors.ts" }
TypeScript/tests/cases/compiler/typeUsedAsValueError2.ts_0_406
// @module: amd // @filename: helloInterface.ts interface HelloInterface { world: any; } export = HelloInterface; // @filename: helloNamespace.ts namespace HelloNamespace { export type world = any; } export = HelloNamespace; // @filename: world.ts import HelloInterface = require("helloInterface"); import He...
{ "end_byte": 406, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeUsedAsValueError2.ts" }
TypeScript/tests/cases/compiler/nestedRecursiveArraysOrObjectsError01.ts_0_222
type Style = StyleBase | StyleArray; interface StyleArray extends Array<Style> {} interface StyleBase { foo: string; } const blah: Style = [ [[{ foo: 'asdf', jj: 1 // intentional error }]] ];
{ "end_byte": 222, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nestedRecursiveArraysOrObjectsError01.ts" }
TypeScript/tests/cases/compiler/indexSignatureAndMappedType.ts_0_729
// @strict: true // @declaration: true // A mapped type { [P in K]: X }, where K is a generic type, is related to // { [key: string]: Y } if X is related to Y. function f1<T, K extends string>(x: { [key: string]: T }, y: Record<K, T>) { x = y; y = x; // Error } function f2<T>(x: { [key: string]: T }, y: Rec...
{ "end_byte": 729, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/indexSignatureAndMappedType.ts" }
TypeScript/tests/cases/compiler/narrowingPastLastAssignment.ts_0_3514
// @strict: true // @noEmit: true // @target: esnext function action(f: Function) {} // Narrowings are preserved in closures created past last assignment function f1(x: string | number) { x = "abc"; action(() => { x /* string | number */ }); x = 42; action(() => { x /* number */ }); } // Narrowings ...
{ "end_byte": 3514, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowingPastLastAssignment.ts" }
TypeScript/tests/cases/compiler/moduleAugmentationDisallowedExtensions.ts_0_899
// @module: commonjs // @filename: x0.ts export let a = 1; // @filename: x.ts namespace N1 { export let x = 1; } declare module "./observable" { var x: number; let y: number; const z: number; let {x1, y1, z0: {n}, z1: {arr: [el1, el2, el3]}}: {x1: number, y1: string, z0: {n: number}, z1: {arr: n...
{ "end_byte": 899, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleAugmentationDisallowedExtensions.ts" }
TypeScript/tests/cases/compiler/es6ClassTest8.ts_0_1098
function f1(x:any) {return x;} class C { constructor() { var bar:any = (function() { return bar; // 'bar' should be resolvable }); var b = f1(f1(bar)); } } class Vector { static norm(v:Vector):Vector {return null;} static minus(v1:Vector, v2:Vector):Vector {retur...
{ "end_byte": 1098, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ClassTest8.ts" }
TypeScript/tests/cases/compiler/returnTypePredicateIsInstantiateInContextOfTarget.tsx_0_433
// @jsx: react // @strict: true /// <reference path="/.lib/react16.d.ts" /> import * as React from "react"; class TestComponent extends React.Component<{ isAny: <T>(obj: any) => obj is T }> { static defaultProps = { isAny: TestComponent.isAny } // Type guard is defined as a static class property ...
{ "end_byte": 433, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/returnTypePredicateIsInstantiateInContextOfTarget.tsx" }
TypeScript/tests/cases/compiler/duplicatePackage_subModule.ts_0_620
// @noImplicitReferences: true // @Filename: /node_modules/a/index.d.ts import Foo from "foo/Foo"; export const o: Foo; // @Filename: /node_modules/a/node_modules/foo/Foo.d.ts export default class Foo { protected source: boolean; } // @Filename: /node_modules/a/node_modules/foo/package.json { "name": "foo", "ver...
{ "end_byte": 620, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicatePackage_subModule.ts" }
TypeScript/tests/cases/compiler/esModuleInteropPrettyErrorRelatedInformation.ts_0_241
// @pretty: true // @esModuleInterop: true // @filename: foo.d.ts declare function foo(): void; declare namespace foo {} export = foo; // @filename: index.ts import * as foo from "./foo"; function invoke(f: () => void) { f(); } invoke(foo);
{ "end_byte": 241, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/esModuleInteropPrettyErrorRelatedInformation.ts" }
TypeScript/tests/cases/compiler/requireOfJsonFileWithoutExtensionResolvesToTs.ts_0_476
// @module: commonjs // @outdir: out/ // @allowJs: true // @fullEmitPaths: true // @resolveJsonModule: true // @Filename: file1.ts import c1 = require('./c'); // resolves to c.ts let x2 = c1.a; import c2 = require('./c.json'); // resolves to c.json if (x2) { let b = c2.b; let x = (c1.b === b); } // @Filename...
{ "end_byte": 476, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/requireOfJsonFileWithoutExtensionResolvesToTs.ts" }
TypeScript/tests/cases/compiler/letAsIdentifier2.ts_0_34
// @target: es6 function let() {}
{ "end_byte": 34, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/letAsIdentifier2.ts" }
TypeScript/tests/cases/compiler/inheritanceStaticPropertyOverridingProperty.ts_0_90
class a { static x: () => string; } class b extends a { static x: () => string; }
{ "end_byte": 90, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inheritanceStaticPropertyOverridingProperty.ts" }
TypeScript/tests/cases/compiler/moduleAugmentationGlobal8_1.ts_0_110
// @target: es5 // @module: amd namespace A { global { interface Array<T> { x } } } export {}
{ "end_byte": 110, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleAugmentationGlobal8_1.ts" }
TypeScript/tests/cases/compiler/collisionThisExpressionAndModuleInGlobal.ts_0_64
module _this { //Error class c { } } var f = () => this;
{ "end_byte": 64, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionThisExpressionAndModuleInGlobal.ts" }
TypeScript/tests/cases/compiler/declarationEmitFirstTypeArgumentGenericFunctionType.ts_0_897
// @declaration: true // @module: commonjs // @target: es6 class X<A> { } var prop11: X< <Tany>() => Tany >; // spaces before the first type argument var prop12: X<(<Tany>() => Tany)>; // spaces before the first type argument function f1() { // Inferred return type return prop11; } function f2() { // Inferred retu...
{ "end_byte": 897, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitFirstTypeArgumentGenericFunctionType.ts" }
TypeScript/tests/cases/compiler/discriminantElementAccessCheck.ts_0_864
type U = TypeA | TypeB; interface TypeA { kind: 'A'; a: number; } interface TypeB { kind: 'B'; b: string; } function assertNever(x: never) { return x; } function IfWithString(val: U) { if (val['kind'] === 'B') { return val.b; } else { return val.a; } } function Switch...
{ "end_byte": 864, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/discriminantElementAccessCheck.ts" }
TypeScript/tests/cases/compiler/staticMismatchBecauseOfPrototype.ts_0_117
interface A { n: number; } declare var A: { prototype: A; new(): A; }; class B extends A { n = ""; }
{ "end_byte": 117, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/staticMismatchBecauseOfPrototype.ts" }
TypeScript/tests/cases/compiler/declInput-2.ts_0_614
// @declaration: true module M { class C { } export class E {} export interface I1 {} interface I2 {} export class D { private c: C; // don't generate public m1: number; public m2: string; public m22: C; // don't generate public m23: E; public m24: I1;...
{ "end_byte": 614, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declInput-2.ts" }
TypeScript/tests/cases/compiler/commentOnArrayElement16.ts_3_76
nst array = [ // comment start 1, 2, // comment end ];
{ "end_byte": 76, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentOnArrayElement16.ts" }
TypeScript/tests/cases/compiler/reactDefaultPropsInferenceSuccess.tsx_0_1627
// @jsx: react // @strict: true // @esModuleInterop: true /// <reference path="/.lib/react16.d.ts" /> import React from 'react'; interface BaseProps { when?: ((value: string) => boolean) | "a" | "b"; error?: boolean; } interface Props extends BaseProps { } class FieldFeedback<P extends Props = BaseProps> extend...
{ "end_byte": 1627, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reactDefaultPropsInferenceSuccess.tsx" }
TypeScript/tests/cases/compiler/discriminantPropertyCheck.ts_0_4007
// @strict: true type Item = Item1 | Item2; interface Base { bar: boolean; } interface Item1 extends Base { kind: "A"; foo: string | undefined; baz: boolean; qux: true; } interface Item2 extends Base { kind: "B"; foo: string | undefined; baz: boolean; qux: false; } function goo1...
{ "end_byte": 4007, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/discriminantPropertyCheck.ts" }
TypeScript/tests/cases/compiler/bigint64ArraySubarray.ts_0_160
// @target: es2020 function bigInt64ArraySubarray() { var arr = new BigInt64Array(10); arr.subarray(); arr.subarray(0); arr.subarray(0, 10); }
{ "end_byte": 160, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/bigint64ArraySubarray.ts" }
TypeScript/tests/cases/compiler/privacyFunctionReturnTypeDeclFile.ts_0_6575
// @module: commonjs // @declaration: true // @Filename:privacyFunctionReturnTypeDeclFile_externalModule.ts class privateClass { } export class publicClass { } export interface publicInterfaceWithPrivateParmeterTypes { new (): privateClass; // Error (): privateClass; // Error [x: number]: privateClass; /...
{ "end_byte": 6575, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyFunctionReturnTypeDeclFile.ts" }
TypeScript/tests/cases/compiler/privacyFunctionReturnTypeDeclFile.ts_6578_13924
export module publicModule { class privateClass { } export class publicClass { } export interface publicInterfaceWithPrivateParmeterTypes { new (): privateClass; // Error (): privateClass; // Error [x: number]: privateClass; // Error myMethod(): privateClass; // Err...
{ "end_byte": 13924, "start_byte": 6578, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyFunctionReturnTypeDeclFile.ts" }
TypeScript/tests/cases/compiler/privacyFunctionReturnTypeDeclFile.ts_13926_22387
module privateModule { class privateClass { } export class publicClass { } export interface publicInterfaceWithPrivateParmeterTypes { new (): privateClass; (): privateClass; [x: number]: privateClass; myMethod(): privateClass; } export interface publicI...
{ "end_byte": 22387, "start_byte": 13926, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyFunctionReturnTypeDeclFile.ts" }