_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
TypeScript/tests/cases/compiler/moduleResolutionWithSymlinks_preserveSymlinks.ts_0_652 | // @noImplicitReferences: true
// @traceResolution: true
// @preserveSymlinks: true
// @moduleResolution: node
// @filename: /linked/index.d.ts
// @symlink: /app/node_modules/linked/index.d.ts,/app/node_modules/linked2/index.d.ts
export { real } from "real";
export class C { private x; }
// @filename: /app/node_modules/real/index.d.ts
export const real: string;
// @filename: /app/app.ts
// We shouldn't resolve symlinks for references either. See the trace.
/// <reference types="linked" />
import { C as C1 } from "linked";
import { C as C2 } from "linked2";
let x = new C1();
// Should fail. We no longer resolve any symlinks.
x = new C2();
| {
"end_byte": 652,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolutionWithSymlinks_preserveSymlinks.ts"
} |
TypeScript/tests/cases/compiler/derivedClassOverridesPrivateFunction1.ts_0_227 | class BaseClass {
constructor() {
this._init();
}
private _init() {
}
}
class DerivedClass extends BaseClass {
constructor() {
super();
}
private _init() {
}
}
new DerivedClass(); | {
"end_byte": 227,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/derivedClassOverridesPrivateFunction1.ts"
} |
TypeScript/tests/cases/compiler/moduleAugmentationImportsAndExports4.ts_0_602 | // @module: commonjs
// @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; }
namespace N {
export interface Ifc { a: number; }
export interface Cls { b: number; }
}
import I = N.Ifc;
import C = N.Cls;
declare module "./f1" {
interface A {
foo(): B;
bar(): I;
baz(): C;
}
}
// @filename: f4.ts
import {A} from "./f1";
import "./f3";
let a: A;
let b = a.foo().n;
let c = a.bar().a;
let d = a.baz().b; | {
"end_byte": 602,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleAugmentationImportsAndExports4.ts"
} |
TypeScript/tests/cases/compiler/destructuringUnspreadableIntoRest.ts_0_1816 | //@target: ES6
class A {
constructor(
public publicProp: string,
private privateProp: string,
protected protectedProp: string,
) {}
get getter(): number {
return 1;
}
set setter(_v: number) {}
method() {
const { ...rest1 } = this;
const { ...rest2 } = this as A;
const { publicProp: _1, ...rest3 } = this;
const { publicProp: _2, ...rest4 } = this as A;
rest1.publicProp;
rest2.publicProp;
rest3.publicProp;
rest4.publicProp;
rest1.privateProp;
rest2.privateProp;
rest3.privateProp;
rest4.privateProp;
rest1.protectedProp;
rest2.protectedProp;
rest3.protectedProp;
rest4.protectedProp;
rest1.getter;
rest2.getter;
rest3.getter;
rest4.getter;
rest1.setter;
rest2.setter;
rest3.setter;
rest4.setter;
rest1.method;
rest2.method;
rest3.method;
rest4.method;
}
}
function destructure<T extends A>(x: T) {
const { ...rest1 } = x;
const { ...rest2 } = x as A;
const { publicProp: _1, ...rest3 } = x;
const { publicProp: _2, ...rest4 } = x as A;
rest1.publicProp;
rest2.publicProp;
rest3.publicProp;
rest4.publicProp;
rest1.privateProp;
rest2.privateProp;
rest3.privateProp;
rest4.privateProp;
rest1.protectedProp;
rest2.protectedProp;
rest3.protectedProp;
rest4.protectedProp;
rest1.getter;
rest2.getter;
rest3.getter;
rest4.getter;
rest1.setter;
rest2.setter;
rest3.setter;
rest4.setter;
rest1.method;
rest2.method;
rest3.method;
rest4.method;
}
| {
"end_byte": 1816,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/destructuringUnspreadableIntoRest.ts"
} |
TypeScript/tests/cases/compiler/ambientEnum1.ts_4_143 | declare enum E1 {
y = 4.23
}
// Ambient enum with computer member
declare enum E2 {
x = 'foo'.length
} | {
"end_byte": 143,
"start_byte": 4,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ambientEnum1.ts"
} |
TypeScript/tests/cases/compiler/es6ImportDefaultBindingInEs5.ts_0_243 | // @target: es5
// @module: commonjs
// @declaration: true
// @filename: es6ImportDefaultBindingInEs5_0.ts
var a = 10;
export = a;
// @filename: es6ImportDefaultBindingInEs5_1.ts
import defaultBinding from "./es6ImportDefaultBindingInEs5_0"; | {
"end_byte": 243,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ImportDefaultBindingInEs5.ts"
} |
TypeScript/tests/cases/compiler/arrayOfExportedClass.ts_0_372 | // @module: commonjs
// @Filename: arrayOfExportedClass_0.ts
class Car {
foo: string;
}
export = Car;
// @Filename: arrayOfExportedClass_1.ts
///<reference path='arrayOfExportedClass_0.ts'/>
import Car = require('./arrayOfExportedClass_0');
class Road {
public cars: Car[];
public AddCars(cars: Car[]) {
this.cars = cars;
}
}
export = Road;
| {
"end_byte": 372,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arrayOfExportedClass.ts"
} |
TypeScript/tests/cases/compiler/nestedBlockScopedBindings5.ts_0_1076 | function a0() {
for (let x in []) {
x = x + 1;
}
for (let x;;) {
x = x + 2;
}
}
function a1() {
for (let x in []) {
x = x + 1;
() => x;
}
for (let x;;) {
x = x + 2;
}
}
function a2() {
for (let x in []) {
x = x + 1;
}
for (let x;;) {
x = x + 2;
() => x;
}
}
function a3() {
for (let x in []) {
x = x + 1;
() => x;
}
for (let x;false;) {
x = x + 2;
() => x;
}
switch (1) {
case 1:
let x;
() => x;
break;
}
}
function a4() {
for (let x in []) {
x = x + 1;
}
for (let x;false;) {
x = x + 2;
}
switch (1) {
case 1:
let x;
() => x;
break;
}
}
function a5() {
let y;
for (let x in []) {
x = x + 1;
}
for (let x;false;) {
x = x + 2;
() => x;
}
switch (1) {
case 1:
let x;
break;
}
} | {
"end_byte": 1076,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nestedBlockScopedBindings5.ts"
} |
TypeScript/tests/cases/compiler/noUsedBeforeDefinedErrorInTypeContext.ts_0_317 | // @noEmit: true
// https://github.com/microsoft/TypeScript/issues/8775
interface IThing<T> {
owner: T;
}
var foo = {
one: {} as IThing<typeof foo>,
}
let baz = {
two: {} as IThing<typeof bar>,
}
let bar = {
three: {} as IThing<typeof bar>,
}
const qwe = {
four: {} as IThing<typeof qwe>,
}
| {
"end_byte": 317,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noUsedBeforeDefinedErrorInTypeContext.ts"
} |
TypeScript/tests/cases/compiler/anyIsAssignableToVoid.ts_0_123 | interface P {
p: void;
}
interface Q extends P { // check assignability here. any is assignable to void.
p: any;
} | {
"end_byte": 123,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/anyIsAssignableToVoid.ts"
} |
TypeScript/tests/cases/compiler/controlFlowAnalysisOnBareThisKeyword.ts_0_288 | // @strict: true
declare function isBig(x: any): x is { big: true };
function bigger(this: {}) {
if (isBig(this)) {
this.big; // Expect property to exist
}
}
function bar(this: string | number) {
if (typeof this === "string") {
const x: string = this;
}
} | {
"end_byte": 288,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/controlFlowAnalysisOnBareThisKeyword.ts"
} |
TypeScript/tests/cases/compiler/superCallFromClassThatDerivesFromGenericType1.ts_0_136 | declare class B<T> {
m<U>(): B<U>;
static g(): B<any>;
}
class D extends B<any> {
constructor() {
super();
}
}
| {
"end_byte": 136,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/superCallFromClassThatDerivesFromGenericType1.ts"
} |
TypeScript/tests/cases/compiler/contextualTyping4.ts_0_59 | class foo { public bar:{id:number;} = {id:5, name:"foo"}; } | {
"end_byte": 59,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTyping4.ts"
} |
TypeScript/tests/cases/compiler/overloadOnConstConstraintChecks4.ts_0_250 | class Z { }
class A extends Z { private x = 1 }
class B extends A {}
class C extends A {
public foo() { }
}
function foo(name: 'hi'): B;
function foo(name: 'bye'): C;
function foo(name: string): A;
function foo(name: any): Z {
return null;
}
| {
"end_byte": 250,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overloadOnConstConstraintChecks4.ts"
} |
TypeScript/tests/cases/compiler/chainedAssignment3.ts_0_215 | class A {
id: number;
}
class B extends A {
value: string;
}
var a: A;
var b: B;
a = b = null;
a = b = new B();
b = a = new B();
a.id = b.value = null;
// error cases
b = a = new A();
a = b = new A();
| {
"end_byte": 215,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/chainedAssignment3.ts"
} |
TypeScript/tests/cases/compiler/blockScopedEnumVariablesUseBeforeDef.ts_0_209 | // @target: ES5
function foo1() {
return E.A
enum E { A }
}
function foo2() {
return E.A
const enum E { A }
}
const config = {
a: AfterObject.A,
};
const enum AfterObject {
A = 2,
}
| {
"end_byte": 209,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/blockScopedEnumVariablesUseBeforeDef.ts"
} |
TypeScript/tests/cases/compiler/commonJsImportClassExpression.ts_0_141 | // @Filename: mod1.ts
export = class {
chunk = 1
}
// @Filename: use.ts
import Chunk = require('./mod1')
declare var c: Chunk;
c.chunk;
| {
"end_byte": 141,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commonJsImportClassExpression.ts"
} |
TypeScript/tests/cases/compiler/unusedFunctionsinNamespaces1.ts_0_108 | //@noUnusedLocals:true
//@noUnusedParameters:true
namespace Validation {
function function1() {
}
} | {
"end_byte": 108,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedFunctionsinNamespaces1.ts"
} |
TypeScript/tests/cases/compiler/unusedPrivateMethodInClass1.ts_0_120 | //@noUnusedLocals:true
//@noUnusedParameters:true
class greeter {
private function1() {
var y = 10;
}
} | {
"end_byte": 120,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedPrivateMethodInClass1.ts"
} |
TypeScript/tests/cases/compiler/declarationEmitArrayTypesFromGenericArrayUsage.ts_0_60 | // @declaration: true
interface A extends Array<string> { }
| {
"end_byte": 60,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitArrayTypesFromGenericArrayUsage.ts"
} |
TypeScript/tests/cases/compiler/jsPropertyAssignedAfterMethodDeclaration_nonError.ts_0_208 | // @allowJs: true
// @checkJs: true
// @noEmit: true
// @noImplicitThis: true
// @Filename: /a.js
const o = {
a() {
// Should not be treated as a declaration.
this.a = () => {};
}
};
| {
"end_byte": 208,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsPropertyAssignedAfterMethodDeclaration_nonError.ts"
} |
TypeScript/tests/cases/compiler/genericMergedDeclarationUsingTypeParameter2.ts_0_93 | class foo<T> { constructor(x: T) { } }
module foo {
export var x: T;
var y = <T>1;
}
| {
"end_byte": 93,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericMergedDeclarationUsingTypeParameter2.ts"
} |
TypeScript/tests/cases/compiler/blockScopedFunctionDeclarationStrictES6.ts_0_199 | // @target: ES6
"use strict";
if (true) {
function foo() { } // Allowed to declare block scope function
foo(); // This call should be ok
}
foo(); // Cannot find name since foo is block scoped | {
"end_byte": 199,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/blockScopedFunctionDeclarationStrictES6.ts"
} |
TypeScript/tests/cases/compiler/optionalPropertiesTest.ts_0_867 | var x: {p1:number; p2?:string; p3?:{():number;};};
interface IFoo
{
id: number;
name?: string;
print?(): void;
}
var foo: IFoo;
foo = { id: 1234 }; // Ok
foo = { id: 1234, name: "test" }; // Ok
foo = { name: "test" }; // Error, id missing
foo = {id: 1234, print:()=>{}} // Ok
var s = foo.name || "default";
if (foo.print !== undefined) foo.print();
interface i1 { M: () => void; };
interface i2 { M?: () => void; };
interface i3 { M: number; };
interface i4 { M?: number; };
var test1: i1 = {};
var test2: i3 = {};
var test3: i2 = {};
var test4: i4 = {};
var test5: i1 = { M: function () { } };
var test6: i3 = { M: 5 };
var test7: i2 = { M: function () { } };
test7 = {};
var test8: i4 = { M: 5 }
test8 = {};
var test9_1: i2;
var test9_2: i1;
test9_1 = test9_2;
var test10_1: i1;
var test10_2: i2;
test10_1 = test10_2; | {
"end_byte": 867,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/optionalPropertiesTest.ts"
} |
TypeScript/tests/cases/compiler/overloadsAndTypeArgumentArity.ts_0_333 | declare function Callbacks(flags?: string): void;
declare function Callbacks<T>(flags?: string): void;
declare function Callbacks<T1, T2>(flags?: string): void;
declare function Callbacks<T1, T2, T3>(flags?: string): void;
Callbacks<number, string, boolean>('s'); // no error
new Callbacks<number, string, boolean>('s'); // no error | {
"end_byte": 333,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overloadsAndTypeArgumentArity.ts"
} |
TypeScript/tests/cases/compiler/assignmentCompatability25.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:{two:number;};;
export var __val__aa = aa;
}
__test2__.__val__aa = __test1__.__val__obj4 | {
"end_byte": 336,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatability25.ts"
} |
TypeScript/tests/cases/compiler/compilerOptionsOutFileAndNoEmit.ts_0_67 | // @outFile: a.js
// @noEmit: true
// @fileName: a.ts
class c {
}
| {
"end_byte": 67,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/compilerOptionsOutFileAndNoEmit.ts"
} |
TypeScript/tests/cases/compiler/stringMappingAssignability.ts_0_96 | // @strict: true
const x: Uppercase<string> = 42;
const y: Uppercase<string> = { foo: "bar" };
| {
"end_byte": 96,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/stringMappingAssignability.ts"
} |
TypeScript/tests/cases/compiler/contextuallyTypedJsxAttribute.ts_0_479 | // @jsx: preserve
// @noImplicitAny: true
// @filename: index.tsx
interface Elements {
foo: { callback?: (value: number) => void };
bar: { callback?: (value: string) => void };
}
type Props<C extends keyof Elements> = { as?: C } & Elements[C];
declare function Test<C extends keyof Elements>(props: Props<C>): null;
<Test
as="bar"
callback={(value) => {}}
/>;
Test({
as: "bar",
callback: (value) => {},
});
<Test<'bar'>
as="bar"
callback={(value) => {}}
/>;
| {
"end_byte": 479,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextuallyTypedJsxAttribute.ts"
} |
TypeScript/tests/cases/compiler/reactNamespaceImportPresevation.tsx_0_287 | //@jsx: preserve
//@module: commonjs
//@reactNamespace: myReactLib
//@filename: modules.d.ts
declare module "my-React-Lib" {
var a: any;
export = a;
}
//@filename: test.tsx
import * as myReactLib from "my-React-Lib"; // should not be elided
declare var foo: any;
<foo data/>;
| {
"end_byte": 287,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reactNamespaceImportPresevation.tsx"
} |
TypeScript/tests/cases/compiler/extendPrivateConstructorClass.ts_0_108 | declare namespace abc {
class XYZ {
private constructor();
}
}
class C extends abc.XYZ {
}
| {
"end_byte": 108,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/extendPrivateConstructorClass.ts"
} |
TypeScript/tests/cases/compiler/indexerSignatureWithRestParam.ts_0_67 | interface I {
[...x]: string;
}
class C {
[...x]: string
} | {
"end_byte": 67,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/indexerSignatureWithRestParam.ts"
} |
TypeScript/tests/cases/compiler/inferentialTypingWithFunctionType.ts_0_119 | declare function map<T, U>(x: T, f: (s: T) => U): U;
declare function identity<V>(y: V): V;
var s = map("", identity); | {
"end_byte": 119,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inferentialTypingWithFunctionType.ts"
} |
TypeScript/tests/cases/compiler/moduleAugmentationGlobal4.ts_0_252 | // @module: commonjs
// @declaration: true
// @filename: f1.ts
declare global {
interface Something {x}
}
export {};
// @filename: f2.ts
declare global {
interface Something {y}
}
export {};
// @filename: f3.ts
import "./f1";
import "./f2";
| {
"end_byte": 252,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleAugmentationGlobal4.ts"
} |
TypeScript/tests/cases/compiler/exportSpecifierAndLocalMemberDeclaration.ts_0_181 | declare module "m2" {
module X {
interface I { }
}
function Y();
export { Y as X };
function Z(): X.I;
}
declare module "m2" {
function Z2(): X.I;
} | {
"end_byte": 181,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportSpecifierAndLocalMemberDeclaration.ts"
} |
TypeScript/tests/cases/compiler/thisInFunctionCallJs.ts_0_790 | // @target: es2015
// @allowJs: true
// @checkJs: true
// @noEmit: true
// @noImplicitThis: true
// @filename: /a.js
class Test {
constructor() {
/** @type {number[]} */
this.data = [1, 2, 3];
}
finderRaw() {
this.data.find(function (d) {
return d === this.data.length
})
}
forEacherRaw() {
this.data.forEach(function (d) {
console.log(d === this.data.length)
})
}
forEacher() {
this.data.forEach(
/** @this {Test} */
function (d) {
console.log(d === this.data.length)
}, this)
}
finder() {
this.data.find(
/** @this {Test} */
function (d) {
return d === this.data.length
}, this)
}
}
| {
"end_byte": 790,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/thisInFunctionCallJs.ts"
} |
TypeScript/tests/cases/compiler/enumNegativeLiteral1.ts_0_28 | enum E {
a = -5, b, c
}
| {
"end_byte": 28,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumNegativeLiteral1.ts"
} |
TypeScript/tests/cases/compiler/duplicateLocalVariable3.ts_0_120 | var x = 1;
var x = 2;
function f() {
var y = 1;
var y = 2;
}
function f2() {
var z = 3;
var z = "";
} | {
"end_byte": 120,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateLocalVariable3.ts"
} |
TypeScript/tests/cases/compiler/jsxSpreadTag.ts_0_535 | // @jsx: react
// @target: es2015,esnext
// @filename: /a.tsx
declare const React: any;
const t1 = <div {...<span />} />;
const t2 = <div {...<span className="foo" />} />;
const t3 = <Comp
right={<div>x</div>}
{...{ wrong: <div>x</div>}}
/>;
const t4 = <Comp
right={<div>x</div>}
{...{ wrong() { return <div>x</div>; }}}
/>;
const t5 = <Comp
right={<div>x</div>}
{...{ get wrong() { return <div>x</div>; }}}
/>;
const t6 = <Comp
right={<div>x</div>}
{...{ set wrong(s) { let a = <div>x</div>; }}}
/>;
| {
"end_byte": 535,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsxSpreadTag.ts"
} |
TypeScript/tests/cases/compiler/strictModeUseContextualKeyword.ts_3_171 | se strict"
var as = 0;
function foo(as: string) { }
class C {
public as() { }
}
function F() {
function as() { }
}
function H() {
let {as} = { as: 1 };
}
| {
"end_byte": 171,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/strictModeUseContextualKeyword.ts"
} |
TypeScript/tests/cases/compiler/duplicateTypeParameters3.ts_0_45 | interface X {
x: () => <A, A>() => void;
}
| {
"end_byte": 45,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateTypeParameters3.ts"
} |
TypeScript/tests/cases/compiler/ambientClassDeclarationWithExtends.ts_0_441 | // @Filename: ambientClassDeclarationExtends_singleFile.ts
declare class A { }
declare class B extends A { }
declare class C {
public foo;
}
namespace D { var x; }
declare class D extends C { }
var d: C = new D();
// @Filename: ambientClassDeclarationExtends_file1.ts
declare class E {
public bar;
}
namespace F { var y; }
// @Filename: ambientClassDeclarationExtends_file2.ts
declare class F extends E { }
var f: E = new F();
| {
"end_byte": 441,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/ambientClassDeclarationWithExtends.ts"
} |
TypeScript/tests/cases/compiler/downlevelLetConst10.ts_0_17 | let a: number = 1 | {
"end_byte": 17,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/downlevelLetConst10.ts"
} |
TypeScript/tests/cases/compiler/systemModule6.ts_0_70 | // @module: system
export class C {}
function foo() {
new C();
}
| {
"end_byte": 70,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/systemModule6.ts"
} |
TypeScript/tests/cases/compiler/nestedBlockScopedBindings16.ts_0_387 | var x;
for (; false;) {
{
let x;
() => x;
}
}
var y;
for (; false;) {
{
let y;
y = 1;
}
}
var z0;
for (; false;) {
switch (1){
case 1:
let z0;
() => z0;
break;
}
}
var z;
for (; false;) {
switch (1){
case 1:
let z;
z = 1;
break;
}
} | {
"end_byte": 387,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nestedBlockScopedBindings16.ts"
} |
TypeScript/tests/cases/compiler/declarationEmitDefaultExportWithStaticAssignment.ts_0_511 | // @declaration: true
// @filename: foo.ts
export class Foo {}
// @filename: index1.ts
import {Foo} from './foo';
export default function Example() {}
Example.Foo = Foo
// @filename: index2.ts
import {Foo} from './foo';
export {Foo};
export default function Example() {}
Example.Foo = Foo
// @filename: index3.ts
export class Bar {}
export default function Example() {}
Example.Bar = Bar
// @filename: index4.ts
function A() { }
function B() { }
export function C() {
return null;
}
C.A = A;
C.B = B; | {
"end_byte": 511,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitDefaultExportWithStaticAssignment.ts"
} |
TypeScript/tests/cases/compiler/importedModuleClassNameClash.ts_0_71 | //@module: amd
import foo = m1;
export module m1 { }
class foo { }
| {
"end_byte": 71,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importedModuleClassNameClash.ts"
} |
TypeScript/tests/cases/compiler/overloadOnConstantsInvalidOverload1.ts_0_258 | class Base { foo() { } }
class Derived1 extends Base { bar() { } }
class Derived2 extends Base { baz() { } }
class Derived3 extends Base { biz() { } }
function foo(name: "SPAN"): Derived1;
function foo(name: "DIV"): Derived2 {
return null;
}
foo("HI"); | {
"end_byte": 258,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overloadOnConstantsInvalidOverload1.ts"
} |
TypeScript/tests/cases/compiler/signatureInstantiationWithRecursiveConstraints.ts_0_170 | // @strict: true
// Repro from #17148
class Foo {
myFunc<T extends Foo>(arg: T) {}
}
class Bar {
myFunc<T extends Bar>(arg: T) {}
}
const myVar: Foo = new Bar();
| {
"end_byte": 170,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/signatureInstantiationWithRecursiveConstraints.ts"
} |
TypeScript/tests/cases/compiler/unmatchedParameterPositions.ts_0_157 | // @strict: true
// Repros from #40251
declare let s: (...items: never[]) => never[];
let t1: () => unknown[] = s;
let t2: (...args: []) => unknown[] = s;
| {
"end_byte": 157,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unmatchedParameterPositions.ts"
} |
TypeScript/tests/cases/compiler/SystemModuleForStatementNoInitializer.ts_0_154 | //@module: system
export { };
let i = 0;
let limit = 10;
for (; i < limit; ++i) {
break;
}
for (; ; ++i) {
break;
}
for (; ;) {
break;
}
| {
"end_byte": 154,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/SystemModuleForStatementNoInitializer.ts"
} |
TypeScript/tests/cases/compiler/captureSuperPropertyAccessInSuperCall01.ts_0_167 | class A {
constructor(f: () => string) {
}
public blah(): string { return ""; }
}
class B extends A {
constructor() {
super(() => { return super.blah(); })
}
} | {
"end_byte": 167,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/captureSuperPropertyAccessInSuperCall01.ts"
} |
TypeScript/tests/cases/compiler/propertyNamesWithStringLiteral.ts_0_362 | class _Color {
a: number; r: number; g: number; b: number;
}
interface NamedColors {
azure: _Color;
"blue": _Color;
"pale blue": _Color;
}
module Color {
export var namedColors: NamedColors;
}
var a = Color.namedColors["azure"];
var a = Color.namedColors.blue; // Should not error
var a = Color.namedColors["pale blue"]; // should not error
| {
"end_byte": 362,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/propertyNamesWithStringLiteral.ts"
} |
TypeScript/tests/cases/compiler/restElementWithNumberPropertyName.ts_0_50 | // @target: es5
const { 0: a, ...b } = [0, 1, 2];
| {
"end_byte": 50,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/restElementWithNumberPropertyName.ts"
} |
TypeScript/tests/cases/compiler/numericEnumMappedType.ts_0_865 | // @strict: true
// @declaration: true
// Repro from #31771
enum E1 { ONE, TWO, THREE }
declare enum E2 { ONE, TWO, THREE }
type Bins1 = { [k in E1]?: string; }
type Bins2 = { [k in E2]?: string; }
const b1: Bins1 = {};
const b2: Bins2 = {};
const e1: E1 = E1.ONE;
const e2: E2 = E2.ONE;
b1[1] = "a";
b1[e1] = "b";
b2[1] = "a";
b2[e2] = "b";
// Multiple numeric enum types accrue to the same numeric index signature in a mapped type
declare function val(): number;
enum N1 { A = val(), B = val() }
enum N2 { C = val(), D = val() }
type T1 = { [K in N1 | N2]: K };
// Enum types with string valued members are always literal enum types and therefore
// ONE and TWO below are not computed members but rather just numerically valued members
// with auto-incremented values.
declare enum E { ONE, TWO, THREE = 'x' }
const e: E = E.ONE;
const x: E.ONE = e;
| {
"end_byte": 865,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/numericEnumMappedType.ts"
} |
TypeScript/tests/cases/compiler/contextuallyTypedSymbolNamedProperties.ts_0_519 | // @strict: true
// @declaration: true
// @target: esnext
// Repros from #43628
const A = Symbol("A");
const B = Symbol("B");
type Action =
| {type: typeof A, data: string}
| {type: typeof B, data: number}
declare const ab: Action;
declare function f<T extends { type: string | symbol }>(action: T, blah: { [K in T['type']]: (p: K) => void }): any;
f(ab, {
[A]: ap => { ap.description },
[B]: bp => { bp.description },
})
const x: { [sym: symbol]: (p: string) => void } = { [A]: s => s.length };
| {
"end_byte": 519,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextuallyTypedSymbolNamedProperties.ts"
} |
TypeScript/tests/cases/compiler/topLevelLambda4.ts_0_48 | //@module: amd
export var x = () => this.window; | {
"end_byte": 48,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/topLevelLambda4.ts"
} |
TypeScript/tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions5.ts_3_157 | @target: es6
function f(x: TemplateStringsArray, y: string, z: string) {
}
// Incomplete call, but too many parameters.
f `123qdawdrqw${ 1 }${ 2 }${ | {
"end_byte": 157,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions5.ts"
} |
TypeScript/tests/cases/compiler/continueTarget5.ts_0_122 | // @allowUnusedLabels: true
target:
while (true) {
function f() {
while (true) {
continue target;
}
}
} | {
"end_byte": 122,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/continueTarget5.ts"
} |
TypeScript/tests/cases/compiler/unusedImports7.ts_0_243 | //@noUnusedLocals:true
//@noUnusedParameters:true
// @Filename: file1.ts
export class Calculator {
handleChar() {}
}
export function test() {
}
export default function test2() {
}
// @Filename: file2.ts
import * as n from "./file1"
| {
"end_byte": 243,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedImports7.ts"
} |
TypeScript/tests/cases/compiler/declFileTypeAnnotationStringLiteral.ts_0_263 | // @target: ES5
// @declaration: true
function foo(a: "hello"): number;
function foo(a: "name"): string;
function foo(a: string): string | number;
function foo(a: string): string | number {
if (a === "hello") {
return a.length;
}
return a;
} | {
"end_byte": 263,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileTypeAnnotationStringLiteral.ts"
} |
TypeScript/tests/cases/compiler/overloadEquivalenceWithStatics.ts_0_155 | class A1<T> {
static B<S>(v: A1<S>): A1<S>; // 1
static B<S>(v: S): A1<S>; // 2 : Error Duplicate signature
static B<S>(v: any): A1<S> {
return null;
}
}
| {
"end_byte": 155,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overloadEquivalenceWithStatics.ts"
} |
TypeScript/tests/cases/compiler/es6ImportDefaultBindingWithExport.ts_0_271 | // @module: amd
// @declaration: true
// @target: ES5
// @filename: server.ts
var a = 10;
export default a;
// @filename: client.ts
export import defaultBinding from "server";
export var x = defaultBinding;
export import defaultBinding2 from "server"; // non referenced | {
"end_byte": 271,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es6ImportDefaultBindingWithExport.ts"
} |
TypeScript/tests/cases/compiler/metadataImportType.ts_0_116 | // @experimentalDecorators: true
// @emitDecoratorMetadata: true
export class A {
@test
b: import('./b').B
} | {
"end_byte": 116,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/metadataImportType.ts"
} |
TypeScript/tests/cases/compiler/sourceMap-LineBreaks.ts_0_670 | // @target: ES5
// @sourcemap: true
var endsWithlineSeparator = 10;
var endsWithParagraphSeparator = 10;
var endsWithNextLine = 1;
var endsWithLineFeed = 1;
var endsWithCarriageReturnLineFeed = 1;
var endsWithCarriageReturn = 1;
var endsWithLineFeedCarriageReturn = 1;
var endsWithLineFeedCarriageReturnLineFeed = 1;
var stringLiteralWithLineFeed = "line 1\
line 2";
var stringLiteralWithCarriageReturnLineFeed = "line 1\
line 2";
var stringLiteralWithCarriageReturn = "line 1\
line 2";
var stringLiteralWithLineSeparator = "line 1\
line 2";
var stringLiteralWithParagraphSeparator = "line 1\
line 2";
var stringLiteralWithNextLine = "line 1\
line 2"; | {
"end_byte": 670,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMap-LineBreaks.ts"
} |
TypeScript/tests/cases/compiler/inferStringLiteralUnionForBindingElement.ts_0_602 | declare function func<T extends string>(arg: { keys: T[] }): { readonly keys: T[]; readonly firstKey: T; };
function func1() {
const { firstKey } = func({keys: ["aa", "bb"]})
const a: "aa" | "bb" = firstKey;
const { keys } = func({keys: ["aa", "bb"]})
const b: ("aa" | "bb")[] = keys;
}
function func2() {
const { keys, firstKey } = func({keys: ["aa", "bb"]})
const a: "aa" | "bb" = firstKey;
const b: ("aa" | "bb")[] = keys;
}
function func3() {
const x = func({keys: ["aa", "bb"]})
const a: "aa" | "bb" = x.firstKey;
const b: ("aa" | "bb")[] = x.keys;
}
| {
"end_byte": 602,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inferStringLiteralUnionForBindingElement.ts"
} |
TypeScript/tests/cases/compiler/narrowingOfQualifiedNames.ts_0_2225 | // @strict: true
// Repro from #43411
interface IProperties {
foo?: {
aaa: string
bbb: string
}
}
function init(properties: IProperties) {
if (properties.foo) {
type FooOK = typeof properties.foo;
properties.foo; // type is { aaa: string; bbb: string; }
for (const x of [1, 2, 3]) {
properties.foo; // type is { aaa: string; bbb: string; }
type FooOrUndefined = typeof properties.foo; // type should be { aaa: string; bbb: string; }
}
}
}
interface DeepOptional {
a?: {
b?: {
c?: string
}
}
}
function init2(foo: DeepOptional) {
if (foo.a) {
type A = typeof foo.a;
type B = typeof foo.a.b;
type C = typeof foo.a.b.c;
for(const _ of [1]) {
type A = typeof foo.a;
type B = typeof foo.a.b;
type C = typeof foo.a.b.c;
if (foo.a.b) {
type A = typeof foo.a;
type B = typeof foo.a.b;
type C = typeof foo.a.b.c;
for(const _ of [1]) {
type A = typeof foo.a;
type B = typeof foo.a.b;
type C = typeof foo.a.b.c;
if (foo.a.b.c) {
type A = typeof foo.a;
type B = typeof foo.a.b;
type C = typeof foo.a.b.c;
for(const _ of [1]) {
type A = typeof foo.a;
type B = typeof foo.a.b;
type C = typeof foo.a.b.c;
}
}
}
}
}
}
}
// Repro from #48289
type Fish = { type: 'fish', hasFins: true }
type Dog = { type: 'dog', saysWoof: true }
type Pet = Fish | Dog;
function handleDogBroken<PetType extends Pet>(pet: PetType) {
if(pet.type === 'dog') {
const _okay1 = pet.saysWoof;
const _okay2: typeof pet.saysWoof = pet.saysWoof;
}
}
function handleDogWorking(pet: Pet) {
if(pet.type === 'dog') {
const _okay1 = pet.saysWoof;
const _okay2: typeof pet.saysWoof = pet.saysWoof;
}
} | {
"end_byte": 2225,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowingOfQualifiedNames.ts"
} |
TypeScript/tests/cases/compiler/assignmentCompatability11.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 obj = {two: 1};
export var __val__obj = obj;
}
__test2__.__val__obj = __test1__.__val__obj4 | {
"end_byte": 336,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatability11.ts"
} |
TypeScript/tests/cases/compiler/useBeforeDeclaration_jsx.tsx_0_329 | // @jsx: preserve
// @target: ES6
namespace JSX {
export interface Element {}
}
class C {
static a = <C.z></C.z>;
static b = <C.z/>;
static c = <span {...C.x}></span>;
static d = <span id={C.y}></span>;
static e = <span>{C.y}</span>;
static x = {};
static y = '';
static z = () => <b></b>;
}
| {
"end_byte": 329,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/useBeforeDeclaration_jsx.tsx"
} |
TypeScript/tests/cases/compiler/mappedTypeGenericInstantiationPreservesHomomorphism.ts_0_368 | // @declaration: true
// @filename: internal.ts
export declare function usePrivateType<T extends unknown[]>(...args: T): PrivateMapped<T[any]>;
type PrivateMapped<Obj> = {[K in keyof Obj]: Obj[K]};
// @filename: api.ts
import {usePrivateType} from './internal';
export const mappedUnionWithPrivateType = <T extends unknown[]>(...args: T) => usePrivateType(...args);
| {
"end_byte": 368,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mappedTypeGenericInstantiationPreservesHomomorphism.ts"
} |
TypeScript/tests/cases/compiler/systemModuleConstEnumsSeparateCompilation.ts_0_265 | // @module: system
// @isolatedModules: true
declare function use(a: any);
const enum TopLevelConstEnum { X }
export function foo() {
use(TopLevelConstEnum.X);
use(M.NonTopLevelConstEnum.X);
}
module M {
export const enum NonTopLevelConstEnum { X }
} | {
"end_byte": 265,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/systemModuleConstEnumsSeparateCompilation.ts"
} |
TypeScript/tests/cases/compiler/variableDeclarator1.ts_0_65 | var a = function () {
var c = 1;
return c;
}; | {
"end_byte": 65,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/variableDeclarator1.ts"
} |
TypeScript/tests/cases/compiler/objectLiteralWithNumericPropertyName.ts_0_56 | interface A {
0: string;
}
var x: A = {
0: 3
};
| {
"end_byte": 56,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectLiteralWithNumericPropertyName.ts"
} |
TypeScript/tests/cases/compiler/argumentsPropertyNameInJsMode2.ts_0_140 | // @allowJs: true
// @checkJs: true
// @declaration: true
// @outDir: ./out
// @filename: a.js
function f(x) {
arguments;
}
f(1, 2, 3);
| {
"end_byte": 140,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/argumentsPropertyNameInJsMode2.ts"
} |
TypeScript/tests/cases/compiler/stringIndexerAssignments1.ts_0_136 | var x: { [index: string]: string; one: string; };
var a: { one: string; };
var b: { one: number; two: string; };
x = a;
x = b; // error
| {
"end_byte": 136,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/stringIndexerAssignments1.ts"
} |
TypeScript/tests/cases/compiler/declarationEmitBindingPatterns.ts_0_111 | // @declaration: true
const k = ({x: z = 'y'}) => { }
var a;
function f({} = a, [] = a, { p: {} = a} = a) {
} | {
"end_byte": 111,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitBindingPatterns.ts"
} |
TypeScript/tests/cases/compiler/assignmentToAnyArrayRestParameters.ts_0_623 | // @strict: true
// @noEmit: true
// Repros from #57122
function foo<T extends string[]>(
fa: (s: string, ...args: string[]) => string,
fb: (s: string, ...args: T) => string
) {
const f1: (...args: any) => string = fa;
const f2: (...args: any[]) => string = fa;
const f3: (...args: any) => string = fb;
const f4: (...args: any[]) => string = fb;
}
function bar<T extends string[], K extends number>() {
type T00 = string[]["0"];
type T01 = string[]["0.0"]; // Error
type T02 = string[][K | "0"];
type T10 = T["0"];
type T11 = T["0.0"]; // Error
type T12 = T[K | "0"];
}
| {
"end_byte": 623,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentToAnyArrayRestParameters.ts"
} |
TypeScript/tests/cases/compiler/controlFlowFinallyNoCatchAssignments.ts_0_201 | // @strict: true
let x: number;
x = Math.random();
let a: number;
try {
if (x) {
a = 1;
} else {
a = 2;
}
} finally {
console.log(x);
}
console.log(a); // <- error here | {
"end_byte": 201,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/controlFlowFinallyNoCatchAssignments.ts"
} |
TypeScript/tests/cases/compiler/restElementAssignable.ts_0_450 | // @strict: true
{
const { ...props } = {};
// Use to fail
const t1: { [x: symbol]: unknown } = props;
// Working equivalent
const t2: { [x: symbol]: unknown } = {};
}
{
const { ...props } = { a: 1, b: false, c: "str" };
// Use to fail
const t1: { [x: string]: number | boolean | string } = props;
// Working equivalent
const t2: { [x: string]: number | boolean | string } = { a: 1, b: false, c: "str" };;
}
| {
"end_byte": 450,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/restElementAssignable.ts"
} |
TypeScript/tests/cases/compiler/collisionThisExpressionAndPropertyNameAsConstuctorParameter.ts_0_986 | class Foo2 {
constructor(_this: number) { //Error
var lambda = () => {
return x => this; // New scope. So should inject new _this capture
}
}
}
class Foo3 {
constructor(private _this: number) { // Error
var lambda = () => {
return x => this; // New scope. So should inject new _this capture
}
}
}
class Foo4 {
constructor(_this: number); // No code gen - no error
constructor(_this: string); // No code gen - no error
constructor(_this: any) { // Error
var lambda = () => {
return x => this; // New scope. So should inject new _this capture
}
}
}
class Foo5 {
constructor(_this: number); // No code gen - no error
constructor(_this: string); // No code gen - no error
constructor(private _this: any) { // Error
var lambda = () => {
return x => this; // New scope. So should inject new _this capture
}
}
} | {
"end_byte": 986,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionThisExpressionAndPropertyNameAsConstuctorParameter.ts"
} |
TypeScript/tests/cases/compiler/assignmentCompatability40.ts_0_441 | 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 class classWithPrivate<T> { constructor(private one: T) {} } var x5 = new classWithPrivate(1);;
export var __val__x5 = x5;
}
__test2__.__val__x5 = __test1__.__val__obj4 | {
"end_byte": 441,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatability40.ts"
} |
TypeScript/tests/cases/compiler/enumAssignmentCompat6.ts_0_1389 | // @filename: a.ts
namespace numerics {
export enum DiagnosticCategory {
Warning,
Error,
Suggestion,
Message,
}
export enum DiagnosticCategory2 {
Warning,
Error,
Suggestion,
Message,
}
}
namespace strings {
export enum DiagnosticCategory {
Warning = "Warning",
Error = "Error",
Suggestion = "Suggestion",
Message = "Message",
}
}
declare namespace ambients {
export enum DiagnosticCategory {
Warning,
Error,
Suggestion,
Message,
}
}
function f(x: numerics.DiagnosticCategory, y: strings.DiagnosticCategory) {
x = y;
y = x;
}
function g(x: numerics.DiagnosticCategory2, y: strings.DiagnosticCategory) {
x = y;
y = x;
}
function h(x: numerics.DiagnosticCategory, y: ambients.DiagnosticCategory) {
x = y;
y = x;
}
function i(x: strings.DiagnosticCategory, y: ambients.DiagnosticCategory) {
x = y;
y = x;
}
// @filename: f.ts
export enum DiagnosticCategory {
Warning,
Error,
Suggestion,
Message,
}
export let x: DiagnosticCategory;
(() => {
enum DiagnosticCategory {
Warning = "Warning",
Error = "Error",
Suggestion = "Suggestion",
Message = "Message",
}
function f(y: DiagnosticCategory) {
x = y;
y = x;
}
})() | {
"end_byte": 1389,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumAssignmentCompat6.ts"
} |
TypeScript/tests/cases/compiler/collisionThisExpressionAndVarInGlobal.ts_0_34 | var _this = 1;
var f = () => this; | {
"end_byte": 34,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionThisExpressionAndVarInGlobal.ts"
} |
TypeScript/tests/cases/compiler/typeGuardNarrowByMutableUntypedField.ts_0_296 | // @lib: es6
declare function hasOwnProperty<P extends PropertyKey>(target: {}, property: P): target is { [K in P]: unknown };
declare const arrayLikeOrIterable: ArrayLike<any> | Iterable<any>;
if (hasOwnProperty(arrayLikeOrIterable, 'length')) {
let x: number = arrayLikeOrIterable.length;
} | {
"end_byte": 296,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeGuardNarrowByMutableUntypedField.ts"
} |
TypeScript/tests/cases/compiler/overloadRet.ts_0_213 | interface I {
f(s:string):number;
f(n:number):string;
g(n:number):any;
g(n:number,m:number):string;
h(n:number):I;
h(b:boolean):number;
i(b:boolean):number;
i(b:boolean):any;
} | {
"end_byte": 213,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overloadRet.ts"
} |
TypeScript/tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts_0_360 | // @noimplicitany: true
function f1([a], {b}, c, d) { // error
}
function f2([a = undefined], {b = null}, c = undefined, d = null) { // error
}
function f3([a]: [any], {b}: { b: any }, c: any, d: any) {
}
function f4({b}: { b }, x: { b }) { // error in type instead
}
function f5([a1] = [undefined], {b1} = { b1: null }, c1 = undefined, d1 = null) { // error
} | {
"end_byte": 360,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts"
} |
TypeScript/tests/cases/compiler/constructorOverloads4.ts_0_261 | declare module M {
export class Function {
constructor(...args: string[]);
}
export function Function(...args: any[]): any;
export function Function(...args: string[]): Function;
}
(new M.Function("return 5"))();
M.Function("yo");
| {
"end_byte": 261,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constructorOverloads4.ts"
} |
TypeScript/tests/cases/compiler/noAsConstNameLookup.ts_0_686 | // @strict: true
// @target: es2015
// Repros from #44292
type Store = { a: 123 }
export type Cleaner = <W extends Store>(runner: FeatureRunner<W>) => Promise<any>
export class FeatureRunner<W extends Store> {
private readonly cleaners: Cleaner[] = []
async runFeature(): Promise<any> {
const objectWhichShouldBeConst = {
flags: {},
settings: {},
} as const;
return objectWhichShouldBeConst
}
async run(): Promise<any> {
const result = {}
this.cleaners.forEach(c => c(this))
return result
}
}
export class C<T> {
f(): void {
let one = 1 as const;
}
}
new C<string>().f();
| {
"end_byte": 686,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noAsConstNameLookup.ts"
} |
TypeScript/tests/cases/compiler/constructorStaticParamNameErrors.ts_0_130 | 'use strict'
// static as constructor parameter name should give error if 'use strict'
class test {
constructor (static) { }
} | {
"end_byte": 130,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constructorStaticParamNameErrors.ts"
} |
TypeScript/tests/cases/compiler/targetTypeObjectLiteralToAny.ts_0_256 | function suggest(){
var TypeScriptKeywords:string[];
var result:any;
TypeScriptKeywords.forEach(function(keyword) {
result.push({text:keyword, type:"keyword"}); // this should not cause a crash - push should be typed to any
});
}
| {
"end_byte": 256,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/targetTypeObjectLiteralToAny.ts"
} |
TypeScript/tests/cases/compiler/subSubClassCanAccessProtectedConstructor.ts_0_435 | class Base {
protected constructor() { }
public instance1 = new Base(); // allowed
}
class Subclass extends Base {
public instance1_1 = new Base(); // allowed
public instance1_2 = new Subclass(); // allowed
}
class SubclassOfSubclass extends Subclass {
public instance2_1 = new Base(); // allowed
public instance2_2 = new Subclass(); // allowed
public instance2_3 = new SubclassOfSubclass(); // allowed
}
| {
"end_byte": 435,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/subSubClassCanAccessProtectedConstructor.ts"
} |
TypeScript/tests/cases/compiler/declarationFilesWithTypeReferences2.ts_0_227 | // @types: node
// @declaration: true
// @currentDirectory: /
// @filename: /node_modules/@types/node/index.d.ts
interface Error2 {
stack2: string;
}
// @filename: /app.ts
function foo(): Error2 {
return undefined;
} | {
"end_byte": 227,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationFilesWithTypeReferences2.ts"
} |
TypeScript/tests/cases/compiler/duplicateConstructSignature.ts_0_47 | interface I {
(): number;
(): string;
} | {
"end_byte": 47,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateConstructSignature.ts"
} |
TypeScript/tests/cases/compiler/exportImport.ts_0_296 | //@module: amd
//@declaration: true
// @Filename: w1.ts
export = Widget1
class Widget1 { name = 'one'; }
// @Filename: exporter.ts
export import w = require('./w1');
// @Filename: consumer.ts
import e = require('./exporter');
export function w(): e.w { // Should be OK
return new e.w();
} | {
"end_byte": 296,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportImport.ts"
} |
TypeScript/tests/cases/compiler/arrayLiteralComments.ts_0_226 | var testArrayWithFunc = [
// Function comment
function() {
let x = 1;
},
// String comment
'1',
// Numeric comment
2,
// Object comment
{ a: 1 },
// Array comment
[1, 2, 3]
] | {
"end_byte": 226,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arrayLiteralComments.ts"
} |
TypeScript/tests/cases/compiler/json.stringify.ts_0_231 | // @strictNullChecks: true
var value = null;
JSON.stringify(value, undefined, 2);
JSON.stringify(value, null, 2);
JSON.stringify(value, ["a", 1], 2);
JSON.stringify(value, (k) => undefined, 2);
JSON.stringify(value, undefined, 2); | {
"end_byte": 231,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/json.stringify.ts"
} |
TypeScript/tests/cases/compiler/privacyClassExtendsClauseDeclFile.ts_0_3041 | // @module: commonjs
// @declaration: true
// @Filename: privacyClassExtendsClauseDeclFile_externalModule.ts
export module publicModule {
export class publicClassInPublicModule {
private f1() {
}
}
class privateClassInPublicModule {
}
class privateClassExtendingPublicClassInModule extends publicClassInPublicModule {
}
class privateClassExtendingPrivateClassInModule extends privateClassInPublicModule {
}
export class publicClassExtendingPublicClassInModule extends publicClassInPublicModule {
}
export class publicClassExtendingPrivateClassInModule extends privateClassInPublicModule { // Should error
}
class privateClassExtendingFromPrivateModuleClass extends privateModule.publicClassInPrivateModule {
}
export class publicClassExtendingFromPrivateModuleClass extends privateModule.publicClassInPrivateModule { // Should error
}
}
module privateModule {
export class publicClassInPrivateModule {
private f1() {
}
}
class privateClassInPrivateModule {
}
class privateClassExtendingPublicClassInModule extends publicClassInPrivateModule {
}
class privateClassExtendingPrivateClassInModule extends privateClassInPrivateModule {
}
export class publicClassExtendingPublicClassInModule extends publicClassInPrivateModule {
}
export class publicClassExtendingPrivateClassInModule extends privateClassInPrivateModule {
}
class privateClassExtendingFromPrivateModuleClass extends privateModule.publicClassInPrivateModule {
}
export class publicClassExtendingFromPrivateModuleClass extends privateModule.publicClassInPrivateModule {
}
}
export class publicClass {
private f1() {
}
}
class privateClass {
}
class privateClassExtendingPublicClass extends publicClass {
}
class privateClassExtendingPrivateClassInModule extends privateClass {
}
export class publicClassExtendingPublicClass extends publicClass {
}
export class publicClassExtendingPrivateClass extends privateClass { // Should error
}
class privateClassExtendingFromPrivateModuleClass extends privateModule.publicClassInPrivateModule {
}
export class publicClassExtendingFromPrivateModuleClass extends privateModule.publicClassInPrivateModule { // Should error
}
// @Filename: privacyClassExtendsClauseDeclFile_GlobalFile.ts
module publicModuleInGlobal {
export class publicClassInPublicModule {
private f1() {
}
}
class privateClassInPublicModule {
}
class privateClassExtendingPublicClassInModule extends publicClassInPublicModule {
}
class privateClassExtendingPrivateClassInModule extends privateClassInPublicModule {
}
export class publicClassExtendingPublicClassInModule extends publicClassInPublicModule {
}
export class publicClassExtendingPrivateClassInModule extends privateClassInPublicModule { // Should error
}
}
class publicClassInGlobal {
}
class publicClassExtendingPublicClassInGlobal extends publicClassInGlobal {
}
| {
"end_byte": 3041,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyClassExtendsClauseDeclFile.ts"
} |
TypeScript/tests/cases/compiler/functionCall1.ts_0_45 | function foo():any{return ""};
var x = foo(); | {
"end_byte": 45,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionCall1.ts"
} |
TypeScript/tests/cases/compiler/moduleVisibilityTest2.ts_2_1240 | module OuterMod {
export function someExportedOuterFunc() { return -1; }
export module OuterInnerMod {
export function someExportedOuterInnerFunc() { return "foo"; }
}
}
import OuterInnerAlias = OuterMod.OuterInnerMod;
module M {
module InnerMod {
export function someExportedInnerFunc() { return -2; }
}
enum E {
A,
B,
C,
}
var x = 5;
export declare var exported_var;
var y = x + x;
interface I {
someMethod():number;
}
class B {public b = 0;}
export class C implements I {
public someMethodThatCallsAnOuterMethod() {return OuterInnerAlias.someExportedOuterInnerFunc();}
public someMethodThatCallsAnInnerMethod() {return InnerMod.someExportedInnerFunc();}
public someMethodThatCallsAnOuterInnerMethod() {return OuterMod.someExportedOuterFunc();}
public someMethod() { return 0; }
public someProp = 1;
constructor() {
function someInnerFunc() { return 2; }
var someInnerVar = 3;
}
}
var someModuleVar = 4;
function someModuleFunction() { return 5;}
}
module M {
export var c = x;
export var meb = M.E.B;
}
var cprime : M.I = <M.I>null;
var c = new M.C();
var z = M.x;
var alpha = M.E.A;
var omega = M.exported_var;
c.someMethodThatCallsAnOuterMethod();
| {
"end_byte": 1240,
"start_byte": 2,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleVisibilityTest2.ts"
} |
TypeScript/tests/cases/compiler/moduleResolutionWithSuffixes_notSpecified.ts_0_292 | // moduleSuffixes is not specified. Normal module resolution should occur.
// @filename: /tsconfig.json
{
"compilerOptions": {
"moduleResolution": "node",
"traceResolution": true,
}
}
// @filename: /index.ts
import { base } from "./foo";
// @filename: /foo.ts
export function base() {}
| {
"end_byte": 292,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolutionWithSuffixes_notSpecified.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.