_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/compiler/privacyFunctionReturnTypeDeclFile.ts_22389_32847
module publicModuleInGlobal { class privateClass { } export class publicClass { } module privateModule { class privateClass { } export class publicClass { } export interface publicInterfaceWithPrivateParmeterTypes { new (): privateClass; ...
{ "end_byte": 32847, "start_byte": 22389, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyFunctionReturnTypeDeclFile.ts" }
TypeScript/tests/cases/compiler/privacyFunctionReturnTypeDeclFile.ts_32853_37742
class privateClassWithWithPrivateParmeterTypes { static myPublicStaticMethod(): privateClass { return null; } private static myPrivateStaticMethod(): privateClass { return null; } myPublicMethod(): privateClass { return null; } ...
{ "end_byte": 37742, "start_byte": 32853, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyFunctionReturnTypeDeclFile.ts" }
TypeScript/tests/cases/compiler/newMissingIdentifier.ts_0_16
var x = new ();
{ "end_byte": 16, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/newMissingIdentifier.ts" }
TypeScript/tests/cases/compiler/contextualTyping24.ts_0_101
var foo:(a:{():number; (i:number):number; })=>number; foo = function(this: void, a:string){return 5};
{ "end_byte": 101, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTyping24.ts" }
TypeScript/tests/cases/compiler/avoidListingPropertiesForTypesWithOnlyCallOrConstructSignatures.ts_0_138
interface Dog { barkable: true } declare function getRover(): Dog export let x:Dog = getRover; // export let x: Dog = getRover;
{ "end_byte": 138, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/avoidListingPropertiesForTypesWithOnlyCallOrConstructSignatures.ts" }
TypeScript/tests/cases/compiler/consistentAliasVsNonAliasRecordBehavior.ts_0_1122
// TODO: FIXME: All the below cases labeled `no error` _should be an error_, and are only prevented from so being // by incorrect variance-based relationships // Ref: https://github.com/Microsoft/TypeScript/issues/29698 type Record2<K extends keyof any, T> = { [P in K]: T; }; function defaultRecord(x: Record<'a',...
{ "end_byte": 1122, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/consistentAliasVsNonAliasRecordBehavior.ts" }
TypeScript/tests/cases/compiler/incrementOnNullAssertion.ts_0_246
// @strict: true interface Dictionary<T> { [myFavouriteType: string]: T | undefined } const x = 'bar' let foo: Dictionary<number> = {} if (foo[x] === undefined) { foo[x] = 1 } else { let nu = foo[x] let n = foo[x] foo[x]!++ }
{ "end_byte": 246, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/incrementOnNullAssertion.ts" }
TypeScript/tests/cases/compiler/moduleMemberWithoutTypeAnnotation2.ts_0_367
module TypeScript { export module CompilerDiagnostics { export interface IDiagnosticWriter { Alert(output: string): void; } export var diagnosticWriter = null; export function Alert(output: string) { if (diagnosticWriter) { diagnosticWriter....
{ "end_byte": 367, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleMemberWithoutTypeAnnotation2.ts" }
TypeScript/tests/cases/compiler/contextuallyTypedParametersWithQuestionToken.ts_0_395
// @strict: true // @noEmit: true // https://github.com/microsoft/TypeScript/issues/54948 function acceptNum(num: number) {} const f1: (a: string, b: number) => void = function self(a, b?) { acceptNum(b); // error self(""); self("", undefined); }; const f2: (a: string, b: number) => void = function self(a, b?...
{ "end_byte": 395, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextuallyTypedParametersWithQuestionToken.ts" }
TypeScript/tests/cases/compiler/breakNotInIterationOrSwitchStatement1.ts_0_6
break;
{ "end_byte": 6, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/breakNotInIterationOrSwitchStatement1.ts" }
TypeScript/tests/cases/compiler/modulePrologueES6.ts_0_66
// @module: es6 // @target: es6 "use strict"; export class Foo {}
{ "end_byte": 66, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/modulePrologueES6.ts" }
TypeScript/tests/cases/compiler/parseTypes.ts_1_212
var x = <() => number>null; var y = <{(): number; }>null; var z = <{new(): number; }>null var w = <{[x:number]: number; }>null function f() { return 3 }; function g(s: string) { true }; y=f; y=g; x=g; w=g; z=g;
{ "end_byte": 212, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parseTypes.ts" }
TypeScript/tests/cases/compiler/commentsMultiModuleSingleFile.ts_0_380
// @target: ES5 // @declaration: true // @removeComments: false /** this is multi declare module*/ module multiM { /** class b*/ export class b { } // class d export class d { } } /// this is multi module 2 module multiM { /** class c comment*/ export class c { } /// class e ...
{ "end_byte": 380, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentsMultiModuleSingleFile.ts" }
TypeScript/tests/cases/compiler/modifiersOnInterfaceIndexSignature1.ts_0_45
interface I { public [a: string]: number; }
{ "end_byte": 45, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/modifiersOnInterfaceIndexSignature1.ts" }
TypeScript/tests/cases/compiler/numericLiteralsWithTrailingDecimalPoints02.ts_0_803
// @lib: es5 // @removeComments: true 1..toString(); 1.0.toString(); 1.toString(); 1.+2.0 + 3. ; // Preserve whitespace where important for JS compatibility var i: number = 1; var test1 = i.toString(); var test2 = 2.toString(); var test3 = 3 .toString(); var test4 = 3 .toString(); var test5 = 3 .toString(); var te...
{ "end_byte": 803, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/numericLiteralsWithTrailingDecimalPoints02.ts" }
TypeScript/tests/cases/compiler/declarationEmitNameConflicts.ts_0_1256
// @declaration: true // @module: commonjs // @Filename: declarationEmit_nameConflicts_1.ts module f { export class c { } } export = f; // @Filename: declarationEmit_nameConflicts_0.ts import im = require('./declarationEmit_nameConflicts_1'); export module M { export function f() { } export class C { } exp...
{ "end_byte": 1256, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitNameConflicts.ts" }
TypeScript/tests/cases/compiler/optionsSourcemapInlineSourcesSourceRoot.ts_0_78
// @sourcemap: true // @inlineSources: true // @sourceRoot: local var a = 10;
{ "end_byte": 78, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/optionsSourcemapInlineSourcesSourceRoot.ts" }
TypeScript/tests/cases/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts_0_398
// @declaration: true export enum MouseButton { LEFT_BUTTON = 1, RIGHT_BUTTON = 2, MIDDLE_BUTTON = 4, XBUTTON1_BUTTON = 5, XBUTTON2_BUTTON = 6, NO_BUTTON = 0, } export const DOMMouseButton = { '-1': MouseButton.NO_BUTTON, "0": MouseButton.LEFT_BUTTON, "1": MouseButton.MIDDLE_BUTTON, "2": MouseButton.RIGHT_BU...
{ "end_byte": 398, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts" }
TypeScript/tests/cases/compiler/nonConflictingRecursiveBaseTypeMembers.ts_0_127
interface A<T> { x: C<T> } interface B<T> { x: C<T> } interface C<T> extends A<T>, B<T> { } // Should not be an error
{ "end_byte": 127, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nonConflictingRecursiveBaseTypeMembers.ts" }
TypeScript/tests/cases/compiler/nonIdenticalTypeConstraints.ts_0_498
class Different { a: number; b: string; c: boolean; } class Foo<T extends Function> { n: T; } interface Foo<T extends Different> { y: T; } interface Qux<T extends Different> { y: T; } class Qux<T extends Function> { n: T; } class Bar<T extends Function> { n: T; } interface Bar<T extend...
{ "end_byte": 498, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nonIdenticalTypeConstraints.ts" }
TypeScript/tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts_0_108
type TreeNode = { name: string; parent: TreeNode; } var nodes: TreeNode[]; nodes.map(n => n.name);
{ "end_byte": 108, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts" }
TypeScript/tests/cases/compiler/recur1.ts_0_133
var salt:any = new salt.pepper(); salt.pepper = function() {} var cobalt = new cobalt.pitch(); cobalt.pitch = function() {}
{ "end_byte": 133, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recur1.ts" }
TypeScript/tests/cases/compiler/exportEqualsCommonJs.ts_0_50
// @module: commonjs export = { ["hi"]: "there" };
{ "end_byte": 50, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportEqualsCommonJs.ts" }
TypeScript/tests/cases/compiler/exportDefaultAsyncFunction2.ts_0_614
// @target: es6 // @filename: asyncawait.ts export function async<T>(...args: any[]): any { } export function await(...args: any[]): any { } // @filename: a.ts import { async, await } from 'asyncawait'; export default async(() => await(Promise.resolve(1))); // @filename: b.ts export default async () => { return 0; }...
{ "end_byte": 614, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportDefaultAsyncFunction2.ts" }
TypeScript/tests/cases/compiler/shadowingViaLocalValueOrBindingElement.ts_0_244
if (true) { let x; if (true) { var x = 0; // Error var { x = 0 } = { x: 0 }; // Error var { x: x = 0 } = { x: 0 }; // Error var { x } = { x: 0 }; // Error var { x: x } = { x: 0 }; // Error } }
{ "end_byte": 244, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/shadowingViaLocalValueOrBindingElement.ts" }
TypeScript/tests/cases/compiler/throwWithoutNewLine2.ts_0_8
throw a;
{ "end_byte": 8, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/throwWithoutNewLine2.ts" }
TypeScript/tests/cases/compiler/assignmentCompatability4.ts_0_336
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:number;};; export var __val__aa = aa; } __test2__.__val__aa = __tes...
{ "end_byte": 336, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatability4.ts" }
TypeScript/tests/cases/compiler/objectLiteralFreshnessWithSpread.ts_0_107
let x = { b: 1, extra: 2 } let xx: { a, b } = { a: 1, ...x, z: 3 } // error for 'z', no error for 'extra'
{ "end_byte": 107, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectLiteralFreshnessWithSpread.ts" }
TypeScript/tests/cases/compiler/pathMappingBasedModuleResolution6_classic.ts_0_467
// @module: amd // @traceResolution: true // @filename: c:/root/src/tsconfig.json { "compilerOptions": { "rootDirs": [ ".", "../generated/src" ] } } // @filename: c:/root/src/file1.ts import {x} from "./project/file3"; declare function use(x: string); use(x.toExponentia...
{ "end_byte": 467, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/pathMappingBasedModuleResolution6_classic.ts" }
TypeScript/tests/cases/compiler/sourceMap-Comments2.ts_0_342
// @target: ES5 // @sourcemap: true function foo(str: string, num: number): void { return; } /** * some sort of block quote */ function bar(str: string, num: number): void { return; } // some sort of comment function baz(str: string, num: number): void { return; } function qat(str: string, num: number)...
{ "end_byte": 342, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMap-Comments2.ts" }
TypeScript/tests/cases/compiler/mergedEnumDeclarationCodeGen.ts_0_48
enum E { a, b = a } enum E { c = a }
{ "end_byte": 48, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mergedEnumDeclarationCodeGen.ts" }
TypeScript/tests/cases/compiler/contextualTypeLogicalOr.ts_0_366
// Repro from #18005 let x = 123; var a = x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || x && [1, 2, 3, 4] || ...
{ "end_byte": 366, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTypeLogicalOr.ts" }
TypeScript/tests/cases/compiler/recursiveFunctionTypes1.ts_0_43
class C { static g(t: typeof C.g){ } }
{ "end_byte": 43, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveFunctionTypes1.ts" }
TypeScript/tests/cases/compiler/anyIndexedAccessArrayNoException.ts_0_16
var x: any[[]];
{ "end_byte": 16, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/anyIndexedAccessArrayNoException.ts" }
TypeScript/tests/cases/compiler/aliasAssignments.ts_0_297
//@module: commonjs // @Filename: aliasAssignments_moduleA.ts export class someClass { public someData: string; } // @Filename: aliasAssignments_1.ts import moduleA = require("./aliasAssignments_moduleA"); var x = moduleA; x = 1; // Should be error var y = 1; y = moduleA; // should be error
{ "end_byte": 297, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/aliasAssignments.ts" }
TypeScript/tests/cases/compiler/mergedDeclarationExports.ts_0_458
// OK -- one is type, one is value interface b {} export const b = 1; // OK -- one is a type, one is a namespace, one is a value. type t = 0; namespace t { interface I {} } export const t = 0; // Should get errors if they have some meaning in common. // both types interface c {} export interface c {} // both types ...
{ "end_byte": 458, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mergedDeclarationExports.ts" }
TypeScript/tests/cases/compiler/moduleNodeImportRequireEmit.ts_0_308
// @target: es5,es2016,es2020,esnext // @module: nodenext // @filename: package.json { "type": "module" } // @filename: mod.d.ts declare module "foo"; // @filename: index.ts /// <reference path="./mod.d.ts" /> // This should emit a call to createRequire(import.meta.url) import foo = require("foo"); foo;
{ "end_byte": 308, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleNodeImportRequireEmit.ts" }
TypeScript/tests/cases/compiler/continueInIterationStatement4.ts_0_40
for (var i in something) { continue; }
{ "end_byte": 40, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/continueInIterationStatement4.ts" }
TypeScript/tests/cases/compiler/declarationEmitExactOptionalPropertyTypesNodeNotReused.ts_0_481
// @declaration: true // @strict: true // @exactOptionalPropertyTypes: true,false type InexactOptionals<A> = { [K in keyof A as undefined extends A[K] ? K : never]?: undefined extends A[K] ? A[K] | undefined : A[K]; } & { [K in keyof A as undefined extends A[K] ? never : K]: A[K]; }; type In = { fo...
{ "end_byte": 481, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitExactOptionalPropertyTypesNodeNotReused.ts" }
TypeScript/tests/cases/compiler/stringHasStringValuedNumericIndexer.ts_0_24
var str: string = ""[0];
{ "end_byte": 24, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/stringHasStringValuedNumericIndexer.ts" }
TypeScript/tests/cases/compiler/divergentAccessorsTypes1.ts_0_1216
// @strict: true // @target: esnext class Test1 { get foo(): string { return "" } set foo(s: string | number) { let a = s as string; let b = s as number; } get bar(): string | number { return "" } set bar(s: string | number | boolean) { } } interface Test2 { get foo(): str...
{ "end_byte": 1216, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/divergentAccessorsTypes1.ts" }
TypeScript/tests/cases/compiler/specializedInheritedConstructors1.ts_0_368
interface ViewOptions<TModel> { model: TModel; } class View<TModel> { constructor(options: ViewOptions<TModel>) { } model: TModel; } class Model { } class MyView extends View<Model> { } var m: ViewOptions<Model> = { model: new Model() }; var aView = new View({ model: new Model() }); var aView2 = new Vie...
{ "end_byte": 368, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/specializedInheritedConstructors1.ts" }
TypeScript/tests/cases/compiler/continueStatementInternalComments.ts_0_53
foo: for (;;) { /*1*/ continue /*2*/ foo /*3*/; }
{ "end_byte": 53, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/continueStatementInternalComments.ts" }
TypeScript/tests/cases/compiler/checkSuperCallBeforeThisAccessing1.ts_3_175
ass Based { } class Derived extends Based { public x: number; constructor() { super(); this; this.x = 10; var that = this; } }
{ "end_byte": 175, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/checkSuperCallBeforeThisAccessing1.ts" }
TypeScript/tests/cases/compiler/constEnumMergingWithValues5.ts_0_114
//@module: amd //@filename: m1.ts //@preserveConstEnums: true module foo { const enum E { X } } export = foo
{ "end_byte": 114, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constEnumMergingWithValues5.ts" }
TypeScript/tests/cases/compiler/es6ExportDefaultFunctionDeclaration.ts_0_71
// @target: es6 // @declaration: true export default function f() { }
{ "end_byte": 71, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ExportDefaultFunctionDeclaration.ts" }
TypeScript/tests/cases/compiler/limitDeepInstantiations.ts_0_139
// Repro from #14837 type Foo<T extends "true", B> = { "true": Foo<T, Foo<T, B>> }[T]; let f1: Foo<"true", {}>; let f2: Foo<"false", {}>;
{ "end_byte": 139, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/limitDeepInstantiations.ts" }
TypeScript/tests/cases/compiler/unionTypeWithIndexAndTuple.ts_0_114
interface I { [index: number]: any; someOtherProperty: number; } function f(args: ["a"] | I) { } f(["a"]);
{ "end_byte": 114, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unionTypeWithIndexAndTuple.ts" }
TypeScript/tests/cases/compiler/exportDeclarationInInternalModule.ts_0_276
// @target: es5 // @module: commonjs // @declaration: true class Bbb { } class Aaa extends Bbb { } module Aaa { export class SomeType { } } module Bbb { export class SomeType { } export * from Aaa; // this line causes the nullref } var a: Bbb.SomeType;
{ "end_byte": 276, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportDeclarationInInternalModule.ts" }
TypeScript/tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors4.ts_4_632
false ? (arg?: number = 0) => 47 : null; false ? ((arg?: number = 0) => 57) : null; false ? null : (arg?: number = 0) => 67; ((arg?:number = 1) => 0) + '' + ((arg?:number = 2) => 106); foo( (a) => 110, ((a) => 111), (a) => { return 112; }, (a? ) => ...
{ "end_byte": 632, "start_byte": 4, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors4.ts" }
TypeScript/tests/cases/compiler/superPropertyAccessInComputedPropertiesOfNestedType_ES6.ts_0_221
// @target: ES6 class A { foo() { return 1; } } class B extends A { foo() { return 2; } bar() { return class { [super.foo()]() { return 100; } } } }
{ "end_byte": 221, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/superPropertyAccessInComputedPropertiesOfNestedType_ES6.ts" }
TypeScript/tests/cases/compiler/propertyOrdering2.ts_0_115
class Foo { constructor(public x, y) { } foo() { var a = this.x; return this.y; } }
{ "end_byte": 115, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/propertyOrdering2.ts" }
TypeScript/tests/cases/compiler/declarationEmitKeywordDestructuring.ts_0_495
// @declaration: true type P = { enum: boolean; function: boolean; abstract: boolean; async: boolean; await: boolean; one: boolean; }; function f1({ enum: _enum, ...rest }: P) { return rest; } function f2({ function: _function, ...rest }: P) { return rest; } function f3({ abstract: _...
{ "end_byte": 495, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitKeywordDestructuring.ts" }
TypeScript/tests/cases/compiler/mixingFunctionAndAmbientModule1.ts_0_695
module A { declare module My { export var x: number; } function My(s: string) { } } module B { declare module My { export var x: number; } function My(s: boolean); function My(s: any) { } } module C { declare module My { export var x: number; } declare f...
{ "end_byte": 695, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mixingFunctionAndAmbientModule1.ts" }
TypeScript/tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts_3_304
@target: es5 function f0(a, [a, [b]], {b}) { } function f1([a, a]) { } function f2({b}, {b}) { } function f3([c,[c],[[c]]]) { } function f4({d, d:{d}}) { } function f5({e, e: {e}}, {e}, [d,e, [[e]]], ...e) { } function f6([f, ...f]) { } function f7(a, func = (a) => { return 1 }) { } // not error
{ "end_byte": 304, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts" }
TypeScript/tests/cases/compiler/metadataOfEventAlias.ts_0_359
// @experimentalDecorators: true // @emitDecoratorMetadata: true // @target: es5 // @skipLibCheck: true // @includeBuiltFile: lib.d.ts // @filename: event.ts export interface Event { title: string }; // @filename: test.ts import { Event } from './event'; function Input(target: any, key: string): void { } export class...
{ "end_byte": 359, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/metadataOfEventAlias.ts" }
TypeScript/tests/cases/compiler/asyncFunctionContextuallyTypedReturns.ts_0_975
// @target: es6 // @strict: true declare function f(cb: (v: boolean) => [0] | PromiseLike<[0]>): void; f(v => v ? [0] : Promise.reject()); f(async v => v ? [0] : Promise.reject()); declare function g(cb: (v: boolean) => "contextuallyTypable" | PromiseLike<"contextuallyTypable">): void; g(v => v ? "contextuallyTypable"...
{ "end_byte": 975, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/asyncFunctionContextuallyTypedReturns.ts" }
TypeScript/tests/cases/compiler/importTypeResolutionJSDocEOF.ts_0_233
// @allowJs: true // @noEmit: true // @checkJs: true // @filename: interfaces.d.ts export interface Bar { prop: string } // @filename: usage.js /** @type {Bar} */ export let bar; /** @typedef {import('./interfaces').Bar} Bar */
{ "end_byte": 233, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importTypeResolutionJSDocEOF.ts" }
TypeScript/tests/cases/compiler/inferenceUnionOfObjectsMappedContextualType.ts_0_500
// @strict: true type Entity = { someDate: Date | null; } & ({ id: string; } | { id: number; }) type RowRendererMeta<TInput extends {}> = { [key in keyof TInput]: { key: key; caption: string; formatter?: (value: TInput[key]) => string; }; } type RowRenderer<TInput extends {}> = RowRendererMeta<TInput>[keyof R...
{ "end_byte": 500, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inferenceUnionOfObjectsMappedContextualType.ts" }
TypeScript/tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExport.ts_0_224
//@module: commonjs // @declaration: true export module a { export module b { export interface I { foo(); } } } export module c { import b = a.b; export var x: b.I; x.foo(); }
{ "end_byte": 224, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExport.ts" }
TypeScript/tests/cases/compiler/unusedParameterProperty2.ts_0_126
//@noUnusedLocals:true //@noUnusedParameters:true class A { constructor(private used) { let foge = used; } }
{ "end_byte": 126, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedParameterProperty2.ts" }
TypeScript/tests/cases/compiler/nearbyIdenticalGenericLambdasAssignable.ts_0_743
declare const fA: <T>() => { v: T }; const fB = <T>() => { return { v: '' as any as T }; }; const fC = <T>() => { return {} as any as { v: T }; }; // Hover display is identical on all of these type TA = typeof fA; type TB = typeof fB; type TC = typeof fC; type TL = <T>() => { v: T }; declare function accA(x:...
{ "end_byte": 743, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nearbyIdenticalGenericLambdasAssignable.ts" }
TypeScript/tests/cases/compiler/coAndContraVariantInferences.ts_0_808
// @strict: true // @declaration: true type A = { kind: 'a' }; type B = { kind: 'b' }; declare const a: A; declare const b: B; declare function fab(arg: A | B): void; declare function foo<T>(x: { kind: T }, f: (arg: { kind: T }) => void): void; foo(a, fab); foo(b, fab); // Repro from #45603 interface Action<TNam...
{ "end_byte": 808, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/coAndContraVariantInferences.ts" }
TypeScript/tests/cases/compiler/continueNotInIterationStatement1.ts_0_9
continue;
{ "end_byte": 9, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/continueNotInIterationStatement1.ts" }
TypeScript/tests/cases/compiler/internalAliasEnumInsideLocalModuleWithExport.ts_0_232
//@module: commonjs // @declaration: true export module a { export enum weekend { Friday, Saturday, Sunday } } export module c { export import b = a.weekend; export var bVal: b = b.Sunday; }
{ "end_byte": 232, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/internalAliasEnumInsideLocalModuleWithExport.ts" }
TypeScript/tests/cases/compiler/generatorES6_2.ts_0_70
// @target: es6 class C { public * foo() { yield 1 } }
{ "end_byte": 70, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/generatorES6_2.ts" }
TypeScript/tests/cases/compiler/unusedVariablesWithUnderscoreInForOfLoop.ts_0_557
// @noUnusedLocals: true function t1() { for (const [_a, b] of [['key', 1]]) { console.log(b); } for (const [a, _b] of [['key', 1]]) { console.log(a); } for (const [_a, _b] of [['key', 1]]) {} } function t2() { for (const [_a, b] of [['key', 1]]) {} for (const [a, _b] o...
{ "end_byte": 557, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedVariablesWithUnderscoreInForOfLoop.ts" }
TypeScript/tests/cases/compiler/derivedTypeIncompatibleSignatures.ts_0_577
interface A { (a: string): string; } interface B extends A { (a: string): number; // Number is not a subtype of string. Should error. } interface C { new (a: string): string; } interface D extends C { new (a: string): number; // Number is not a subtype of string. Should error. } interface E { ...
{ "end_byte": 577, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/derivedTypeIncompatibleSignatures.ts" }
TypeScript/tests/cases/compiler/promiseTypeInference.ts_0_344
declare class CPromise<T> { then<U>(success?: (value: T) => CPromise<U>): CPromise<U>; } interface IPromise<T> { then<U>(success?: (value: T) => IPromise<U>): IPromise<U>; } declare function load(name: string): CPromise<string>; declare function convert(s: string): IPromise<number>; var $$x = load("something")...
{ "end_byte": 344, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/promiseTypeInference.ts" }
TypeScript/tests/cases/compiler/systemExportAssignment3.ts_0_192
// @target: es5 // @module: system // @filename: modules.d.ts declare module "a" { var a: number; export = a; // OK, in ambient context } // @filename: b.ts import * as a from "a";
{ "end_byte": 192, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/systemExportAssignment3.ts" }
TypeScript/tests/cases/compiler/lateBoundFunctionMemberAssignmentDeclarations.ts_0_200
// @declaration: true // @target: es6 // @strict: true // @filename: index.ts export function foo() {} foo.bar = 12; const _private = Symbol(); foo[_private] = "ok"; const x: string = foo[_private];
{ "end_byte": 200, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/lateBoundFunctionMemberAssignmentDeclarations.ts" }
TypeScript/tests/cases/compiler/declFileTypeAnnotationUnionType.ts_0_492
// @target: ES5 // @declaration: true class c { private p: string; } module m { export class c { private q: string; } export class g<T> { private r: string; } } class g<T> { private s: string; } // Just the name var k: c | m.c = new c() || new m.c(); var l = new c() || new m.c(...
{ "end_byte": 492, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileTypeAnnotationUnionType.ts" }
TypeScript/tests/cases/compiler/deprecatedCompilerOptions2.ts_0_476
// @typeScriptVersion: 5.0 // @filename: /foo/tsconfig.json { "compilerOptions": { "module": "amd", "target": "ES3", "noImplicitUseStrict": true, "keyofStringsOnly": true, "suppressExcessPropertyErrors": true, "suppressImplicitAnyIndexErrors": true, "noStrictG...
{ "end_byte": 476, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/deprecatedCompilerOptions2.ts" }
TypeScript/tests/cases/compiler/classPropInitializationInferenceWithElementAccess.ts_0_259
// @noEmit: true // @strict: true // repro #49339 export class Cls { x; y; z; 0; constructor(seed: number) { this['x'] = [seed]; this['y'] = { seed }; this['z'] = `${seed}`; this[0] = [seed]; } }
{ "end_byte": 259, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classPropInitializationInferenceWithElementAccess.ts" }
TypeScript/tests/cases/compiler/alwaysStrictModule6.ts_3_80
@alwaysStrict: true // @target: es5 // Targeting ES5 export const a = 1;
{ "end_byte": 80, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/alwaysStrictModule6.ts" }
TypeScript/tests/cases/compiler/noCollisionThisExpressionAndVarInGlobal.ts_0_35
var _this = 1; var f = () => _this;
{ "end_byte": 35, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noCollisionThisExpressionAndVarInGlobal.ts" }
TypeScript/tests/cases/compiler/enumDecl1.ts_0_102
// @declaration: true declare module mAmbient { enum e { x, y, z } }
{ "end_byte": 102, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumDecl1.ts" }
TypeScript/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.ts_0_240
// @module: amd // @declaration: true // @target: ES5 // @filename: server.ts var a = 10; export default a; // @filename: client.ts export import defaultBinding, * as nameSpaceBinding from "server"; export var x: number = defaultBinding;
{ "end_byte": 240, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.ts" }
TypeScript/tests/cases/compiler/es5ExportDefaultFunctionDeclaration4.ts_0_192
// @target: es5 // @module: commonjs // @declaration: true declare module "bar" { var before: typeof func; export default function func(): typeof func; var after: typeof func; }
{ "end_byte": 192, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es5ExportDefaultFunctionDeclaration4.ts" }
TypeScript/tests/cases/compiler/requiredInitializedParameter1.ts_0_246
function f1(a, b = 0, c) { } function f2(a, b = 0, c = 0) { } function f3(a, b = 0, c?) { } function f4(a, b = 0, ...c) { } f1(0, 1, 2); f2(0, 1, 2); f3(0, 1, 2); f4(0, 1, 2); f1(0, 1); f2(0, 1); f3(0, 1); f4(0, 1); f1(0); f2(0); f3(0); f4(0);
{ "end_byte": 246, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/requiredInitializedParameter1.ts" }
TypeScript/tests/cases/compiler/defaultNamedExportWithType4.ts_0_73
// @target: esnext interface Foo {} const Foo = {}; export default Foo;
{ "end_byte": 73, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/defaultNamedExportWithType4.ts" }
TypeScript/tests/cases/compiler/classAccessorInitializationInferenceWithElementAccess1.ts_0_300
// @strict: true // @target: esnext // @declaration: true export class Cls { accessor x; accessor y; accessor z; accessor 0; constructor(seed: number) { this['x'] = [seed]; this['y'] = { seed }; this['z'] = `${seed}`; this[0] = [seed]; } }
{ "end_byte": 300, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classAccessorInitializationInferenceWithElementAccess1.ts" }
TypeScript/tests/cases/compiler/strictTypeofUnionNarrowing.ts_0_644
// @strict: true function stringify1(anything: { toString(): string } | undefined): string { return typeof anything === "string" ? anything.toUpperCase() : ""; } function stringify2(anything: {} | undefined): string { return typeof anything === "string" ? anything.toUpperCase() : ""; } function stringify3(any...
{ "end_byte": 644, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/strictTypeofUnionNarrowing.ts" }
TypeScript/tests/cases/compiler/functionCall18.ts_0_109
// Repro from #26835 declare function foo<T>(a: T, b: T); declare function foo(a: {}); foo<string>("hello");
{ "end_byte": 109, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionCall18.ts" }
TypeScript/tests/cases/compiler/genericMappedTypeAsClause.ts_0_821
// @strict: true type Model = { a: string; b: number; }; type MappedModel<Suffix extends string> = { [K in keyof Model as `${K}${Suffix}`]: Model[K]; }; const foo1: MappedModel<'Foo'> = { aFoo: 'test', bFoo: 42 }; const foo2: MappedModel<'Foo'> = { bFoo: 'bar' }; // Error function f1<T extends string>(...
{ "end_byte": 821, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericMappedTypeAsClause.ts" }
TypeScript/tests/cases/compiler/classDeclarationBlockScoping2.ts_0_119
function f() { class C {} var c1 = C; { class C {} var c2 = C; } return C === c1; }
{ "end_byte": 119, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classDeclarationBlockScoping2.ts" }
TypeScript/tests/cases/compiler/internalAliasClass.ts_0_126
// @declaration: true module a { export class c { } } module c { import b = a.c; export var x: b = new b(); }
{ "end_byte": 126, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/internalAliasClass.ts" }
TypeScript/tests/cases/compiler/typeParameterArgumentEquivalence.ts_0_161
function foo<T>() { var x: (item: number) => boolean; var y: (item: T) => boolean; x = y; // Should be an error y = x; // Shound be an error }
{ "end_byte": 161, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeParameterArgumentEquivalence.ts" }
TypeScript/tests/cases/compiler/parseInvalidNonNullableTypes.ts_0_386
// @strict: true function f1(a: string): a is string! { return true; } function f2(a: string): a is !string { return true; } function f3(a: string!) {} function f4(a: number!) {} function f5(a: !string) {} function f6(a: !number) {} function f7(): string! {} function f8(): !string {} const a = 1 as any!; ...
{ "end_byte": 386, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parseInvalidNonNullableTypes.ts" }
TypeScript/tests/cases/compiler/exportAssignmentWithPrivacyError.ts_0_297
//@module: amd interface connectmodule { (res, req, next): void; } interface connectexport { use: (mod: connectmodule) => connectexport; listen: (port: number) => void; } var server: { (): connectexport; test1: connectmodule; test2(): connectmodule; }; export = server;
{ "end_byte": 297, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportAssignmentWithPrivacyError.ts" }
TypeScript/tests/cases/compiler/constraintErrors1.ts_0_40
function foo5<T extends hm>(test: T) { }
{ "end_byte": 40, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constraintErrors1.ts" }
TypeScript/tests/cases/compiler/computedPropertiesTransformedInOtherwiseNonTSClasses.ts_0_121
// @lib: es6 namespace NS { export const x = Symbol(); class NotTransformed { [NS.x]: number; } }
{ "end_byte": 121, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/computedPropertiesTransformedInOtherwiseNonTSClasses.ts" }
TypeScript/tests/cases/compiler/instanceofTypeAliasToGenericClass.ts_0_294
declare class TableClass<S = any> { _field: S; } export type Table = TableClass; function fn<T extends Table>(o: T) { return o instanceof TableClass; } function fn2<T extends TableClass>(o: T) { return o instanceof TableClass; } declare const o: Table; o instanceof TableClass;
{ "end_byte": 294, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/instanceofTypeAliasToGenericClass.ts" }
TypeScript/tests/cases/compiler/genericCallInferenceConditionalType1.ts_0_356
// @strict: true // @noEmit: true // https://github.com/microsoft/TypeScript/issues/59108 declare const f: <T>(f: (x: T) => unknown) => (x: T) => unknown; declare const g: <T extends unknown>(x: { foo: T }) => unknown; const h = f(g); type FirstParameter<T> = T extends (x: infer P) => unknown ? P : unknown; type X...
{ "end_byte": 356, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericCallInferenceConditionalType1.ts" }
TypeScript/tests/cases/compiler/importNonExportedMember11.ts_0_191
// @esModuleInterop: true // @module: es2015 // @checkJs: true // @allowJs: true // @noEmit: true // @Filename: a.ts class Foo {} export = Foo; // @Filename: b.js import { Foo } from './a';
{ "end_byte": 191, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importNonExportedMember11.ts" }
TypeScript/tests/cases/compiler/contextuallyTypingOrOperator.ts_0_283
var v: { a: (_: string) => number } = { a: s => s.length } || { a: s => 1 }; var v2 = (s: string) => s.length || function (s) { s.length }; var v3 = (s: string) => s.length || function (s: number) { return 1 }; var v4 = (s: number) => 1 || function (s: string) { return s.length };
{ "end_byte": 283, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextuallyTypingOrOperator.ts" }
TypeScript/tests/cases/compiler/exportImportMultipleFiles.ts_0_400
//@module: amd // @Filename: exportImportMultipleFiles_math.ts export function add(a, b) { return a + b; } // @Filename: exportImportMultipleFiles_library.ts export import math = require("exportImportMultipleFiles_math"); math.add(3, 4); // OK // @Filename: exportImportMultipleFiles_userCode.ts import lib = require('...
{ "end_byte": 400, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportImportMultipleFiles.ts" }
TypeScript/tests/cases/compiler/overloadModifiersMustAgree.ts_0_261
//@module: commonjs class baz { public foo(); private foo(bar?: any) { } // error - access modifiers do not agree } declare function bar(); export function bar(s: string); function bar(s?: string) { } interface I { foo? (); foo(s: string); }
{ "end_byte": 261, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overloadModifiersMustAgree.ts" }
TypeScript/tests/cases/compiler/fromAsIdentifier1.ts_0_9
var from;
{ "end_byte": 9, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/fromAsIdentifier1.ts" }
TypeScript/tests/cases/compiler/moduleCodeGenTest3.ts_0_58
module Baz { export var x = "hello"; } Baz.x = "goodbye";
{ "end_byte": 58, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleCodeGenTest3.ts" }