_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/collisionSuperAndLocalFunctionInAccessors.ts_0_781
// @target: es5 function _super() { // No error } class Foo { get prop1(): number { function _super() { // No error } return 10; } set prop1(val: number) { function _super() { // No error } } } class b extends Foo { get prop2(): number { function _supe...
{ "end_byte": 781, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionSuperAndLocalFunctionInAccessors.ts" }
TypeScript/tests/cases/compiler/crashDeclareGlobalTypeofExport.ts_0_348
// @esModuleInterop: true // @Filename: bar.d.ts import * as foo from './foo' export as namespace foo export = foo; declare global { const foo: typeof foo; } // @Filename: foo.d.ts interface Root { /** * A .default property for ES6 default import compatibility */ default: Root; } declare const...
{ "end_byte": 348, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/crashDeclareGlobalTypeofExport.ts" }
TypeScript/tests/cases/compiler/cannotIndexGenericWritingError.ts_0_325
// @strict: true // @noEmit: true // From #47357 function foo<T extends Record<string | symbol, any>>(target: T, p: string | symbol) { target[p] = ""; // error } function foo2<T extends number[] & { [s: string]: number | string }>(target: T, p: string | number) { target[p] = 1; // error target[1] = 1; //...
{ "end_byte": 325, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/cannotIndexGenericWritingError.ts" }
TypeScript/tests/cases/compiler/multiSignatureTypeInference.ts_0_2406
// @strict: true // @noEmit: true declare function f1(arg: boolean): string; declare function f1(arg1: number, arg2: number): number; declare function f1(...args: string[]): string[]; declare function f2(arg: unknown): unknown; declare function f3(): string; type AllParams<T> = T extends { (...a: infer A1): any...
{ "end_byte": 2406, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/multiSignatureTypeInference.ts" }
TypeScript/tests/cases/compiler/superNewCall1.ts_1_185
class A<T1, T2> { constructor(private map: (value: T1) => T2) { } } class B extends A<number, string> { constructor() { new super(value => String(value)); } }
{ "end_byte": 185, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/superNewCall1.ts" }
TypeScript/tests/cases/compiler/classIndexer2.ts_0_95
class C123 { [s: string]: number; x: number; y: string; constructor() { } }
{ "end_byte": 95, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classIndexer2.ts" }
TypeScript/tests/cases/compiler/errorsOnImportedSymbol.ts_0_298
// @module: commonjs // @target: ES5 // @Filename: errorsOnImportedSymbol_0.ts interface Sammy { new (): any; (): number; } export = Sammy; // @Filename: errorsOnImportedSymbol_1.ts import Sammy = require("./errorsOnImportedSymbol_0"); var x = new Sammy.Sammy(); var y = Sammy.Sammy();
{ "end_byte": 298, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/errorsOnImportedSymbol.ts" }
TypeScript/tests/cases/compiler/taggedTemplatesInDifferentScopes.ts_0_208
export function tag(parts: TemplateStringsArray, ...values: any[]) { return parts[0]; } function foo() { tag `foo`; tag `foo2`; } function bar() { tag `bar`; tag `bar2`; } foo(); bar();
{ "end_byte": 208, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/taggedTemplatesInDifferentScopes.ts" }
TypeScript/tests/cases/compiler/jsdocResolveNameFailureInTypedef.ts_0_158
// @allowJs: true // @checkJs: true // @noEmit: true // @Filename: /a.js /** * @param {Ty} x */ function f(x) {} /** * @typedef {CantResolveThis} Ty */
{ "end_byte": 158, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsdocResolveNameFailureInTypedef.ts" }
TypeScript/tests/cases/compiler/jsDeclarationEmitExportedClassWithExtends.ts_0_1146
// @checkJs: true // @outDir: out // @declaration: true // @module: esnext // @moduleResolution: nodenext // @filename: node_modules/lit/package.json { "name": "lit", "version": "0.0.1", "type": "module", "exports": { ".": { "types": "./development/index.d.ts" } } } // @filename:...
{ "end_byte": 1146, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsDeclarationEmitExportedClassWithExtends.ts" }
TypeScript/tests/cases/compiler/typePredicatesInUnion.ts_0_179
interface A { pred(x: {}): x is boolean; } interface B { pred(x: {}): x is string; } type Or = A | B; function f(o: Or, x: {}) { if (o.pred(x)) { x; } }
{ "end_byte": 179, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typePredicatesInUnion.ts" }
TypeScript/tests/cases/compiler/systemObjectShorthandRename.ts_0_185
// @module: system // @target: es2015 // @filename: x.ts export const x = 'X' // @filename: index.ts import {x} from './x.js' const x2 = {x} const a = {x2} const x3 = x const b = {x3}
{ "end_byte": 185, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/systemObjectShorthandRename.ts" }
TypeScript/tests/cases/compiler/typeArgumentsOnFunctionsWithNoTypeParameters.ts_0_130
function foo<T, U>(f: (v: T) => U) { var r1 = f<number>(1); var r2 = f(1); var r3 = f<any>(null); var r4 = f(null); }
{ "end_byte": 130, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeArgumentsOnFunctionsWithNoTypeParameters.ts" }
TypeScript/tests/cases/compiler/declarationEmitShadowingInferNotRenamed.ts_0_588
// @declaration: true // Any instance type type Client = string // Modified instance type UpdatedClient<C> = C & {foo: number} export const createClient = < D extends | (new (...args: any[]) => Client) // accept class | Record<string, new (...args: any[]) => Client> // or map of classes >( clientDef: D ):...
{ "end_byte": 588, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitShadowingInferNotRenamed.ts" }
TypeScript/tests/cases/compiler/constructorReturnsInvalidType.ts_0_89
class X { constructor() { return 1; } foo() { } } var x = new X();
{ "end_byte": 89, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constructorReturnsInvalidType.ts" }
TypeScript/tests/cases/compiler/mappedTypeAsStringTemplate.ts_0_144
// Repro from #44220 function foo<T extends { [K in keyof T as `${Extract<K, string>}y`]: number }>(foox: T) { } const c = { x: 1 }; foo(c);
{ "end_byte": 144, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mappedTypeAsStringTemplate.ts" }
TypeScript/tests/cases/compiler/privacyVarDeclFile.ts_0_9752
// @module: commonjs // @declaration: true // @Filename:privacyVarDeclFile_externalModule.ts class privateClass { } export class publicClass { } export interface publicInterfaceWithPrivatePropertyTypes { myProperty: privateClass; // Error } export interface publicInterfaceWithPublicPropertyTypes { myProper...
{ "end_byte": 9752, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyVarDeclFile.ts" }
TypeScript/tests/cases/compiler/privacyVarDeclFile.ts_9754_16224
module publicModuleInGlobal { class privateClass { } export class publicClass { } module privateModule { class privateClass { } export class publicClass { } export interface publicInterfaceWithPrivatePropertyTypes { myProperty: privateClass; ...
{ "end_byte": 16224, "start_byte": 9754, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyVarDeclFile.ts" }
TypeScript/tests/cases/compiler/es6ImportDefaultBindingMergeErrors.ts_0_618
// @module: commonjs // @target: ES5 // @filename: es6ImportDefaultBindingMergeErrors_0.ts var a = 10; export default a; // @filename: es6ImportDefaultBindingMergeErrors_1.ts import defaultBinding from "./es6ImportDefaultBindingMergeErrors_0"; interface defaultBinding { // This is ok } var x = defaultBinding; import ...
{ "end_byte": 618, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ImportDefaultBindingMergeErrors.ts" }
TypeScript/tests/cases/compiler/inKeywordNarrowingWithNoUncheckedIndexedAccess.ts_0_777
// @strict: true // @noEmit: true // @noUncheckedIndexedAccess: true declare function invariant(condition: boolean): asserts condition; function f1(obj: Record<string, string>) { invariant("test" in obj); return obj.test; // string } function f2(obj: Record<string, string>) { if ("test" in obj) { ...
{ "end_byte": 777, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inKeywordNarrowingWithNoUncheckedIndexedAccess.ts" }
TypeScript/tests/cases/compiler/inferentialTypingUsingApparentType2.ts_0_119
function foo<T extends { m(p: string): number }>(x: T): T { return undefined; } foo({ m(x) { return x.length } });
{ "end_byte": 119, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inferentialTypingUsingApparentType2.ts" }
TypeScript/tests/cases/compiler/useBeforeDeclaration.ts_0_365
// @outFile: test.js // @fileName: A.ts namespace ts { export function printVersion():void { log("Version: " + sys.version); // the call of sys.version is deferred, should not report an error. } export function log(info:string):void { } } // @fileName: B.ts namespace ts { export let sy...
{ "end_byte": 365, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/useBeforeDeclaration.ts" }
TypeScript/tests/cases/compiler/nodeNextCjsNamespaceImportDefault1.ts_0_269
// @module: nodenext // @moduleResolution: nodenext // @outDir: ./out // @declaration: true // @filename: src/a.cts export const a: number = 1; // @filename: src/foo.mts import d, {a} from './a.cjs'; import * as ns from './a.cjs'; export {d, a, ns}; d.a; ns.default.a;
{ "end_byte": 269, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nodeNextCjsNamespaceImportDefault1.ts" }
TypeScript/tests/cases/compiler/computedPropertiesInDestructuring2.ts_0_50
let foo2 = () => "bar"; let {[foo2()]: bar3} = {};
{ "end_byte": 50, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/computedPropertiesInDestructuring2.ts" }
TypeScript/tests/cases/compiler/privacyCheckExternalModuleExportAssignmentOfGenericClass.ts_0_399
// @module: commonjs // @declaration: true // @Filename: privacyCheckExternalModuleExportAssignmentOfGenericClass_0.ts export = Foo; class Foo<A> { constructor(public a: A) { } } // @Filename: privacyCheckExternalModuleExportAssignmentOfGenericClass_1.ts import Foo = require("./privacyCheckExternalModuleExportAssi...
{ "end_byte": 399, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyCheckExternalModuleExportAssignmentOfGenericClass.ts" }
TypeScript/tests/cases/compiler/duplicateIdentifierRelatedSpans1.ts_0_175
// @pretty: true // @filename: file1.ts class Foo { } const Bar = 3; // @filename: file2.ts type Foo = number; class Bar {} // @filename: file3.ts type Foo = 54; let Bar = 42
{ "end_byte": 175, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateIdentifierRelatedSpans1.ts" }
TypeScript/tests/cases/compiler/downlevelLetConst7.ts_0_5
let a
{ "end_byte": 5, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/downlevelLetConst7.ts" }
TypeScript/tests/cases/compiler/jsFileCompilationExternalPackageError.ts_0_238
// @allowJs: true // @noEmit: true // @module: commonjs // @filename: moduleA/a.js import {a} from "b"; a++; import {c} from "c"; c++; // @filename: node_modules/b.ts var a = 10; // @filename: node_modules/c.js exports.a = 10; c = 10;
{ "end_byte": 238, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationExternalPackageError.ts" }
TypeScript/tests/cases/compiler/jsFileCompilationWithOutDeclarationFileNameSameAsInputJsFile.ts_0_129
// @declaration: true // @outFile: /b.js // @filename: /a.ts class c { } // @filename: /b.d.ts declare function foo(): boolean;
{ "end_byte": 129, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationWithOutDeclarationFileNameSameAsInputJsFile.ts" }
TypeScript/tests/cases/compiler/indexingTypesWithNever.ts_0_3849
// @strict: true type TestObj = { a: string; b: number; }; // Should be never but without an error type Result1 = TestObj[never]; type EmptyObj = {}; // Should be never but without an error type Result2 = EmptyObj[keyof EmptyObj]; declare function genericFn1<T>(obj: T): T[never]; // Should be never const resu...
{ "end_byte": 3849, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/indexingTypesWithNever.ts" }
TypeScript/tests/cases/compiler/isolatedModulesUnspecifiedModule.ts_0_62
// @isolatedModules: true // @filename: file1.ts export var x;
{ "end_byte": 62, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/isolatedModulesUnspecifiedModule.ts" }
TypeScript/tests/cases/compiler/declarationEmitExportAliasVisibiilityMarking.ts_0_473
// @lib: es2015 // @declaration: true // @filename: Types.ts type Suit = 'Hearts' | 'Spades' | 'Clubs' | 'Diamonds'; type Rank = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 'Jack' | 'Queen' | 'King'; export { Suit, Rank }; // @filename: Card.ts import { Suit, Rank } from './Types'; export default (suit: Suit, rank: R...
{ "end_byte": 473, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitExportAliasVisibiilityMarking.ts" }
TypeScript/tests/cases/compiler/numericIndexerConstraint3.ts_0_111
class A { foo: number; } class B extends A { bar: string; } class C { 0: B; [x: number]: A; }
{ "end_byte": 111, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/numericIndexerConstraint3.ts" }
TypeScript/tests/cases/compiler/classDeclarationCheckUsedBeforeDefinitionInItself.ts_0_67
// @target: es6 class C3 { static intance = new C3(); // ok }
{ "end_byte": 67, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classDeclarationCheckUsedBeforeDefinitionInItself.ts" }
TypeScript/tests/cases/compiler/contextualTypeIterableUnions.ts_0_321
// @strict: true // @target: esnext declare class DMap<K, V> { constructor(iterable: Iterable<[K, V]> | undefined); } new DMap([["1", 2]]); const i1: Iterable<{ a: true }> | undefined = [{ a: true }]; const i2: Iterable<{ a: true }> | Iterable<{ b: false }> = [{ b: false }]; const i3: Iterable<number> | 1[] = [2];...
{ "end_byte": 321, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTypeIterableUnions.ts" }
TypeScript/tests/cases/compiler/emitCapturingThisInTupleDestructuring1.ts_3_208
clare function wrapper(x: any); wrapper((array: [any]) => { [this.test, this.test1, this.test2] = array; // even though there is a compiler error, we should still emit lexical capture for "this" });
{ "end_byte": 208, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emitCapturingThisInTupleDestructuring1.ts" }
TypeScript/tests/cases/compiler/nestedGenericConditionalTypeWithGenericImportType.ts_0_205
// #31824 // @filename: name.ts export type Name<T> = any; // @filename: index.ts type T<X> = any extends ((any extends any ? any : string) extends any ? import("./name").Name<X> : any) ? any : any;
{ "end_byte": 205, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nestedGenericConditionalTypeWithGenericImportType.ts" }
TypeScript/tests/cases/compiler/systemModuleWithSuperClass.ts_0_173
// @module: system // @Filename: foo.ts export class Foo { a: string; } // @Filename: bar.ts import {Foo} from './foo'; export class Bar extends Foo { b: string; }
{ "end_byte": 173, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/systemModuleWithSuperClass.ts" }
TypeScript/tests/cases/compiler/propertyAccessibility2.ts_0_49
class C { private static x = 1; } var c = C.x;
{ "end_byte": 49, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/propertyAccessibility2.ts" }
TypeScript/tests/cases/compiler/emitBundleWithShebang1.ts_3_119
@target: es5 // @outFile: outFile.js // @module: amd #!/usr/bin/env gjs class Doo {} class Scooby extends Doo {}
{ "end_byte": 119, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emitBundleWithShebang1.ts" }
TypeScript/tests/cases/compiler/declFileExportImportChain.ts_0_618
//@module: amd //@declaration: true // @Filename: declFileExportImportChain_a.ts module m1 { export module m2 { export class c1 { } } } export = m1; // @Filename: declFileExportImportChain_b.ts export import a = require("declFileExportImportChain_a"); // @Filename: declFileExportImportChain_b...
{ "end_byte": 618, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileExportImportChain.ts" }
TypeScript/tests/cases/compiler/uncalledFunctionChecksInConditional.ts_0_898
// @strictNullChecks: true declare function isFoo(): boolean; declare function isBar(): boolean; declare const isUndefinedFoo: (() => boolean) | undefined; if (isFoo) { // error on isFoo } if (isFoo || isBar) { // error on isFoo, isBar } if (isFoo || isFoo()) { // error on isFoo } if (isUndefinedFoo ||...
{ "end_byte": 898, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/uncalledFunctionChecksInConditional.ts" }
TypeScript/tests/cases/compiler/parsingDeepParenthensizedExpression.ts_0_1360
// @allowJs: true // @noEmit: true // @fileName: a.js function Y(e, t) { e |= 0, t |= 0; var r, i, a, u, s, c, d, h, p, _, m, g, y, A, T, v, M = 0, E = 0, w = 0, S = 0; ...
{ "end_byte": 1360, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parsingDeepParenthensizedExpression.ts" }
TypeScript/tests/cases/compiler/parsingDeepParenthensizedExpression.ts_1361_4832
(E = (E = (E = (E = (E = (E = (E = (E = (E = (E = (E = (E = (E = (E = (E = (E = (E = (E = (E = (E = (E = E + ((((w = (w = (w = w + (606105819 + (((S = (S = (S = S + ((((M = (M = (M = M + (((E & w | (-1 ^ E) & S) + (0 | o[T >> 2]) | 0) - 680876936 | 0) | 0) << 7 | M >>> 25) + E | 0) & E | (-1 ^ M) & w) + (0 | o[(T + 4 |...
{ "end_byte": 4832, "start_byte": 1361, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parsingDeepParenthensizedExpression.ts" }
TypeScript/tests/cases/compiler/parsingDeepParenthensizedExpression.ts_4833_7987
+ ((((w = (w = (w = w + (1735328473 + (((S = (S = (S = S + ((((M = (M = (M = M + (((E & S | w & (-1 ^ S)) + (0 | o[(T + 52 | 0) >> 2]) | 0) - 1444681467 | 0) | 0) << 5 | M >>> 27) + E | 0) & w | E & (-1 ^ w)) + (0 | o[(T + 8 | 0) >> 2]) | 0) - 51403784 | 0) | 0) << 9 | S >>> 23) + M | 0) & E | M & (-1 ^ E)) + (0 | o[(T...
{ "end_byte": 7987, "start_byte": 4833, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parsingDeepParenthensizedExpression.ts" }
TypeScript/tests/cases/compiler/parsingDeepParenthensizedExpression.ts_7988_9204
(1309151649 + (((S = (S = (S = S + (((E ^ ((M = (M = (M = M + (1873313359 + ((w ^ (E | -1 ^ S)) + (0 | o[(T + 32 | 0) >> 2]) | 0) | 0) | 0) << 6 | M >>> 26) + E | 0) | -1 ^ w)) + (0 | o[(T + 60 | 0) >> 2]) | 0) - 30611744 | 0) | 0) << 10 | S >>> 22) + M | 0) ^ ((w = (w = (w = w + (((M ^ (S | -1 ^ E)) + (0 | o[(T + 24 |...
{ "end_byte": 9204, "start_byte": 7988, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parsingDeepParenthensizedExpression.ts" }
TypeScript/tests/cases/compiler/circularConstraintYieldsAppropriateError.ts_0_308
// https://github.com/Microsoft/TypeScript/issues/16861 class BaseType<T> { bar: T } class NextType<C extends { someProp: any }, T = C['someProp']> extends BaseType<T> { baz: string; } class Foo extends NextType<Foo> { someProp: { test: true } } const foo = new Foo(); foo.bar.test
{ "end_byte": 308, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/circularConstraintYieldsAppropriateError.ts" }
TypeScript/tests/cases/compiler/transformsElideNullUndefinedType.ts_0_1174
// @target: es6 var v0: null; var v1: undefined; function f0(): null { return null; } function f1(): undefined { return undefined; } var f2 = function (): null { return null; } var f3 = function (): undefined { return undefined; } var f4 = (): null => null; var f5 = (): undefined => undefined; function f6(p0: null...
{ "end_byte": 1174, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/transformsElideNullUndefinedType.ts" }
TypeScript/tests/cases/compiler/genericArrayAssignment1.ts_0_41
var s: string[]; var n: number[]; s = n;
{ "end_byte": 41, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericArrayAssignment1.ts" }
TypeScript/tests/cases/compiler/constructorOverloads3.ts_0_407
declare class FooBase { constructor(s: string); constructor(n: number); constructor(x: any); } class Foo extends FooBase { constructor(s: string); constructor(n: number); constructor(a: any); constructor(x: any, y?: any) { } bar1() { /*WScript.Echo("Yo");*/} } var f1 = new Foo("hey")...
{ "end_byte": 407, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constructorOverloads3.ts" }
TypeScript/tests/cases/compiler/noImplicitAnyFunctionExpressionAssignment.ts_0_161
// @noimplicitany: true var x: (a: any) => void = function <T>(x: T) { return null; }; var x2: (a: any) => void = function f<T>(x: T) { return null; };
{ "end_byte": 161, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noImplicitAnyFunctionExpressionAssignment.ts" }
TypeScript/tests/cases/compiler/narrowingOfDottedNames.ts_0_1228
// @strict: true // Repro from #8383 class A { prop!: { a: string; }; } class B { prop!: { b: string; } } function isA(x: any): x is A { return x instanceof A; } function isB(x: any): x is B { return x instanceof B; } function f1(x: A | B) { while (true) { if (x instanceof A) { ...
{ "end_byte": 1228, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowingOfDottedNames.ts" }
TypeScript/tests/cases/compiler/homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts_0_713
// @strict: true // @noEmit: true type HandleOptions<O> = { [I in keyof O]: { value: O[I]; }; }; declare function func1< T extends Record<PropertyKey, readonly any[]>, >(fields: { [K in keyof T]: { label: string; options: [...HandleOptions<T[K]>]; }; }): T; const result = ...
{ "end_byte": 713, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/homomorphicMappedTypeWithNonHomomorphicInstantiationSpreadable1.ts" }
TypeScript/tests/cases/compiler/classWithOverloadImplementationOfWrongName2.ts_0_70
class C { foo(): string; bar(x): any { } foo(x): number; }
{ "end_byte": 70, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classWithOverloadImplementationOfWrongName2.ts" }
TypeScript/tests/cases/compiler/internalAliasVarInsideLocalModuleWithoutExport.ts_0_146
//@module: amd // @declaration: true export module a { export var x = 10; } export module c { import b = a.x; export var bVal = b; }
{ "end_byte": 146, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/internalAliasVarInsideLocalModuleWithoutExport.ts" }
TypeScript/tests/cases/compiler/jsxFactoryAndJsxFragmentFactory.tsx_0_168
//@jsx: react //@jsxFactory: h //@jsxFragmentFactory: Frag declare var h: any; declare var Frag: any; <></>; <><span>1</span><><span>2.1</span><span>2.2</span></></>;
{ "end_byte": 168, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsxFactoryAndJsxFragmentFactory.tsx" }
TypeScript/tests/cases/compiler/declarationEmitOfTypeofAliasedExport.ts_0_138
// @declaration: true // @filename: /a.ts class C {} export { C as D } // @filename: /b.ts import * as a from "./a"; export default a.D;
{ "end_byte": 138, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitOfTypeofAliasedExport.ts" }
TypeScript/tests/cases/compiler/commentsArgumentsOfCallExpression1.ts_3_218
nction foo(/*c1*/ x: any) { } foo(/*c2*/ 1); foo(/*c3*/ function () { }); foo( /*c4*/ () => { }); foo( /*c5*/ /*c6*/ () => { }); foo(/*c7*/ () => { }); foo( /*c7*/ /*c8*/() => { });
{ "end_byte": 218, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentsArgumentsOfCallExpression1.ts" }
TypeScript/tests/cases/compiler/pathMappingBasedModuleResolution6_node.ts_0_472
// @module: commonjs // @traceResolution: true // @filename: c:/root/src/tsconfig.json { "compilerOptions": { "rootDirs": [ ".", "../generated/src" ] } } // @filename: c:/root/src/file1.ts import {x} from "./project/file3"; declare function use(x: string); use(x.toFixed...
{ "end_byte": 472, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/pathMappingBasedModuleResolution6_node.ts" }
TypeScript/tests/cases/compiler/unusedIdentifiersConsolidated1.ts_0_1899
//@noUnusedLocals:true //@noUnusedParameters:true function greeter(person: string) { var unused = 20; } class Dummy<usedtypeparameter, unusedtypeparameter> { private unusedprivatevariable: string; private greeting: string; public unusedpublicvariable: string; public typedvariable: usedtypeparamete...
{ "end_byte": 1899, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedIdentifiersConsolidated1.ts" }
TypeScript/tests/cases/compiler/functionCall6.ts_0_73
function foo(a:string){}; foo('bar'); foo(2); foo('foo', 'bar'); foo();
{ "end_byte": 73, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionCall6.ts" }
TypeScript/tests/cases/compiler/controlFlowBreakContinueWithLabel.ts_0_241
// @strict: true enum User { A, B } let user: User = User.A label: while (true) { switch (user) { case User.A: user = User.B; continue label; case User.B: break label; } } user;
{ "end_byte": 241, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/controlFlowBreakContinueWithLabel.ts" }
TypeScript/tests/cases/compiler/genericSignatureInheritance.ts_0_67
interface I { <T>(x: T): string; } interface I2 extends I { }
{ "end_byte": 67, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericSignatureInheritance.ts" }
TypeScript/tests/cases/compiler/indexWithUndefinedAndNull.ts_0_224
// @strictNullChecks: false interface N { [n: number]: string; } interface S { [s: string]: number; } let n: N; let s: S; let str: string = n[undefined]; str = n[null]; let num: number = s[undefined]; num = s[null];
{ "end_byte": 224, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/indexWithUndefinedAndNull.ts" }
TypeScript/tests/cases/compiler/undeclaredVarEmit.ts_0_10
f: number;
{ "end_byte": 10, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/undeclaredVarEmit.ts" }
TypeScript/tests/cases/compiler/superInObjectLiterals_ES6.ts_0_1058
// @target: ES6 var obj = { __proto__: { method() { } }, method() { super.method(); }, get prop() { super.method(); return 10; }, set prop(value) { super.method(); }, p1: function () { super.method(); }, p2: function f()...
{ "end_byte": 1058, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/superInObjectLiterals_ES6.ts" }
TypeScript/tests/cases/compiler/ambientExternalModuleWithRelativeModuleName.ts_0_115
declare module "./relativeModule" { var x: string; } declare module ".\\relativeModule" { var x: string; }
{ "end_byte": 115, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ambientExternalModuleWithRelativeModuleName.ts" }
TypeScript/tests/cases/compiler/duplicateAnonymousModuleClasses.ts_0_415
module F { class Helper { } } module F { // Should not be an error class Helper { } } module Foo { class Helper { } } module Foo { // Should not be an error class Helper { } } module Gar { module Foo { class Helper { } } ...
{ "end_byte": 415, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateAnonymousModuleClasses.ts" }
TypeScript/tests/cases/compiler/blockScopedEnumVariablesUseBeforeDef_isolatedModules.ts_0_236
// @target: ES5 // @isolatedModules: true function foo1() { return E.A enum E { A } } function foo2() { return E.A const enum E { A } } const config = { a: AfterObject.A, }; const enum AfterObject { A = 2, }
{ "end_byte": 236, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/blockScopedEnumVariablesUseBeforeDef_isolatedModules.ts" }
TypeScript/tests/cases/compiler/controlFlowArrayErrors.ts_0_1347
// @noImplicitAny: true declare function cond(): boolean; function f1() { let x = []; // Implicit any[] error in some locations let y = x; // Implicit any[] error x.push(5); let z = x; } function f2() { let x; // Implicit any[] error in some locations x = []; let y = x; // Impl...
{ "end_byte": 1347, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/controlFlowArrayErrors.ts" }
TypeScript/tests/cases/compiler/commentsInheritance.ts_0_2674
// @target: ES5 // @declaration: true // @removeComments: false /** i1 is interface with properties*/ interface i1 { /** i1_p1*/ i1_p1: number; /** i1_f1*/ i1_f1(): void; /** i1_l1*/ i1_l1: () => void; // il_nc_p1 i1_nc_p1: number; i1_nc_f1(): void; i1_nc_l1: () => void; p1:...
{ "end_byte": 2674, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentsInheritance.ts" }
TypeScript/tests/cases/compiler/optionsStrictPropertyInitializationStrict.ts_0_64
// @strict: true // @strictPropertyInitialization: true var x;
{ "end_byte": 64, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/optionsStrictPropertyInitializationStrict.ts" }
TypeScript/tests/cases/compiler/systemDefaultExportCommentValidity.ts_0_148
// @module: system const Home = {} export default Home // There is intentionally no semicolon on the prior line, this comment should not break emit
{ "end_byte": 148, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/systemDefaultExportCommentValidity.ts" }
TypeScript/tests/cases/compiler/classExtendsNull2.ts_0_199
// @strict: true // @noEmit: true // https://github.com/microsoft/TypeScript/issues/55499 interface Base {} class C extends null { constructor() { super(); } } interface C extends Base {}
{ "end_byte": 199, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classExtendsNull2.ts" }
TypeScript/tests/cases/compiler/emptyAnonymousObjectNarrowing.ts_0_919
// @strictNullChecks: true,false declare let nonNull: {}; if (nonNull === "foo") { nonNull; } else { nonNull; } declare let obj: { a: string }; if (nonNull === obj) { nonNull; } else { nonNull; } function f1<T>(x: T) { if (nonNull === x) { nonNull; } else { nonNull; } } function f2<T extends...
{ "end_byte": 919, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emptyAnonymousObjectNarrowing.ts" }
TypeScript/tests/cases/compiler/captureThisInSuperCall.ts_0_144
class A { constructor(p:any) {} } class B extends A { constructor() { super({ test: () => this.someMethod()}); } someMethod() {} }
{ "end_byte": 144, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/captureThisInSuperCall.ts" }
TypeScript/tests/cases/compiler/recursiveProperties.ts_0_143
// @target: ES5 class A { get testProp() { return this.testProp; } } class B { set testProp(value:string) { this.testProp = value; } }
{ "end_byte": 143, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveProperties.ts" }
TypeScript/tests/cases/compiler/freshLiteralInference.ts_0_497
declare function f1<T extends "1" | "2" | "3">(x: T): T; const value = f1("1"); // regular "1" let x1 = value; // regular "1" declare function f2<T extends "1" | "2" | "3">(x: { value: T }): { value: T }; const obj2 = f2({ value: "1" }); // { value: regular "1" } let x2 = obj2.value; // regular "1" declare func...
{ "end_byte": 497, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/freshLiteralInference.ts" }
TypeScript/tests/cases/compiler/assignmentCompatability16.ts_0_345
module __test1__ { export interface interfaceWithPublicAndOptional<T,U> { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional<number,string> = { one: 1 };; export var __val__obj4 = obj4; } module __test2__ { export var obj = {one: <any[]>[1]}; export var __val__obj = obj; } __test2__.__val__ob...
{ "end_byte": 345, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatability16.ts" }
TypeScript/tests/cases/compiler/strictSubtypeAndNarrowing.ts_0_5202
// @strict: true // Check that `any` is a strict supertype of `unknown` declare const x11: { x: unknown }; declare const x12: { x: any }; const a11 = [x11, x12]; const a12 = [x12, x11]; declare const x21: { x: any }; declare const x22: { x: unknown }; const a21 = [x22, x21]; const a22 = [x21, x22]; // Strict subt...
{ "end_byte": 5202, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/strictSubtypeAndNarrowing.ts" }
TypeScript/tests/cases/compiler/noImplicitAnyForwardReferencedInterface.ts_3_125
@noImplicitAny: true declare var x: Entry; interface Entry { // Should return error for implicit any. new (); }
{ "end_byte": 125, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noImplicitAnyForwardReferencedInterface.ts" }
TypeScript/tests/cases/compiler/iteratorsAndStrictNullChecks.ts_0_173
// @target : ES6 // @strictNullChecks: true // for..of for (const x of ["a", "b"]) { x.substring; } // Spread const xs = [1, 2, 3]; const ys = [4, 5]; xs.push(...ys);
{ "end_byte": 173, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/iteratorsAndStrictNullChecks.ts" }
TypeScript/tests/cases/compiler/namespaceMergedWithImportAliasNoCrash.ts_0_367
// @filename: file1.ts export namespace Library { export type Bar = { a: number }; } var x: Library.Bar; // should work Library.foo; // should be an error // @filename: file2.ts import * as Lib from './file1'; namespace Lib { // should fail to merge export const foo: string = ""; } Lib.foo; // should work var x...
{ "end_byte": 367, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/namespaceMergedWithImportAliasNoCrash.ts" }
TypeScript/tests/cases/compiler/functionOverloads38.ts_0_150
function foo(bar:{a:number;}[]):string; function foo(bar:{a:boolean;}[]):number; function foo(bar:{a:any;}[]):any{ return bar } var x = foo([{a:1}]);
{ "end_byte": 150, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloads38.ts" }
TypeScript/tests/cases/compiler/moduleResolution_relativeImportJsFile_noImplicitAny.ts_0_151
// @noImplicitReferences: true // @noImplicitAny: true // @Filename: /src/b.js export const x = 0; // @Filename: /src/a.ts import * as b from "./b";
{ "end_byte": 151, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolution_relativeImportJsFile_noImplicitAny.ts" }
TypeScript/tests/cases/compiler/fuzzy.ts_0_507
module M { export interface I { works:()=>R; alsoWorks:()=>R; doesntWork:()=>R; } export interface R { anything:number; oneI:I; } export class C implements I { constructor(public x:number) { } works():R { return <R>({ anyt...
{ "end_byte": 507, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/fuzzy.ts" }
TypeScript/tests/cases/compiler/checkMergedGlobalUMDSymbol.ts_0_264
// @Filename: three.d.ts export namespace THREE { export class Vector2 {} } // @Filename: global.d.ts import * as _three from './three'; export as namespace THREE; declare global { export const THREE: typeof _three; } // @Filename: test.ts const m = THREE
{ "end_byte": 264, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/checkMergedGlobalUMDSymbol.ts" }
TypeScript/tests/cases/compiler/jsdocUnexpectedCharacter.ts_0_99
// @allowJs: true // @checkJs: true // @noEmit: true // @Filename: /a.js /** @x # */ var UI = {};
{ "end_byte": 99, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsdocUnexpectedCharacter.ts" }
TypeScript/tests/cases/compiler/parametersSyntaxErrorNoCrash3.ts_0_187
// @strict: true // @noEmit: true // @noTypesAndSymbols: true // https://github.com/microsoft/TypeScript/issues/59449 export function getHtml({ return " string" // a long string; }
{ "end_byte": 187, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parametersSyntaxErrorNoCrash3.ts" }
TypeScript/tests/cases/compiler/defaultDeclarationEmitNamedCorrectly.ts_0_307
// @declaration: true export interface Things<P, T> { p: P; t: T; } export function make<P, CTor>(x: { new (): CTor & {props: P} }): Things<P, CTor> { return null as any; } export interface Props { } export default class MyComponent { props: Props; static create = make(MyComponent); }
{ "end_byte": 307, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/defaultDeclarationEmitNamedCorrectly.ts" }
TypeScript/tests/cases/compiler/forOfTransformsExpression.ts_0_188
// https://github.com/Microsoft/TypeScript/issues/11024 let items = [{ name: "A" }, { name: "C" }, { name: "B" }]; for (var item of items.sort((a, b) => a.name.localeCompare(b.name))) { }
{ "end_byte": 188, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/forOfTransformsExpression.ts" }
TypeScript/tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts_0_577
//@noimplicitany: true // these should be errors class GetAndSet { getAndSet = null; // error at "getAndSet" public get haveGetAndSet() { // this should not be an error return this.getAndSet; } // this shouldn't be an error public set haveGetAndSet(value) { // error at "va...
{ "end_byte": 577, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts" }
TypeScript/tests/cases/compiler/unusedNamespaceInModule.ts_0_109
//@noUnusedLocals:true //@noUnusedParameters:true module A { namespace B { } export namespace C {} }
{ "end_byte": 109, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedNamespaceInModule.ts" }
TypeScript/tests/cases/compiler/contextualPropertyOfGenericMappedType.ts_0_202
// Repro for #24694 // @noImplicitAny: true declare function f<T extends object>(data: T, handlers: { [P in keyof T]: (value: T[P], prop: P) => void; }): void; f({ data: 0 }, { data(value, key) {} });
{ "end_byte": 202, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualPropertyOfGenericMappedType.ts" }
TypeScript/tests/cases/compiler/constructorInvocationWithTooFewTypeArgs.ts_0_64
class D<T, U> { x: T y: U } var d = new D<number>();
{ "end_byte": 64, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constructorInvocationWithTooFewTypeArgs.ts" }
TypeScript/tests/cases/compiler/initializedParameterBeforeNonoptionalNotOptional.ts_0_352
// @strict: true // @filename: index.d.ts export declare function foo({a}?: { a?: string; }): void; export declare function foo2({a}: { a?: string | undefined; } | undefined, b: string): void; export declare function foo3({a, b: {c}}: { a?: string | undefined; b?: {c?: string | undefined;} | undefined; ...
{ "end_byte": 352, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/initializedParameterBeforeNonoptionalNotOptional.ts" }
TypeScript/tests/cases/compiler/funClodule.ts_0_337
declare function foo(); declare module foo { export function x(): any; } declare class foo { } // Should error declare class foo2 { } declare module foo2 { export function x(): any; } declare function foo2(); // Should error function foo3() { } module foo3 { export function x(): any { } } class foo3 { ...
{ "end_byte": 337, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/funClodule.ts" }
TypeScript/tests/cases/compiler/exportsInAmbientModules2.ts_0_146
// @module: amd // @filename: external.d.ts export default class C {} // @filename: main.ts declare module "M" { export * from "external" }
{ "end_byte": 146, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportsInAmbientModules2.ts" }
TypeScript/tests/cases/compiler/abstractPropertyNegative.ts_0_1096
//@target: ES5 interface A { prop: string; m(): string; } abstract class B implements A { abstract prop: string; public abstract readonly ro: string; abstract get readonlyProp(): string; abstract m(): string; abstract get mismatch(): string; abstract set mismatch(val: number); } class C ...
{ "end_byte": 1096, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/abstractPropertyNegative.ts" }
TypeScript/tests/cases/compiler/duplicateLocalVariable4.ts_0_37
enum E{ a } var x = E; var x = E.a;
{ "end_byte": 37, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateLocalVariable4.ts" }