_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/interfaceDeclaration3.ts_0_1051
//@module: amd interface I1 { item:number; } module M1 { interface I1 { item:string; } interface I2 { item:number; } class C1 implements I1 { public item:number; } class C2 implements I1 { public item:string; } class C3 implements I2 { public item:number; } ...
{ "end_byte": 1051, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/interfaceDeclaration3.ts" }
TypeScript/tests/cases/compiler/reservedNameOnModuleImport.ts_0_150
declare module test { module mstring { } // Should be fine; this does not clobber any declared values. export import string = mstring; }
{ "end_byte": 150, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reservedNameOnModuleImport.ts" }
TypeScript/tests/cases/compiler/recursiveExportAssignmentAndFindAliasedType5.ts_0_741
//@module: amd // @Filename: recursiveExportAssignmentAndFindAliasedType5_moduleC.ts import self = require("recursiveExportAssignmentAndFindAliasedType5_moduleD"); export = self; // @Filename: recursiveExportAssignmentAndFindAliasedType5_moduleD.ts import self = require("recursiveExportAssignmentAndFindAliasedType5_mo...
{ "end_byte": 741, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveExportAssignmentAndFindAliasedType5.ts" }
TypeScript/tests/cases/compiler/functionWithAnyReturnTypeAndNoReturnExpression.ts_0_102
// All should be allowed function f(): any { } var f2: () => any = () => { }; var f3 = (): any => { };
{ "end_byte": 102, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionWithAnyReturnTypeAndNoReturnExpression.ts" }
TypeScript/tests/cases/compiler/requireOfJsonFileWithEmptyObjectWithErrors.ts_0_288
// @module: commonjs // @outdir: out/ // @allowJs: true // @fullEmitPaths: true // @resolveJsonModule: true // @Filename: file1.ts import b1 = require('./b.json'); let x = b1.a; import b2 = require('./b.json'); if (x) { let b = b2.b; x = (b1.b === b); } // @Filename: b.json { }
{ "end_byte": 288, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/requireOfJsonFileWithEmptyObjectWithErrors.ts" }
TypeScript/tests/cases/compiler/modularizeLibrary_TargetES5UsingES6Lib.ts_3_1276
@lib: es5,es6 // @target: es6 // Using Es6 array function f(x: number, y: number, z: number) { return Array.from(arguments); } f(1, 2, 3); // no error // Using ES6 collection var m = new Map<string, number>(); m.clear(); // Using ES6 iterable m.keys(); // Using ES6 function function Baz() { } Baz.name; // Us...
{ "end_byte": 1276, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/modularizeLibrary_TargetES5UsingES6Lib.ts" }
TypeScript/tests/cases/compiler/indexerConstraints2.ts_0_1022
class A { a: number; } class B extends A { b: number; } // Inheritance class F { [s: string]: B } class G extends F { [n: number]: A } // Other way class H { [n: number]: A } class I extends H { [s: string]: B } // With hidden indexer class J { [n: number]: {} } class K extends J { [n: numbe...
{ "end_byte": 1022, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/indexerConstraints2.ts" }
TypeScript/tests/cases/compiler/propertyAccess6.ts_0_26
var foo: any; foo.bar = 4;
{ "end_byte": 26, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/propertyAccess6.ts" }
TypeScript/tests/cases/compiler/narrowingRestGenericCall.ts_0_213
interface Slugs { foo: string; bar: string; } function call<T extends object>(obj: T, cb: (val: T) => void) { cb(obj); } declare let obj: Slugs; call(obj, ({foo, ...rest}) => { console.log(rest.bar); });
{ "end_byte": 213, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowingRestGenericCall.ts" }
TypeScript/tests/cases/compiler/inlineConditionalHasSimilarAssignability.ts_0_352
type MyExtract<T, U> = T extends U ? T : never function foo<T>(a: T) { const b: Extract<any[], T> = 0 as any; a = b; // ok const c: (any[] extends T ? any[] : never) = 0 as any; a = c; const d: MyExtract<any[], T> = 0 as any; a = d; // ok type CustomType = any[] extends T ? any[] : never; const e: C...
{ "end_byte": 352, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inlineConditionalHasSimilarAssignability.ts" }
TypeScript/tests/cases/compiler/circularConstrainedMappedTypeNoCrash.ts_0_101
type Loop<T, U extends Loop<T, U>> = { [P in keyof T]: U[P] extends boolean ? number : string; };
{ "end_byte": 101, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/circularConstrainedMappedTypeNoCrash.ts" }
TypeScript/tests/cases/compiler/callOverloadViaElementAccessExpression.ts_0_195
class C { foo(x: number): number; foo(x: string): string; foo(x: any): any { return null; } } var c = new C(); var r: string = c['foo'](1); var r2: number = c['foo']('');
{ "end_byte": 195, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/callOverloadViaElementAccessExpression.ts" }
TypeScript/tests/cases/compiler/breakTarget2.ts_0_40
target: while (true) { break target; }
{ "end_byte": 40, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/breakTarget2.ts" }
TypeScript/tests/cases/compiler/unusedImports9.ts_0_234
//@noUnusedLocals:true //@noUnusedParameters:true // @Filename: file1.ts export class Calculator { handleChar() {} } export function test() { } export function test2() { } // @Filename: file2.ts import c = require('./file1')
{ "end_byte": 234, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedImports9.ts" }
TypeScript/tests/cases/compiler/unionTypeWithRecursiveSubtypeReduction2.ts_0_257
class Module { public members: Class[]; } class Namespace { public members: (Class | Property)[]; } class Class { public parent: Namespace; } class Property { public parent: Module | Class; } var c: Class; var p: Property; c = p; p = c;
{ "end_byte": 257, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unionTypeWithRecursiveSubtypeReduction2.ts" }
TypeScript/tests/cases/compiler/overloadBindingAcrossDeclarationBoundaries.ts_0_524
interface Opt1 { p?: any; } interface Opt2 { q?: any; } interface Opt3 { r?: any; } interface Opt4 { s?: any; } interface A { a(o: Opt1): Opt1; a(o: Opt2): Opt2; (o: Opt1): Opt1; (o: Opt2): Opt2; new (o: Opt1): Opt1; new (o: Opt2): Opt2; } interface A { a(o: Opt3): Opt3; ...
{ "end_byte": 524, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overloadBindingAcrossDeclarationBoundaries.ts" }
TypeScript/tests/cases/compiler/infinitelyExpandingTypes2.ts_0_201
interface Foo<T> { x: Foo<Foo<T>>; } interface Bar<T> extends Foo<T> { y: string; } function f(p: Foo<number>) { console.log(p); } var v: Bar<number> = null; f(v); // should not error
{ "end_byte": 201, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/infinitelyExpandingTypes2.ts" }
TypeScript/tests/cases/compiler/letInConstDeclarations_ES5.ts_0_130
// @target: es5 // All use of let in const declaration should be an error const x = 50, let = 5; { const x = 10, let = 20; }
{ "end_byte": 130, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/letInConstDeclarations_ES5.ts" }
TypeScript/tests/cases/compiler/unicodeEscapesInNames02.ts_0_752
// @target: es5,es2015 // @module: es2015 // @sourcemap: true // Example from https://mathiasbynens.be/notes/javascript-identifiers-es6 // Astral characters should be accepted in ES2015 // @filename: extendedEscapesForAstralsInVarsAndClasses.ts // U+102A7 CARIAN LETTER A2 var 𐊧: string; var \u{102A7}: string; if (M...
{ "end_byte": 752, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unicodeEscapesInNames02.ts" }
TypeScript/tests/cases/compiler/contextuallyTypedParametersWithInitializers1.ts_0_2660
// @strict: true // @declaration: true declare function id1<T>(input: T): T; declare function id2<T extends (x: any) => any>(input: T): T; declare function id3<T extends (x: { foo: any }) => any>(input: T): T; declare function id4<T extends (x: { foo?: number }) => any>(input: T): T; declare function id5<T extends (x?...
{ "end_byte": 2660, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextuallyTypedParametersWithInitializers1.ts" }
TypeScript/tests/cases/compiler/noImplicitAnyForIn.ts_3_541
@noImplicitAny: true var x: {}[] = [[1, 2, 3], ["hello"]]; for (var i in x) { for (var j in x[i]) { //Should yield an implicit 'any' error var _j = x[i][j]; } for (var k in x[0]) { var k1 = x[0]; //Should yield an implicit 'any' error var k2 = k1[k]; } } for...
{ "end_byte": 541, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noImplicitAnyForIn.ts" }
TypeScript/tests/cases/compiler/missingReturnStatement.ts_0_89
module Test { export class Bug { public foo():string { } } }
{ "end_byte": 89, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/missingReturnStatement.ts" }
TypeScript/tests/cases/compiler/es6ExportAssignment3.ts_0_144
// @target: es6 // @filename: a.d.ts declare var a: number; export = a; // OK, in ambient context // @filename: b.ts import * as a from "a";
{ "end_byte": 144, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ExportAssignment3.ts" }
TypeScript/tests/cases/compiler/extendsJavaScript.ts_0_141
// @allowJs: true // @checkJs: false // @outDir: ./out // @filename: extendsJavaScript.js /** * @extends {SomeBase} */ class MyClass { }
{ "end_byte": 141, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/extendsJavaScript.ts" }
TypeScript/tests/cases/compiler/tsxAttributeQuickinfoTypesSameAsObjectLiteral.tsx_0_276
// @jsx: preserve namespace JSX { export interface IntrinsicElements { span: {}; } export interface Element { something?: any; } } const Foo = (props: { foo: "A" | "B" | "C" }) => <span>{props.foo}</span>; Foo({ foo: "B" }); <Foo foo="B" />
{ "end_byte": 276, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/tsxAttributeQuickinfoTypesSameAsObjectLiteral.tsx" }
TypeScript/tests/cases/compiler/classImplementsClass6.ts_0_267
class A { static bar(): string { return ""; } foo(): number { return 1; } } class C implements A { foo() { return 1; } } class C2 extends A {} var c: C; var c2: C2; c = c2; c2 = c; c.bar(); // error c2.bar(); // should error
{ "end_byte": 267, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classImplementsClass6.ts" }
TypeScript/tests/cases/compiler/declarationEmitExpandoWithGenericConstraint.ts_0_359
// @declaration: true export interface Point { readonly x: number; readonly y: number; } export interface Rect<p extends Point> { readonly a: p; readonly b: p; } export const Point = (x: number, y: number): Point => ({ x, y }); export const Rect = <p extends Point>(a: p, b: p): Rect<p> => ({ a, b }); ...
{ "end_byte": 359, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitExpandoWithGenericConstraint.ts" }
TypeScript/tests/cases/compiler/declFileConstructSignatures.ts_0_1736
// @target: ES5 // @declaration: true // @removeComments: false // @module: commonjs // @Filename: declFileConstructSignatures_0.ts export interface IConstructSignature { /** This comment should appear for foo*/ new (): string; } export interface IConstructSignatureWithParameters { /** This is comment for...
{ "end_byte": 1736, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileConstructSignatures.ts" }
TypeScript/tests/cases/compiler/typeGuardNarrowsIndexedAccessOfKnownProperty5.ts_0_390
// @strict: true const a: { key?: { x?: number } } = {}; const aIndex = "key"; if (a[aIndex] && a[aIndex].x) { a[aIndex].x // number } const b: { key: { x?: number } } = { key: {} }; const bIndex = "key"; if (b[bIndex].x) { b[bIndex].x // number } interface Foo { x: number | undefined; } const c: Foo[] =...
{ "end_byte": 390, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeGuardNarrowsIndexedAccessOfKnownProperty5.ts" }
TypeScript/tests/cases/compiler/emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts_0_1096
// This should behave the same as emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts // Begin types from Lodash. interface Dictionary<T> { [index: string]: T; } interface NumericDictionary<T> { [index: number]: T; } type ObjectIterator<TObject, TResult> = ( value: TObject[keyof TObject], key: string, ...
{ "end_byte": 1096, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts" }
TypeScript/tests/cases/compiler/emptyArrayDestructuringExpressionVisitedByTransformer.ts_0_54
var a = [] = [1].map(_ => _); var b = [1].map(_ => _);
{ "end_byte": 54, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emptyArrayDestructuringExpressionVisitedByTransformer.ts" }
TypeScript/tests/cases/compiler/duplicateIdentifierShouldNotShortCircuitBaseTypeBinding.ts_0_387
//@module: amd // @FileName: duplicateIdentifierShouldNotShortCircuitBaseTypeBinding_0.ts export interface IPoint {} export module Shapes { export class Point implements IPoint {} } // @FileName: duplicateIdentifierShouldNotShortCircuitBaseTypeBinding_1.ts //var x = new Shapes.Point(); //interface IPoint {} //...
{ "end_byte": 387, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateIdentifierShouldNotShortCircuitBaseTypeBinding.ts" }
TypeScript/tests/cases/compiler/discriminateWithOptionalProperty4.ts_0_501
// @strict: true // @exactOptionalPropertyTypes: true, false // @noEmit: true // https://github.com/microsoft/TypeScript/issues/55566 export function main(a: string[] | undefined) { const z = a ? { a } : { b: ["there"] }; z.a // ? z.a.toString() : z.b.toString(); const zWorkAround: | { a: string[]...
{ "end_byte": 501, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/discriminateWithOptionalProperty4.ts" }
TypeScript/tests/cases/compiler/argumentsReferenceInObjectLiteral_Js.ts_0_389
// @checkJs: true // @allowJs: true // @target: es6 // @outDir: ./out // @filename: /a.js const a = () => { return { arguments: [], }; }; const b = () => { const c = { arguments: [], } return c; }; const c = () => { return { arguments, }; } const d = () => { c...
{ "end_byte": 389, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/argumentsReferenceInObjectLiteral_Js.ts" }
TypeScript/tests/cases/compiler/relationalOperatorComparable.ts_0_611
function f(onethree: 1 | 3, two: 2) { const t = true; const f = false; let a1 = onethree < two; // ok let a2 = onethree < true; // error, number and boolean let a3 = onethree <= false; // error, number and boolean let a4 = onethree >= t; // error, number and boolean let a5 = onethree > f; //...
{ "end_byte": 611, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/relationalOperatorComparable.ts" }
TypeScript/tests/cases/compiler/intersectionType_useDefineForClassFields.ts_0_212
// @target: ESNext // @useDefineForClassFields: true type Foo<T> = { [k in keyof T & string]: any } function bar<T>(_p: T): { new(): Foo<T> } { return null as any; } class Baz extends bar({ x: 1 }) { }
{ "end_byte": 212, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/intersectionType_useDefineForClassFields.ts" }
TypeScript/tests/cases/compiler/genericTypeAssertions1.ts_0_150
class A<T> { foo(x: T) { }} var foo = new A<number>(); var r: A<string> = <A<number>>new A(); // error var r2: A<number> = <A<A<number>>>foo; // error
{ "end_byte": 150, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericTypeAssertions1.ts" }
TypeScript/tests/cases/compiler/systemModule8.ts_0_410
// @allowUnreachableCode: true // @module: system export var x; x = 1; x++; x--; ++x; --x; x += 1; x -= 1; x *= 1; x /= 1; x |= 1; x &= 1; x + 1; x - 1; x & 1; x | 1; for (x = 5;;x++) {} for (x = 8;;x--) {} for (x = 15;;++x) {} for (x = 18;;--x) {} for (let x = 50;;) {} function foo() { x = 100; } export let [y]...
{ "end_byte": 410, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/systemModule8.ts" }
TypeScript/tests/cases/compiler/keywordExpressionInternalComments.ts_0_132
/*1*/ new /*2*/ Array /*3*/; /*1*/ typeof /*2*/ Array /*3*/; /*1*/ void /*2*/ Array /*3*/; /*1*/ delete /*2*/ Array.toString /*3*/;
{ "end_byte": 132, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/keywordExpressionInternalComments.ts" }
TypeScript/tests/cases/compiler/genericTypeWithMultipleBases2.ts_0_204
//@module: amd export interface I1 { m1: () => void; } export interface I2 { m2: () => void; } export interface I3<T> extends I2, I1 { p1: T; } var x: I3<number>; x.p1; x.m1(); x.m2();
{ "end_byte": 204, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericTypeWithMultipleBases2.ts" }
TypeScript/tests/cases/compiler/letDeclarations-access.ts_0_259
// @target: ES6 let x = 0 // No errors x = 1; x += 2; x -= 3; x *= 4; x /= 5; x %= 6; x <<= 7; x >>= 8; x >>>= 9; x &= 10; x |= 11; x ^= 12; x++; x--; ++x; --x; var a = x + 1; function f(v: number) { } f(x); if (x) { } x; (x); -x; +x; x.toString();
{ "end_byte": 259, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/letDeclarations-access.ts" }
TypeScript/tests/cases/compiler/primitiveConstraints1.ts_0_177
function foo1<T extends U, U>(t: T, u: U) { } foo1<string, number>('hm', 1); // no error function foo2<T, U extends T>(t: T, u: U) { } foo2<number, string>(1, 'hm'); // error
{ "end_byte": 177, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/primitiveConstraints1.ts" }
TypeScript/tests/cases/compiler/inKeywordAndUnknown.ts_0_934
// @strict: true // Repro from #50531 function f(x: {}, y: unknown) { if (!("a" in x)) { return; } x; // {} if (!y) { return; } y; // {} if (!("a" in y)) { return; } y; // {} } // Repro from #51007 function isHTMLTable(table: unknown): boolean { ret...
{ "end_byte": 934, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inKeywordAndUnknown.ts" }
TypeScript/tests/cases/compiler/matchingOfObjectLiteralConstraints.ts_0_83
function foo2<T, U extends { y: T; }>(x: U, z: T) { } foo2({ y: "foo" }, "foo");
{ "end_byte": 83, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/matchingOfObjectLiteralConstraints.ts" }
TypeScript/tests/cases/compiler/exportDefaultDuplicateCrash.ts_0_139
// @noTypesAndSymbols: true // #38214 export default function () { } export { default } from './hi' export { aa as default } from './hi'
{ "end_byte": 139, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportDefaultDuplicateCrash.ts" }
TypeScript/tests/cases/compiler/moduleAugmentationsBundledOutput1.ts_0_1039
// @target: es5 // @module: amd // @declaration: true // @outFile: out.js // @filename: m1.ts export class Cls { } // @filename: m2.ts import {Cls} from "./m1"; (<any>Cls.prototype).foo = function() { return 1; }; (<any>Cls.prototype).bar = function() { return "1"; }; declare module "./m1" { interface Cls { ...
{ "end_byte": 1039, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleAugmentationsBundledOutput1.ts" }
TypeScript/tests/cases/compiler/unionExcessPropertyCheckNoApparentPropTypeMismatchErrors.ts_0_320
interface IStringDictionary<V> { [name: string]: V; } interface INumberDictionary<V> { [idx: number]: V; } declare function forEach<T>(from: IStringDictionary<T> | INumberDictionary<T>, callback: (entry: { key: any; value: T; }, remove: () => void) => any); let count = 0; forEach({ toString: 123 }, () => count++);
{ "end_byte": 320, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unionExcessPropertyCheckNoApparentPropTypeMismatchErrors.ts" }
TypeScript/tests/cases/compiler/recursiveSpecializationOfSignatures.ts_0_96
class S0<B, A> { set S1(S2: S0<any,any>) { } constructor(public S17: S0<any, (S18) => A>) { } }
{ "end_byte": 96, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveSpecializationOfSignatures.ts" }
TypeScript/tests/cases/compiler/circularlySimplifyingConditionalTypesNoCrash.ts_0_1663
// @strict: true type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>; type Shared< // Circularly self constraining type, defered thanks to mapping InjectedProps, DecorationTargetProps extends Shared<InjectedProps, DecorationTargetProps> > = { [P in Extract<keyof InjectedProps, keyof Deco...
{ "end_byte": 1663, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/circularlySimplifyingConditionalTypesNoCrash.ts" }
TypeScript/tests/cases/compiler/moduleResolutionWithSuffixes_threeLastIsBlank1.ts_0_488
// moduleSuffixes has three entries, and the last one is blank. Module resolution should match on the first suffix. // @filename: /tsconfig.json { "compilerOptions": { "moduleResolution": "node", "traceResolution": true, "moduleSuffixes": ["-ios", "__native", ""] } } // @filename: /index.ts import { ios } fro...
{ "end_byte": 488, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolutionWithSuffixes_threeLastIsBlank1.ts" }
TypeScript/tests/cases/compiler/nodeColonModuleResolution.ts_0_1009
// @moduleResolution: node // @traceResolution: true // @filename: /a/b/node_modules/@types/node/ph.d.ts declare module 'ph' { namespace constants { const NODE_PERFORMANCE_GC_MAJOR: number; const NODE_PERFORMANCE_GC_MINOR: number; const NODE_PERFORMANCE_GC_INCREMENTAL: number; cons...
{ "end_byte": 1009, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nodeColonModuleResolution.ts" }
TypeScript/tests/cases/compiler/unionPropertyExistence.ts_0_487
interface A { inAll: string; notInB: string; notInC: string; } interface B { inAll: boolean; onlyInB: number; notInC: string; } interface C { inAll: number; notInB: string; } type AB = A | B; type ABC = C | AB; var ab: AB; var abc: ABC; declare const x: "foo" | "bar"; declare const ...
{ "end_byte": 487, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unionPropertyExistence.ts" }
TypeScript/tests/cases/compiler/functionLikeInParameterInitializer.ts_0_327
// error export function bar(func = () => foo) { let foo = "in"; } // error export function baz1(func = { f() { return foo } }) { let foo = "in"; } // error export function baz2(func = function () { return foo }) { let foo = "in"; } // error export function baz3(func = class { x = foo }) { let foo = "...
{ "end_byte": 327, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionLikeInParameterInitializer.ts" }
TypeScript/tests/cases/compiler/exportDefaultInterface.ts_0_177
// @Filename: a.ts export default interface A { value: number; } var a: A; a.value.toExponential(); // @Filename: b.ts import A from './a'; var a: A; a.value.toExponential();
{ "end_byte": 177, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportDefaultInterface.ts" }
TypeScript/tests/cases/compiler/noImplicitThisBigThis.ts_0_849
// @declaration: true // @noImplicitThis: true // https://github.com/microsoft/TypeScript/issues/29902 function createObj() { return { func1() { return this; }, func2() { return this; }, func3() { return this; } }; } function...
{ "end_byte": 849, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noImplicitThisBigThis.ts" }
TypeScript/tests/cases/compiler/sourcemapValidationDuplicateNames.ts_0_114
// @sourcemap: true module m1 { var x = 10; export class c { } } module m1 { var b = new m1.c(); }
{ "end_byte": 114, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourcemapValidationDuplicateNames.ts" }
TypeScript/tests/cases/compiler/fallFromLastCase2.ts_0_444
// @noFallthroughCasesInSwitch: true declare function use(a: string); function foo1(a: number) { switch (a) { case 1: use("1"); break; case 2: use("2"); case 3: use("3"); } } function foo2(a: number) { switch (a) { case 1: ...
{ "end_byte": 444, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/fallFromLastCase2.ts" }
TypeScript/tests/cases/compiler/unusedModuleInModule.ts_0_79
//@noUnusedLocals:true //@noUnusedParameters:true module A { module B {} }
{ "end_byte": 79, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedModuleInModule.ts" }
TypeScript/tests/cases/compiler/overloadGenericFunctionWithRestArgs.ts_0_187
class B<V>{ private id: V; } class A<U>{ GetEnumerator: () => B<U>; } function Choice<T>(...v_args: T[]): A<T>; function Choice<T>(...v_args: T[]): A<T> { return new A<T>(); }
{ "end_byte": 187, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overloadGenericFunctionWithRestArgs.ts" }
TypeScript/tests/cases/compiler/es5ExportEqualsDts.ts_0_186
// @target: es5 // @module: commonjs // @declaration: true class A { foo() { var aVal: A.B; return aVal; } } module A { export interface B { } } export = A
{ "end_byte": 186, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es5ExportEqualsDts.ts" }
TypeScript/tests/cases/compiler/exportAsNamespace.d.ts_0_99
// issue: https://github.com/Microsoft/TypeScript/issues/11545 export var X; export as namespace N
{ "end_byte": 99, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportAsNamespace.d.ts" }
TypeScript/tests/cases/compiler/symbolMergeValueAndImportedType.ts_0_216
// @target: es2015 // @module: commonjs // @skipLibCheck: true // @lib: es2015,dom // @filename: main.ts import { X } from "./other"; const X = 42; console.log('X is ' + X); // @filename: other.ts export type X = {};
{ "end_byte": 216, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/symbolMergeValueAndImportedType.ts" }
TypeScript/tests/cases/compiler/letInNonStrictMode.ts_0_35
let [x] = [1]; let {a: y} = {a: 1};
{ "end_byte": 35, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/letInNonStrictMode.ts" }
TypeScript/tests/cases/compiler/expandoFunctionContextualTypesNoValue.ts_0_86
// GH #38532 import Foo from "blah"; export function Foo() { } Foo.bar = () => { };
{ "end_byte": 86, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/expandoFunctionContextualTypesNoValue.ts" }
TypeScript/tests/cases/compiler/requireOfJsonFileWithoutResolveJsonModule.ts_0_292
// @module: commonjs // @outdir: out/ // @allowJs: true // @fullEmitPaths: true // @Filename: file1.ts import b1 = require('./b.json'); // error let x = b1.a; import b2 = require('./b.json'); // error if (x) { let b = b2.b; x = (b1.b === b); } // @Filename: b.json contents Not read
{ "end_byte": 292, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/requireOfJsonFileWithoutResolveJsonModule.ts" }
TypeScript/tests/cases/compiler/declarationEmitCastReusesTypeNode5.ts_0_1158
// @strict: true // @strictNullChecks: true,false // @declaration: true // @noTypesAndSymbols: true // @emitDeclarationOnly: true export const vNumberLiteral = null! as 1 | 1 export const vStringLiteral = null! as "1" | "1" export const vLiteral = null! as "1" | "1" type R = { foo: string } export class C { // un...
{ "end_byte": 1158, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitCastReusesTypeNode5.ts" }
TypeScript/tests/cases/compiler/exportDeclarationsInAmbientNamespaces2.ts_1_116
declare module "mod" { export var x: number; } declare namespace N { export { x } from "mod"; // Error }
{ "end_byte": 116, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportDeclarationsInAmbientNamespaces2.ts" }
TypeScript/tests/cases/compiler/genericInferenceDefaultTypeParameterJsxReact.tsx_0_466
// @strict: true // @esModuleInterop: true // @jsx: react /// <reference path="/.lib/react16.d.ts" /> // Repro from #50858 import React, { ComponentPropsWithRef, ElementType, ReactNode } from 'react'; type ButtonBaseProps<T extends ElementType> = ComponentPropsWithRef<T> & { children?: ReactNode }; function Compon...
{ "end_byte": 466, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericInferenceDefaultTypeParameterJsxReact.tsx" }
TypeScript/tests/cases/compiler/declarationEmitTypeParameterNameInOuterScope.ts_0_273
// @declaration: true // @skipLibCheck: false class A { } var a = <A,>(x: A) => x; function a2<A,>(x: A) { return x } var a3 = <A,>(x: A) => new A(); function a4<A,>(x: A) { return new A() } interface B { } var b = <B,>(x: B) => x; function b2<B,>(x: B) { return x }
{ "end_byte": 273, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitTypeParameterNameInOuterScope.ts" }
TypeScript/tests/cases/compiler/requireOfJsonFileWithModuleNodeResolutionEmitNone.ts_0_225
// @module: none // @moduleResolution: node // @outdir: out/ // @fullEmitPaths: true // @resolveJsonModule: true // @Filename: file1.ts import * as b from './b.json'; // @Filename: b.json { "a": true, "b": "hello" }
{ "end_byte": 225, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/requireOfJsonFileWithModuleNodeResolutionEmitNone.ts" }
TypeScript/tests/cases/compiler/invalidTypeNames.ts_0_93
// Refer to calling code - a real illegal name is subbed in here class illegal_name_here { }
{ "end_byte": 93, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/invalidTypeNames.ts" }
TypeScript/tests/cases/compiler/yieldExpressionInnerCommentEmit.ts_0_173
// @target: es6 function * foo2() { /*comment1*/ yield 1; yield /*comment2*/ 2; yield 3 /*comment3*/ yield */*comment4*/ [4]; yield /*comment5*/* [5]; }
{ "end_byte": 173, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/yieldExpressionInnerCommentEmit.ts" }
TypeScript/tests/cases/compiler/mappedTypeGenericInstantiationPreservesInlineForm.ts_0_299
// @strict: true // @declaration: true // @emitDeclarationOnly: true // repro from #53109 export const test1 = <T = Record<string, never>>(schema: { [K in keyof Required<T>]: T[K]; }) => {} export function test2<T = Record<string, never>>(schema: { [K in keyof Required<T>]: T[K]; }) {};
{ "end_byte": 299, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mappedTypeGenericInstantiationPreservesInlineForm.ts" }
TypeScript/tests/cases/compiler/excessPropertyCheckWithEmptyObject.ts_0_351
// Repro from #14910 // Excess property error expected here Object.defineProperty(window, "prop", { value: "v1.0.0", readonly: false }); interface A { x?: string } // Excess property error expected here let a: A & ThisType<any> = { y: 10 }; interface Empty {} // Excess property error expected here let x: Empty & {...
{ "end_byte": 351, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/excessPropertyCheckWithEmptyObject.ts" }
TypeScript/tests/cases/compiler/infiniteExpandingTypeThroughInheritanceInstantiation.ts_0_89
interface A<T> { x: A<B<T>> } interface B<T> extends A<T> // error { x: B<A<T>> }
{ "end_byte": 89, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/infiniteExpandingTypeThroughInheritanceInstantiation.ts" }
TypeScript/tests/cases/compiler/isolatedDeclarationErrorsFunctionDeclarations.ts_0_414
// @declaration: true // @isolatedDeclarations: true // @declarationMap: false // @target: ESNext export function noReturn() {} export function noParamAnnotation(p): void {} export function noParamAnnotationDefault(p = 1): void {} export function noParamAnnotationBadDefault(p = 1 + 1, p2 = { a: 1 + 1 }, p3 = [1 + 1...
{ "end_byte": 414, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/isolatedDeclarationErrorsFunctionDeclarations.ts" }
TypeScript/tests/cases/compiler/decoratorMetadataNoLibIsolatedModulesTypes.ts_0_174
// @experimentalDecorators: true // @emitDecoratorMetadata: true // @noLib: true // @isolatedModules: true export class B { @Decorate member: Map<string, number>; }
{ "end_byte": 174, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/decoratorMetadataNoLibIsolatedModulesTypes.ts" }
TypeScript/tests/cases/compiler/privacyTopLevelInternalReferenceImportWithoutExport.ts_0_3603
//@module: amd //@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_privat...
{ "end_byte": 3603, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyTopLevelInternalReferenceImportWithoutExport.ts" }
TypeScript/tests/cases/compiler/moduleResolutionWithExtensions_notSupported3.ts_0_221
// @noImplicitReferences: true // @jsx: preserve // @traceResolution: true // If we have "--jsx" set and not "--allowJs", it's an implicit-any module. // @Filename: /jsx.jsx // @Filename: /a.ts import jsx from "./jsx";
{ "end_byte": 221, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolutionWithExtensions_notSupported3.ts" }
TypeScript/tests/cases/compiler/indexClassByNumber.ts_0_178
// Shouldn't be able to index a class instance by a number (unless it has declared a number index signature) class foo { } var f = new foo(); f[0] = 4; // Shouldn't be allowed
{ "end_byte": 178, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/indexClassByNumber.ts" }
TypeScript/tests/cases/compiler/declarationEmitExportDeclaration.ts_0_261
// @target: es5 // @module: commonjs // @declaration: true // @filename: utils.ts export function foo() { } export function bar() { } export interface Buzz { } // @filename: index.ts import {foo, bar, Buzz} from "./utils"; foo(); let obj: Buzz; export {bar};
{ "end_byte": 261, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitExportDeclaration.ts" }
TypeScript/tests/cases/compiler/duplicateObjectLiteralProperty_computedName2.ts_0_293
const n = 1; const s = "s"; enum E1 { A = "ENUM_KEY" } enum E2 { B } const t1 = { [n]: 1, [n]: 1, // duplicate } const t2 = { [s]: 1, [s]: 1, // duplicate } const t3 = { [E1.A]: 1, [E1.A]: 1, // duplicate } const t4 = { [E2.B]: 1, [E2.B]: 1, // duplicate }
{ "end_byte": 293, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateObjectLiteralProperty_computedName2.ts" }
TypeScript/tests/cases/compiler/indexSignatureWithInitializer1.ts_0_38
class C { [a: number = 1]: number; }
{ "end_byte": 38, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/indexSignatureWithInitializer1.ts" }
TypeScript/tests/cases/compiler/spreadParameterTupleType.ts_0_334
// @declaration: true function f1() { type A = [s: string]; type C = [...A, ...A]; return function fn(...args: C) { } } function f2() { type A = [a: string]; type B = [b: string]; type C = [c: string]; type D = [...A, ...A, ...B, ...A, ...B, ...B, ...A, ...C]; return function fn(...a...
{ "end_byte": 334, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/spreadParameterTupleType.ts" }
TypeScript/tests/cases/compiler/jsFileCompilationTypeAssertions.ts_0_105
// @allowJs: true // @filename: /src/a.js // @outFile: /lib/a.js 0 as number; var v = <string>undefined;
{ "end_byte": 105, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationTypeAssertions.ts" }
TypeScript/tests/cases/compiler/keyofModuleObjectHasCorrectKeys.ts_0_246
// @filename: example.ts export default function add(a: number, b: number) { return a + b; } // @filename: test.ts import * as example from './example'; declare function test<T>(object: T, method: keyof T): void; test(example, "default");
{ "end_byte": 246, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/keyofModuleObjectHasCorrectKeys.ts" }
TypeScript/tests/cases/compiler/commentOnImportStatement2.ts_0_97
// @module: commonjs // @removeComments: false /* not copyright */ import foo = require('./foo');
{ "end_byte": 97, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentOnImportStatement2.ts" }
TypeScript/tests/cases/compiler/arrayConcatMap.ts_0_67
var x = [].concat([{ a: 1 }], [{ a: 2 }]) .map(b => b.a);
{ "end_byte": 67, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arrayConcatMap.ts" }
TypeScript/tests/cases/compiler/contextualTyping40.ts_0_67
var foo = <{():number; (i:number):number; }> function(){return 1;};
{ "end_byte": 67, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTyping40.ts" }
TypeScript/tests/cases/compiler/exportAssignmentWithoutAllowSyntheticDefaultImportsError.ts_0_121
// @module: es2015 // @Filename: /bar.ts export = bar; function bar() {} // @Filename: /foo.ts import bar from './bar';
{ "end_byte": 121, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportAssignmentWithoutAllowSyntheticDefaultImportsError.ts" }
TypeScript/tests/cases/compiler/allowSyntheticDefaultImports5.ts_0_162
// @module: system // @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": 162, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/allowSyntheticDefaultImports5.ts" }
TypeScript/tests/cases/compiler/omitTypeHelperModifiers01.ts_0_278
// @strict: true type A = { a: number; b?: string; readonly c: boolean; d: unknown; }; type B = Omit<A, 'a'>; function f(x: B) { const b = x.b; x.b = "hello"; x.b = undefined; const c = x.c; x.c = true; const d = x.d; x.d = d; }
{ "end_byte": 278, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/omitTypeHelperModifiers01.ts" }
TypeScript/tests/cases/compiler/promiseTypeInferenceUnion.ts_0_469
// @target: esnext // @lib: esnext function f1(x: number): number | Promise<number> { return Promise.resolve(x); } function f2(x: number): number | PromiseLike<number> { return Promise.resolve(x); } function f3(x: number): number | Promise<number> | PromiseLike<number> { return Promise.resolve(x); } const g1:...
{ "end_byte": 469, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/promiseTypeInferenceUnion.ts" }
TypeScript/tests/cases/compiler/pathMappingBasedModuleResolution_rootImport_aliasWithRoot_realRootFile.ts_0_456
// @noImplicitReferences: true // @traceResolution: true // @allowJs: true // @filename: /foo.ts export function foo() {} // @filename: /bar.js export function bar() {} // @filename: /root/a.ts import { foo } from "/foo"; import { bar } from "/bar"; // @filename: /root/tsconfig.json { "compilerOptions": { ...
{ "end_byte": 456, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/pathMappingBasedModuleResolution_rootImport_aliasWithRoot_realRootFile.ts" }
TypeScript/tests/cases/compiler/blockScopedSameNameFunctionDeclarationES5.ts_0_345
// @target: ES5 function foo(a: number) { if (a === 1) { function foo() { } // duplicate function foo(); foo(10); // not ok } else { function foo() { } // duplicate function foo(); foo(10); // not ok } foo(10); // not ok foo(); } foo(10); foo();...
{ "end_byte": 345, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/blockScopedSameNameFunctionDeclarationES5.ts" }
TypeScript/tests/cases/compiler/functionWithDefaultParameterWithNoStatements8.ts_0_64
function foo(a = undefined) { } function bar(a = undefined) { }
{ "end_byte": 64, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionWithDefaultParameterWithNoStatements8.ts" }
TypeScript/tests/cases/compiler/parseJsxExtends1.ts_0_186
// @jsx: react // @filename: index.tsx declare const React: any; export function Foo() { // No error; "const" is lowercase and therefore intrinsic. return <const T extends/> }
{ "end_byte": 186, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parseJsxExtends1.ts" }
TypeScript/tests/cases/compiler/declarationQuotedMembers.ts_0_108
// @declaration: true export declare const mapped: { [K in 'a-b-c']: number } export const example = mapped;
{ "end_byte": 108, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationQuotedMembers.ts" }
TypeScript/tests/cases/compiler/ParameterList6.ts_0_53
class C { constructor(C: (public A) => any) { } }
{ "end_byte": 53, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ParameterList6.ts" }
TypeScript/tests/cases/compiler/missingArgument1.ts_0_10
foo(a,,b);
{ "end_byte": 10, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/missingArgument1.ts" }