_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/jsxIntrinsicUnions.tsx_0_191
// @jsx: react /// <reference path="/.lib/react16.d.ts" /> import * as React from "react"; const El = Math.random() ? 'h1' : 'h2'; const tag = <El className="ok" key="key">{"Title"}</El>;
{ "end_byte": 191, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsxIntrinsicUnions.tsx" }
TypeScript/tests/cases/compiler/isolatedModulesImportExportElision.ts_0_274
// @isolatedModules: true // @target: es5 // @module: commonjs // @filename: file1.ts import {c} from "module" import {c2} from "module" import * as ns from "module" class C extends c2.C { } let x = new c(); let y = ns.value; export {c1} from "module"; export var z = x;
{ "end_byte": 274, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/isolatedModulesImportExportElision.ts" }
TypeScript/tests/cases/compiler/literals1.ts_0_210
var a = 42; var b = 0xFA34; var c = 0.1715; var d = 3.14E5; var e = 8.14e-5; var f = true; var g = false; var h = ""; var i = "hi"; var j = ''; var k = 'q\tq'; var m = /q/; var n = /\d+/g; var o = /[3-5]+/i;
{ "end_byte": 210, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/literals1.ts" }
TypeScript/tests/cases/compiler/exportAssignmentWithImportStatementPrivacyError.ts_0_412
//@module: amd module m2 { export interface connectModule { (res, req, next): void; } export interface connectExport { use: (mod: connectModule) => connectExport; listen: (port: number) => void; } } module M { export var server: { (): m2.connectExport; test1...
{ "end_byte": 412, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportAssignmentWithImportStatementPrivacyError.ts" }
TypeScript/tests/cases/compiler/declarationEmitReadonlyComputedProperty.ts_0_404
// @declaration: true // @lib: es2015 // @filename: bug.ts export const SYMBOL = Symbol() export interface Interface { readonly [SYMBOL]: string; // remove readonly and @showEmit to see the expected error } export function createInstance(): Interface { return { [SYMBOL]: '' } } // @filename: index.ts impo...
{ "end_byte": 404, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitReadonlyComputedProperty.ts" }
TypeScript/tests/cases/compiler/moduleResolution_packageJson_notAtPackageRoot.ts_0_379
// @noImplicitReferences: true // @traceResolution: true // Loads from a "fake" nested package.json, not from the one at the root. // @Filename: /node_modules/foo/bar/package.json { "types": "types.d.ts" } // @Filename: /node_modules/foo/package.json {} // @Filename: /node_modules/foo/bar/types.d.ts export const x:...
{ "end_byte": 379, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolution_packageJson_notAtPackageRoot.ts" }
TypeScript/tests/cases/compiler/narrowCommaOperatorNestedWithinLHS.ts_0_552
const otherValue = () => true; const value: { inner: number | string } = null as any; function isNumber(obj: any): obj is number { return true; // method implementation irrelevant } if (typeof (otherValue(), value).inner === 'number') { const a = value.inner; // number const b: number = (otherValue(), val...
{ "end_byte": 552, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowCommaOperatorNestedWithinLHS.ts" }
TypeScript/tests/cases/compiler/genericSignatureIdentity.ts_0_443
// This test is here to remind us of our current limits of type identity checking. // Ideally all of the below declarations would be considered different (and thus errors) // but they aren't because we erase type parameters to type any and don't check that // constraints are identical. var x: { <T extends Date>(x:...
{ "end_byte": 443, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericSignatureIdentity.ts" }
TypeScript/tests/cases/compiler/arithmeticOnInvalidTypes2.ts_0_134
var obj = function f<T>(a: T, b: T) { var z1 = a + b; var z2 = a - b; var z3 = a * b; var z4 = a / b; return a; };
{ "end_byte": 134, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arithmeticOnInvalidTypes2.ts" }
TypeScript/tests/cases/compiler/typeAliasDoesntMakeModuleInstantiated.ts_0_365
declare module m { // type alias declaration here shouldnt make the module declaration instantiated type Selector = string| string[] |Function; export interface IStatic { (selector: any /* Selector */): IInstance; } export interface IInstance { } } declare var m: m.IStatic; // Should be ok ...
{ "end_byte": 365, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeAliasDoesntMakeModuleInstantiated.ts" }
TypeScript/tests/cases/compiler/functionOverloads41.ts_0_147
function foo(bar:{a:number;}[]):string; function foo(bar:{a:boolean;}[]):number; function foo(bar:{a:any;}[]):any{ return bar } var x = foo([{}]);
{ "end_byte": 147, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloads41.ts" }
TypeScript/tests/cases/compiler/objectLiteralWithSemicolons2.ts_0_25
var v = { a; b; c }
{ "end_byte": 25, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectLiteralWithSemicolons2.ts" }
TypeScript/tests/cases/compiler/unreachableDeclarations.ts_0_1262
// @strict: true // @preserveConstEnums: true, false // @allowUnreachableCode: false function func1() { aFunc(); console.log(EnumA.Value); console.log(EnumB.Value); return; function aFunc() { console.log(EnumA.Value); console.log(EnumB.Value); } enum EnumA { Value } ...
{ "end_byte": 1262, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unreachableDeclarations.ts" }
TypeScript/tests/cases/compiler/classFieldsBrokenConstructorEmitNoCrash1.ts_0_114
// @strict: true // @useDefineForClassFields: false // @target: es2021 class Test { prop = 42; constructor }
{ "end_byte": 114, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classFieldsBrokenConstructorEmitNoCrash1.ts" }
TypeScript/tests/cases/compiler/jsxElementTypeLiteral.tsx_0_555
// @strict: true // @jsx: react /// <reference path="/.lib/react16.d.ts" /> import * as React from "react"; declare global { namespace JSX { // This should only use keys of JSX.IntrinsicElements. // Diverging here to illustrate different error messages. type ElementType = "div"; } } // should be fine ...
{ "end_byte": 555, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsxElementTypeLiteral.tsx" }
TypeScript/tests/cases/compiler/declarationEmitDoesNotUseReexportedNamespaceAsLocal.ts_0_236
// @target: esnext // @module: esnext // @declaration: true // @filename: sub.ts export function a() {} // @filename: index.ts export const x = add(import("./sub")); export * as Q from "./sub"; declare function add<T>(x: Promise<T>): T;
{ "end_byte": 236, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitDoesNotUseReexportedNamespaceAsLocal.ts" }
TypeScript/tests/cases/compiler/checkInfiniteExpansionTermination2.ts_0_428
// Regression test for #1002 // Before fix this code would cause infinite loop interface IObservable<T> { n: IObservable<T[]>; } interface ISubject<T> extends IObservable<T> { } declare function combineLatest<TOther>(x: IObservable<TOther>[]): void; declare function combineLatest(): void; function fn<T>() { ...
{ "end_byte": 428, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/checkInfiniteExpansionTermination2.ts" }
TypeScript/tests/cases/compiler/privacyFunctionCannotNameReturnTypeDeclFile.ts_0_4811
// @module: commonjs // @declaration: true // @Filename: privacyFunctionReturnTypeDeclFile_GlobalWidgets.ts declare module "GlobalWidgets" { export class Widget3 { name: string; } export function createWidget3(): Widget3; export module SpecializedGlobalWidget { export class Widget4 { ...
{ "end_byte": 4811, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyFunctionCannotNameReturnTypeDeclFile.ts" }
TypeScript/tests/cases/compiler/contextualSignature_objectLiteralMethodMayReturnNever.ts_0_91
interface I { m(): number; } const o: I = { m() { throw new Error("not implemented"); } };
{ "end_byte": 91, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualSignature_objectLiteralMethodMayReturnNever.ts" }
TypeScript/tests/cases/compiler/classFieldSuperAccessibleJs1.ts_0_243
// @strict: true // @checkJs: true // @target: esnext // @noEmit: true // @filename: index.js class C { static blah1 = 123; } C.blah2 = 456; class D extends C { static { console.log(super.blah1); console.log(super.blah2); } }
{ "end_byte": 243, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classFieldSuperAccessibleJs1.ts" }
TypeScript/tests/cases/compiler/library_DatePrototypeProperties.ts_0_1468
// Properties of the Date prototype object as per ES5 spec // http://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5 Date.prototype.constructor; Date.prototype.toString(); Date.prototype.toDateString(); Date.prototype.toTimeString(); Date.prototype.toLocaleString(); Date.prototype.toLocaleDateString(); Date.prototy...
{ "end_byte": 1468, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/library_DatePrototypeProperties.ts" }
TypeScript/tests/cases/compiler/unusedPrivateStaticMembers.ts_0_766
// @noUnusedLocals: true // @target: esnext // @useDefineForClassFields: false class Test1 { private static m1() {} public static test() { Test1.m1(); } } class Test2 { private static p1 = 0 public static test() { Test2.p1; } } class Test3 { private static p1 = 0; priv...
{ "end_byte": 766, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedPrivateStaticMembers.ts" }
TypeScript/tests/cases/compiler/genericTypeReferencesRequireTypeArgs.ts_0_187
class C<T> { foo(): T { return null } } interface I<T> { bar(): T; } var c1: C; // error var i1: I; // error var c2: C<I>; // should be an error var i2: I<C>; // should be an error
{ "end_byte": 187, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericTypeReferencesRequireTypeArgs.ts" }
TypeScript/tests/cases/compiler/privacyCheckAnonymousFunctionParameter2.ts_0_277
//@module: amd //@declaration: true export var x = 1; // Makes this an external module interface Iterator<T> { x: T } module Q { export function foo<T>(x: (a: Iterator<T>) => number) { return x; } } module Q { function bar() { foo(null); } }
{ "end_byte": 277, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyCheckAnonymousFunctionParameter2.ts" }
TypeScript/tests/cases/compiler/requireOfJsonFileWithModuleNodeResolutionEmitUmd.ts_0_224
// @module: umd // @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": 224, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/requireOfJsonFileWithModuleNodeResolutionEmitUmd.ts" }
TypeScript/tests/cases/compiler/contextuallyTypeArgumentsKeyword.ts_0_219
// @noEmit: true // @allowJs: true // @checkJs: true // @skipLibCheck: true // @lib: es2017, dom // @Filename: foo.js // Repro for #16585 const x = { bar() { setTimeout(function() { arguments }, 0); } }
{ "end_byte": 219, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextuallyTypeArgumentsKeyword.ts" }
TypeScript/tests/cases/compiler/functionOverloads10.ts_0_89
function foo(foo:string, bar:number); function foo(foo:string); function foo(foo:any){ }
{ "end_byte": 89, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloads10.ts" }
TypeScript/tests/cases/compiler/constInClassExpression.ts_0_36
let C = class { const a = 4; };
{ "end_byte": 36, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constInClassExpression.ts" }
TypeScript/tests/cases/compiler/assignLambdaToNominalSubtypeOfFunction.ts_0_158
interface IResultCallback extends Function { x: number; } function fn(cb: IResultCallback) { } fn((a, b) => true); fn(function (a, b) { return true; })
{ "end_byte": 158, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignLambdaToNominalSubtypeOfFunction.ts" }
TypeScript/tests/cases/compiler/selfReferentialDefaultNoStackOverflow.ts_0_204
// @allowJs: true // @checkJs: true // @strict: true // @outDir: ./out // @filename: QSpinner.js import DefaultSpinner from './QSpinner' export default { mixins: [DefaultSpinner], name: 'QSpinner' }
{ "end_byte": 204, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/selfReferentialDefaultNoStackOverflow.ts" }
TypeScript/tests/cases/compiler/nonNullableReduction.ts_0_526
// @strict: true // Repros from #43425 type Transform1<T> = ((value: string) => T) | (string extends T ? undefined : never); type Transform2<T> = string extends T ? ((value: string) => T) | undefined : (value: string) => T; function test<T>(f1: Transform1<T>, f2: Transform2<T>) { f1?.("hello"); f2?.("hello")...
{ "end_byte": 526, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nonNullableReduction.ts" }
TypeScript/tests/cases/compiler/jsFileCompilationHeritageClauseSyntaxOfClass.ts_0_61
// @allowJs: true // @filename: a.js class C implements D { }
{ "end_byte": 61, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationHeritageClauseSyntaxOfClass.ts" }
TypeScript/tests/cases/compiler/typeParameterAsBaseClass.ts_0_51
class C<T> extends T {} class C2<T> implements T {}
{ "end_byte": 51, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeParameterAsBaseClass.ts" }
TypeScript/tests/cases/compiler/collisionExportsRequireAndUninstantiatedModule.ts_0_262
//@module: amd export module require { // no error export interface I { } } export function foo(): require.I { return null; } export module exports { // no error export interface I { } } export function foo2(): exports.I { return null; }
{ "end_byte": 262, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionExportsRequireAndUninstantiatedModule.ts" }
TypeScript/tests/cases/compiler/contextualTypeCaching.ts_0_1069
// @strict: true // @noEmit: true // Repro from #52575 export interface Event<T> { callback: (response: T) => void; nested: { nestedCallback: (response: T) => void; } } export type CustomEvents = { a: Event<string> b: Event<number> }; declare function emit<T extends keyof CustomEvents>(t...
{ "end_byte": 1069, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTypeCaching.ts" }
TypeScript/tests/cases/compiler/doNotEmitDetachedComments.ts_3_230
@removeComments: true /* multi line comment */ var x = 10; // Single Line comment function foo() { } /* multi-line comment */ //======================== function bar() { } //========================
{ "end_byte": 230, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/doNotEmitDetachedComments.ts" }
TypeScript/tests/cases/compiler/typeofThisInMethodSignature.ts_0_138
// @strict: true // @noEmit: true // Repro from #54167 export class A { x = 1 a(x: typeof this.x): void {} } const a = new A().a(1);
{ "end_byte": 138, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeofThisInMethodSignature.ts" }
TypeScript/tests/cases/compiler/genericCallWithNonGenericArgs1.ts_0_39
function f<T>(x: any) { } f<any>(null)
{ "end_byte": 39, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericCallWithNonGenericArgs1.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.ts_3_44
@sourcemap: true var {x} = { x: 20 };
{ "end_byte": 44, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.ts" }
TypeScript/tests/cases/compiler/readonlyInDeclarationFile.ts_0_1350
// @target: es5 // @declaration: true interface Foo { readonly x: number; readonly [x: string]: Object; } class C { readonly [x: string]: Object; private readonly a1: number; protected readonly a2: number; public readonly a3: number; private get b1() { return 1 } protected get b2() { r...
{ "end_byte": 1350, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/readonlyInDeclarationFile.ts" }
TypeScript/tests/cases/compiler/aliasUsageInArray.ts_0_634
//@module: commonjs // @Filename: aliasUsageInArray_backbone.ts export class Model { public someData: string; } // @Filename: aliasUsageInArray_moduleA.ts import Backbone = require("./aliasUsageInArray_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } // @Filenam...
{ "end_byte": 634, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/aliasUsageInArray.ts" }
TypeScript/tests/cases/compiler/classMemberWithMissingIdentifier2.ts_0_60
class C { public {[name:string]:VariableDeclaration}; }
{ "end_byte": 60, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classMemberWithMissingIdentifier2.ts" }
TypeScript/tests/cases/compiler/moduleResolutionWithSuffixes_one_dirModuleWithIndex.ts_0_388
// moduleSuffixes has one entry and there's a matching dir with an index file. // @filename: /tsconfig.json { "compilerOptions": { "moduleResolution": "node", "traceResolution": true, "moduleSuffixes": [".ios"] } } // @filename: /index.ts import { ios } from "./foo"; // @filename: /foo/index.ios.ts export fun...
{ "end_byte": 388, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolutionWithSuffixes_one_dirModuleWithIndex.ts" }
TypeScript/tests/cases/compiler/widenToAny1.ts_1_146
function foo1<T>(f1: { x: T; y: T }): T { return undefined; } var z1: number = foo1({ x: undefined, y: "def" }); // Best common type is any
{ "end_byte": 146, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/widenToAny1.ts" }
TypeScript/tests/cases/compiler/gettersAndSettersTypesAgree.ts_0_400
class C { public get Foo() { return "foo";} // ok public set Foo(foo) {} // ok - type inferred from getter return statement public get Bar() { return "foo";} // ok public set Bar(bar:string) {} // ok - type must be declared } var o1 = {get Foo(){return 0;}, set Foo(val){}}; // ok - types agree (infere...
{ "end_byte": 400, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/gettersAndSettersTypesAgree.ts" }
TypeScript/tests/cases/compiler/numericIndexExpressions.ts_0_216
interface Numbers1 { 1: string; } interface Strings1 { '1': string; } var x: Numbers1; x[1] = 4; // error x['1'] = 4; // error var y: Strings1; y['1'] = 4; // should be error y[1] = 4; // should be error
{ "end_byte": 216, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/numericIndexExpressions.ts" }
TypeScript/tests/cases/compiler/asyncYieldStarContextualType.ts_0_1094
// @target: esnext // @noEmit: true // https://github.com/microsoft/TypeScript/issues/57903 interface Result<T, E> { [Symbol.iterator](): Generator<E, T, unknown> } type Book = { id: string; title: string; authorId: string }; type Author = { id: string; name: string }; type BookWithAuthor = Book & { author: Autho...
{ "end_byte": 1094, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/asyncYieldStarContextualType.ts" }
TypeScript/tests/cases/compiler/indexerConstraints.ts_0_555
interface A { a: number; } interface B extends A { b: number; } // Good case interface D { [s: string]: A; } interface D { [n: number]: B; } // Bad case interface E { [s: string]: B; } interface E { [n: number]: A; } // Inheritance interface F { [s: string]: B; } interface G extends F { [n: n...
{ "end_byte": 555, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/indexerConstraints.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationDebugger.ts_0_29
// @sourcemap: true debugger;
{ "end_byte": 29, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationDebugger.ts" }
TypeScript/tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts_0_242
//@noUnusedLocals:true //@noUnusedParameters:true var greeter = function (person: string, person2: string) { var unused = 20; var maker = function (child: string): void { var unused2 = 22; } person2 = "dummy value"; }
{ "end_byte": 242, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts" }
TypeScript/tests/cases/compiler/optionsCompositeWithIncrementalFalse.ts_0_69
// @composite: true // @incremental: false const x = "Hello World";
{ "end_byte": 69, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/optionsCompositeWithIncrementalFalse.ts" }
TypeScript/tests/cases/compiler/redeclarationOfVarWithGenericType.ts_0_55
var a1: { fn<T>(x: T): T }; var a1: { fn<T>(x: T): T };
{ "end_byte": 55, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/redeclarationOfVarWithGenericType.ts" }
TypeScript/tests/cases/compiler/declarationEmitTypeAliasWithTypeParameters1.ts_3_136
@declaration: true export type Bar<X, Y> = () => [X, Y]; export type Foo<Y> = Bar<any, Y>; export const y = (x: Foo<string>) => 1
{ "end_byte": 136, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitTypeAliasWithTypeParameters1.ts" }
TypeScript/tests/cases/compiler/classExpressionExtendingAbstractClass.ts_0_104
abstract class A { abstract foo(): void; } var C = class extends A { // no error reported! };
{ "end_byte": 104, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classExpressionExtendingAbstractClass.ts" }
TypeScript/tests/cases/compiler/typeArgumentInferenceApparentType1.ts_0_110
//@target: ES6 function method<T>(iterable: Iterable<T>): T { return; } var res: string = method("test");
{ "end_byte": 110, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeArgumentInferenceApparentType1.ts" }
TypeScript/tests/cases/compiler/scopeCheckStaticInitializer.ts_0_274
class X { static illegalBeforeProperty = X.data; static okBeforeMethod = X.method; static illegal2 = After.data; static illegal3 = After.method; static data = 13; static method() { } } class After { static data = 12; static method() { }; }
{ "end_byte": 274, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/scopeCheckStaticInitializer.ts" }
TypeScript/tests/cases/compiler/constEnumErrors.ts_0_620
// @lib: es5 const enum E { A } module E { var x = 1; } const enum E1 { // illegal case // forward reference to the element of the same enum X = Y, // forward reference to the element of the same enum Y = E1.Z, Y1 = E1["Z"] } const enum E2 { A } var y0 = E2[1] var name = "A"; var...
{ "end_byte": 620, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constEnumErrors.ts" }
TypeScript/tests/cases/compiler/forInStatement6.ts_0_46
var a: any; var expr: any; for (a in expr) { }
{ "end_byte": 46, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/forInStatement6.ts" }
TypeScript/tests/cases/compiler/moduleResolutionWithSymlinks.ts_0_1316
// When symlinked files are in node_modules, they are resolved with realpath; // so a linked file does not create a duplicate SourceFile of the real one. // @noImplicitReferences: true // @traceResolution: true // @fullEmitPaths: true // @filename: /src/library-a/index.ts // @symlink: /src/library-b/node_modules/libra...
{ "end_byte": 1316, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolutionWithSymlinks.ts" }
TypeScript/tests/cases/compiler/declarationEmitDestructuringOptionalBindingParametersInOverloads.ts_3_216
@declaration: true function foo([x, y, z] ?: [string, number, boolean]); function foo(...rest: any[]) { } function foo2( { x, y, z }?: { x: string; y: number; z: boolean }); function foo2(...rest: any[]) { }
{ "end_byte": 216, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitDestructuringOptionalBindingParametersInOverloads.ts" }
TypeScript/tests/cases/compiler/baseIndexSignatureResolution.ts_0_531
class Base { private a: string; } class Derived extends Base { private b: string; } // Note - commmenting "extends Foo" prevents the error interface Foo { [i: number]: Base; } interface FooOf<TBase extends Base> extends Foo { [i: number]: TBase; } var x: FooOf<Derived> = null; var y: Derived = x[0]; /* // Not...
{ "end_byte": 531, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/baseIndexSignatureResolution.ts" }
TypeScript/tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments2.ts_0_230
function f<T, U>(y: T, y1: U, p: (z: U) => T, p1: (x: T) => U): [T, U] { return [y, p1(y)]; } interface A { a: A; } interface B extends A { b; } var a: A, b: B; var d = f(a, b, x => x, x => x); // A => A not assignable to A => B
{ "end_byte": 230, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments2.ts" }
TypeScript/tests/cases/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts_3_168
ass A { blub = 6; } class B extends A { constructor(public x: number) { "use strict"; 'someStringForEgngInject'; super() } }
{ "end_byte": 168, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts" }
TypeScript/tests/cases/compiler/arrowFunctionParsingGenericInObject.ts_0_862
// @target: esnext const fn1 = () => ({ test: <T = undefined>(value: T): T => value, extraValue: () => {}, }) const fn1async = () => ({ test: async <T = undefined>(value: T): Promise<T> => value, extraValue: () => {}, }) const fn2 = () => ({ test: <T>(value: T): T => value, extraValue: () => {...
{ "end_byte": 862, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arrowFunctionParsingGenericInObject.ts" }
TypeScript/tests/cases/compiler/jsFileCompilationAbstractModifier.ts_0_73
// @allowJs: true // @filename: a.js abstract class c { abstract x; }
{ "end_byte": 73, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationAbstractModifier.ts" }
TypeScript/tests/cases/compiler/strictModeReservedWordInDestructuring.ts_3_308
se strict" var [public] = [1]; var { x: public } = { x: 1 }; var [[private]] = [["hello"]]; var { y: { s: static }, z: { o: { p: package } }} = { y: { s: 1 }, z: { o: { p: 'h' } } }; var { public, protected } = { public: 1, protected: 2 }; var { public: a, protected: b } = { public: 1, protected: 2 };
{ "end_byte": 308, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/strictModeReservedWordInDestructuring.ts" }
TypeScript/tests/cases/compiler/classImplementsClass3.ts_0_175
class A { foo(): number { return 1; } } class C implements A { foo() { return 1; } } class C2 extends A {} // no errors var c: C; var c2: C2; c = c2; c2 = c;
{ "end_byte": 175, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classImplementsClass3.ts" }
TypeScript/tests/cases/compiler/typedArrays-es6.ts_0_605
// @target: ES6 const float32Array = new Float32Array(1); [...float32Array]; const float64Array = new Float64Array(1); [...float64Array]; const int16Array = new Int16Array(1); [...int16Array]; const int32Array = new Int32Array(1); [...int32Array]; const int8Array = new Int8Array(1); [...int8Array]; const nodeList...
{ "end_byte": 605, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typedArrays-es6.ts" }
TypeScript/tests/cases/compiler/incorrectClassOverloadChain.ts_0_61
class C { foo(): string; foo(x): number; x = 1; }
{ "end_byte": 61, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/incorrectClassOverloadChain.ts" }
TypeScript/tests/cases/compiler/discriminableUnionWithIntersectedMembers.ts_0_388
// regression test for https://github.com/microsoft/TypeScript/issues/33243 type X = | { x: 'x', y: number } & { y: number } | { x: 'y', y: number, z?: boolean } & { y: number } // error const x: X = 4 as any as { x: 'x' | 'y', y: number }; type Y = | { x: 'x', y: number } | { x: 'y', y: number, z?: boolean }...
{ "end_byte": 388, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/discriminableUnionWithIntersectedMembers.ts" }
TypeScript/tests/cases/compiler/declarationEmitPreservesHasNoDefaultLibDirective.ts_0_264
// @declaration: true /// <reference no-default-lib="true"/> class Foo { public: string; } interface Array<T> {} interface Boolean {} interface Function {} interface IArguments {} interface Number {} interface Object {} interface RegExp {} interface String {}
{ "end_byte": 264, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitPreservesHasNoDefaultLibDirective.ts" }
TypeScript/tests/cases/compiler/moduleWithValuesAsType.ts_0_50
module A { var b = 1; } var a: A; // no error
{ "end_byte": 50, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleWithValuesAsType.ts" }
TypeScript/tests/cases/compiler/discriminateWithOptionalProperty1.ts_0_203
// @strict: true // @exactOptionalPropertyTypes: true, false // @noEmit: true type Box<T> = { done?: false } | { done: true; value: T }; declare const box: Box<number>; if (box.done) { box.value; }
{ "end_byte": 203, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/discriminateWithOptionalProperty1.ts" }
TypeScript/tests/cases/compiler/reverseInferenceInContextualInstantiation.ts_0_115
function compare<T>(a: T, b: T): number { return 0; } var x: number[]; x.sort(compare); // Error, but shouldn't be
{ "end_byte": 115, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reverseInferenceInContextualInstantiation.ts" }
TypeScript/tests/cases/compiler/pathMappingBasedModuleResolution_rootImport_aliasWithRoot_multipleAliases.ts_0_549
// @noImplicitReferences: true // @traceResolution: true // @allowJs: true // @filename: /root/import/foo.ts export function foo() {} // @filename: /root/client/bar.js export function bar() {} // @filename: /root/src/a.ts import { foo } from "/import/foo"; import { bar } from "/client/bar"; // @filename: /root/tsco...
{ "end_byte": 549, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/pathMappingBasedModuleResolution_rootImport_aliasWithRoot_multipleAliases.ts" }
TypeScript/tests/cases/compiler/incrementOnTypeParameter.ts_0_118
class C<T> { a: T; foo() { this.a++; for (var i: T, j = 0; j < 10; i++) { } } }
{ "end_byte": 118, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/incrementOnTypeParameter.ts" }
TypeScript/tests/cases/compiler/genericTypeAssertions4.ts_0_449
class A { foo() { return ""; } } class B extends A { bar() { return 1; } } class C extends A { baz() { return 1; } } var a: A; var b: B; var c: C; function foo2<T extends A>(x: T) { var y = x; y = a; // error: cannot convert A to T y = b; // error: cannot convert B to T y = c; // error: ...
{ "end_byte": 449, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericTypeAssertions4.ts" }
TypeScript/tests/cases/compiler/narrowingUnionWithBang.ts_0_1839
// @strict: true type WorkingType = { thing?: { name: 'Error1', message: string } | { name: 'Error2', message: string } | { name: 'Error3', message: string } | { name: 'Error4', message: string } | { name: 'Error5', message: string } | { name: 'Error6', message: string } | { name: 'Error...
{ "end_byte": 1839, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowingUnionWithBang.ts" }
TypeScript/tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.ts_0_331
// 3.8.4 Assignment Compatibility interface Applicable { apply(blah: any); // also works for 'apply' } var x: Applicable; // Should fail x = ''; x = ['']; x = 4; x = {}; // Should work function f() { }; x = f; function fn(c: Applicable) { } // Should Fail fn(''); fn(['']); fn(4); fn({}); // Should work fn(...
{ "end_byte": 331, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.ts" }
TypeScript/tests/cases/compiler/sourceMapWithNonCaseSensitiveFileNames.ts_0_369
// @outFile: testfiles/fooResult.js // @sourcemap: true // @useCaseSensitiveFileNames: false // @Filename: testFiles/app.ts // Note in the out result we are using same folder name only different in casing // Since this is non case sensitive, the relative paths should be just app.ts and app2.ts in the sourcemap class c ...
{ "end_byte": 369, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapWithNonCaseSensitiveFileNames.ts" }
TypeScript/tests/cases/compiler/strictModeReservedWord.ts_3_651
t let = 10; function foo() { "use strict" var public = 10; var static = "hi"; let let = "blah"; var package = "hello" function package() { } function bar(private, implements, let) { } function baz<implements, protected>() { } function barn(cb: (private, public, package) => void) { }...
{ "end_byte": 651, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/strictModeReservedWord.ts" }
TypeScript/tests/cases/compiler/isolatedModulesPlainFile-System.ts_0_109
// @target: es5 // @module: system // @isolatedModules: true declare function run(a: number): void; run(1);
{ "end_byte": 109, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/isolatedModulesPlainFile-System.ts" }
TypeScript/tests/cases/compiler/errorForUsingPropertyOfTypeAsType01.ts_0_720
namespace Test1 { export interface Foo { bar: string; } var x: Foo.bar = ""; var y: Test1.Foo.bar = ""; } namespace Test2 { export class Foo { bar: string; } var x: Foo.bar = ""; var y: Test2.Foo.bar = ""; } namespace Test3 { export type Foo = { bar: strin...
{ "end_byte": 720, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/errorForUsingPropertyOfTypeAsType01.ts" }
TypeScript/tests/cases/compiler/sourceMapValidationDestructuringForOfObjectBindingPatternDefaultValues2.ts_0_5058
// @lib: es5 // @sourcemap: true declare var console: { log(msg: any): void; } interface Robot { name: string; skill: string; } interface MultiRobot { name: string; skills: { primary: string; secondary: string; }; } let robots: Robot[] = [{ name: "mower", skill: "mowing" }, { n...
{ "end_byte": 5058, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationDestructuringForOfObjectBindingPatternDefaultValues2.ts" }
TypeScript/tests/cases/compiler/awaitedTypeNoLib.ts_0_720
// @strictFunctionTypes: true // @noLib: true type NotPromise<T> = T extends Thenable<unknown> ? T : T extends PromiseLike<unknown> ? never : T; type Receiver<T> = (value: NotPromise<T>) => void; class Thenable<T> { then(a: Receiver<T>) {} private handleResolve<TResult>( result: NotPromise<TResult> ...
{ "end_byte": 720, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/awaitedTypeNoLib.ts" }
TypeScript/tests/cases/compiler/contextuallyTypedParametersWithInitializers4.ts_0_280
// @strict: true // @noEmit: true declare function test< TContext, TMethods extends Record<string, (ctx: TContext, ...args: (1 | 2)[]) => unknown>, >(context: TContext, methods: TMethods): void; test( { count: 0, }, { checkLimit: (ctx, max = 3) => {}, }, );
{ "end_byte": 280, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextuallyTypedParametersWithInitializers4.ts" }
TypeScript/tests/cases/compiler/classExpressionWithStaticProperties3.ts_0_245
// @target: es5 // @lib: es5 declare var console: any; const arr: {y(): number}[] = []; for (let i = 0; i < 3; i++) { arr.push(class C { static x = i; static y = () => C.x * 2; }); } arr.forEach(C => console.log(C.y()));
{ "end_byte": 245, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classExpressionWithStaticProperties3.ts" }
TypeScript/tests/cases/compiler/functionOverloadsOnGenericArity2.ts_0_109
interface I { then(p: string): string; then<U>(p: string): string; then<U, T>(p: string): Date; }
{ "end_byte": 109, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloadsOnGenericArity2.ts" }
TypeScript/tests/cases/compiler/decrementAndIncrementOperators.ts_0_222
var x = 0; // errors 1 ++; (1)++; (1)--; ++(1); --(1); (1 + 2)++; (1 + 2)--; ++(1 + 2); --(1 + 2); (x + x)++; (x + x)--; ++(x + x); --(x + x); //OK x++; x--; ++x; --x; (x)++; --(x); ((x))++; ((x))--; x[x++]++;
{ "end_byte": 222, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/decrementAndIncrementOperators.ts" }
TypeScript/tests/cases/compiler/shebangError.ts_0_87
// @lib: es5 var foo = 'Shebang is only allowed on the first line'; #!/usr/bin/env node
{ "end_byte": 87, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/shebangError.ts" }
TypeScript/tests/cases/compiler/typeOfThisInStatics.ts_0_126
class C { static foo() { var r = this; } static get x() { var r = this; return 1; } }
{ "end_byte": 126, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeOfThisInStatics.ts" }
TypeScript/tests/cases/compiler/superPropertyAccess_ES5.ts_0_539
// @target: ES5 class MyBase { getValue(): number { return 1; } get value(): number { return 1; } } class MyDerived extends MyBase { constructor() { super(); const f1 = super.getValue(); const f2 = super.value; } } var d = new MyDerived(); var f3 = d.value; class A { private _property: stri...
{ "end_byte": 539, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/superPropertyAccess_ES5.ts" }
TypeScript/tests/cases/compiler/instantiatedReturnTypeContravariance.ts_0_159
interface B<T> { name: string; x(): T; } class c { foo(): B<void> { return null; } } class d extends c { foo(): B<number> { return null; } }
{ "end_byte": 159, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/instantiatedReturnTypeContravariance.ts" }
TypeScript/tests/cases/compiler/exportInterfaceClassAndValue.ts_0_73
export const foo = 1 export declare class foo {} export interface foo {}
{ "end_byte": 73, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportInterfaceClassAndValue.ts" }
TypeScript/tests/cases/compiler/es6ExportEquals.ts_0_76
// @target: es6 // @declaration: true export function f() { } export = f;
{ "end_byte": 76, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ExportEquals.ts" }
TypeScript/tests/cases/compiler/contextualSignatureInArrayElementLibEs5.ts_0_288
// @strict: true // @noEmit: true // @lib: es5 // See: https://github.com/microsoft/TypeScript/pull/53280#discussion_r1138684984 declare function test( arg: Record<string, (arg: string) => void> | Array<(arg: number) => void> ): void; test([ (arg) => { arg; // number }, ]);
{ "end_byte": 288, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualSignatureInArrayElementLibEs5.ts" }
TypeScript/tests/cases/compiler/es6ModuleModuleDeclaration.ts_0_506
// @target: ES6 export module m1 { export var a = 10; var b = 10; export module innerExportedModule { export var k = 10; var l = 10; } export module innerNonExportedModule { export var x = 10; var y = 10; } } module m2 { export var a = 10; var b = 10; ...
{ "end_byte": 506, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ModuleModuleDeclaration.ts" }
TypeScript/tests/cases/compiler/jsxEmptyExpressionNotCountedAsChild2.tsx_0_642
// @strict: true // @noEmit: true // @jsx: preserve // repro from #38108 export {} declare global { namespace JSX { type Element = any; interface ElementAttributesProperty { __properties__: {}; } interface IntrinsicElements { [key: string]: string; ...
{ "end_byte": 642, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsxEmptyExpressionNotCountedAsChild2.tsx" }
TypeScript/tests/cases/compiler/noMappedGetSet.ts_0_47
type OH_NO = { get [K in WAT](): string };
{ "end_byte": 47, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noMappedGetSet.ts" }
TypeScript/tests/cases/compiler/flowInFinally1.ts_0_166
// @strictNullChecks: true class A { constructor() { } method() { } } let a: A | null = null; try { a = new A(); } finally { if (a) { a.method(); } }
{ "end_byte": 166, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/flowInFinally1.ts" }