_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
TypeScript/tests/cases/compiler/arrayIndexWithArrayFails.ts_0_113 | declare const arr1: (string | string[])[];
declare const arr2: number[];
const j = arr2[arr1[0]]; // should error | {
"end_byte": 113,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arrayIndexWithArrayFails.ts"
} |
TypeScript/tests/cases/compiler/regexpExecAndMatchTypeUsages.ts_0_699 | // @strict: true,false
// @noUncheckedIndexedAccess: true
// @exactOptionalPropertyTypes: true
// @lib: es2018
export function foo(matchResult: RegExpMatchArray, execResult: RegExpExecArray) {
matchResult[0].length;
matchResult[999].length;
matchResult.index + 0;
matchResult.input.length;
matchResult.groups["someVariable"].length;
matchResult.groups = undefined;
execResult[0].length;
execResult[999].length;
execResult.index + 0;
execResult.input.length;
execResult.groups["someVariable"].length;
execResult.groups = undefined;
if (Math.random()) {
matchResult = execResult;
}
else {
execResult = matchResult
}
}
| {
"end_byte": 699,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/regexpExecAndMatchTypeUsages.ts"
} |
TypeScript/tests/cases/compiler/mappedTypeTupleConstraintAssignability.ts_0_1208 | // @strict: true
// @noEmit: true
// https://github.com/microsoft/TypeScript/issues/53359#issuecomment-1475390594
type Writeable<T> = { -readonly [P in keyof T]: T[P] };
type EnumValues = [string, ...string[]];
type Values<T extends EnumValues> = { [k in T[number]]: k; };
declare class ZodEnum<T extends [string, ...string[]]> {
get enum(): Values<T>
}
declare function createZodEnum<U extends string, T extends Readonly<[U, ...U[]]>>(values: T): ZodEnum<Writeable<T>>;
// https://github.com/microsoft/TypeScript/issues/53359#issuecomment-1475390607
type Maybe<T> = T | null | undefined;
type AnyTuple = [unknown, ...unknown[]];
type AnyObject = { [k: string]: any };
type Flags = "s" | "d" | "";
interface ISchema<T, C = any, F extends Flags = any, D = any> {
__flags: F;
__context: C;
__outputType: T;
__default: D;
}
declare class TupleSchema<
TType extends Maybe<AnyTuple> = AnyTuple | undefined,
TContext = AnyObject,
TDefault = undefined,
TFlags extends Flags = ""
> {
constructor(schemas: [ISchema<any>, ...ISchema<any>[]]);
}
export function create<T extends AnyTuple>(schemas: {
[K in keyof T]: ISchema<T[K]>;
}) {
return new TupleSchema<T | undefined>(schemas);
}
| {
"end_byte": 1208,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mappedTypeTupleConstraintAssignability.ts"
} |
TypeScript/tests/cases/compiler/nodeResolution4.ts_0_192 | // @module: commonjs
// @moduleResolution: node
// @filename: ref.ts
var x = 1;
// @filename: a.ts
/// <reference path="ref.ts"/>
export var y;
// @filename: b.ts
import y = require("./a"); | {
"end_byte": 192,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nodeResolution4.ts"
} |
TypeScript/tests/cases/compiler/ambientModules.ts_3_64 | clare module Foo.Bar { export var foo; };
Foo.Bar.foo = 5; | {
"end_byte": 64,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ambientModules.ts"
} |
TypeScript/tests/cases/compiler/overloadOnConstInCallback1.ts_0_220 | class C {
x1(a: number, callback: (x: 'hi') => number); // error
x1(a: number, callback: (x: any) => number) {
callback('hi');
callback('bye');
var hm = "hm";
callback(hm);
}
} | {
"end_byte": 220,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overloadOnConstInCallback1.ts"
} |
TypeScript/tests/cases/compiler/augmentExportEquals1_1.ts_0_432 | // @module: amd
// @filename: file1.d.ts
declare module "file1" {
var x: number;
export = x;
}
// @filename: file2.ts
/// <reference path="file1.d.ts"/>
import x = require("file1");
// augmentation for 'file1'
// should error since 'file1' does not have namespace meaning
declare module "file1" {
interface A { a }
}
// @filename: file3.ts
import x = require("file1");
import "file2";
let a: x.A; // should not work | {
"end_byte": 432,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/augmentExportEquals1_1.ts"
} |
TypeScript/tests/cases/compiler/multipleClassPropertyModifiersErrors.ts_0_149 | class C {
public public p1;
private private p2;
static static p3;
public private p4;
private public p5;
public static p6;
private static p7;
} | {
"end_byte": 149,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/multipleClassPropertyModifiersErrors.ts"
} |
TypeScript/tests/cases/compiler/checkJsFiles2.ts_0_111 | // @allowJs: true
// @checkJs: false
// @noEmit: true
// @fileName: a.js
// @ts-check
var x = "string";
x = 0; | {
"end_byte": 111,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/checkJsFiles2.ts"
} |
TypeScript/tests/cases/compiler/jsFileCompilationEmitTrippleSlashReference.ts_0_198 | // @allowJs: true
// @outFile: out.js
// @declaration: true
// @filename: a.ts
class c {
}
// @filename: b.js
/// <reference path="c.js"/>
function foo() {
}
// @filename: c.js
function bar() {
}
| {
"end_byte": 198,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationEmitTrippleSlashReference.ts"
} |
TypeScript/tests/cases/compiler/thisBinding.ts_0_240 | module M {
export interface I {
z;
}
export class C {
public x=0;
f(x:I) {
x.e; // e not found
x.z; // ok
}
constructor() {
({z:10,f:this.f}).f(<I>({}));
}
}
}
class C {
f(x: number) {
}
} | {
"end_byte": 240,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/thisBinding.ts"
} |
TypeScript/tests/cases/compiler/genericTypeWithCallableMembers.ts_0_287 | interface Constructable {
new (): Constructable;
}
class C<T extends Constructable> {
constructor(public data: T, public data2: Constructable) { }
create() {
var x = new this.data(); // no error
var x2 = new this.data2(); // was error, shouldn't be
}
}
| {
"end_byte": 287,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericTypeWithCallableMembers.ts"
} |
TypeScript/tests/cases/compiler/reverseMappedTypeInferenceSameSource1.ts_0_884 | // @strict: true
// @noEmit: true
type Action<T extends string = string> = {
type: T;
};
interface UnknownAction extends Action {
[extraProps: string]: unknown;
}
type Reducer<S = any, A extends Action = UnknownAction> = (
state: S | undefined,
action: A,
) => S;
type ReducersMapObject<S = any, A extends Action = UnknownAction> = {
[K in keyof S]: Reducer<S[K], A>;
};
interface ConfigureStoreOptions<S = any, A extends Action = UnknownAction> {
reducer: Reducer<S, A> | ReducersMapObject<S, A>;
}
declare function configureStore<S = any, A extends Action = UnknownAction>(
options: ConfigureStoreOptions<S, A>,
): void;
{
const reducer: Reducer<number> = () => 0;
const store1 = configureStore({ reducer });
}
const counterReducer1: Reducer<number> = () => 0;
const store2 = configureStore({
reducer: {
counter1: counterReducer1,
},
});
export {}
| {
"end_byte": 884,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reverseMappedTypeInferenceSameSource1.ts"
} |
TypeScript/tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt3.ts_3_261 | dule Z {
export module M {
export function bar() {
return "";
}
}
export interface I { }
}
module A.M {
import M = Z.M;
import M = Z.I;
export function bar() {
}
M.bar(); // Should call Z.M.bar
} | {
"end_byte": 261,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt3.ts"
} |
TypeScript/tests/cases/compiler/es5-asyncFunctionElementAccess.ts_0_271 | // @lib: es5,es2015.promise
// @noEmitHelpers: true
// @target: ES5
declare var x, y, z, a, b, c;
async function elementAccess0() {
z = await x[y];
}
async function elementAccess1() {
z = (await x)[y];
}
async function elementAccess2() {
z = x[await y];
}
| {
"end_byte": 271,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es5-asyncFunctionElementAccess.ts"
} |
TypeScript/tests/cases/compiler/commentsAfterCaseClauses1.ts_3_315 | nction getSecurity(level) {
switch(level){
case 0: // Zero
case 1: // one
case 2: // two
return "Hi";
case 3: // three
case 4 : // four
return "hello";
case 5: // five
default: // default
return "world";
}
} | {
"end_byte": 315,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentsAfterCaseClauses1.ts"
} |
TypeScript/tests/cases/compiler/indexIntoEnum.ts_0_47 | module M {
enum E { }
var x = E[0];
} | {
"end_byte": 47,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/indexIntoEnum.ts"
} |
TypeScript/tests/cases/compiler/commentInEmptyParameterList1.ts_0_58 | // @removeComments: false
function foo(/** nothing */) {
} | {
"end_byte": 58,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentInEmptyParameterList1.ts"
} |
TypeScript/tests/cases/compiler/contextualTypingFunctionReturningFunction2.ts_0_114 | declare function f(n: number): void;
declare function f(cb: () => (n: number) => number): void;
f(() => n => n);
| {
"end_byte": 114,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTypingFunctionReturningFunction2.ts"
} |
TypeScript/tests/cases/compiler/declarationEmitMonorepoBaseUrl.ts_0_1655 | // @noTypesAndSymbols: true
// @Filename: /tsconfig.json
{
"compilerOptions": {
"module": "nodenext",
"declaration": true,
"outDir": "temp",
"baseUrl": "."
}
}
// @Filename: /node_modules/.pnpm/@babel+parser@7.23.6/node_modules/@babel/parser/package.json
{
"name": "@babel/parser",
"version": "7.23.6",
"main": "./lib/index.js",
"types": "./typings/babel-parser.d.ts"
}
// @Filename: /node_modules/.pnpm/@babel+parser@7.23.6/node_modules/@babel/parser/typings/babel-parser.d.ts
export declare function createPlugin(): PluginConfig;
export declare class PluginConfig {}
// @Filename: /packages/compiler-core/package.json
{
"name": "@vue/compiler-core",
"version": "3.0.0",
"main": "./src/index.ts",
"dependencies": {
"@babel/parser": "^7.0.0"
}
}
// @Filename: /packages/compiler-core/src/index.ts
import { PluginConfig } from "@babel/parser";
// @Filename: /packages/compiler-sfc/package.json
{
"name": "@vue/compiler-sfc",
"version": "3.0.0",
"main": "./src/index.ts",
"dependencies": {
"@babel/parser": "^7.0.0",
"@vue/compiler-core": "^3.0.0"
}
}
// @Filename: /packages/compiler-sfc/src/index.ts
import { createPlugin } from "@babel/parser";
export function resolveParserPlugins() {
return [createPlugin()];
}
// @link: /node_modules/.pnpm/@babel+parser@7.23.6/node_modules/@babel/parser -> /node_modules/@babel/parser
// @link: /node_modules/.pnpm/@babel+parser@7.23.6/node_modules/@babel/parser -> /packages/compiler-core/node_modules/@babel/parser
// @link: /node_modules/.pnpm/@babel+parser@7.23.6/node_modules/@babel/parser -> /packages/compiler-sfc/node_modules/@babel/parser | {
"end_byte": 1655,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitMonorepoBaseUrl.ts"
} |
TypeScript/tests/cases/compiler/namespaceNotMergedWithFunctionDefaultExport.ts_0_391 | // @moduleResolution: node10
// @module: commonjs
// repro from https://github.com/microsoft/TypeScript/issues/54342
// @Filename: replace-in-file/types/index.d.ts
declare module 'replace-in-file' {
export function replaceInFile(config: unknown): Promise<unknown[]>;
export default replaceInFile;
namespace replaceInFile {
export function sync(config: unknown): unknown[];
}
} | {
"end_byte": 391,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/namespaceNotMergedWithFunctionDefaultExport.ts"
} |
TypeScript/tests/cases/compiler/classOrder2.ts_1_106 | class A extends B {
foo() { this.bar(); }
}
class B {
bar() { }
}
var a = new A();
a.foo();
| {
"end_byte": 106,
"start_byte": 1,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classOrder2.ts"
} |
TypeScript/tests/cases/compiler/distributiveConditionalTypeConstraints.ts_0_2114 | // @strict: true
// @noEmit: true
type IsArray<T> = T extends unknown[] ? true : false;
function f1<T extends object>(x: IsArray<T>) {
let t: true = x; // Error
let f: false = x; // Error
}
function f2<T extends unknown[]>(x: IsArray<T>) {
let t: true = x;
let f: false = x; // Error
}
function f3<T extends string[]>(x: IsArray<T>) {
let t: true = x;
let f: false = x; // Error
}
function f4<T extends Function>(x: IsArray<T>) {
let t: true = x; // Error
let f: false = x;
}
type ZeroOf<T> =
T extends null ? null :
T extends undefined ? undefined :
T extends string ? "" :
T extends number ? 0 :
T extends boolean ? false :
never;
function f10<T extends {}>(x: ZeroOf<T>) {
let t: "" | 0 | false = x;
}
type Foo<T> = T extends "abc" | 42 ? true : false;
function f20<T extends string>(x: Foo<T>) {
let t: false = x; // Error
}
// Modified repro from #30152
interface A { foo(): void; }
interface B { bar(): void; }
interface C { foo(): void, bar(): void }
function test1<T extends A>(y: T extends B ? number : string) {
if (typeof y == 'string') {
y; // T extends B ? number : string
}
else {
y; // never
}
const newY: string | number = y;
newY; // string
}
function test2<T extends A>(y: T extends B ? string : number) {
if (typeof y == 'string') {
y; // never
}
else {
y; // T extends B ? string : number
}
const newY: string | number = y;
newY; // number
}
function test3<T extends A>(y: T extends C ? number : string) {
if (typeof y == 'string') {
y; // (T extends C ? number : string) & string
}
else {
y; // T extends C ? number : string
}
const newY: string | number = y;
newY; // string | number
}
function test4<T extends A>(y: T extends C ? string : number) {
if (typeof y == 'string') {
y; // (T extends C ? string : number) & string
}
else {
y; // T extends C ? string : number
}
const newY: string | number = y;
newY; // string | number
}
| {
"end_byte": 2114,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/distributiveConditionalTypeConstraints.ts"
} |
TypeScript/tests/cases/compiler/outModuleTripleSlashRefs.ts_0_547 | // @target: ES5
// @sourcemap: true
// @declaration: true
// @module: amd
// @outFile: all.js
// @Filename: ref/a.ts
/// <reference path="./b.ts" />
export class A {
member: typeof GlobalFoo;
}
// @Filename: ref/b.ts
/// <reference path="./c.d.ts" />
class Foo {
member: Bar;
}
declare var GlobalFoo: Foo;
// @Filename: ref/c.d.ts
/// <reference path="./d.d.ts" />
declare class Bar {
member: Baz;
}
// @Filename: ref/d.d.ts
declare class Baz {
member: number;
}
// @Filename: b.ts
import {A} from "./ref/a";
export class B extends A { }
| {
"end_byte": 547,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/outModuleTripleSlashRefs.ts"
} |
TypeScript/tests/cases/compiler/isolatedModulesConstEnum.ts_0_278 | // @isolatedModules: true
// @filename: /foo.d.ts
declare const enum EventName {
FOO = 1,
BAR = 2
}
type E1 = {
[EventName.FOO]: number;
[EventName.BAR]: string;
};
// @filename: /bar.ts
type E2 = {
[EventName.FOO]: number;
[EventName.BAR]: string;
};
| {
"end_byte": 278,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/isolatedModulesConstEnum.ts"
} |
TypeScript/tests/cases/compiler/narrowBySwitchDiscriminantUndefinedCase1.ts_0_787 | // @strict: true
// @exactOptionalPropertyTypes: true, false
// @noUncheckedIndexedAccess: true, false
// @noEmit: true
// https://github.com/microsoft/TypeScript/issues/57999
interface A {
optionalProp?: "hello";
}
function func(arg: A) {
const { optionalProp } = arg;
switch (optionalProp) {
case undefined:
return undefined;
case "hello":
return "hello";
default:
assertUnreachable(optionalProp);
}
}
function func2() {
const optionalProp = ["hello" as const][Math.random()];
switch (optionalProp) {
case undefined:
return undefined;
case "hello":
return "hello";
default:
assertUnreachable(optionalProp);
}
}
function assertUnreachable(_: never): never {
throw new Error("Unreachable path taken");
}
| {
"end_byte": 787,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowBySwitchDiscriminantUndefinedCase1.ts"
} |
TypeScript/tests/cases/compiler/assignmentNonObjectTypeConstraints.ts_0_240 | const enum E { A, B, C }
function foo<T extends number>(x: T) {
var y: number = x; // Ok
}
foo(5);
foo(E.A);
class A { a }
class B { b }
function bar<T extends A | B>(x: T) {
var y: A | B = x; // Ok
}
bar(new A);
bar(new B);
| {
"end_byte": 240,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentNonObjectTypeConstraints.ts"
} |
TypeScript/tests/cases/compiler/staticsInAFunction.ts_0_102 | // @lib: es5
function boo{
static test()
static test(name:string)
static test(name?:any){}
}
| {
"end_byte": 102,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/staticsInAFunction.ts"
} |
TypeScript/tests/cases/compiler/moduleAugmentationDoesNamespaceMergeOfReexport.ts_0_407 | // @filename: file.ts
export namespace Root {
export interface Foo {
x: number;
}
}
// @filename: reexport.ts
export * from "./file";
// @filename: augment.ts
import * as ns from "./reexport";
declare module "./reexport" {
export namespace Root {
export interface Foo {
self: Foo;
}
}
}
declare const f: ns.Root.Foo;
f.x;
f.self;
f.self.x;
f.self.self; | {
"end_byte": 407,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleAugmentationDoesNamespaceMergeOfReexport.ts"
} |
TypeScript/tests/cases/compiler/conditionalExpressionNewLine2.ts_0_21 | var v = a
? b : c; | {
"end_byte": 21,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/conditionalExpressionNewLine2.ts"
} |
TypeScript/tests/cases/compiler/constructorReturningAPrimitive.ts_0_380 | // technically not allowed by JavaScript but we don't have a 'not-primitive' constraint
// functionally only possible when your class is otherwise devoid of members so of little consequence in practice
class A {
constructor() {
return 1;
}
}
var a = new A();
class B<T> {
constructor() {
var x: T;
return x;
}
}
var b = new B<number>(); | {
"end_byte": 380,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constructorReturningAPrimitive.ts"
} |
TypeScript/tests/cases/compiler/implicitAnyAmbients.ts_0_451 | // @noimplicitany: true
declare module m {
var x; // error
var y: any;
function f(x); // error
function f2(x: any); // error
function f3(x: any): any;
interface I {
foo(); // error
foo2(x: any); // error
foo3(x: any): any;
}
class C {
foo(); // error
foo2(x: any); // error
foo3(x: any): any;
}
module n {
var y; // error
}
import m2 = n;
} | {
"end_byte": 451,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/implicitAnyAmbients.ts"
} |
TypeScript/tests/cases/compiler/narrowedImports_assumeInitialized.ts_0_167 | // @strictNullChecks: true
// @Filename: /a.d.ts
declare namespace a {
export const x: number;
}
export = a;
// @Filename: /b.ts
import a = require("./a");
a.x;
| {
"end_byte": 167,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowedImports_assumeInitialized.ts"
} |
TypeScript/tests/cases/compiler/conflictMarkerTrivia2.ts_0_98 | class C {
foo() {
<<<<<<< B
a();
}
=======
b();
}
>>>>>>> A
public bar() { }
}
| {
"end_byte": 98,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/conflictMarkerTrivia2.ts"
} |
TypeScript/tests/cases/compiler/inheritedConstructorWithRestParams.ts_0_189 | class Base {
constructor(...a: string[]) { }
}
class Derived extends Base { }
// Ok
new Derived("", "");
new Derived("");
new Derived();
// Errors
new Derived("", 3);
new Derived(3); | {
"end_byte": 189,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inheritedConstructorWithRestParams.ts"
} |
TypeScript/tests/cases/compiler/esModuleInteropUsesExportStarWhenDefaultPlusNames.ts_0_83 | // @esModuleInterop: true
import Deps, { var2 } from './dep';
void Deps;
void var2; | {
"end_byte": 83,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/esModuleInteropUsesExportStarWhenDefaultPlusNames.ts"
} |
TypeScript/tests/cases/compiler/paramPropertiesInSignatures.ts_0_275 | class C1 {
constructor(public p1:string); // ERROR
constructor(private p2:number); // ERROR
constructor(public p3:any) {} // OK
}
declare class C2 {
constructor(public p1:string); // ERROR
constructor(private p2:number); // ERROR
constructor(public p3:any); // ERROR
} | {
"end_byte": 275,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/paramPropertiesInSignatures.ts"
} |
TypeScript/tests/cases/compiler/decoratorMetadataNoStrictNull.ts_0_189 | // @experimentalDecorators: true
// @emitDecoratorMetadata: true
const dec = (obj: {}, prop: string) => undefined
class Foo {
@dec public foo: string | null;
@dec public bar: string;
} | {
"end_byte": 189,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/decoratorMetadataNoStrictNull.ts"
} |
TypeScript/tests/cases/compiler/cloduleTest1.ts_2_255 | declare function $(selector: string): $;
interface $ {
addClass(className: string): $;
}
module $ {
export interface AjaxSettings {
}
export function ajax(options: AjaxSettings) { }
}
var it: $ = $('.foo').addClass('bar');
| {
"end_byte": 255,
"start_byte": 2,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/cloduleTest1.ts"
} |
TypeScript/tests/cases/compiler/thisExpressionOfGenericObject.ts_0_103 | class MyClass1<T> {
private obj: MyClass1<string>;
constructor() {
() => this;
}
}
| {
"end_byte": 103,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/thisExpressionOfGenericObject.ts"
} |
TypeScript/tests/cases/compiler/jsFileAlternativeUseOfOverloadTag.ts_0_1597 | // @allowJs: true
// @outDir: dist/
// @declaration: true
// @filename: jsFileAlternativeUseOfOverloadTag.js
// These are a few examples of existing alternative uses of @overload tag.
// They will not work as expected with our implementation, but we are
// trying to make sure that our changes do not result in any crashes here.
const example1 = {
/**
* @overload Example1(value)
* Creates Example1
* @param value [String]
*/
constructor: function Example1(value, options) {},
};
const example2 = {
/**
* Example 2
*
* @overload Example2(value)
* Creates Example2
* @param value [String]
* @param secretAccessKey [String]
* @param sessionToken [String]
* @example Creates with string value
* const example = new Example('');
* @overload Example2(options)
* Creates Example2
* @option options value [String]
* @example Creates with options object
* const example = new Example2({
* value: '',
* });
*/
constructor: function Example2() {},
};
const example3 = {
/**
* @overload evaluate(options = {}, [callback])
* Evaluate something
* @note Something interesting
* @param options [map]
* @return [string] returns evaluation result
* @return [null] returns nothing if callback provided
* @callback callback function (error, result)
* If callback is provided it will be called with evaluation result
* @param error [Error]
* @param result [String]
* @see callback
*/
evaluate: function evaluate(options, callback) {},
};
| {
"end_byte": 1597,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileAlternativeUseOfOverloadTag.ts"
} |
TypeScript/tests/cases/compiler/quotedPropertyName1.ts_0_30 | class Test1 {
"prop1" = 0;
} | {
"end_byte": 30,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/quotedPropertyName1.ts"
} |
TypeScript/tests/cases/compiler/exportNamespaceDeclarationRetainsVisibility.ts_0_165 | // @declaration: true
namespace X {
interface A {
kind: 'a';
}
interface B {
kind: 'b';
}
export type C = A | B;
}
export = X; | {
"end_byte": 165,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportNamespaceDeclarationRetainsVisibility.ts"
} |
TypeScript/tests/cases/compiler/modulePrologueUmd.ts_0_50 | // @module: umd
"use strict";
export class Foo {} | {
"end_byte": 50,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/modulePrologueUmd.ts"
} |
TypeScript/tests/cases/compiler/typeAliasDeclareKeywordNewlines.ts_0_574 | var declare: string, type: number;
// The following is invalid but should declare a type alias named 'T1':
declare type /*unexpected newline*/
T1 = null;
const t1: T1 = null; // Assert that T1 is the null type.
let T: null;
// The following should use a variable named 'declare', use a variable named
// 'type', and assign to a variable named 'T'.
declare /*ASI*/
type /*ASI*/
T = null;
// The following should use a variable named 'declare' and declare a type alias
// named 'T2':
declare /*ASI*/
type T2 = null;
const t2: T2 = null; // Assert that T2 is the null type.
| {
"end_byte": 574,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeAliasDeclareKeywordNewlines.ts"
} |
TypeScript/tests/cases/compiler/capturedLetConstInLoop10.ts_0_923 | class A {
foo() {
for (let x of [0]) {
let f = function() { return x; };
this.bar(f());
}
}
bar(a: number) {
}
baz() {
for (let x of [1]) {
let a = function() { return x; };
for (let y of [1]) {
let b = function() { return y; };
this.bar(b());
}
this.bar(a());
}
}
baz2() {
for (let x of [1]) {
let a = function() { return x; };
this.bar(a());
for (let y of [1]) {
let b = function() { return y; };
this.bar(b());
}
}
}
}
class B {
foo() {
let a =
() => {
for (let x of [0]) {
let f = () => x;
this.bar(f());
}
}
}
bar(a: number) {
}
} | {
"end_byte": 923,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/capturedLetConstInLoop10.ts"
} |
TypeScript/tests/cases/compiler/optionalParamInOverride.ts_0_101 | class Z {
public func(): void { }
}
class Y extends Z {
public func(value?: any): void { }
}
| {
"end_byte": 101,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/optionalParamInOverride.ts"
} |
TypeScript/tests/cases/compiler/visibilityOfTypeParameters.ts_0_131 | // @module:commonjs
//@declaration: true
export class MyClass {
protected myMethod<T>(val: T): T {
return val;
}
} | {
"end_byte": 131,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/visibilityOfTypeParameters.ts"
} |
TypeScript/tests/cases/compiler/functionWithDefaultParameterWithNoStatements3.ts_0_50 | function foo(a = "") { }
function bar(a = "") {
} | {
"end_byte": 50,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionWithDefaultParameterWithNoStatements3.ts"
} |
TypeScript/tests/cases/compiler/taggedTemplateWithoutDeclaredHelper.ts_0_237 | // @target: es5
// @module: commonjs
// @importHelpers: true
// @strict: true
// @filename: foo.ts
function id<T>(x: T) {
return x;
}
export const result = id `hello world`;
// @filename: ./node_modules/tslib/index.d.ts
export { };
| {
"end_byte": 237,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/taggedTemplateWithoutDeclaredHelper.ts"
} |
TypeScript/tests/cases/compiler/noImplicitAnyReferencingDeclaredInterface.ts_3_126 | @noImplicitAny: true
interface Entry {
// Should return error for implicit any.
new ();
}
declare var x: Entry; | {
"end_byte": 126,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noImplicitAnyReferencingDeclaredInterface.ts"
} |
TypeScript/tests/cases/compiler/letKeepNamesOfTopLevelItems.ts_0_61 | let x;
function foo() {
let x;
}
module A {
let x;
} | {
"end_byte": 61,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/letKeepNamesOfTopLevelItems.ts"
} |
TypeScript/tests/cases/compiler/unusedInterfaceinNamespace5.ts_0_267 | //@noUnusedLocals:true
//@noUnusedParameters:true
namespace Validation {
interface i1 {
}
export interface i2 {
}
interface i3 extends i1 {
}
export class c1 implements i3 {
}
interface i4 {
}
export let c2:i4;
} | {
"end_byte": 267,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedInterfaceinNamespace5.ts"
} |
TypeScript/tests/cases/compiler/typeArgInference.ts_0_451 | interface I {
f<T, U>(a1: { a: T; b: U }[], a2: { a: T; b: U }[]): { c: T; d: U };
g<T, U>(...arg: { a: T; b: U }[][]): { c: T; d: U };
}
var o = { a: 3, b: "test" };
var x: I;
var t1 = x.f([o], [o]);
var t1: { c: number; d: string };
var t2 = x.f<number, string>([o], [o]);
var t2: { c: number; d: string };
var t3 = x.g([o], [o]);
var t3: { c: number; d: string };
var t4 = x.g<number, string>([o], [o]);
var t4: { c: number; d: string };
| {
"end_byte": 451,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeArgInference.ts"
} |
TypeScript/tests/cases/compiler/exportImportAndClodule.ts_0_370 | module K {
export class L {
constructor(public name: string) { }
}
export module L {
export var y = 12;
export interface Point {
x: number;
y: number;
}
}
}
module M {
export import D = K.L;
}
var o: { name: string };
var o = new M.D('Hello');
var p: { x: number; y: number; }
var p: M.D.Point; | {
"end_byte": 370,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportImportAndClodule.ts"
} |
TypeScript/tests/cases/compiler/capturedLetConstInLoop5.ts_0_4485 | declare function use(a: any);
//====let
function foo0(x) {
for (let x of []) {
var v = x;
(function() { return x + v });
(() => x + v);
if (x == 1) {
return;
}
}
use(v);
}
function foo00(x) {
for (let x in []) {
var v = x;
(function() { return x + v });
(() => x + v);
if (x == "1") {
return;
}
}
use(v);
}
function foo1(x) {
for (let x = 0; x < 1; ++x) {
var v = x;
(function() { return x + v });
(() => x + v);
if (x == 1) {
return;
}
}
use(v);
}
function foo2(x) {
while (1 === 1) {
let x = 1;
var v = x;
(function() { return x + v });
(() => x + v);
if (x == 1) {
return;
}
}
use(v);
}
function foo3(x) {
do {
let x;
var v;
(function() { return x + v });
(() => x + v);
if (x == 1) {
return;
}
} while (1 === 1)
use(v);
}
function foo4(x) {
for (let y = 0; y < 1; ++y) {
var v = y;
let x = 1;
(function() { return x + v });
(() => x + v);
if (x == 1) {
return;
}
}
use(v);
}
function foo5(x) {
for (let x = 0, y = 1; x < 1; ++x) {
var v = x;
(function() { return x + y + v });
(() => x + y + v);
if (x == 1) {
return;
}
}
use(v);
}
function foo6(x) {
while (1 === 1) {
let x, y;
var v = x;
(function() { return x + y + v });
(() => x + y + v);
if (x == 1) {
return;
}
};
use(v)
}
function foo7(x) {
do {
let x, y;
var v = x;
(function() { return x + y + v });
(() => x + y + v);
if (x == 1) {
return;
}
} while (1 === 1);
use(v);
}
function foo8(x) {
for (let y = 0; y < 1; ++y) {
let x = 1;
var v = x;
(function() { return x + y + v });
(() => x + y + v);
if (x == 1) {
return;
}
}
use(v);
}
//====const
function foo0_c(x) {
for (const x of []) {
var v = x;
(function() { return x + v });
(() => x + v);
if (x == 1) {
return;
}
}
use(v);
}
function foo00_c(x) {
for (const x in []) {
var v = x;
(function() { return x + v });
(() => x + v);
if (x == "1") {
return;
}
}
use(v);
}
function foo1_c(x) {
for (const x = 0; x < 1;) {
var v = x;
(function() { return x + v });
(() => x + v);
if (x == 1) {
return;
}
}
use(v);
}
function foo2_c(x) {
while (1 === 1) {
const x = 1;
var v = x;
(function() { return x + v });
(() => x + v);
if (x == 1) {
return;
}
}
use(v);
}
function foo3_c(x) {
do {
const x = 1;
var v;
(function() { return x + v });
(() => x + v);
if (x == 1) {
return;
}
} while (1 === 1)
use(v);
}
function foo4_c(x) {
for (const y = 0; y < 1;) {
var v = y;
let x = 1;
(function() { return x + v });
(() => x + v);
if (x == 1) {
return;
}
}
use(v);
}
function foo5_c(x) {
for (const x = 0, y = 1; x < 1;) {
var v = x;
(function() { return x + y + v });
(() => x + y + v);
if (x == 1) {
return;
}
}
use(v);
}
function foo6_c(x) {
while (1 === 1) {
const x = 1, y = 1;
var v = x;
(function() { return x + y + v });
(() => x + y + v);
if (x == 1) {
return;
}
}
use(v)
}
function foo7_c(x) {
do {
const x = 1, y = 1;
var v = x;
(function() { return x + y + v });
(() => x + y + v);
if (x == 1) {
return;
}
} while (1 === 1)
use(v);
}
function foo8_c(x) {
for (const y = 0; y < 1;) {
const x = 1;
var v = x;
(function() { return x + y + v });
(() => x + y + v);
if (x == 1) {
return;
}
}
use(v);
} | {
"end_byte": 4485,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/capturedLetConstInLoop5.ts"
} |
TypeScript/tests/cases/compiler/requireOfJsonFileWithDeclaration.ts_0_324 | // @module: commonjs
// @outdir: out/
// @fullEmitPaths: true
// @resolveJsonModule: true
// @declaration: 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
{
"a": true,
"b": "hello"
} | {
"end_byte": 324,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/requireOfJsonFileWithDeclaration.ts"
} |
TypeScript/tests/cases/compiler/declFileForVarList.ts_0_67 | // @declaration: true
var x, y, z = 1;
var x1 = 1, y2 = 2, z2 = 3; | {
"end_byte": 67,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileForVarList.ts"
} |
TypeScript/tests/cases/compiler/classExpressionWithStaticPropertiesES62.ts_0_139 | //@target: es6
var v = class C {
static a = 1;
static b
static c = {
x: "hi"
}
static d = C.c.x + " world";
}; | {
"end_byte": 139,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classExpressionWithStaticPropertiesES62.ts"
} |
TypeScript/tests/cases/compiler/moduleAugmentationImportsAndExports1.ts_0_416 | // @module: commonjs
// @declaration: true
// @filename: f1.ts
export class A {}
// @filename: f2.ts
export class B {
n: number;
}
// @filename: f3.ts
import {A} from "./f1";
import {B} from "./f2";
A.prototype.foo = function () { return undefined; }
declare module "./f1" {
interface A {
foo(): B;
}
}
// @filename: f4.ts
import {A} from "./f1";
import "./f3";
let a: A;
let b = a.foo().n; | {
"end_byte": 416,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleAugmentationImportsAndExports1.ts"
} |
TypeScript/tests/cases/compiler/declFileTypeAnnotationTupleType.ts_0_312 | // @target: ES5
// @declaration: true
class c {
}
module m {
export class c {
}
export class g<T> {
}
}
class g<T> {
}
// Just the name
var k: [c, m.c] = [new c(), new m.c()];
var l = k;
var x: [g<string>, m.g<number>, () => c] = [new g<string>(), new m.g<number>(), () => new c()];
var y = x; | {
"end_byte": 312,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileTypeAnnotationTupleType.ts"
} |
TypeScript/tests/cases/compiler/commentsCommentParsing.ts_0_3584 | // @target: ES5
// @declaration: true
// @removeComments: false
/// This is simple /// comments
function simple() {
}
simple();
/// multiLine /// Comments
/// This is example of multiline /// comments
/// Another multiLine
function multiLine() {
}
multiLine();
/** this is eg of single line jsdoc style comment */
function jsDocSingleLine() {
}
jsDocSingleLine();
/** this is multiple line jsdoc stule comment
*New line1
*New Line2*/
function jsDocMultiLine() {
}
jsDocMultiLine();
/** this is multiple line jsdoc stule comment
*New line1
*New Line2*/
/** Shoul mege this line as well
* and this too*/ /** Another this one too*/
function jsDocMultiLineMerge() {
}
jsDocMultiLineMerge();
/// Triple slash comment
/** jsdoc comment */
function jsDocMixedComments1() {
}
jsDocMixedComments1();
/// Triple slash comment
/** jsdoc comment */ /*** another jsDocComment*/
function jsDocMixedComments2() {
}
jsDocMixedComments2();
/** jsdoc comment */ /*** another jsDocComment*/
/// Triple slash comment
function jsDocMixedComments3() {
}
jsDocMixedComments3();
/** jsdoc comment */ /*** another jsDocComment*/
/// Triple slash comment
/// Triple slash comment 2
function jsDocMixedComments4() {
}
jsDocMixedComments4();
/// Triple slash comment 1
/** jsdoc comment */ /*** another jsDocComment*/
/// Triple slash comment
/// Triple slash comment 2
function jsDocMixedComments5() {
}
jsDocMixedComments5();
/*** another jsDocComment*/
/// Triple slash comment 1
/// Triple slash comment
/// Triple slash comment 2
/** jsdoc comment */
function jsDocMixedComments6() {
}
jsDocMixedComments6();
// This shoulnot be help comment
function noHelpComment1() {
}
noHelpComment1();
/* This shoulnot be help comment */
function noHelpComment2() {
}
noHelpComment2();
function noHelpComment3() {
}
noHelpComment3();
/** Adds two integers and returns the result
* @param {number} a first number
* @param b second number
*/
function sum(a: number, b: number) {
return a + b;
}
sum(10, 20);
/** This is multiplication function*/
/** @param */
/** @param a first number*/
/** @param b */
/** @param c {
@param d @anotherTag*/
/** @param e LastParam @anotherTag*/
function multiply(a: number, b: number, c?: number, d?, e?) {
}
/** fn f1 with number
* @param { string} b about b
*/
function f1(a: number);
function f1(b: string);
/**@param opt optional parameter*/
function f1(aOrb, opt?) {
return aOrb;
}
/** This is subtract function
@param { a
*@param { number | } b this is about b
@param { { () => string; } } c this is optional param c
@param { { () => string; } d this is optional param d
@param { { () => string; } } e this is optional param e
@param { { { () => string; } } f this is optional param f
*/
function subtract(a: number, b: number, c?: () => string, d?: () => string, e?: () => string, f?: () => string) {
}
/** this is square function
@paramTag { number } a this is input number of paramTag
@param { number } a this is input number
@returnType { number } it is return type
*/
function square(a: number) {
return a * a;
}
/** this is divide function
@param { number} a this is a
@paramTag { number } g this is optional param g
@param { number} b this is b
*/
function divide(a: number, b: number) {
}
/** this is jsdoc style function with param tag as well as inline parameter help
*@param a it is first parameter
*@param c it is third parameter
*/
function jsDocParamTest(/** this is inline comment for a */a: number, /** this is inline comment for b*/ b: number, c: number, d: number) {
return a + b + c + d;
}
/**/
class NoQuickInfoClass {
} | {
"end_byte": 3584,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentsCommentParsing.ts"
} |
TypeScript/tests/cases/compiler/collisionCodeGenModuleWithMemberVariable.ts_0_70 | module m1 {
export var m1 = 10;
var b = m1;
}
var foo = m1.m1; | {
"end_byte": 70,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionCodeGenModuleWithMemberVariable.ts"
} |
TypeScript/tests/cases/compiler/duplicateStringNamedProperty1.ts_0_88 | //@module: commonjs
export interface Album {
"artist": string;
artist: string;
} | {
"end_byte": 88,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateStringNamedProperty1.ts"
} |
TypeScript/tests/cases/compiler/propertiesAndIndexersForNumericNames.ts_0_2085 | class C {
[i: number]: number;
// These all have numeric names; they should error
// because their types are not compatible with the numeric indexer.
public "1": string = "number"; // Error
public "-1": string = "negative number"; // Error
public "-2.5": string = "negative number"; // Error
public "3.141592": string = "pi-sitive number"; // Error
public "1.2e-20": string = "really small number"; // Error
public "Infinity": string = "A gillion"; // Error
public "-Infinity": string = "Negative-a-gillion"; // Error
public "NaN": string = "not a number"; // Error
// These all have *partially* numeric names,
// but should really be treated as plain string literals.
public " 1": string = "leading space"; // No error
public "1 ": string = "trailing space"; // No error
public "": string = "no nothing"; // No error
public " ": string = "just space"; // No error
public "1 0 1": string = "several numbers and spaces"; // No error
public "hunter2": string = "not a password"; // No error
public "+Infinity": string = "A gillion"; // No error
public "+NaN": string = "not a positive number"; // No error
public "-NaN": string = "not a negative number"; // No error
// These fall into the above category, however, they are "trickier";
// these all are *scanned* as numeric literals, but they are not written in
// "canonical" numeric representations.
public "+1": string = "positive number (for the paranoid)"; // No error
public "1e0": string = "just one"; // No error
public "-0": string = "just zero"; // No error
public "-0e0": string = "just zero"; // No error
public "0xF00D": string = "hex food"; // No error
public "0xBEEF": string = "hex beef"; // No error
public "0123": string = "oct 83"; // No error
public "0o123": string = "explicit oct 83"; // No error
public "0b101101001010": string = "explicit binary"; // No error
public "0.000000000000000000012": string = "should've been in exponential form"; // No error
}
| {
"end_byte": 2085,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/propertiesAndIndexersForNumericNames.ts"
} |
TypeScript/tests/cases/compiler/overEagerReturnTypeSpecialization.ts_0_417 | //Note: Below simpler repro
interface I1<T> {
func<U>(callback: (value: T) => U): I1<U>;
}
declare var v1: I1<number>;
var r1: I1<string> = v1.func(num => num.toString()) // Correctly returns an I1<string>
.func(str => str.length); // should error
var r2: I1<number> = v1.func(num => num.toString()) // Correctly returns an I1<string>
.func(str => str.length); // should be ok
| {
"end_byte": 417,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overEagerReturnTypeSpecialization.ts"
} |
TypeScript/tests/cases/compiler/blockScopedFunctionDeclarationInStrictClass.ts_0_159 | // @target: ES5
class c {
method() {
if (true) {
function foo() { }
foo(); // ok
}
foo(); // not ok
}
} | {
"end_byte": 159,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/blockScopedFunctionDeclarationInStrictClass.ts"
} |
TypeScript/tests/cases/compiler/commentsInterface.ts_0_1706 | // @target: ES5
// @declaration: true
// @removeComments: false
/** this is interface 1*/
interface i1 {
}
var i1_i: i1;
interface nc_i1 {
}
var nc_i1_i: nc_i1;
/** this is interface 2 with memebers*/
interface i2 {
/** this is x*/
x: number;
/** this is foo*/
foo: (/**param help*/b: number) => string;
/** this is indexer*/
[/**string param*/i: string]: any;
/**new method*/
new (/** param*/i: i1);
nc_x: number;
nc_foo: (b: number) => string;
[i: number]: number;
/** this is call signature*/
(/**paramhelp a*/a: number,/**paramhelp b*/ b: number) : number;
/** this is fnfoo*/
fnfoo(/**param help*/b: number): string;
nc_fnfoo(b: number): string;
// nc_y
nc_y: number;
}
var i2_i: i2;
var i2_i_x = i2_i.x;
var i2_i_foo = i2_i.foo;
var i2_i_foo_r = i2_i.foo(30);
var i2_i_i2_si = i2_i["hello"];
var i2_i_i2_ii = i2_i[30];
var i2_i_n = new i2_i(i1_i);
var i2_i_nc_x = i2_i.nc_x;
var i2_i_nc_foo = i2_i.nc_foo;
var i2_i_nc_foo_r = i2_i.nc_foo(30);
var i2_i_r = i2_i(10, 20);
var i2_i_fnfoo = i2_i.fnfoo;
var i2_i_fnfoo_r = i2_i.fnfoo(10);
var i2_i_nc_fnfoo = i2_i.nc_fnfoo;
var i2_i_nc_fnfoo_r = i2_i.nc_fnfoo(10);
interface i3 {
/** Comment i3 x*/
x: number;
/** Function i3 f*/
f(/**number parameter*/a: number): string;
/** i3 l*/
l: (/**comment i3 l b*/b: number) => string;
nc_x: number;
nc_f(a: number): string;
nc_l: (b: number) => string;
}
var i3_i: i3;
i3_i = {
f: /**own f*/ (/**i3_i a*/a: number) => "Hello" + a,
l: this.f,
/** own x*/
x: this.f(10),
nc_x: this.l(this.x),
nc_f: this.f,
nc_l: this.l
};
i3_i.f(10);
i3_i.l(10);
i3_i.nc_f(10);
i3_i.nc_l(10);
| {
"end_byte": 1706,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentsInterface.ts"
} |
TypeScript/tests/cases/compiler/narrowedConstInMethod.ts_0_385 | // @strictNullChecks: true
// Fixes #10501, possibly null 'x'
function f() {
const x: string | null = <any>{};
if (x !== null) {
return {
bar() { return x.length; } // ok
};
}
}
function f2() {
const x: string | null = <any>{};
if (x !== null) {
return class {
bar() { return x.length; } // ok
};
}
}
| {
"end_byte": 385,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowedConstInMethod.ts"
} |
TypeScript/tests/cases/compiler/typeGuardConstructorClassAndNumber.ts_0_2140 | // Typical case
class C1 {
property1: string;
}
let var1: C1 | number;
if (var1.constructor == C1) {
var1; // C1
var1.property1; // string
}
else {
var1; // number | C1
}
if (var1["constructor"] == C1) {
var1; // C1
var1.property1; // string
}
else {
var1; // number | C1
}
if (var1.constructor === C1) {
var1; // C1
var1.property1; // string
}
else {
var1; // number | C1
}
if (var1["constructor"] === C1) {
var1; // C1
var1.property1; // string
}
else {
var1; // number | C1
}
if (C1 == var1.constructor) {
var1; // C1
var1.property1; // string
}
else {
var1; // number | C1
}
if (C1 == var1["constructor"]) {
var1; // C1
var1.property1; // string
}
else {
var1; // number | C1
}
if (C1 === var1.constructor) {
var1; // C1
var1.property1; // string
}
else {
var1; // number | C1
}
if (C1 === var1["constructor"]) {
var1; // C1
var1.property1; // string
}
else {
var1; // number | C1
}
if (var1.constructor != C1) {
var1; // C1 | number
var1.property1; // error
}
else {
var1; // C1
}
if (var1["constructor"] != C1) {
var1; // C1 | number
var1.property1; // error
}
else {
var1; // C1
}
if (var1.constructor !== C1) {
var1; // C1 | number
var1.property1; // error
}
else {
var1; // C1
}
if (var1["constructor"] !== C1) {
var1; // C1 | number
var1.property1; // error
}
else {
var1; // C1
}
if (C1 != var1.constructor) {
var1; // C1 | number
var1.property1; // error
}
else {
var1; // C1
}
if (C1 != var1["constructor"]) {
var1; // C1 | number
var1.property1; // error
}
else {
var1; // C1
}
if (C1 !== var1.constructor) {
var1; // C1 | number
var1.property1; // error
}
else {
var1; // C1
}
if (C1 !== var1["constructor"]) {
var1; // C1 | number
var1.property1; // error
}
else {
var1; // C1
}
// Repro from #37660
function foo(instance: Function | object) {
if (typeof instance === 'function') {
if (instance.prototype == null || instance.prototype.constructor == null) {
return instance.length;
}
}
}
| {
"end_byte": 2140,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeGuardConstructorClassAndNumber.ts"
} |
TypeScript/tests/cases/compiler/destructuredDeclarationEmit.ts_0_616 | // @declaration: true
// @filename: foo.ts
const foo = { bar: 'hello', bat: 'world', bam: { bork: { bar: 'a', baz: 'b' } } };
const arr: [0, 1, 2, ['a', 'b', 'c', [{def: 'def'}, {sec: 'sec'}]]] = [0, 1, 2, ['a', 'b', 'c', [{def: 'def'}, {sec: 'sec'}]]];
export { foo, arr };
// @filename: index.ts
import { foo, arr } from './foo';
export { foo, arr };
const { bar: baz, bat, bam: { bork: { bar: ibar, baz: ibaz } } } = foo;
export { baz, ibaz };
const [ , one, , [, bee, , [, {sec} ]]] = arr;
export { one, bee, sec };
const getFoo = () => ({
foo: 'foo'
});
const { foo: foo2 } = getFoo();
export { foo2 };
| {
"end_byte": 616,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/destructuredDeclarationEmit.ts"
} |
TypeScript/tests/cases/compiler/infinitelyExpandingBaseTypes1.ts_0_112 | interface A<T>
{
x : A<A<T>>
}
interface B<T>
{
x : B<T>
}
interface C<T> extends A<T>, B<T> { }
| {
"end_byte": 112,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/infinitelyExpandingBaseTypes1.ts"
} |
TypeScript/tests/cases/compiler/declarationEmitExpressionWithNonlocalPrivateUniqueSymbol.ts_0_177 | // @declaration: true
// @filename: a.ts
type AX = { readonly A: unique symbol };
export const A: AX = 0 as any;
// @filename: b.ts
import { A } from './a';
export const A1 = A; | {
"end_byte": 177,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitExpressionWithNonlocalPrivateUniqueSymbol.ts"
} |
TypeScript/tests/cases/compiler/jsdocParamTagOnPropertyInitializer.ts_0_170 | // @allowJs: true
// @checkJs: true
// @noEmit: true
// @noImplicitAny: true
// @Filename: /a.js
class Foo {
/**@param {string} x */
m = x => x.toLowerCase();
}
| {
"end_byte": 170,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsdocParamTagOnPropertyInitializer.ts"
} |
TypeScript/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues3.ts_0_2032 | // @lib: es5
// @sourcemap: true
declare var console: {
log(msg: any): void;
}
type Robot = [number, string, string];
type MultiSkilledRobot = [string, string[]];
var robotA: Robot = [1, "mower", "mowing"];
var robotB: Robot = [2, "trimmer", "trimming"];
var multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]];
var multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]];
let nameA: string, numberB: number, nameB: string, skillB: string;
let robotAInfo: (number | string)[];
let multiSkillB: string[], nameMB: string, primarySkillB: string, secondarySkillB: string;
let multiRobotAInfo: (string | string[])[];
[, nameA = "helloNoName"] = robotA;
[, nameB = "helloNoName"] = getRobotB();
[, nameB = "helloNoName"] = [2, "trimmer", "trimming"];
[, multiSkillB = []] = multiRobotB;
[, multiSkillB = []] = getMultiRobotB();
[, multiSkillB = []] = ["roomba", ["vacuum", "mopping"]];
[numberB = -1] = robotB;
[numberB = -1] = getRobotB();
[numberB = -1] = [2, "trimmer", "trimming"];
[nameMB = "helloNoName"] = multiRobotB;
[nameMB = "helloNoName"] = getMultiRobotB();
[nameMB = "helloNoName"] = ["trimmer", ["trimming", "edging"]];
[numberB = -1, nameB = "helloNoName", skillB = "noSkill"] = robotB;
[numberB = -1, nameB = "helloNoName", skillB = "noSkill"] = getRobotB();
[numberB = -1, nameB = "helloNoName", skillB = "noSkill"] = [2, "trimmer", "trimming"];
[nameMB = "helloNoName", [primarySkillB = "noSkill", secondarySkillB = "noSkill"] = []] = multiRobotB;
[nameMB = "helloNoName", [primarySkillB = "noSkill", secondarySkillB = "noSkill"] = []] = getMultiRobotB();
[nameMB = "helloNoName", [primarySkillB = "noSkill", secondarySkillB = "noSkill"] = []] =
["trimmer", ["trimming", "edging"]];
[numberB = -1, ...robotAInfo] = robotB;
[numberB = -1, ...robotAInfo] = getRobotB();
[numberB = -1, ...robotAInfo] = <Robot>[2, "trimmer", "trimming"];
if (nameA == nameB) {
console.log(skillB);
}
function getRobotB() {
return robotB;
}
function getMultiRobotB() {
return multiRobotB;
} | {
"end_byte": 2032,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues3.ts"
} |
TypeScript/tests/cases/compiler/callOfConditionalTypeWithConcreteBranches.ts_0_1445 | type Q<T> = number extends T ? (n: number) => void : never;
function fn<T>(arg: Q<T>) {
// Expected: OK
// Actual: Cannot convert 10 to number & T
arg(10);
}
// Legal invocations are not problematic
fn<string | number>(m => m.toFixed());
fn<number>(m => m.toFixed());
// Ensure the following real-world example that relies on substitution still works
type ExtractParameters<T> = "parameters" extends keyof T
// The above allows "parameters" to index `T` since all later
// instances are actually implicitly `"parameters" & keyof T`
? {
[K in keyof T["parameters"]]: T["parameters"][K];
}[keyof T["parameters"]]
: {};
// Original example, but with inverted variance
type Q2<T> = number extends T ? (cb: (n: number) => void) => void : never;
function fn2<T>(arg: Q2<T>) {
function useT(_arg: T): void {}
// Expected: OK
arg(arg => useT(arg));
}
// Legal invocations are not problematic
fn2<string | number>(m => m(42));
fn2<number>(m => m(42));
// webidl-conversions example where substituion must occur, despite contravariance of the position
// due to the invariant usage in `Parameters`
type X<V> = V extends (...args: any[]) => any ? (...args: Parameters<V>) => void : Function;
// vscode - another `Parameters` example
export type AddFirstParameterToFunctions<Target> = {
[K in keyof Target]: Target[K] extends (...args: any[]) => void
? (...args: Parameters<Target[K]>) => void
: void
}; | {
"end_byte": 1445,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/callOfConditionalTypeWithConcreteBranches.ts"
} |
TypeScript/tests/cases/compiler/privacyCheckExportAssignmentOnExportedGenericInterface1.ts_0_163 | //@module: commonjs
//@declaration: true
module Foo {
export interface A<T> {
}
}
interface Foo<T> {
}
var Foo: new () => Foo.A<Foo<string>>;
export = Foo; | {
"end_byte": 163,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyCheckExportAssignmentOnExportedGenericInterface1.ts"
} |
TypeScript/tests/cases/compiler/genericsWithoutTypeParameters1.ts_0_423 | class C<T> {
foo(): T { return null }
}
interface I<T> {
bar(): T;
}
var c1: C;
var i1: I;
var c2: C<I>;
var i2: I<C>;
function foo(x: C, y: I) { }
function foo2(x: C<I>, y: I<C>) { }
var x: { a: C } = { a: new C<number>() };
var x2: { a: I } = { a: { bar() { return 1 } } };
class D<T> {
x: C;
y: D;
}
interface J<T> {
x: I;
y: J;
}
class A<T> { }
function f<T>(x: T): A {
return null;
} | {
"end_byte": 423,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericsWithoutTypeParameters1.ts"
} |
TypeScript/tests/cases/compiler/objectLiteralParameterResolution.ts_0_434 | interface Foo{
extend<T>(target: T, ...objs: any[]): T;
extend<T>(deep: boolean, target: T, ...objs: any[]): T;
}
declare var $: Foo;
var s = $.extend({
type: "GET" ,
data: "data" ,
success: wrapSuccessCallback(requestContext, callback) ,
error: wrapErrorCallback(requestContext, errorCallback) ,
dataType: "json" ,
converters: { "text json": "" },
traditional: true ,
timeout: 12,
}, "");
| {
"end_byte": 434,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectLiteralParameterResolution.ts"
} |
TypeScript/tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts_3_564 | terface public { }
class Foo {
constructor(private, public, static) {
private = public = static;
}
public banana(x: public) { }
}
class C {
constructor(public public, let) {
}
foo1(private, static, public) {
function let() { }
var z = function let() { };
}
public pulbic() { } // No Error;
}
class D<public, private>{ }
class E implements public { }
class F implements public.private.B { }
class F1 implements public.private.implements { }
class G extends package { }
class H extends package.A { } | {
"end_byte": 564,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts"
} |
TypeScript/tests/cases/compiler/numericIndexerConstraint1.ts_0_98 | class Foo { foo() { } }
var x: { [index: string]: number; };
var result: Foo = x["one"]; // error
| {
"end_byte": 98,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/numericIndexerConstraint1.ts"
} |
TypeScript/tests/cases/compiler/jsxChildrenWrongType.tsx_0_501 | // @jsx: react
// @strict: true
// @target: ES2017
// @module: ESNext
// @esModuleInterop: true
// @skipLibCheck: true
// @filename: other.tsx
// @exactOptionalPropertyTypes: true
/// <reference path="/.lib/react18/react18.d.ts" />
/// <reference path="/.lib/react18/global.d.ts" />
interface PropsType {
children: [string, number?] | Iterable<boolean>;
}
declare class Foo extends React.Component<PropsType, {}> {}
const b = (
<Foo>
{<div/> as unknown}
{"aa"}
</Foo>
); | {
"end_byte": 501,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsxChildrenWrongType.tsx"
} |
TypeScript/tests/cases/compiler/moduleResolutionWithSuffixes_oneNotFound.ts_0_343 | // moduleSuffixes has one entry but there isn't a matching file. Module resolution should fail.
// @filename: /tsconfig.json
{
"compilerOptions": {
"moduleResolution": "node",
"traceResolution": true,
"moduleSuffixes": [".ios"]
}
}
// @filename: /index.ts
import { ios } from "./foo";
// @filename: /foo.ts
export function base() {}
| {
"end_byte": 343,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolutionWithSuffixes_oneNotFound.ts"
} |
TypeScript/tests/cases/compiler/unusedParametersThis.ts_0_629 | //@noImplicitThis:true
//@noUnusedLocals:true
//@noUnusedParameters:true
class A {
public a: number;
public method(this: this): number {
return this.a;
}
public method2(this: A): number {
return this.a;
}
public method3(this: this): number {
var fn = () => this.a;
return fn();
}
public method4(this: A): number {
var fn = () => this.a;
return fn();
}
static staticMethod(this: A): number {
return this.a;
}
}
function f(this: A): number {
return this.a
}
var f2 = function f2(this: A): number {
return this.a;
}; | {
"end_byte": 629,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedParametersThis.ts"
} |
TypeScript/tests/cases/compiler/parseGenericArrowRatherThanLeftShift.ts_0_138 | type Bar = ReturnType<<T>(x: T) => number>;
declare const a: Bar;
function foo<T>(_x: T) {}
const b = foo<<T>(x: T) => number>(() => 1);
| {
"end_byte": 138,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parseGenericArrowRatherThanLeftShift.ts"
} |
TypeScript/tests/cases/compiler/gettersAndSettersErrors.ts_0_488 | class C {
public get Foo() { return "foo";} // ok
public set Foo(foo:string) {} // ok
public Foo = 0; // error - duplicate identifier Foo - confirmed
public get Goo(v:string):string {return null;} // error - getters must not have a parameter
public set Goo(v:string):string {} // error - setters must not specify a return type
}
class E {
private get Baz():number { return 0; }
public set Baz(n:number) {} // error - accessors do not agree in visibility
}
| {
"end_byte": 488,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/gettersAndSettersErrors.ts"
} |
TypeScript/tests/cases/compiler/promiseChaining.ts_0_355 | class Chain<T> {
constructor(public value: T) { }
then<S>(cb: (x: T) => S): Chain<S> {
var result = cb(this.value);
// should get a fresh type parameter which each then call
var z = this.then(x => result)/*S*/.then(x => "abc")/*string*/.then(x => x.length)/*number*/; // No error
return new Chain(result);
}
}
| {
"end_byte": 355,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/promiseChaining.ts"
} |
TypeScript/tests/cases/compiler/declarationEmitUnnessesaryTypeReferenceNotAdded.ts_0_890 | // @declaration: true
// @target: es5
// @module: commonjs
// @strict: true
// @noImplicitReferences: true
// @currentDirectory: /
// @filename: /node_modules/@types/minimist/minimist.d.ts
declare namespace thing {
interface ParsedArgs {}
}
declare function thing(x: any): thing.ParsedArgs;
export = thing;
// @filename: /node_modules/@types/minimist/package.json
{
"name": "minimist",
"version": "0.0.1",
"types": "./minimist.d.ts"
}
// @filename: /node_modules/@types/process/process.d.ts
declare const thing: any;
export = thing;
// @filename: /node_modules/@types/process/package.json
{
"name": "process",
"version": "0.0.1",
"types": "./process.d.ts"
}
// @filename: /index.ts
import minimist = require('minimist');
import process = require('process');
export default function parseArgs(): minimist.ParsedArgs {
return minimist(process.argv.slice(2));
}
| {
"end_byte": 890,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitUnnessesaryTypeReferenceNotAdded.ts"
} |
TypeScript/tests/cases/compiler/declareModifierOnImport1.ts_0_21 | declare import a = b; | {
"end_byte": 21,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declareModifierOnImport1.ts"
} |
TypeScript/tests/cases/compiler/nonexistentPropertyOnUnion.ts_0_65 | function f(x: string | Promise<string>) {
x.toLowerCase();
}
| {
"end_byte": 65,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nonexistentPropertyOnUnion.ts"
} |
TypeScript/tests/cases/compiler/jsExtendsImplicitAny.ts_0_310 | // @allowJs: true
// @checkJs: true
// @noEmit: true
// @noImplicitAny: true
// @Filename: /a.d.ts
declare class A<T> { x: T; }
// @Filename: /b.js
class B extends A {}
new B().x;
/** @augments A */
class C extends A { }
new C().x;
/** @augments A<number, number, number> */
class D extends A {}
new D().x; | {
"end_byte": 310,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsExtendsImplicitAny.ts"
} |
TypeScript/tests/cases/compiler/downlevelLetConst5.ts_0_19 | const a: number = 1 | {
"end_byte": 19,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/downlevelLetConst5.ts"
} |
TypeScript/tests/cases/compiler/collisionExportsRequireAndFunctionInGlobalFile.ts_0_335 | function exports() {
return 1;
}
function require() {
return "require";
}
module m3 {
function exports() {
return 1;
}
function require() {
return "require";
}
}
module m4 {
export function exports() {
return 1;
}
export function require() {
return "require";
}
} | {
"end_byte": 335,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionExportsRequireAndFunctionInGlobalFile.ts"
} |
TypeScript/tests/cases/compiler/libTypeScriptOverrideSimple.ts_0_297 | // @traceResolution: true
// @Filename: /node_modules/@typescript/lib-dom/index.d.ts
interface ABC { abc: string }
// @Filename: index.ts
/// <reference lib="dom" />
const a: ABC = { abc: "Hello" }
// This should fail because libdom has been replaced
// by the module above ^
window.localStorage | {
"end_byte": 297,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/libTypeScriptOverrideSimple.ts"
} |
TypeScript/tests/cases/compiler/duplicateIdentifierRelatedSpans3.ts_0_277 | // @pretty: true
// @filename: file1.ts
interface TopLevel {
duplicate1: () => string;
duplicate2: () => string;
duplicate3: () => string;
}
// @filename: file2.ts
interface TopLevel {
duplicate1(): number;
duplicate2(): number;
duplicate3(): number;
}
| {
"end_byte": 277,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateIdentifierRelatedSpans3.ts"
} |
TypeScript/tests/cases/compiler/moduleInTypePosition1.ts_0_277 | // @module: commonjs
// @Filename: moduleInTypePosition1_0.ts
export class Promise {
foo: string;
}
// @Filename: moduleInTypePosition1_1.ts
///<reference path='moduleInTypePosition1_0.ts'/>
import WinJS = require('./moduleInTypePosition1_0');
var x = (w1: WinJS) => { };
| {
"end_byte": 277,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleInTypePosition1.ts"
} |
TypeScript/tests/cases/compiler/noCollisionThisExpressionAndLocalVarInMethod.ts_0_372 | var _this = 2;
class a {
method1() {
return {
doStuff: (callback) => () => {
var _this = 2;
return callback(_this);
}
}
}
method2() {
var _this = 2;
return {
doStuff: (callback) => () => {
return callback(_this);
}
}
}
} | {
"end_byte": 372,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noCollisionThisExpressionAndLocalVarInMethod.ts"
} |
TypeScript/tests/cases/compiler/es6ClassTest2.ts_0_2757 | class BasicMonster {
constructor(public name: string, public health: number) {
}
attack(target) {
// WScript.Echo("Attacks " + target);
}
isAlive = true;
}
var m1 = new BasicMonster("1", 100);
var m2 = new BasicMonster("2", 100);
m1.attack(m2);
m1.health = 0;
console.log((<any>m5.isAlive).toString());
class GetSetMonster {
constructor(public name: string, private _health: number) {
}
attack(target) {
// WScript.Echo("Attacks " + target);
}
// The contextual keyword "get" followed by an identifier and
// a curly body defines a getter in the same way that "get"
// defines one in an object literal.
get isAlive() {
return this._health > 0;
}
// Likewise, "set" can be used to define setters.
set health(value: number) {
if (value < 0) {
throw new Error('Health must be non-negative.')
}
this._health = value
}
}
var m3 = new BasicMonster("1", 100);
var m4 = new BasicMonster("2", 100);
m3.attack(m4);
m3.health = 0;
var x = (<any>m5.isAlive).toString()
class OverloadedMonster {
constructor(name: string);
constructor(public name: string, public health?: number) {
}
attack();
attack(a: any);
attack(target?) {
//WScript.Echo("Attacks " + target);
}
isAlive = true;
}
var m5 = new OverloadedMonster("1");
var m6 = new OverloadedMonster("2");
m5.attack(m6);
m5.health = 0;
var y = (<any>m5.isAlive).toString()
class SplatMonster {
constructor(...args: string[]) { }
roar(name: string, ...args: number[]) { }
}
function foo() { return true; }
class PrototypeMonster {
age: number = 1;
name: string;
b = foo();
}
class SuperParent {
constructor(a: number) {
}
b(b: string) {
}
c() {
}
}
class SuperChild extends SuperParent {
constructor() {
super(1);
}
b() {
super.b('str');
}
c() {
super.c();
}
}
class Statics {
static foo = 1;
static bar: string;
static baz() {
return "";
}
}
var stat = new Statics();
interface IFoo {
x: number;
z: string;
}
class ImplementsInterface implements IFoo {
public x: number;
public z: string;
constructor() {
this.x = 1;
this.z = "foo";
}
}
class Visibility {
public foo() { }
private bar() { }
private x: number;
public y: number;
public z: number;
constructor() {
this.x = 1;
this.y = 2;
}
}
class BaseClassWithConstructor {
constructor(public x: number, public s: string) { }
}
// used to test codegen
class ChildClassWithoutConstructor extends BaseClassWithConstructor { }
var ccwc = new ChildClassWithoutConstructor(1, "s");
| {
"end_byte": 2757,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ClassTest2.ts"
} |
TypeScript/tests/cases/compiler/constEnumPreserveEmitNamedExport2.ts_0_172 | // @preserveConstEnums: true
// @target: esnext
// @filename: a.ts
const enum A {
Foo
};
export { A };
// @filename: b.ts
import { A } from './a';
export { A as B };
| {
"end_byte": 172,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constEnumPreserveEmitNamedExport2.ts"
} |
TypeScript/tests/cases/compiler/setterWithReturn.ts_0_147 | class C234 {
public set p1(arg1) {
if (true) {
return arg1;
}
else {
return 0;
}
}
} | {
"end_byte": 147,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/setterWithReturn.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.