_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt.ts_3_175
dule Z.M { export function bar() { return ""; } } module A.M { import M = Z.M; export function bar() { } M.bar(); // Should call Z.M.bar }
{ "end_byte": 175, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt.ts" }
TypeScript/tests/cases/compiler/genericRecursiveImplicitConstructorErrors2.ts_0_546
module TypeScript2 { export interface DeclKind { }; export interface PullTypesymbol { }; export interface SymbolLinkKind { }; export enum PullSymbolVisibility { Private, Public }   export class PullSymbol { constructor (name: string, declKind: DeclKind) { } // link methods public ad...
{ "end_byte": 546, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericRecursiveImplicitConstructorErrors2.ts" }
TypeScript/tests/cases/compiler/functionAssignmentError.ts_0_73
var func = function (){return "ONE";}; func = function (){return "ONE";};
{ "end_byte": 73, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionAssignmentError.ts" }
TypeScript/tests/cases/compiler/requireOfJsonFileWithNoContent.ts_0_285
// @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": 285, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/requireOfJsonFileWithNoContent.ts" }
TypeScript/tests/cases/compiler/exportSpecifierForAGlobal.ts_0_170
// @declaration: true // @module: commonjs // @filename: a.d.ts declare class X { } // @filename: b.ts export {X}; export function f() { var x: X; return x; }
{ "end_byte": 170, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportSpecifierForAGlobal.ts" }
TypeScript/tests/cases/compiler/recursiveExportAssignmentAndFindAliasedType7.ts_0_929
//@module: amd // @Filename: recursiveExportAssignmentAndFindAliasedType7_moduleC.ts import self = require("recursiveExportAssignmentAndFindAliasedType7_moduleD"); var selfVar = self; export = selfVar; // @Filename: recursiveExportAssignmentAndFindAliasedType7_moduleD.ts import self = require("recursiveExportAssignmen...
{ "end_byte": 929, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveExportAssignmentAndFindAliasedType7.ts" }
TypeScript/tests/cases/compiler/missingDomElements.ts_0_462
// @lib: esnext interface Element {} interface EventTarget {} interface HTMLElement {} interface HTMLInputElement {} ({} as any as Element).textContent; ({} as any as HTMLElement).textContent; ({} as any as HTMLInputElement).textContent; ({} as any as EventTarget & HTMLInputElement).textContent interface HTMLElement...
{ "end_byte": 462, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/missingDomElements.ts" }
TypeScript/tests/cases/compiler/interfaceDeclaration1.ts_0_605
interface I1 { item:number; item:number; } interface I2 { item:any; item:number; } interface I3 { prototype:number; } interface I4 { class:number; number:number; super:number; prototype:number; } interface I5 extends I5 { foo():void; } interface I6 { ():void; } interface ...
{ "end_byte": 605, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/interfaceDeclaration1.ts" }
TypeScript/tests/cases/compiler/ClassDeclaration9.ts_0_21
class C { foo(); }
{ "end_byte": 21, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ClassDeclaration9.ts" }
TypeScript/tests/cases/compiler/jsxNamespaceImplicitImportJSXNamespaceFromPragmaPickedOverGlobalOne.tsx_0_2292
// @strict: true // @jsx: react // @filename: /node_modules/react/index.d.ts export = React; export as namespace React; declare namespace React { } declare global { namespace JSX { interface Element { } interface ElementClass { } interface ElementAttributesProperty { } interface El...
{ "end_byte": 2292, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsxNamespaceImplicitImportJSXNamespaceFromPragmaPickedOverGlobalOne.tsx" }
TypeScript/tests/cases/compiler/missingReturnStatement1.ts_0_60
class Foo { foo(): number { //return 4; } }
{ "end_byte": 60, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/missingReturnStatement1.ts" }
TypeScript/tests/cases/compiler/jsdocImportTypeNodeNamespace.ts_0_308
// @allowJs: true // @checkJs: true // @noEmit: true // #40767 // @Filename: GeometryType.d.ts declare namespace _default { export const POINT: string; } export default _default; // @Filename: Main.js export default function () { return /** @type {import('./GeometryType.js').default} */ ('Point'); }
{ "end_byte": 308, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsdocImportTypeNodeNamespace.ts" }
TypeScript/tests/cases/compiler/accessorBodyInTypeContext.ts_0_166
type A = { get foo() { return 0 } }; type B = { set foo(v: any) { } }; interface X { get foo() { return 0 } } interface Y { set foo(v: any) { } }
{ "end_byte": 166, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/accessorBodyInTypeContext.ts" }
TypeScript/tests/cases/compiler/functionOverloads33.ts_0_119
function foo(bar:string):string; function foo(bar:any):number; function foo(bar:any):any{ return bar } var x = foo(5);
{ "end_byte": 119, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloads33.ts" }
TypeScript/tests/cases/compiler/asiAmbientFunctionDeclaration.ts_3_25
clare function foo()
{ "end_byte": 25, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/asiAmbientFunctionDeclaration.ts" }
TypeScript/tests/cases/compiler/systemModule11.ts_0_629
// @module: system // @isolatedModules: true // set of tests cases that checks generation of local storage for exported names // @filename: file1.ts export var x; export function foo() {} export * from 'bar'; // @filename: file2.ts var x; var y; export {x}; export {y as y1} export * from 'bar'; // @filename: fil...
{ "end_byte": 629, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/systemModule11.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationFunctionExpressions.ts_0_178
// @sourcemap: true var greetings = 0; var greet = (greeting: string): number => { greetings++; return greetings; } greet("Hello"); var incrGreetings = () => greetings++;
{ "end_byte": 178, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationFunctionExpressions.ts" }
TypeScript/tests/cases/compiler/superCallWithCommentEmit01.ts_0_174
class A { constructor(public text: string) { } } class B extends A { constructor(text: string) { // this is subclass constructor super(text) } }
{ "end_byte": 174, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/superCallWithCommentEmit01.ts" }
TypeScript/tests/cases/compiler/sourceMapWithMultipleFilesWithFileEndingWithInterface.ts_0_332
// @outFile: fooResult.js // @sourcemap: true // @Filename: a.ts module M { export var X = 1; } interface Navigator { getGamepads(func?: any): any; webkitGetGamepads(func?: any): any msGetGamepads(func?: any): any; webkitGamepads(func?: any): any; } // @Filename: b.ts module m1 { export class c...
{ "end_byte": 332, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapWithMultipleFilesWithFileEndingWithInterface.ts" }
TypeScript/tests/cases/compiler/emptyThenWithoutWarning.ts_0_85
let a = 4; if(a === 1 || a === 2 || a === 3) { } else { let message = "Ooops"; }
{ "end_byte": 85, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emptyThenWithoutWarning.ts" }
TypeScript/tests/cases/compiler/classStaticPropertyAccess.ts_0_268
// @strict: true // @target: ES5 class A { public static "\""() {} public static x: number = 1; public static y: number = 1; private static _b: number = 2; } const a = new A(); a["\""] // Error a['y'] // Error a.y // Error A._b // Error A.a
{ "end_byte": 268, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classStaticPropertyAccess.ts" }
TypeScript/tests/cases/compiler/taggedTemplatesWithIncompleteNoSubstitutionTemplate1.ts_3_140
@target: es6 function f(x: TemplateStringsArray, y: string, z: string) { } // Incomplete call, not enough parameters. f `123qdawdrqw
{ "end_byte": 140, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/taggedTemplatesWithIncompleteNoSubstitutionTemplate1.ts" }
TypeScript/tests/cases/compiler/commentsModules.ts_0_1936
// @target: ES5 // @declaration: true // @removeComments: false /** Module comment*/ module m1 { /** b's comment*/ export var b: number; /** foo's comment*/ function foo() { return b; } /** m2 comments*/ export module m2 { /** class comment;*/ export class c { ...
{ "end_byte": 1936, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentsModules.ts" }
TypeScript/tests/cases/compiler/constructorOverloads8.ts_0_355
class C { constructor(x) { } constructor(y, x) { } // illegal, 2 constructor implementations } class D { constructor(x: number); constructor(y: string); // legal, overload signatures for 1 implementation constructor(x) { } } interface I { new (x); new (x, y); // legal, overload signatures ...
{ "end_byte": 355, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constructorOverloads8.ts" }
TypeScript/tests/cases/compiler/commentLeadingCloseBrace.ts_3_245
clare function commentedParameters(...args): any; function ifelse() { if (commentedParameters(1, 2)) { /*comment1*/ commentedParameters(3, 4); /*comment2*/ } else { commentedParameters(5, 6); } }
{ "end_byte": 245, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentLeadingCloseBrace.ts" }
TypeScript/tests/cases/compiler/commentOnDecoratedClassDeclaration.ts_0_232
// @experimentalDecorators: true declare function decorator(x: string): any; /** * Leading trivia */ @decorator("hello") class Remote { } /** * Floating Comment */ @decorator("hi") class AnotherRomote { constructor() {} }
{ "end_byte": 232, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentOnDecoratedClassDeclaration.ts" }
TypeScript/tests/cases/compiler/destructuringPropertyAssignmentNameIsNotAssignmentTarget.ts_0_133
// test for #10668 function qux(bar: { value: number }) { let foo: number; ({ value: foo } = bar); let x = () => bar; }
{ "end_byte": 133, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/destructuringPropertyAssignmentNameIsNotAssignmentTarget.ts" }
TypeScript/tests/cases/compiler/augmentExportEquals3.ts_0_377
// @module: amd // @filename: file1.ts function foo() {} namespace foo { export var v = 1; } export = foo; // @filename: file2.ts import x = require("./file1"); x.b = 1; // OK - './file1' is a namespace declare module "./file1" { interface A { a } let b: number; } // @filename: file3.ts import * as x f...
{ "end_byte": 377, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/augmentExportEquals3.ts" }
TypeScript/tests/cases/compiler/declFileTypeAnnotationTypeQuery.ts_0_570
// @target: ES5 // @declaration: true class c { } module m { export class c { } export class g<T> { } } class g<T> { } // Just the name function foo(): typeof c { return c; } function foo2() { return c; } // Qualified name function foo3(): typeof m.c { return m.c; } function foo4() { ...
{ "end_byte": 570, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileTypeAnnotationTypeQuery.ts" }
TypeScript/tests/cases/compiler/objectMembersOnTypes.ts_0_167
interface I {} class AAA implements I { } var x: number; x.toString(); var i: I; i.toString(); // used to be an error var c: AAA; c.toString(); // used to be an error
{ "end_byte": 167, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectMembersOnTypes.ts" }
TypeScript/tests/cases/compiler/commentOnArrayElement7.ts_3_62
nst array = [/* element 1 */ 1, /* end of element 1 */];
{ "end_byte": 62, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentOnArrayElement7.ts" }
TypeScript/tests/cases/compiler/sourceMapWithCaseSensitiveFileNames.ts_0_398
// @outFile: testfiles/fooResult.js // @sourcemap: true // @useCaseSensitiveFileNames: true // @Filename: testFiles/app.ts // Note in the out result we are using same folder name only different in casing // Since this is case sensitive, the folders are different and hence the relative paths in sourcemap shouldn't be ju...
{ "end_byte": 398, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapWithCaseSensitiveFileNames.ts" }
TypeScript/tests/cases/compiler/returnTypeTypeArguments.ts_0_1256
class One<T>{ value: T; } class Two<T, U>{ value: T; id: U; } class Three<T, U, V>{ value: T; id: U; name: V; } function A1(): One { return null; } function A2(): Two { return null; } function A3(): Three { return null; } function B1(): Two<number> { return null; } function B2(): Three<string>...
{ "end_byte": 1256, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/returnTypeTypeArguments.ts" }
TypeScript/tests/cases/compiler/jsxNamespaceImplicitImportJSXNamespaceFromConfigPickedOverGlobalOne.tsx_0_2196
// @strict: true // @jsx: preserve,react-jsx // @jsxImportSource: @emotion/react // @filename: /node_modules/react/index.d.ts export = React; export as namespace React; declare namespace React {} declare global { namespace JSX { interface Element {} interface ElementClass {} interface ElementAttributesP...
{ "end_byte": 2196, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsxNamespaceImplicitImportJSXNamespaceFromConfigPickedOverGlobalOne.tsx" }
TypeScript/tests/cases/compiler/checkJsFiles_noErrorLocation.ts_0_259
// @allowJs: true // @checkJs: true // @noEmit: true // @fileName: a.js // @ts-check class A { constructor() { } foo() { return 4; } } class B extends A { constructor() { super(); this.foo = () => 3; } } const i = new B(); i.foo();
{ "end_byte": 259, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/checkJsFiles_noErrorLocation.ts" }
TypeScript/tests/cases/compiler/indexedAccessWithFreshObjectLiteral.ts_0_710
// @strict: true function foo (id: string) { return { a: 1, b: "", c: true }[id] } function bar (id: 'a' | 'b') { return { a: 1, b: "", c: false }[id] } function baz (id: '1' | '2') { return { 1: 1, 2: "", 3: false }[id] } function qux (id: 1 | 2) { ...
{ "end_byte": 710, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/indexedAccessWithFreshObjectLiteral.ts" }
TypeScript/tests/cases/compiler/innerModExport2.ts_0_397
module Outer { // inner mod 1 var non_export_var: number; module { var non_export_var = 0; export var export_var = 1; function NonExportFunc() { return 0; } export function ExportFunc() { return 0; } } var export_var: number; export var outer_var_export = 0; ...
{ "end_byte": 397, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/innerModExport2.ts" }
TypeScript/tests/cases/compiler/declarationEmitReexportedSymlinkReference3.ts_0_1630
// @filename: monorepo/pkg1/dist/index.d.ts export * from './types'; // @filename: monorepo/pkg1/dist/types.d.ts export declare type A = { id: string; }; export declare type B = { id: number; }; export declare type IdType = A | B; export declare class MetadataAccessor<T, D extends IdType = IdType> { readonl...
{ "end_byte": 1630, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitReexportedSymlinkReference3.ts" }
TypeScript/tests/cases/compiler/argumentsAsPropertyName2.ts_0_227
// target: es5 function foo() { for (let x = 0; x < 1; ++x) { let i : number; [].forEach(function () { i }); ({ arguments: 0 }); ({ arguments }); ({ arguments: arguments }); } }
{ "end_byte": 227, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/argumentsAsPropertyName2.ts" }
TypeScript/tests/cases/compiler/arrowFunctionInConstructorArgument1.ts_0_102
class C { constructor(x: () => void) { } } var c = new C(() => { return asdf; } ) // should error
{ "end_byte": 102, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arrowFunctionInConstructorArgument1.ts" }
TypeScript/tests/cases/compiler/overridingPrivateStaticMembers.ts_0_142
class Base2 { private static y: { foo: string }; } class Derived2 extends Base2 { private static y: { foo: string; bar: string; }; }
{ "end_byte": 142, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overridingPrivateStaticMembers.ts" }
TypeScript/tests/cases/compiler/expressionTypeNodeShouldError.ts_0_781
// @Filename: base.d.ts declare const x: "foo".charCodeAt(0); // @filename: string.ts interface String { typeof<T>(x: T): T; } class C { foo() { const x: "".typeof(this.foo); } } const nodes = document.getElementsByTagName("li"); type ItemType = "".typeof(nodes.item(0)); // @filename: number.ts ...
{ "end_byte": 781, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/expressionTypeNodeShouldError.ts" }
TypeScript/tests/cases/compiler/es5ExportDefaultClassDeclaration3.ts_0_209
// @target: es5 // @module: commonjs // @declaration: true var before: C = new C(); export default class C { method(): C { return new C(); } } var after: C = new C(); var t: typeof C = C;
{ "end_byte": 209, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es5ExportDefaultClassDeclaration3.ts" }
TypeScript/tests/cases/compiler/resolutionCandidateFromPackageJsonField2.ts_0_401
// @moduleResolution: node10,bundler // @filename: tsconfig.json { "compilerOptions": { "paths": { "foo/*": ["./dist/*"], "baz/*.ts": ["./types/*.d.ts"] } } } // @filename: dist/bar.ts export const a = 1234; // @filename: types/main.d.ts export const b: string; // @fi...
{ "end_byte": 401, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/resolutionCandidateFromPackageJsonField2.ts" }
TypeScript/tests/cases/compiler/excessPropertyCheckWithNestedArrayIntersection.ts_0_412
interface ValueOnlyFields { fields: Array<{ value: number | null; }>; } interface ValueAndKeyFields { fields: Array<{ key: string | null; value: number | null; }>; } interface BugRepro { dataType: ValueAndKeyFields & ValueOnlyFields; } const repro: BugRepro = { dataType: { ...
{ "end_byte": 412, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/excessPropertyCheckWithNestedArrayIntersection.ts" }
TypeScript/tests/cases/compiler/typeParametersShouldNotBeEqual3.ts_0_155
function ff<T extends Object, U extends Object>(x: T, y: U) { var z: Object; x = x; // Ok x = y; // Ok x = z; // Ok z = x; // Ok }
{ "end_byte": 155, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeParametersShouldNotBeEqual3.ts" }
TypeScript/tests/cases/compiler/collisionThisExpressionAndLocalVarInProperty.ts_0_332
class class1 { public prop1 = { doStuff: (callback) => () => { var _this = 2; return callback(this); } } } class class2 { constructor() { var _this = 2; } public prop1 = { doStuff: (callback) => () => { return callback(this); ...
{ "end_byte": 332, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionThisExpressionAndLocalVarInProperty.ts" }
TypeScript/tests/cases/compiler/instanceSubtypeCheck1.ts_0_80
interface A<T> { x: A<B<T>> } interface B<T> extends A<T> { x: B<A<T>> }
{ "end_byte": 80, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/instanceSubtypeCheck1.ts" }
TypeScript/tests/cases/compiler/missingTypeArguments2.ts_0_74
class A<T> { } var x: () => A; (a: A) => { }; var y: A<A>; (): A => null;
{ "end_byte": 74, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/missingTypeArguments2.ts" }
TypeScript/tests/cases/compiler/derivedTypeCallingBaseImplWithOptionalParams.ts_0_318
interface MyInterface { myMethod(...myList: any[]); } class MyClass implements MyInterface { myMethod(myList: any[]) { // valid } } var x: MyInterface = new MyClass(); x.myMethod(); // should be valid, but MyClass has no implementation to handle it. var y: MyClass = new MyClass(); y.myMethod(); // error
{ "end_byte": 318, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/derivedTypeCallingBaseImplWithOptionalParams.ts" }
TypeScript/tests/cases/compiler/contextualTyping8.ts_0_46
var foo:{id:number;}[] = [<{id:number;}>({})];
{ "end_byte": 46, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTyping8.ts" }
TypeScript/tests/cases/compiler/declFileTypeAnnotationArrayType.ts_0_792
// @target: ES5 // @declaration: true class c { } module m { export class c { } export class g<T> { } } class g<T> { } // Just the name function foo(): c[] { return [new c()]; } function foo2() { return [new c()]; } // Qualified name function foo3(): m.c[] { return [new m.c()]; } function...
{ "end_byte": 792, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileTypeAnnotationArrayType.ts" }
TypeScript/tests/cases/compiler/exportEqualsAmd.ts_0_45
// @module: amd export = { ["hi"]: "there" };
{ "end_byte": 45, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportEqualsAmd.ts" }
TypeScript/tests/cases/compiler/computedPropertyNameWithImportedKey.ts_0_199
// @declaration: true // @lib: es6 // @filename: /a.ts export const a = Symbol(); // @filename: /b.ts import { a } from "./a"; export function fn({ [a]: value }: any): string { return value; }
{ "end_byte": 199, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/computedPropertyNameWithImportedKey.ts" }
TypeScript/tests/cases/compiler/commentOnClassAccessor1.ts_0_76
class C { /** * @type {number} */ get bar(): number { return 1;} }
{ "end_byte": 76, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentOnClassAccessor1.ts" }
TypeScript/tests/cases/compiler/anonterface.ts_0_199
module M { export class C { m(fn:{ (n:number):string; },n2:number):string { return fn(n2); } } } var c=new M.C(); c.m(function(n) { return "hello: "+n; },18);
{ "end_byte": 199, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/anonterface.ts" }
TypeScript/tests/cases/compiler/declarationEmitPrivatePromiseLikeInterface.ts_0_1269
// @declaration: true // @skipLibCheck: true // @noTypesAndSymbols: true // @filename: http-client.ts type TPromise<ResolveType, RejectType = any> = Omit<Promise<ResolveType>, "then" | "catch"> & { then<TResult1 = ResolveType, TResult2 = never>( onfulfilled?: ((value: ResolveType) => TResult1 | PromiseLike<...
{ "end_byte": 1269, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitPrivatePromiseLikeInterface.ts" }
TypeScript/tests/cases/compiler/rectype.ts_0_142
module M { interface I { (i:I):I; } export function f(p: I) { return f }; var i:I; f(i); f(f(i)); f((f(f(i)))); }
{ "end_byte": 142, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/rectype.ts" }
TypeScript/tests/cases/compiler/collisionExportsRequireAndAmbientClass.ts_0_625
//@module: amd //@filename: collisionExportsRequireAndAmbientClass_externalmodule.ts export declare class require { } export declare class exports { } declare module m1 { class require { } class exports { } } module m2 { export declare class require { } export declare class exports { } }...
{ "end_byte": 625, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionExportsRequireAndAmbientClass.ts" }
TypeScript/tests/cases/compiler/expandoFunctionContextualTypesJs.ts_0_933
// @allowJs: true // @checkJs: true // @noEmit: true // @filename: input.js /** @typedef {{ color: "red" | "blue" }} MyComponentProps */ /** * @template P * @typedef {{ (): any; defaultProps?: Partial<P> }} StatelessComponent */ /** * @type {StatelessComponent<MyComponentProps>} */ const MyComponent = () => ...
{ "end_byte": 933, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/expandoFunctionContextualTypesJs.ts" }
TypeScript/tests/cases/compiler/exportDefaultParenthesizeES6.ts_0_99
// @target: es6 // @module: esnext // @filename: classexpr.ts export default (class Foo {} as any);
{ "end_byte": 99, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportDefaultParenthesizeES6.ts" }
TypeScript/tests/cases/compiler/esModuleInteropTslibHelpers.ts_0_523
// @esModuleInterop: true // @importHelpers: true // @noEmitHelpers: true // @filename: refs.d.ts declare module "path"; // @filename: file.ts import path from "path"; path.resolve("", "../"); export class Foo { } // @filename: file2.ts import * as path from "path"; path.resolve("", "../"); export class Foo2 { } // @fi...
{ "end_byte": 523, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/esModuleInteropTslibHelpers.ts" }
TypeScript/tests/cases/compiler/isolatedDeclarationErrorsClassesExpressions.ts_0_363
// @declaration: true // @isolatedDeclarations: true // @declarationMap: false // @strict: true // @target: ESNext export const cls = class { foo: string = ""; } function id<T extends new (...a: any[]) => any>(cls: T) { return cls; } export class Base { } export class Mix extends id(Base) { } export c...
{ "end_byte": 363, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/isolatedDeclarationErrorsClassesExpressions.ts" }
TypeScript/tests/cases/compiler/assignmentCompatability29.ts_0_335
module __test1__ { export interface interfaceWithPublicAndOptional<T,U> { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional<number,string> = { one: 1 };; export var __val__obj4 = obj4; } module __test2__ { export var aa:{one:any[];};; export var __val__aa = aa; } __test2__.__val__aa = __test...
{ "end_byte": 335, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatability29.ts" }
TypeScript/tests/cases/compiler/decoratorReferences.ts_0_488
// @experimentalDecorators: true declare function y(...args: any[]): any; type T = number; @y(1 as T, () => C) // <-- T should be resolved to the type alias, not the type parameter of the class; C should resolve to the class class C<T> { @y(null as T) // <-- y should resolve to the function declaration, not the pa...
{ "end_byte": 488, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/decoratorReferences.ts" }
TypeScript/tests/cases/compiler/exportDeclareClass1.ts_0_202
//@module: amd export declare class eaC { static tF() { }; static tsF(param:any) { }; }; export declare class eaC2 { static tF(); static tsF(param:any); };
{ "end_byte": 202, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportDeclareClass1.ts" }
TypeScript/tests/cases/compiler/promises.ts_0_152
interface Promise<T> { then<U>(success?: (value: T) => U): Promise<U>; then<U>(success?: (value: T) => Promise<U>): Promise<U>; value: T; }
{ "end_byte": 152, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/promises.ts" }
TypeScript/tests/cases/compiler/internalAliasEnumInsideLocalModuleWithoutExport.ts_0_225
//@module: commonjs // @declaration: true export module a { export enum weekend { Friday, Saturday, Sunday } } export module c { import b = a.weekend; export var bVal: b = b.Sunday; }
{ "end_byte": 225, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/internalAliasEnumInsideLocalModuleWithoutExport.ts" }
TypeScript/tests/cases/compiler/recursiveTypeParameterReferenceError2.ts_0_223
interface List<T> { data: T; next: List<T>; owner: List<List<T>>; // Error, recursive reference with wrapped T } interface List2<T> { data: T; next: List2<T>; owner: List2<List2<string>>; // Ok }
{ "end_byte": 223, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveTypeParameterReferenceError2.ts" }
TypeScript/tests/cases/compiler/moduleResolutionWithSuffixes_threeLastIsBlank3.ts_0_380
// moduleSuffixes has three entries, and the last one is blank. Module resolution should match on the blank suffix. // @filename: /tsconfig.json { "compilerOptions": { "moduleResolution": "node", "traceResolution": true, "moduleSuffixes": ["-ios", "__native", ""] } } // @filename: /index.ts import { base } fr...
{ "end_byte": 380, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolutionWithSuffixes_threeLastIsBlank3.ts" }
TypeScript/tests/cases/compiler/assignmentCompatibilityForConstrainedTypeParameters.ts_0_125
function foo<T extends { bar: string }>() { function bar<S extends T>() { var x: S; var y: T; y = x; } }
{ "end_byte": 125, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatibilityForConstrainedTypeParameters.ts" }
TypeScript/tests/cases/compiler/moduleAugmentationGlobal8.ts_0_118
// @target: es5 // @module: amd namespace A { declare global { interface Array<T> { x } } } export {}
{ "end_byte": 118, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleAugmentationGlobal8.ts" }
TypeScript/tests/cases/compiler/noEmitHelpers.ts_0_59
// @noemithelpers: true class A { } class B extends A { }
{ "end_byte": 59, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noEmitHelpers.ts" }
TypeScript/tests/cases/compiler/quotedAccessorName2.ts_0_48
class C { static get "foo"() { return 0; } }
{ "end_byte": 48, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/quotedAccessorName2.ts" }
TypeScript/tests/cases/compiler/declarationFileNoCrashOnExtraExportModifier.ts_0_223
// @filename: input.ts export = exports; declare class exports { constructor(p: number); t: number; } export class Sub { instance!: { t: number; }; } declare namespace exports { export { Sub }; }
{ "end_byte": 223, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationFileNoCrashOnExtraExportModifier.ts" }
TypeScript/tests/cases/compiler/typeGuardNarrowsIndexedAccessOfKnownProperty7.ts_0_198
// @strict: true // @target: esnext export namespace Foo { export const key = Symbol(); } export class C { [Foo.key]: string; constructor() { this[Foo.key] = "hello"; } }
{ "end_byte": 198, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeGuardNarrowsIndexedAccessOfKnownProperty7.ts" }
TypeScript/tests/cases/compiler/enumIdentifierLiterals.ts_0_69
enum Nums { 1.0, 11e-1, 0.12e1, "13e-1", 0xF00D }
{ "end_byte": 69, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumIdentifierLiterals.ts" }
TypeScript/tests/cases/compiler/dynamicNamesErrors.ts_0_1049
// @target: esnext // @module: commonjs // @declaration: true // @useDefineForClassFields: false const c0 = "1"; const c1 = 1; interface T0 { [c0]: number; 1: number; } interface T1 { [c0]: number; } interface T2 { [c0]: string; } interface T3 { [c0]: number; [c1]: string; } let t1: T1; le...
{ "end_byte": 1049, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/dynamicNamesErrors.ts" }
TypeScript/tests/cases/compiler/classImplementsClass4.ts_0_185
class A { private x = 1; 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;
{ "end_byte": 185, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classImplementsClass4.ts" }
TypeScript/tests/cases/compiler/genericTypeAssertions3.ts_0_229
var r = < <T>(x: T) => T > ((x) => { return null; }); // bug was 'could not find dotted symbol T' on x's annotation in the type assertion instead of no error var s = < <T>(x: T) => T > ((x: any) => { return null; }); // no error
{ "end_byte": 229, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericTypeAssertions3.ts" }
TypeScript/tests/cases/compiler/controlFlowInstanceof.ts_0_2154
// @target: es6 // @noEmit: true // @allowJs: true // @checkJs: true // @strictNullChecks: true // @Filename: controlFlowInstanceof.ts // Repros from #10167 function f1(s: Set<string> | Set<number>) { s = new Set<number>(); s; // Set<number> if (s instanceof Set) { s; // Set<number> } s;...
{ "end_byte": 2154, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/controlFlowInstanceof.ts" }
TypeScript/tests/cases/compiler/jsFileFunctionParametersAsOptional.ts_0_136
// @allowJs: true // @noEmit: true // @filename: foo.js function f(a, b, c) { } // @filename: bar.ts f(); f(1); f(1, 2); f(1, 2, 3);
{ "end_byte": 136, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileFunctionParametersAsOptional.ts" }
TypeScript/tests/cases/compiler/instantiateCrossFileMerge.ts_0_190
// @filename: first.ts declare class P<R> { constructor(callback: (resolve: (value: R) => void) => void); } // @filename: second.ts interface P<R> { } new P<string>(r => { r('foo') });
{ "end_byte": 190, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/instantiateCrossFileMerge.ts" }
TypeScript/tests/cases/compiler/declarationEmitReexportedSymlinkReference.ts_0_1613
// @filename: monorepo/pkg1/dist/index.d.ts export * from './types'; // @filename: monorepo/pkg1/dist/types.d.ts export declare type A = { id: string; }; export declare type B = { id: number; }; export declare type IdType = A | B; export declare class MetadataAccessor<T, D extends IdType = IdType> { readonl...
{ "end_byte": 1613, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitReexportedSymlinkReference.ts" }
TypeScript/tests/cases/compiler/es6ImportNamedImportWithTypesAndValues.ts_0_452
// @module: commonjs // @declaration: true // @filename: server.ts export interface I { prop: string; } export interface I2 { prop2: string; } export class C implements I { prop = "hello"; } export class C2 implements I2 { prop2 = "world"; } // @filename: client.ts import { C, I, C2 } from "./server";...
{ "end_byte": 452, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ImportNamedImportWithTypesAndValues.ts" }
TypeScript/tests/cases/compiler/functionInIfStatementInModule.ts_2_89
module Midori { if (false) { function Foo(src) { } } }
{ "end_byte": 89, "start_byte": 2, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionInIfStatementInModule.ts" }
TypeScript/tests/cases/compiler/commentOnInterface1.ts_0_248
//@filename: a.ts /*!================= Keep this pinned ================= */ /*! Don't keep this pinned comment */ interface I { } // Don't keep this comment. interface I2 { } //@filename: b.ts ///<reference path='a.ts'/> interface I3 { }
{ "end_byte": 248, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentOnInterface1.ts" }
TypeScript/tests/cases/compiler/collisionArgumentsFunctionExpressions.ts_0_1187
function foo() { function f1(arguments: number, ...restParameters) { //arguments is error var arguments = 10; // no error } function f12(i: number, ...arguments) { //arguments is error var arguments: any[]; // no error } function f1NoError(arguments: number) { // no error var...
{ "end_byte": 1187, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionArgumentsFunctionExpressions.ts" }
TypeScript/tests/cases/compiler/switchCaseCircularRefeference.ts_0_117
// Repro from #9507 function f(x: {a: "A", b} | {a: "C", e}) { switch (x.a) { case x: break; } }
{ "end_byte": 117, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/switchCaseCircularRefeference.ts" }
TypeScript/tests/cases/compiler/fillInMissingTypeArgsOnConstructCalls.ts_0_62
class A<T extends Object>{ list: T ; } var a = new A();
{ "end_byte": 62, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/fillInMissingTypeArgsOnConstructCalls.ts" }
TypeScript/tests/cases/compiler/duplicateIdentifierRelatedSpans_moduleAugmentation.ts_0_185
// @Filename: /dir/a.ts export const x = 0; // @Filename: /dir/b.ts export {}; declare module "./a" { export const x = 0; } declare module "../dir/a" { export const x = 0; }
{ "end_byte": 185, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateIdentifierRelatedSpans_moduleAugmentation.ts" }
TypeScript/tests/cases/compiler/renamingDestructuredPropertyInFunctionType3.ts_0_268
// @target: es2015 const sym = Symbol(); type O = Record<symbol, unknown> type F14 = ({ [sym]: string }: O) => void; // Error type G14 = new ({ [sym]: string }: O) => void; // Error const f13 = ({ [sym]: string }: O) => { }; function f14 ({ [sym]: string }: O) { };
{ "end_byte": 268, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/renamingDestructuredPropertyInFunctionType3.ts" }
TypeScript/tests/cases/compiler/contextuallyTypedParametersWithInitializers3.ts_0_385
// @strict: true // @noEmit: true type CanvasDirection = "RIGHT" | "LEFT"; interface GraphActions { setDirection: (direction: CanvasDirection) => void; } export declare function create<T>(config: T): void; declare function takesDirection(direction: CanvasDirection): void; create<GraphActions>({ setDirection: (...
{ "end_byte": 385, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextuallyTypedParametersWithInitializers3.ts" }
TypeScript/tests/cases/compiler/out-flag2.ts_0_161
// @target: ES5 // @sourcemap: true // @declaration: true // @module: commonjs // @outFile: c.js // @Filename: a.ts class A { } // @Filename: b.ts class B { }
{ "end_byte": 161, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/out-flag2.ts" }
TypeScript/tests/cases/compiler/overloadResolutionWithAny.ts_0_379
var func: { (s: string): number; (s: any): string; }; func(""); // number func(3); // string var x: any; func(x); // string var func2: { (s: string, t: string): number; (s: any, t: string): boolean; (s: string, t: any): RegExp; (s: any, t: any): string; } func2(x, x); // string func2("", "");...
{ "end_byte": 379, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overloadResolutionWithAny.ts" }
TypeScript/tests/cases/compiler/isolatedDeclarationOutFile.ts_0_417
// @declaration: true // @isolatedDeclarations: true // @outFile: all.js // @module: amd // @target: ESNext // @Filename: a.ts export class A { toUpper(msg: string): string { return msg.toUpperCase(); } } // @Filename: b.ts import { A } from "./a"; export class B extends A { toFixed(n: number): s...
{ "end_byte": 417, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/isolatedDeclarationOutFile.ts" }
TypeScript/tests/cases/compiler/unicodeEscapesInJSDoc.ts_0_320
// @allowJs: true // @checkJs: true // @outDir: ./out // @target: es2018 // @filename: file.js /** * @param {number} \u0061 * @param {number} a\u0061 */ function foo(a, aa) { console.log(a + aa); } /** * @param {number} \u{0061} * @param {number} a\u{0061} */ function bar(a, aa) { console.log(a + aa); }
{ "end_byte": 320, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unicodeEscapesInJSDoc.ts" }
TypeScript/tests/cases/compiler/contextualTyping13.ts_0_51
var foo:(a:number)=>number = function(a){return a};
{ "end_byte": 51, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTyping13.ts" }
TypeScript/tests/cases/compiler/typePredicateAcceptingPartialOfRefinedType.ts_0_265
// @strict: true // @exactOptionalPropertyTypes: true // @noEmit: true // repro #51953 interface Test { testy?: string; } interface Options { test: Test['testy']; } declare function includesAllRequiredOptions(options: Partial<Options>): options is Options;
{ "end_byte": 265, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typePredicateAcceptingPartialOfRefinedType.ts" }
TypeScript/tests/cases/compiler/conditionalTypeContextualTypeSimplificationsSuceeds.ts_0_541
// @strict: true // repro from https://github.com/Microsoft/TypeScript/issues/26395 interface Props { when: (value: string) => boolean; } function bad<P extends Props>( attrs: string extends keyof P ? { [K in keyof P]: P[K] } : { [K in keyof P]: P[K] }) { } function good1<P extends Props>( attrs: string ex...
{ "end_byte": 541, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/conditionalTypeContextualTypeSimplificationsSuceeds.ts" }