_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
TypeScript/tests/cases/compiler/declarationEmitComputedPropertyNameSymbol1.ts_0_310 | // @strict: true
// @lib: esnext
// @declaration: true
// @emitDeclarationOnly: true
// @filename: type.ts
export namespace Foo {
export const sym = Symbol();
}
export type Type = { x?: { [Foo.sym]: 0 } };
// @filename: index.ts
import { type Type } from "./type";
export const foo = { ...({} as Type) };
| {
"end_byte": 310,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitComputedPropertyNameSymbol1.ts"
} |
TypeScript/tests/cases/compiler/declFileTypeofFunction.ts_0_546 | // @declaration: true
function f(n: typeof f): string;
function f(n: typeof g): string;
function f() { return undefined; }
function g(n: typeof g): number;
function g(n: typeof f): number;
function g() { return undefined; }
var b: () => typeof b;
function b1() {
return b1;
}
function foo(): typeof foo {
return null;
}
var foo1: typeof foo;
var foo2 = foo;
var foo3 = function () {
return foo3;
}
var x = () => {
return x;
}
function foo5(x: number) {
function bar(x: number) {
return x;
}
return bar;
} | {
"end_byte": 546,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileTypeofFunction.ts"
} |
TypeScript/tests/cases/compiler/exportAssignmentWithoutIdentifier1.ts_0_129 | //@module: commonjs
function Greeter() {
//...
}
Greeter.prototype.greet = function () {
//...
}
export = new Greeter();
| {
"end_byte": 129,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportAssignmentWithoutIdentifier1.ts"
} |
TypeScript/tests/cases/compiler/narrowingDestructuring.ts_0_1026 | type X = { kind: "a", a: string } | { kind: "b", b: string }
function func<T extends X>(value: T) {
if (value.kind === "a") {
value.a;
const { a } = value;
} else {
value.b;
const { b } = value;
}
}
type Z = { kind: "f", f: { a: number, b: string, c: number } }
| { kind: "g", g: { a: string, b: number, c: string }};
function func2<T extends Z>(value: T) {
if (value.kind === "f") {
const { f: f1 } = value;
const { f: { a, ...spread } } = value;
value.f;
} else {
const { g: { c, ...spread } } = value;
value.g;
}
}
function func3<T extends { kind: "a", a: string } | { kind: "b", b: number }>(t: T) {
if (t.kind === "a") {
const { kind, ...r1 } = t;
const r2 = (({ kind, ...rest }) => rest)(t);
}
}
function farr<T extends [number, string, string] | [string, number, number]>(x: T) {
const [head, ...tail] = x;
if (typeof x[0] === 'number') {
const [head, ...tail] = x;
}
}
| {
"end_byte": 1026,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowingDestructuring.ts"
} |
TypeScript/tests/cases/compiler/declarationEmitClassAccessorsJs1.ts_0_327 | // @strict: true
// @checkJs: true
// @declaration: true
// @emitDeclarationOnly: true
// @filename: index.js
// https://github.com/microsoft/TypeScript/issues/58167
export class VFile {
/**
* @returns {string}
*/
get path() {
return ''
}
/**
* @param {URL | string} path
*/
set path(path) {
}
}
| {
"end_byte": 327,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitClassAccessorsJs1.ts"
} |
TypeScript/tests/cases/compiler/computedPropertiesWithSetterAssignment.ts_0_357 | // @target: esnext
// @strict: true
// @filename: /a.ts
const k = Symbol();
const enum Props {
k = 'k',
}
interface Foo {
get k(): Set<string>;
set k(v: Iterable<string>);
get [k](): Set<string>;
set [k](v: Iterable<string>);
}
declare const foo: Foo;
foo.k = ['foo'];
foo['k'] = ['foo'];
foo[Props.k] = ['foo'];
foo[k] = ['foo'];
| {
"end_byte": 357,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/computedPropertiesWithSetterAssignment.ts"
} |
TypeScript/tests/cases/compiler/fileWithNextLine1.ts_3_136 | Note: there is a nextline (0x85) in the string
// 0. It should be counted as a space and should not cause an error.
var v = '
'; | {
"end_byte": 136,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/fileWithNextLine1.ts"
} |
TypeScript/tests/cases/compiler/unusedFunctionsinNamespaces4.ts_0_156 | //@noUnusedLocals:true
//@noUnusedParameters:true
namespace Validation {
var function1 = function() {
}
export function function2() {
}
} | {
"end_byte": 156,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedFunctionsinNamespaces4.ts"
} |
TypeScript/tests/cases/compiler/moduleOuterQualification.ts_0_189 | // @declaration: true
declare module outer {
interface Beta { }
module inner {
// .d.ts emit: should be 'extends outer.Beta'
export interface Beta extends outer.Beta { }
}
}
| {
"end_byte": 189,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleOuterQualification.ts"
} |
TypeScript/tests/cases/compiler/unusedPrivateMethodInClass4.ts_0_251 | //@noUnusedLocals:true
//@noUnusedParameters:true
class greeter {
private function1() {
var y = 10;
}
private function2() {
var y = 10;
}
public function3() {
var y = 10;
this.function2();
}
} | {
"end_byte": 251,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedPrivateMethodInClass4.ts"
} |
TypeScript/tests/cases/compiler/declarationEmitForGlobalishSpecifierSymlink2.ts_0_712 | // @useCaseSensitiveFilenames: true
// @declaration: true
// @filename: /cache/typescript-fsa/src/impl.d.ts
export function getA(): A;
export enum A {
Val
}
// @filename: /cache/typescript-fsa/index.d.ts
export * from "./src/impl";
// @filename: /cache/typescript-fsa/package.json
{
"name": "typescript-fsa",
"version": "1.0.0"
}
// @filename: /p1/index.ts
import * as _whatever from "p2";
import { getA } from "typescript-fsa";
export const a = getA();
// @filename: /p2/index.d.ts
export const a: import("typescript-fsa").A;
// @link: /p2 -> /p1/node_modules/p2
// @link: /cache/typescript-fsa -> /p1/node_modules/typescript-fsa
// @link: /cache/typescript-fsa -> /p2/node_modules/typescript-fsa
| {
"end_byte": 712,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitForGlobalishSpecifierSymlink2.ts"
} |
TypeScript/tests/cases/compiler/circularBaseTypes.ts_0_321 | // @strict: true
// @declaration: true
// Repro from #38098
type M<T> = { value: T };
interface M2 extends M<M3> {}; // Error
type M3 = M2[keyof M2]; // Error
function f(m: M3) {
return m.value;
}
// Repro from #32581
type X<T> = { [K in keyof T]: string } & { b: string };
interface Y extends X<Y> {
a: "";
}
| {
"end_byte": 321,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/circularBaseTypes.ts"
} |
TypeScript/tests/cases/compiler/spreadIdenticalTypesRemoved.ts_0_453 | // @strict: true
interface Animal {
name: string;
kind: string;
age: number;
location: string;
owner: object;
}
function clonePet(pet: Animal, fullCopy?: boolean) {
return {
name: pet.name,
kind: pet.kind,
...(fullCopy && pet),
}
}
interface Animal2 {
name: string;
owner?: string;
}
function billOwner(pet: Animal2) {
return {
...(pet.owner && pet),
paid: false
}
}
| {
"end_byte": 453,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/spreadIdenticalTypesRemoved.ts"
} |
TypeScript/tests/cases/compiler/for.ts_0_376 | // @allowUnreachableCode: true
for (var i = 0; i < 10; i++) { // ok
var x1 = i;
}
for (var j: number = 0; j < 10; j++) { // ok
var x2 = j;
}
for (var k = 0; k < 10;) { // ok
k++;
}
for (; i < 10;) { // ok
i++;
}
for (; i > 1; i--) { // ok
}
for (var l = 0; ; l++) { // ok
if (l > 10) {
break;
}
}
for (; ;) { // ok
}
for () { // error
} | {
"end_byte": 376,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/for.ts"
} |
TypeScript/tests/cases/compiler/destructuringTypeGuardFlow.ts_0_821 | // @strictNullChecks: true
type foo = {
bar: number | null;
baz: string;
nested: {
a: number;
b: string | null;
}
};
const aFoo: foo = { bar: 3, baz: "b", nested: { a: 1, b: "y" } };
if (aFoo.bar && aFoo.nested.b) {
const { bar, baz, nested: {a, b: text} } = aFoo;
const right: number = aFoo.bar;
const wrong: number = bar;
const another: string = baz;
const aAgain: number = a;
const bAgain: string = text;
}
type bar = {
elem1: number | null;
elem2: foo | null;
};
const bBar = { elem1: 7, elem2: aFoo };
if (bBar.elem2 && bBar.elem2.bar && bBar.elem2.nested.b) {
const { bar, baz, nested: {a, b: text} } = bBar.elem2;
const right: number = bBar.elem2.bar;
const wrong: number = bar;
const another: string = baz;
const aAgain: number = a;
const bAgain: string = text;
}
| {
"end_byte": 821,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/destructuringTypeGuardFlow.ts"
} |
TypeScript/tests/cases/compiler/classExtendsMultipleBaseClasses.ts_0_47 | class A { }
class B { }
class C extends A,B { } | {
"end_byte": 47,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classExtendsMultipleBaseClasses.ts"
} |
TypeScript/tests/cases/compiler/separate1-2.ts_0_40 | module X {
export function f() { }
} | {
"end_byte": 40,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/separate1-2.ts"
} |
TypeScript/tests/cases/compiler/declarationEmitSpreadStringlyKeyedEnum.ts_0_161 | // @declaration: true
enum AgeGroups { "0-17" , "18-22" , "23-27" , "28-34" , "35-44" , "45-59" , "60-150" }
export const SpotifyAgeGroupEnum = { ...AgeGroups }; | {
"end_byte": 161,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitSpreadStringlyKeyedEnum.ts"
} |
TypeScript/tests/cases/compiler/declFileAccessors.ts_0_2176 | // @target: ES5
// @declaration: true
// @removeComments: false
// @module: commonjs
// @Filename: declFileAccessors_0.ts
/** This is comment for c1*/
export class c1 {
/** getter property*/
public get p3() {
return 10;
}
/** setter property*/
public set p3(/** this is value*/value: number) {
}
/** private getter property*/
private get pp3() {
return 10;
}
/** private setter property*/
private set pp3(/** this is value*/value: number) {
}
/** static getter property*/
static get s3() {
return 10;
}
/** setter property*/
static set s3( /** this is value*/value: number) {
}
public get nc_p3() {
return 10;
}
public set nc_p3(value: number) {
}
private get nc_pp3() {
return 10;
}
private set nc_pp3(value: number) {
}
static get nc_s3() {
return "";
}
static set nc_s3(value: string) {
}
// Only getter property
public get onlyGetter() {
return 10;
}
// Only setter property
public set onlySetter(value: number) {
}
}
// @Filename: declFileAccessors_1.ts
/** This is comment for c2 - the global class*/
class c2 {
/** getter property*/
public get p3() {
return 10;
}
/** setter property*/
public set p3(/** this is value*/value: number) {
}
/** private getter property*/
private get pp3() {
return 10;
}
/** private setter property*/
private set pp3(/** this is value*/value: number) {
}
/** static getter property*/
static get s3() {
return 10;
}
/** setter property*/
static set s3( /** this is value*/value: number) {
}
public get nc_p3() {
return 10;
}
public set nc_p3(value: number) {
}
private get nc_pp3() {
return 10;
}
private set nc_pp3(value: number) {
}
static get nc_s3() {
return "";
}
static set nc_s3(value: string) {
}
// Only getter property
public get onlyGetter() {
return 10;
}
// Only setter property
public set onlySetter(value: number) {
}
} | {
"end_byte": 2176,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileAccessors.ts"
} |
TypeScript/tests/cases/compiler/inheritedConstructorWithRestParams2.ts_0_677 | class IBaseBase<T, U> {
constructor(x: U) { }
}
interface IBase<T, U> extends IBaseBase<T, U> { }
class BaseBase2 {
constructor(x: number) { }
}
declare class BaseBase<T, U> extends BaseBase2 implements IBase<T, U> {
constructor(x: T, ...y: U[]);
constructor(x1: T, x2: T, ...y: U[]);
constructor(x1: T, x2: U, y: T);
}
class Base extends BaseBase<string, number> {
}
class Derived extends Base { }
// Ok
new Derived("", "");
new Derived("", 3);
new Derived("", 3, 3);
new Derived("", 3, 3, 3);
new Derived("", 3, "");
new Derived("", "", 3);
new Derived("", "", 3, 3);
// Errors
new Derived(3);
new Derived("", 3, "", 3);
new Derived("", 3, "", ""); | {
"end_byte": 677,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inheritedConstructorWithRestParams2.ts"
} |
TypeScript/tests/cases/compiler/sourceMapPercentEncoded.ts_0_201 | // @sourceMap: true
// @Filename: ①Ⅻㄨㄩ 啊阿鼾齄丂丄狚狛狜狝﨨﨩ˊˋ˙–⿻〇㐀㐁䶴䶵U1[]U2[]U3[].ts
var a = 1;
var b = 2;
var c = 3; | {
"end_byte": 201,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapPercentEncoded.ts"
} |
TypeScript/tests/cases/compiler/spreadBooleanRespectsFreshness.ts_0_184 | type Foo = FooBase | FooArray;
type FooBase = string | false;
type FooArray = FooBase[];
declare let foo1: Foo;
declare let foo2: Foo;
foo1 = [...Array.isArray(foo2) ? foo2 : [foo2]]; | {
"end_byte": 184,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/spreadBooleanRespectsFreshness.ts"
} |
TypeScript/tests/cases/compiler/typeParameterFixingWithConstraints.ts_0_229 | interface IBar {
[barId: string]: any;
}
interface IFoo {
foo<TBar extends IBar>(bar: TBar, bar1: (bar: TBar) => TBar, bar2: (bar: TBar) => TBar): TBar;
}
var foo: IFoo;
foo.foo({ bar: null }, bar => null, bar => null); | {
"end_byte": 229,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeParameterFixingWithConstraints.ts"
} |
TypeScript/tests/cases/compiler/emitBundleWithShebangAndPrologueDirectives1.ts_3_154 | @outFile: outFile.js
// @module: amd
// @target: es5
// @Filename: test.ts
#!/usr/bin/env gjs
"use strict"
class Doo {}
class Scooby extends Doo {} | {
"end_byte": 154,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emitBundleWithShebangAndPrologueDirectives1.ts"
} |
TypeScript/tests/cases/compiler/concatClassAndString.ts_0_80 | // Shouldn't compile (the long form f = f + ""; doesn't):
class f { }
f += '';
| {
"end_byte": 80,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/concatClassAndString.ts"
} |
TypeScript/tests/cases/compiler/escapedReservedCompilerNamedIdentifier.ts_0_487 | //@declaration: true
// double underscores
var __proto__ = 10;
var o = {
"__proto__": 0
};
var b = o["__proto__"];
var o1 = {
__proto__: 0
};
var b1 = o1["__proto__"];
// Triple underscores
var ___proto__ = 10;
var o2 = {
"___proto__": 0
};
var b2 = o2["___proto__"];
var o3 = {
___proto__: 0
};
var b3 = o3["___proto__"];
// One underscore
var _proto__ = 10;
var o4 = {
"_proto__": 0
};
var b4 = o4["_proto__"];
var o5 = {
_proto__: 0
};
var b5 = o5["_proto__"]; | {
"end_byte": 487,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/escapedReservedCompilerNamedIdentifier.ts"
} |
TypeScript/tests/cases/compiler/jsdocImportTypeResolution.ts_0_241 | // @allowJs: true
// @noEmit: true
// @checkJs: true
// @filename: module.js
export class MyClass {
}
// @filename: usage.js
/**
* @typedef {Object} options
* @property {import("./module").MyClass} option
*/
/** @type {options} */
let v; | {
"end_byte": 241,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsdocImportTypeResolution.ts"
} |
TypeScript/tests/cases/compiler/unusedImports2.ts_0_281 | //@noUnusedLocals:true
//@noUnusedParameters:true
// @Filename: file1.ts
export class Calculator {
handleChar() {}
}
export function test() {
}
// @Filename: file2.ts
import {Calculator} from "./file1"
import {test} from "./file1"
var x = new Calculator();
x.handleChar(); | {
"end_byte": 281,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedImports2.ts"
} |
TypeScript/tests/cases/compiler/recursiveTypeRelations.ts_0_998 | // Repro from #14896
type Attributes<Keys extends keyof any> = {
[Key in Keys]: string;
}
class Query<A extends Attributes<keyof A>> {
multiply<B extends Attributes<keyof B>>(x: B): Query<A & B>;
}
// Repro from #14940
type ClassName<S> = keyof S;
type ClassNameMap<S> = { [K in keyof S]?: boolean }
type ClassNameObjectMap<S> = object & ClassNameMap<S>;
type ClassNameArg<S> = ClassName<S> | ClassNameObjectMap<S>;
export function css<S extends { [K in keyof S]: string }>(styles: S, ...classNames: ClassNameArg<S>[]): string {
const args = classNames.map(arg => {
if (arg == null) {
return null;
}
if (typeof arg == "string") {
return styles[arg];
}
if (typeof arg == "object") {
return Object.keys(arg).reduce<ClassNameObject>((obj: ClassNameObject, key: keyof S) => {
const exportedClassName = styles[key];
obj[exportedClassName] = (arg as ClassNameMap<S>)[key];
return obj;
}, {});
}
});
return "";
}
| {
"end_byte": 998,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/recursiveTypeRelations.ts"
} |
TypeScript/tests/cases/compiler/es5-asyncFunctionForOfStatements.ts_0_1460 | // @lib: es5,es2015.promise
// @noEmitHelpers: true
// @target: ES5
declare var x, y, z, a, b, c;
async function forOfStatement0() {
for (x of y) { z; }
}
async function forOfStatement1() {
for (x of await y) { z; }
}
async function forOfStatement2() {
for (x of y) { await z; }
}
async function forOfStatement3() {
for ((await x).a of y) { z; }
}
async function forOfStatement4() {
for (x.a of await y) { z; }
}
async function forOfStatement5() {
for (x.a of y) { await z; }
}
async function forOfStatement6() {
for (var b of y) { z; }
}
async function forOfStatement7() {
for (var c of await y) { z; }
}
async function forOfStatement8() {
for (var d of y) { await z; }
}
async function forOfStatement9() {
for ([x] of await y) { z; }
}
async function forOfStatement10() {
for ([x] of y) { await z; }
}
async function forOfStatement11() {
for ([x = await a] of y) { z; }
}
async function forOfStatement12() {
for ([x = a] of await y) { z; }
}
async function forOfStatement13() {
for ([x = a] of y) { await z; }
}
async function forOfStatement14() {
for ({ x } of await y) { z; }
}
async function forOfStatement15() {
for ({ x } of y) { await z; }
}
async function forOfStatement16() {
for ({ x = await a } of y) { z; }
}
async function forOfStatement17() {
for ({ x = a } of await y) { z; }
}
async function forOfStatement18() {
for ({ x = a } of y) { await z; }
} | {
"end_byte": 1460,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es5-asyncFunctionForOfStatements.ts"
} |
TypeScript/tests/cases/compiler/pathMappingInheritedBaseUrl.ts_0_421 | // @noTypesAndSymbols: true
// @Filename: /other/tsconfig.base.json
{
"compilerOptions": {
"baseUrl": "."
}
}
// @Filename: /project/tsconfig.json
{
"extends": "../other/tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"paths": {
"p1": ["./lib/p1"]
}
}
}
// @Filename: /other/lib/p1/index.ts
export const p1 = 0;
// @Filename: /project/index.ts
import { p1 } from "p1";
| {
"end_byte": 421,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/pathMappingInheritedBaseUrl.ts"
} |
TypeScript/tests/cases/compiler/superCallFromFunction1.ts_1_54 | function foo() {
super(value => String(value));
} | {
"end_byte": 54,
"start_byte": 1,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/superCallFromFunction1.ts"
} |
TypeScript/tests/cases/compiler/genericWithCallSignatures1.ts_0_408 | // @Filename: genericWithCallSignatures_0.ts
interface Callable<T> {
(): T;
(value: T): void;
}
interface CallableExtention<T> extends Callable<T> { }
// @Filename: genericWithCallSignatures_1.ts
///<reference path="genericWithCallSignatures_0.ts"/>
class MyClass {
public callableThing: CallableExtention<string>;
public myMethod() {
var x = <string> this.callableThing();
}
} | {
"end_byte": 408,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericWithCallSignatures1.ts"
} |
TypeScript/tests/cases/compiler/firstMatchRegExpMatchArray.ts_0_172 | // @strict: true
// @noUncheckedIndexedAccess: true
const match = ''.match(/ /)
if (match !== null) {
const foo: string = match[0]
const bar: string = match[1]
}
| {
"end_byte": 172,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/firstMatchRegExpMatchArray.ts"
} |
TypeScript/tests/cases/compiler/deeplyNestedAssignabilityIssue.ts_0_448 | // @pretty: true
interface A {
a: number;
}
interface Large {
something: {
another: {
more: {
thing: A;
}
yetstill: {
another: A;
}
}
}
}
const x: Large = {
something: {
another: {
more: {
thing: {}
},
yetstill: {
another: {}
}
}
}
}
| {
"end_byte": 448,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/deeplyNestedAssignabilityIssue.ts"
} |
TypeScript/tests/cases/compiler/privatePropertyUsingObjectType.ts_0_349 | //@module: amd
export class FilterManager {
private _filterProviders: { index: IFilterProvider; };
private _filterProviders2: { [index: number]: IFilterProvider; };
private _filterProviders3: { (index: number): IFilterProvider; };
private _filterProviders4: (index: number) => IFilterProvider;
}
export interface IFilterProvider {
}
| {
"end_byte": 349,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privatePropertyUsingObjectType.ts"
} |
TypeScript/tests/cases/compiler/enumConflictsWithGlobalIdentifier.ts_0_128 | // @lib: es5
enum Position {
IgnoreRulesSpecific = 0,
}
var x = IgnoreRulesSpecific.
var y = Position.IgnoreRulesSpecific;
| {
"end_byte": 128,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumConflictsWithGlobalIdentifier.ts"
} |
TypeScript/tests/cases/compiler/amdDependencyCommentName2.ts_0_90 | //@module: amd
///<amd-dependency path='bar' name='b'/>
import m1 = require("m2")
m1.f(); | {
"end_byte": 90,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/amdDependencyCommentName2.ts"
} |
TypeScript/tests/cases/compiler/nestedBlockScopedBindings13.ts_0_84 | for (; false;) {
let x;
() => x;
}
for (; false;) {
let y;
y = 1;
} | {
"end_byte": 84,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nestedBlockScopedBindings13.ts"
} |
TypeScript/tests/cases/compiler/downlevelLetConst15.ts_0_772 | // @target:es5
'use strict'
declare function use(a: any);
var x = 10;
var z0, z1, z2, z3;
{
const x = 20;
use(x);
const [z0] = [1];
use(z0);
const [{a: z1}] = [{a: 1}]
use(z1);
const {a: z2} = { a: 1 };
use(z2);
const {a: {b: z3}} = { a: {b: 1} };
use(z3);
}
use(x);
use(z0);
use(z1);
use(z2);
use(z3);
var z6;
var y = true;
{
const y = "";
const [z6] = [true]
{
const y = 1;
const {a: z6} = { a: 1 }
use(y);
use(z6);
}
use(y);
use(z6);
}
use(y);
use(z6);
var z = false;
var z5 = 1;
{
const z = "";
const [z5] = [5];
{
const _z = 1;
const {a: _z5} = { a: 1 };
// try to step on generated name
use(_z);
}
use(z);
}
use(y); | {
"end_byte": 772,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/downlevelLetConst15.ts"
} |
TypeScript/tests/cases/compiler/systemModule3.ts_0_228 | // @module: system
// @filename: file1.ts
export default function() {}
// @filename: file2.ts
export default function f() {}
// @filename: file3.ts
export default class C {}
// @filename: file4.ts
export default class {} | {
"end_byte": 228,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/systemModule3.ts"
} |
TypeScript/tests/cases/compiler/jsFileCompilationMethodOverloadSyntax.ts_0_75 | // @allowJs: true
// @noEmit: true
// @filename: a.js
class A {
foo();
}
| {
"end_byte": 75,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationMethodOverloadSyntax.ts"
} |
TypeScript/tests/cases/compiler/moduleResolution_noLeadingDot.ts_0_125 | // @noImplicitReferences: true
// @Filename: /node_modules/@types/.svn/README.md
This is a test.
// @Filename: /a.ts
true;
| {
"end_byte": 125,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleResolution_noLeadingDot.ts"
} |
TypeScript/tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts_0_111 | //@noUnusedLocals:true
//@noUnusedParameters:true
var func = function(person: string) {
var unused = 20;
} | {
"end_byte": 111,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts"
} |
TypeScript/tests/cases/compiler/noImplicitAnyIndexingSuppressed.ts_3_1077 | @noImplicitAny: true
//@suppressImplicitAnyIndexErrors: true
enum MyEmusEnum {
emu
}
// Should be okay; should be a string.
var strRepresentation1 = MyEmusEnum[0]
// Should be okay; should be a string.
var strRepresentation2 = MyEmusEnum[MyEmusEnum.emu]
// Should be okay, as we suppress implicit 'any' property access checks
var strRepresentation3 = MyEmusEnum["monehh"];
// Should be okay; should be a MyEmusEnum
var strRepresentation4 = MyEmusEnum["emu"];
// Should be okay, as we suppress implicit 'any' property access checks
var x = {}["hi"];
// Should be okay, as we suppress implicit 'any' property access checks
var y = {}[10];
var hi: any = "hi";
var emptyObj = {};
// Should be okay, as we suppress implicit 'any' property access checks
var z1 = emptyObj[hi];
var z2 = (<any>emptyObj)[hi];
interface MyMap<T> {
[key: string]: T;
}
var m: MyMap<number> = {
"0": 0,
"1": 1,
"2": 2,
"Okay that's enough for today.": NaN
};
var mResult1 = m[MyEmusEnum.emu];
var mResult2 = m[MyEmusEnum[MyEmusEnum.emu]];
var mResult3 = m[hi];
| {
"end_byte": 1077,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noImplicitAnyIndexingSuppressed.ts"
} |
TypeScript/tests/cases/compiler/unknownSymbolInGenericReturnType.ts_0_268 | class Linq {
public static select<T, S>(values: T[], func: (v: T) => A): any[] {
var result = new Array(values.length);
for (var i = 0; i < values.length; i++) {
result[i] = func(values[i]);
}
return result;
}
}
| {
"end_byte": 268,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unknownSymbolInGenericReturnType.ts"
} |
TypeScript/tests/cases/compiler/moduleCodeGenTest5.ts_0_254 | //@module: commonjs
export var x = 0;
var y = 0;
export function f1() {}
function f2() {}
export class C1 {
public p1 = 0;
public p2() {}
}
class C2{
public p1 = 0;
public p2() {}
}
export enum E1 {A=0}
var u = E1.A;
enum E2 {B=0}
var v = E2.B;
| {
"end_byte": 254,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleCodeGenTest5.ts"
} |
TypeScript/tests/cases/compiler/declarationEmitInferredTypeAlias8.ts_0_129 | // @declaration: true
type Foo<T> = T | { x: Foo<T> };
var x: Foo<number[]>;
function returnSomeGlobalValue() {
return x;
} | {
"end_byte": 129,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitInferredTypeAlias8.ts"
} |
TypeScript/tests/cases/compiler/declarationEmitLateBoundAssignments.ts_0_422 | // @strict: true
// @declaration: true
// @target: es6
export function foo() {}
foo.bar = 12;
const _private = Symbol();
foo[_private] = "ok";
const strMem = "strMemName";
foo[strMem] = "ok";
const dashStrMem = "dashed-str-mem";
foo[dashStrMem] = "ok";
const numMem = 42;
foo[numMem] = "ok";
const x: string = foo[_private];
const y: string = foo[strMem];
const z: string = foo[numMem];
const a: string = foo[dashStrMem]; | {
"end_byte": 422,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitLateBoundAssignments.ts"
} |
TypeScript/tests/cases/compiler/mixingStaticAndInstanceOverloads.ts_0_548 | class C1 {
// ERROR
foo1(n: number);
foo1(s: string);
static foo1(a) { }
}
class C2 {
// ERROR
static foo2(n: number);
static foo2(s: string);
foo2(a) { }
}
class C3 {
// ERROR
foo3(n: number);
static foo3(s: string);
foo3(a) { }
}
class C4 {
// ERROR
static foo4(n: number);
foo4(s: string);
static foo4(a) { }
}
class C5 {
// OK
foo5(n: number);
foo5(s: string);
foo5(a) { }
// OK
static foo5(n: number);
static foo5(s: string);
static foo5(a) { }
} | {
"end_byte": 548,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mixingStaticAndInstanceOverloads.ts"
} |
TypeScript/tests/cases/compiler/exportTwoInterfacesWithSameName.ts_0_44 | export interface I {}
export interface I {}
| {
"end_byte": 44,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/exportTwoInterfacesWithSameName.ts"
} |
TypeScript/tests/cases/compiler/declarationEmitFunctionKeywordProp.ts_0_170 | // @declaration: true
function foo() {}
foo.null = true;
function bar() {}
bar.async = true;
bar.normal = false;
function baz() {}
baz.class = true;
baz.normal = false; | {
"end_byte": 170,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitFunctionKeywordProp.ts"
} |
TypeScript/tests/cases/compiler/importAliasFromNamespace.ts_0_506 | // @declaration: true
// @filename: internal.ts
namespace My.Internal {
export function getThing(): void {}
export const enum WhichThing {
A, B, C
}
}
// @filename: usage.ts
/// <reference path="./internal.ts" preserve="true" />
namespace SomeOther.Thing {
import Internal = My.Internal;
export class Foo {
private _which: Internal.WhichThing;
constructor() {
Internal.getThing();
Internal.WhichThing.A ? "foo" : "bar";
}
}
} | {
"end_byte": 506,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importAliasFromNamespace.ts"
} |
TypeScript/tests/cases/compiler/cachedModuleResolution8.ts_0_163 | // @moduleResolution: classic
// @traceResolution: true
// @filename: /a/b/c/d/e/app.ts
import {x} from "foo";
// @filename: /a/b/c/lib.ts
import {x} from "foo"; | {
"end_byte": 163,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/cachedModuleResolution8.ts"
} |
TypeScript/tests/cases/compiler/emptyThenWarning.ts_0_55 | if(1);
let x = 0;
if (true === true); {
x = 1;
} | {
"end_byte": 55,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/emptyThenWarning.ts"
} |
TypeScript/tests/cases/compiler/contextualTypeBasedOnIntersectionWithAnyInTheMix2.ts_0_614 | // @strict: true
// @noEmit: true
type IntrinsicElements = {
a: {
href?: string;
};
div: {
dir?: string;
};
};
type Component<Props> = (props: Props) => unknown;
interface NestedMDXComponents {
[key: string]: Component<any>;
}
type MDXComponents = NestedMDXComponents & {
[Key in keyof IntrinsicElements]?: Component<IntrinsicElements[Key]>;
};
export interface MDXProps {
components?: MDXComponents;
}
declare function MyMDXComponent(props: MDXProps): null;
MyMDXComponent({
components: {
a(props) {
return null;
},
div(props) {
return null;
},
},
});
| {
"end_byte": 614,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTypeBasedOnIntersectionWithAnyInTheMix2.ts"
} |
TypeScript/tests/cases/compiler/declarationEmitExpressionInExtends3.ts_0_799 | // @declaration: true
export class ExportedClass<T> {
x: T;
}
class LocalClass<T, U> {
x: T;
y: U;
}
export interface ExportedInterface {
x: number;
}
interface LocalInterface {
x: number;
}
function getLocalClass<T>(c: T) {
return LocalClass;
}
function getExportedClass<T>(c: T) {
return ExportedClass;
}
export class MyClass extends getLocalClass<LocalInterface>(undefined)<string, number> { // error LocalClass is inaccisible
}
export class MyClass2 extends getExportedClass<LocalInterface>(undefined)<string> { // OK
}
export class MyClass3 extends getExportedClass<LocalInterface>(undefined)<LocalInterface> { // Error LocalInterface is inaccisble
}
export class MyClass4 extends getExportedClass<LocalInterface>(undefined)<ExportedInterface> { // OK
}
| {
"end_byte": 799,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitExpressionInExtends3.ts"
} |
TypeScript/tests/cases/compiler/destructuringInVariableDeclarations2.ts_0_99 | // @target: es6
// @module: commonjs
let { toString } = 1;
{
let { toFixed } = 1;
}
export {};
| {
"end_byte": 99,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/destructuringInVariableDeclarations2.ts"
} |
TypeScript/tests/cases/compiler/contextualTyping35.ts_0_46 | var foo = <{ id: number;}> {id:4, name: "as"}; | {
"end_byte": 46,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTyping35.ts"
} |
TypeScript/tests/cases/compiler/unusedPrivateVariableInClass3.ts_0_137 | //@noUnusedLocals:true
//@noUnusedParameters:true
class greeter {
private x: string;
private y: string;
public z: string;
} | {
"end_byte": 137,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedPrivateVariableInClass3.ts"
} |
TypeScript/tests/cases/compiler/classMemberInitializerWithLamdaScoping5.ts_0_260 | // @lib: es5
declare var console: {
log(message?: any, ...optionalParams: any[]): void;
};
class Greeter {
constructor(message: string) {
}
messageHandler = (message: string) => {
console.log(message); // This shouldnt be error
}
} | {
"end_byte": 260,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classMemberInitializerWithLamdaScoping5.ts"
} |
TypeScript/tests/cases/compiler/tsxFragmentChildrenCheck.ts_0_698 | // @jsx: react
// @noUnusedLocals: true
// @noLib: true
// @skipLibCheck: true
// @libFiles: react.d.ts,lib.d.ts
// @Filename: my-component.tsx
declare var React: any;
export function MyComponent(props: any) {
return <span>my component</span>;
}
// @Filename: file1.tsx
import * as React from 'react'
import { MyComponent } from './my-component'
const MY_STRING: string = 'Ceci n\'est pas une string.'
const MY_CLASSNAME: string = 'jeclass'
class RenderString extends React.PureComponent<any, any> {
render() {
return (
<>
<MyComponent />
<span>{ MY_STRING }</span>
<span className={ MY_CLASSNAME } />
</>
)
}
}
export default RenderString | {
"end_byte": 698,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/tsxFragmentChildrenCheck.ts"
} |
TypeScript/tests/cases/compiler/inheritedStringIndexersFromDifferentBaseTypes2.ts_0_392 | // indexer in B is a subtype of indexer in A
interface A {
[s: string]: {
a;
};
}
interface B {
[s: number]: {
a;
b;
};
}
interface C extends A, B { } // ok
interface D {
[s: number]: {};
}
interface E extends A, D { } // error
interface F extends A, D {
[s: number]: {
a;
};
} // ok because we overrode D's number index signature | {
"end_byte": 392,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inheritedStringIndexersFromDifferentBaseTypes2.ts"
} |
TypeScript/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision7.ts_0_482 | // @noemithelpers: true
// @experimentaldecorators: true
// @emitdecoratormetadata: true
// @target: es5
// @module: commonjs
// @filename: db.ts
export default class db {
public doSomething() {
}
}
// @filename: service.ts
import db from './db';
function someDecorator(target) {
return target;
}
@someDecorator
class MyClass {
db: db.db; //error
constructor(db: db.db) { // error
this.db = db;
this.db.doSomething();
}
}
export {MyClass};
| {
"end_byte": 482,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision7.ts"
} |
TypeScript/tests/cases/compiler/taggedTemplateStringsWithMultilineTemplate.ts_0_47 | function f(...args: any[]): void {
}
f `
\
`; | {
"end_byte": 47,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/taggedTemplateStringsWithMultilineTemplate.ts"
} |
TypeScript/tests/cases/compiler/importHelpersNoHelpersForPrivateFields.ts_0_283 | // @importHelpers: true
// @target: es2020
// @module: commonjs
// @lib: esnext
// @moduleResolution: classic
// @filename: main.ts
export class Foo {
#field = true;
f() {
this.#field = this.#field;
#field in this;
}
}
// @filename: tslib.d.ts
export {}
| {
"end_byte": 283,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/importHelpersNoHelpersForPrivateFields.ts"
} |
TypeScript/tests/cases/compiler/es5ExportDefaultFunctionDeclaration2.ts_0_91 | // @target: es5
// @module: commonjs
// @declaration: true
export default function () { }
| {
"end_byte": 91,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es5ExportDefaultFunctionDeclaration2.ts"
} |
TypeScript/tests/cases/compiler/superNoModifiersCrash.ts_0_225 | // @allowjs: true
// @outDir: ../
// @filename: File.js
class Parent {
initialize() {
super.initialize(...arguments)
return this.asdf = ''
}
}
class Child extends Parent {
initialize() {
}
} | {
"end_byte": 225,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/superNoModifiersCrash.ts"
} |
TypeScript/tests/cases/compiler/errorMessageOnObjectLiteralType.ts_0_102 | var x: {
a: string;
b: number;
};
x.getOwnPropertyNamess();
Object.getOwnPropertyNamess(null); | {
"end_byte": 102,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/errorMessageOnObjectLiteralType.ts"
} |
TypeScript/tests/cases/compiler/cloduleWithPriorUninstantiatedModule.ts_3_227 | Non-ambient & uninstantiated module.
module Moclodule {
export interface Someinterface {
foo(): void;
}
}
class Moclodule {
}
// Instantiated module.
module Moclodule {
export class Manager {
}
} | {
"end_byte": 227,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/cloduleWithPriorUninstantiatedModule.ts"
} |
TypeScript/tests/cases/compiler/tsxReactPropsInferenceSucceedsOnIntersections.tsx_0_490 | // @jsx: react
// @esModuleInterop: true
// @strictNullChecks: true
/// <reference path="/.lib/react16.d.ts" />
import React from "react";
export type ButtonProps<T = {}> = React.ButtonHTMLAttributes<HTMLButtonElement> & {
outline?: boolean;
} & T;
declare class Button<T = {}> extends React.Component<ButtonProps<T>> { }
interface CustomButtonProps extends ButtonProps {
customProp: string;
}
const CustomButton: React.SFC<CustomButtonProps> = props => <Button {...props} />;
| {
"end_byte": 490,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/tsxReactPropsInferenceSucceedsOnIntersections.tsx"
} |
TypeScript/tests/cases/compiler/defaultNamedExportWithType2.ts_0_74 | // @target: esnext
type Foo = number;
const Foo = 1;
export default Foo;
| {
"end_byte": 74,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/defaultNamedExportWithType2.ts"
} |
TypeScript/tests/cases/compiler/jsxHasLiteralType.tsx_0_279 | // @strictNullChecks: true
// @jsx: react
// @skipLibCheck: true
// @libFiles: lib.d.ts,react.d.ts
import * as React from "react";
interface Props {
x?: "a" | "b";
}
class MyComponent<P extends Props = Props> extends React.Component<P, {}> {}
const m = <MyComponent x="a"/>
| {
"end_byte": 279,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsxHasLiteralType.tsx"
} |
TypeScript/tests/cases/compiler/genericArrayAssignmentCompatErrors.ts_0_363 | var myCars=new Array();
var myCars2 = new [];
var myCars3 = new Array({});
var myCars4: Array; // error
var myCars5: Array<any>[];
myCars = myCars2;
myCars = myCars3;
myCars = myCars4;
myCars = myCars5;
myCars2 = myCars;
myCars2 = myCars3;
myCars2 = myCars4;
myCars2 = myCars5;
myCars3 = myCars;
myCars3 = myCars2;
myCars3 = myCars4;
myCars3 = myCars5;
| {
"end_byte": 363,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericArrayAssignmentCompatErrors.ts"
} |
TypeScript/tests/cases/compiler/overrideBaseIntersectionMethod.ts_0_616 | // @strict: true
// Repro from #14615
type Constructor<T> = new (...args: any[]) => T;
const WithLocation = <T extends Constructor<Point>>(Base: T) => class extends Base {
getLocation(): [number, number] {
const [x,y] = super.getLocation();
return [this.x | x, this.y | y];
}
}
class Point {
constructor(public x: number, public y: number) { }
getLocation(): [number, number] {
return [0,0];
}
}
class Foo extends WithLocation(Point) {
calculate() {
return this.x + this.y;
}
getLocation() {
return super.getLocation()
}
whereAmI() {
return this.getLocation();
}
}
| {
"end_byte": 616,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overrideBaseIntersectionMethod.ts"
} |
TypeScript/tests/cases/compiler/nestedCallbackErrorNotFlattened.ts_0_378 | // @strict: true
type Cb<T> = {noAlias: () => T}["noAlias"]; // `"noAlias"` here prevents an alias symbol from being made
// which means the comparison will definitely be structural, rather than by variance
declare const x: Cb<Cb<Cb<Cb<number>>>>; // one more layer of `Cb` adn we'd get a `true` from the deeply-nested symbol check
declare let y: Cb<Cb<Cb<Cb<string>>>>;
y = x; | {
"end_byte": 378,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nestedCallbackErrorNotFlattened.ts"
} |
TypeScript/tests/cases/compiler/prespecializedGenericMembers1.ts_0_317 | //@module: commonjs
export interface IKitty {
}
export class Cat<CatType extends IKitty> {
constructor() {
}
}
export class CatBag {
constructor(cats: { barry: Cat<IKitty>; }) {
}
}
var cat = new Cat<IKitty>();
var catThing = {
barry: cat
};
var catBag = new CatBag(catThing); | {
"end_byte": 317,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/prespecializedGenericMembers1.ts"
} |
TypeScript/tests/cases/compiler/constDeclarations-useBeforeDefinition.ts_0_86 | // @target: ES6
{
c1;
const c1 = 0;
}
var v1;
{
v1;
const v1 = 0;
}
| {
"end_byte": 86,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constDeclarations-useBeforeDefinition.ts"
} |
TypeScript/tests/cases/compiler/quotedModuleNameMustBeAmbient.ts_0_37 | module 'M' {}
declare module 'M2' {} | {
"end_byte": 37,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/quotedModuleNameMustBeAmbient.ts"
} |
TypeScript/tests/cases/compiler/mapGroupBy.ts_0_342 | // @target: esnext
const basic = Map.groupBy([0, 2, 8], x => x < 5 ? 'small' : 'large');
const chars = Map.groupBy('a string', c => c);
type Employee = { name: string, role: 'ic' | 'manager' }
const employees: Set<Employee> = new Set();
const byRole = Map.groupBy(employees, x => x.role);
const byNonKey = Map.groupBy(employees, x => x);
| {
"end_byte": 342,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mapGroupBy.ts"
} |
TypeScript/tests/cases/compiler/errorHandlingInInstanceOf.ts_0_75 | if (x instanceof String) {
}
var y: any;
if (y instanceof UnknownType) {
} | {
"end_byte": 75,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/errorHandlingInInstanceOf.ts"
} |
TypeScript/tests/cases/compiler/multiModuleClodule1.ts_0_255 | class C {
constructor(x: number) { }
foo() { }
bar() { }
static boo() { }
}
module C {
export var x = 1;
var y = 2;
}
module C {
export function foo() { }
function baz() { return ''; }
}
var c = new C(C.x);
c.foo = C.foo; | {
"end_byte": 255,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/multiModuleClodule1.ts"
} |
TypeScript/tests/cases/compiler/tailRecursiveConditionalTypes.ts_0_1408 | // @strict: true
// @declaration: true
type Trim<S extends string> =
S extends ` ${infer T}` ? Trim<T> :
S extends `${infer T} ` ? Trim<T> :
S;
type T10 = Trim<' hello '>;
type T11 = Trim<' hello '>;
type GetChars<S> = GetCharsRec<S, never>;
type GetCharsRec<S, Acc> =
S extends `${infer Char}${infer Rest}` ? GetCharsRec<Rest, Char | Acc> : Acc;
type T20 = GetChars<'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'>;
type Reverse<T> = any[] extends T ? T : ReverseRec<T, []>;
type ReverseRec<T, Acc extends unknown[]> =
T extends [infer Head, ...infer Tail] ? ReverseRec<Tail, [Head, ...Acc]> : Acc;
type T30 = Reverse<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>;
type T31 = Reverse<string[]>;
type TupleOf<T, N extends number> = number extends N ? T[] : TupleOfRec<T, N, []>;
type TupleOfRec<T, N extends number, Acc extends unknown[]> =
Acc["length"] extends N ? Acc : TupleOfRec<T, N, [T, ...Acc]>;
type T40 = TupleOf<any, 200>;
type T41 = TupleOf<any, number>;
| {
"end_byte": 1408,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/tailRecursiveConditionalTypes.ts"
} |
TypeScript/tests/cases/compiler/declarationEmitForGlobalishSpecifierSymlink.ts_0_922 | // @useCaseSensitiveFilenames: true
// @declaration: true
// @filename: /p1/node_modules/typescript-fsa/src/impl.d.ts
export function getA(): A;
export enum A {
Val
}
// @filename: /p1/node_modules/typescript-fsa/index.d.ts
export * from "./src/impl";
// @filename: /p1/node_modules/typescript-fsa/package.json
{
"name": "typescript-fsa",
"version": "1.0.0"
}
// @filename: /p2/node_modules/typescript-fsa/src/impl.d.ts
export function getA(): A;
export enum A {
Val
}
// @filename: /p2/node_modules/typescript-fsa/index.d.ts
export * from "./src/impl";
// @filename: /p2/node_modules/typescript-fsa/package.json
{
"name": "typescript-fsa",
"version": "1.0.0"
}
// @filename: /p1/index.ts
import * as _whatever from "p2";
import { getA } from "typescript-fsa";
export const a = getA();
// @filename: /p2/index.d.ts
export const a: import("typescript-fsa").A;
// @link: /p2 -> /p1/node_modules/p2
| {
"end_byte": 922,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitForGlobalishSpecifierSymlink.ts"
} |
TypeScript/tests/cases/compiler/reuseInnerModuleMember.ts_0_308 | // @module: commonjs
// @Filename: reuseInnerModuleMember_0.ts
export module M { }
// @Filename: reuseInnerModuleMember_1.ts
///<reference path='reuseInnerModuleMember_0.ts'/>
declare module bar {
interface alpha { }
}
import f = require('./reuseInnerModuleMember_0');
module bar {
var x: alpha;
}
| {
"end_byte": 308,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/reuseInnerModuleMember.ts"
} |
TypeScript/tests/cases/compiler/voidOperator1.ts_0_58 | var x: any = void 1;
var y: void = void 1;
var z = void 1; | {
"end_byte": 58,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/voidOperator1.ts"
} |
TypeScript/tests/cases/compiler/unusedImportWithSpread.ts_0_282 | // @target: esnext
// @filename: a.ts
export default { a: 1 };
// @filename: b1.ts
import a from "./a";
const b1 = {} as unknown;
({
// @ts-ignore
...b1,
a
})
// @filename: b2.ts
import a from "./a";
const b2 = {} as never;
({
// @ts-ignore
...b2,
a
})
| {
"end_byte": 282,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unusedImportWithSpread.ts"
} |
TypeScript/tests/cases/compiler/typeofInObjectLiteralType.ts_0_94 | var a: { b: number; c: typeof b }; // Should give error for attempting to use type query on b. | {
"end_byte": 94,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeofInObjectLiteralType.ts"
} |
TypeScript/tests/cases/compiler/genericAssignmentCompatOfFunctionSignatures1.ts_0_164 | var x1 = function foo3<T, U extends { a: T; b: string }>(x: T, z: U) { }
var x2 = function foo3<T, U extends { a: T; b: number }>(x: T, z: U) { }
x1 = x2;
x2 = x1; | {
"end_byte": 164,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericAssignmentCompatOfFunctionSignatures1.ts"
} |
TypeScript/tests/cases/compiler/constructorArgWithGenericCallSignature.ts_0_283 | module Test {
export interface MyFunc {
<T>(value1: T): T;
}
export class MyClass {
constructor(func: MyFunc) { }
}
export function F(func: MyFunc) { }
}
var func: Test.MyFunc;
Test.F(func); // OK
var test = new Test.MyClass(func); // Should be OK
| {
"end_byte": 283,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constructorArgWithGenericCallSignature.ts"
} |
TypeScript/tests/cases/compiler/typeParameterDoesntBlockParameterLookup.ts_0_56 | declare function f<Foo extends Bar, Bar>(Bar: any): void | {
"end_byte": 56,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeParameterDoesntBlockParameterLookup.ts"
} |
TypeScript/tests/cases/compiler/collisionExportsRequireAndInternalModuleAliasInGlobalFile.ts_0_414 | module mOfGloalFile {
export class c {
}
}
import exports = mOfGloalFile.c;
import require = mOfGloalFile.c;
new exports();
new require();
module m1 {
import exports = mOfGloalFile.c;
import require = mOfGloalFile.c;
new exports();
new require();
}
module m2 {
export import exports = mOfGloalFile.c;
export import require = mOfGloalFile.c;
new exports();
new require();
} | {
"end_byte": 414,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionExportsRequireAndInternalModuleAliasInGlobalFile.ts"
} |
TypeScript/tests/cases/compiler/assigningFromObjectToAnythingElse.ts_0_153 | var x: Object;
var y: RegExp;
y = x;
var a: String = Object.create<Object>("");
var c: String = Object.create<Number>(1);
var w: Error = new Object();
| {
"end_byte": 153,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assigningFromObjectToAnythingElse.ts"
} |
TypeScript/tests/cases/compiler/commentOnParenthesizedExpressionOpenParen1.ts_0_57 | var j;
var f: () => any;
<any>( /* Preserve */ j = f());
| {
"end_byte": 57,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/commentOnParenthesizedExpressionOpenParen1.ts"
} |
TypeScript/tests/cases/compiler/classVarianceResolveCircularity2.ts_0_364 | // @strict: true
// Issue #52813
export {};
class Bar<T> {
num!: number;
Value = callme(new Foo(this)).bar.num;
Field: number = callme(new Foo(this)).bar.num;
}
declare function callme(x: Foo<any>): Foo<any>;
declare function callme(x: object): string;
class Foo<T> {
bar!: Bar<T>;
constructor(bar: Bar<T>) {
this.bar = bar;
}
} | {
"end_byte": 364,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/classVarianceResolveCircularity2.ts"
} |
TypeScript/tests/cases/compiler/unionRelationshipCheckPasses.ts_0_114 | // @strict: true
const item: { foo?: undefined } | { foo: number } = null as any as { foo?: number | undefined };
| {
"end_byte": 114,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unionRelationshipCheckPasses.ts"
} |
TypeScript/tests/cases/compiler/asyncIteratorExtraParameters.ts_0_325 | // @target: esnext
// @noEmit: true
// @noTypesAndSymbols: true
// https://github.com/microsoft/TypeScript/issues/57130
const iter = {
async *[Symbol.asyncIterator](_: number) {
yield 0;
}
};
declare function g(...args: any): any;
async function* f() {
for await (const _ of iter);
yield* iter;
}
| {
"end_byte": 325,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/asyncIteratorExtraParameters.ts"
} |
TypeScript/tests/cases/compiler/requireOfJsonFileWithoutOutDir.ts_0_285 | // @module: commonjs
// @fullEmitPaths: true
// @resolveJsonModule: true
// @Filename: file1.ts
import b1 = require('./b.json');
let x = b1.a;
import b2 = require('./b.json');
if (x) {
let b = b2.b;
x = (b1.b === b);
}
// @Filename: b.json
{
"a": true,
"b": "hello"
} | {
"end_byte": 285,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/requireOfJsonFileWithoutOutDir.ts"
} |
TypeScript/tests/cases/compiler/constEnumNamespaceReferenceCausesNoImport.ts_0_335 | // @isolatedModules: true, false
// @filename: foo.ts
export const enum ConstFooEnum {
Some,
Values,
Here
};
export function fooFunc(): void { /* removed */ }
// @filename: index.ts
import * as Foo from "./foo";
function check(x: Foo.ConstFooEnum): void {
switch (x) {
case Foo.ConstFooEnum.Some:
break;
}
} | {
"end_byte": 335,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constEnumNamespaceReferenceCausesNoImport.ts"
} |
TypeScript/tests/cases/compiler/esModuleIntersectionCrash.ts_0_293 | // @esModuleInterop: true
// @filename: mod.d.ts
export = modObj;
declare const modObj: modObj.A & modObj.B;
declare namespace modObj {
interface A { (): void; a: string; }
interface B { (x: string): void; b: string; }
}
// @filename: idx.ts
import * as mod from "./mod";
mod.a;
mod.b; | {
"end_byte": 293,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/esModuleIntersectionCrash.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.