_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
TypeScript/tests/cases/compiler/asyncFunctionsAcrossFiles.ts_0_243 | // @target: es6
// @filename: a.ts
import { b } from './b';
export const a = {
f: async () => {
await b.f();
}
};
// @filename: b.ts
import { a } from './a';
export const b = {
f: async () => {
await a.f();
}
}; | {
"end_byte": 243,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/asyncFunctionsAcrossFiles.ts"
} |
TypeScript/tests/cases/compiler/interMixingModulesInterfaces5.ts_0_222 | module A {
interface B {
name: string;
value: number;
}
export module B {
export function createB(): number {
return null;
}
}
}
var x: number = A.B.createB(); | {
"end_byte": 222,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/interMixingModulesInterfaces5.ts"
} |
TypeScript/tests/cases/compiler/typedArraysCrossAssignability01.ts_3_3415 | @target: ES6
function CheckAssignability() {
let arr_Int8Array = new Int8Array(1);
let arr_Uint8Array = new Uint8Array(1);
let arr_Int16Array = new Int16Array(1);
let arr_Uint16Array = new Uint16Array(1);
let arr_Int32Array = new Int32Array(1);
let arr_Uint32Array = new Uint32Array(1);
let arr_Float32Array = new Float32Array(1);
let arr_Float64Array = new Float64Array(1);
let arr_Uint8ClampedArray = new Uint8ClampedArray(1);
arr_Int8Array = arr_Int8Array;
arr_Int8Array = arr_Uint8Array;
arr_Int8Array = arr_Int16Array;
arr_Int8Array = arr_Uint16Array;
arr_Int8Array = arr_Int32Array;
arr_Int8Array = arr_Uint32Array;
arr_Int8Array = arr_Float32Array;
arr_Int8Array = arr_Float64Array;
arr_Int8Array = arr_Uint8ClampedArray;
arr_Uint8Array = arr_Int8Array;
arr_Uint8Array = arr_Uint8Array;
arr_Uint8Array = arr_Int16Array;
arr_Uint8Array = arr_Uint16Array;
arr_Uint8Array = arr_Int32Array;
arr_Uint8Array = arr_Uint32Array;
arr_Uint8Array = arr_Float32Array;
arr_Uint8Array = arr_Float64Array;
arr_Uint8Array = arr_Uint8ClampedArray;
arr_Int16Array = arr_Int8Array;
arr_Int16Array = arr_Uint8Array;
arr_Int16Array = arr_Int16Array;
arr_Int16Array = arr_Uint16Array;
arr_Int16Array = arr_Int32Array;
arr_Int16Array = arr_Uint32Array;
arr_Int16Array = arr_Float32Array;
arr_Int16Array = arr_Float64Array;
arr_Int16Array = arr_Uint8ClampedArray;
arr_Uint16Array = arr_Int8Array;
arr_Uint16Array = arr_Uint8Array;
arr_Uint16Array = arr_Int16Array;
arr_Uint16Array = arr_Uint16Array;
arr_Uint16Array = arr_Int32Array;
arr_Uint16Array = arr_Uint32Array;
arr_Uint16Array = arr_Float32Array;
arr_Uint16Array = arr_Float64Array;
arr_Uint16Array = arr_Uint8ClampedArray;
arr_Int32Array = arr_Int8Array;
arr_Int32Array = arr_Uint8Array;
arr_Int32Array = arr_Int16Array;
arr_Int32Array = arr_Uint16Array;
arr_Int32Array = arr_Int32Array;
arr_Int32Array = arr_Uint32Array;
arr_Int32Array = arr_Float32Array;
arr_Int32Array = arr_Float64Array;
arr_Int32Array = arr_Uint8ClampedArray;
arr_Float32Array = arr_Int8Array;
arr_Float32Array = arr_Uint8Array;
arr_Float32Array = arr_Int16Array;
arr_Float32Array = arr_Uint16Array;
arr_Float32Array = arr_Int32Array;
arr_Float32Array = arr_Uint32Array;
arr_Float32Array = arr_Float32Array;
arr_Float32Array = arr_Float64Array;
arr_Float32Array = arr_Uint8ClampedArray;
arr_Float64Array = arr_Int8Array;
arr_Float64Array = arr_Uint8Array;
arr_Float64Array = arr_Int16Array;
arr_Float64Array = arr_Uint16Array;
arr_Float64Array = arr_Int32Array;
arr_Float64Array = arr_Uint32Array;
arr_Float64Array = arr_Float32Array;
arr_Float64Array = arr_Float64Array;
arr_Float64Array = arr_Uint8ClampedArray;
arr_Uint8ClampedArray = arr_Int8Array;
arr_Uint8ClampedArray = arr_Uint8Array;
arr_Uint8ClampedArray = arr_Int16Array;
arr_Uint8ClampedArray = arr_Uint16Array;
arr_Uint8ClampedArray = arr_Int32Array;
arr_Uint8ClampedArray = arr_Uint32Array;
arr_Uint8ClampedArray = arr_Float32Array;
arr_Uint8ClampedArray = arr_Float64Array;
arr_Uint8ClampedArray = arr_Uint8ClampedArray;
}
| {
"end_byte": 3415,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typedArraysCrossAssignability01.ts"
} |
TypeScript/tests/cases/compiler/mixinPrivateAndProtected.ts_0_1569 | // Repro from #13830
type Constructor<T> = new(...args: any[]) => T;
class A {
public pb: number = 2;
protected ptd: number = 1;
private pvt: number = 0;
}
function mixB<T extends Constructor<{}>>(Cls: T) {
return class extends Cls {
protected ptd: number = 10;
private pvt: number = 0;
};
}
function mixB2<T extends Constructor<A>>(Cls: T) {
return class extends Cls {
protected ptd: number = 10;
};
}
const
AB = mixB(A),
AB2 = mixB2(A);
function mixC<T extends Constructor<{}>>(Cls: T) {
return class extends Cls {
protected ptd: number = 100;
private pvt: number = 0;
};
}
const
AB2C = mixC(AB2),
ABC = mixC(AB);
const
a = new A(),
ab = new AB(),
abc = new ABC(),
ab2c = new AB2C();
a.pb.toFixed();
a.ptd.toFixed(); // Error
a.pvt.toFixed(); // Error
ab.pb.toFixed();
ab.ptd.toFixed(); // Error
ab.pvt.toFixed(); // Error
abc.pb.toFixed();
abc.ptd.toFixed(); // Error
abc.pvt.toFixed(); // Error
ab2c.pb.toFixed();
ab2c.ptd.toFixed(); // Error
ab2c.pvt.toFixed(); // Error
// Repro from #13924
class Person {
constructor(public name: string) {}
protected myProtectedFunction() {
// do something
}
}
function PersonMixin<T extends Constructor<Person>>(Base: T) {
return class extends Base {
constructor(...args: any[]) {
super(...args);
}
myProtectedFunction() {
super.myProtectedFunction();
// do more things
}
};
}
class Customer extends PersonMixin(Person) {
accountBalance: number;
f() {
}
}
| {
"end_byte": 1569,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mixinPrivateAndProtected.ts"
} |
TypeScript/tests/cases/compiler/genericArgumentCallSigAssignmentCompat.ts_0_694 | module Underscore {
export interface Iterator<T, U> {
(value: T, index: any, list: any): U;
}
export interface Static {
all<T>(list: T[], iterator?: Iterator<T, boolean>, context?: any): boolean;
identity<T>(value: T): T;
}
}
declare var _: Underscore.Static;
// No error, Call signatures of types '<T>(value: T) => T' and 'Underscore.Iterator<{}, boolean>' are compatible when instantiated with any.
// Ideally, we would not have a generic signature here, because it should be instantiated with {} during inferential typing
_.all([true, 1, null, 'yes'], _.identity);
// Ok, because fixing makes us infer boolean for T
_.all([true], _.identity);
| {
"end_byte": 694,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericArgumentCallSigAssignmentCompat.ts"
} |
TypeScript/tests/cases/compiler/indexerA.ts_0_148 | class JQueryElement {
id:string;
}
class JQuery {
[n:number]:JQueryElement
}
var jq:JQuery={ 0: { id : "a" }, 1: { id : "b" } };
jq[0].id; | {
"end_byte": 148,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/indexerA.ts"
} |
TypeScript/tests/cases/compiler/letDeclarations2.ts_0_92 | // @target: ES6
// @declaration: true
module M {
let l1 = "s";
export let l2 = 0;
} | {
"end_byte": 92,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/letDeclarations2.ts"
} |
TypeScript/tests/cases/compiler/declareAlreadySeen.ts_0_142 | module M {
declare declare var x;
declare declare function f();
declare declare module N { }
declare declare class C { }
} | {
"end_byte": 142,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declareAlreadySeen.ts"
} |
TypeScript/tests/cases/compiler/contextSensitiveReturnTypeInference.ts_0_725 | // @strict: true
// Repro from #34849
interface IData {
bar: boolean
}
declare function test<TDependencies>(
getter: (deps: TDependencies, data: IData) => any,
deps: TDependencies,
): any
const DEPS = {
foo: 1
}
test(
(deps, data) => ({
fn1: function() { return deps.foo },
fn2: data.bar
}),
DEPS
);
test(
(deps: typeof DEPS, data) => ({
fn1: function() { return deps.foo },
fn2: data.bar
}),
DEPS
);
test(
(deps, data) => ({
fn1: () => deps.foo,
fn2: data.bar
}),
DEPS
);
test(
(deps, data) => {
return {
fn1() { return deps.foo },
fn2: data.bar
}
},
DEPS
);
test(
(deps) => ({
fn1() { return deps.foo },
fn2: 1
}),
DEPS
);
| {
"end_byte": 725,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextSensitiveReturnTypeInference.ts"
} |
TypeScript/tests/cases/compiler/nongenericConditionalNotPartiallyComputed.ts_0_187 | // Expected: type A = number
// Got: type A = number[] extends (infer T)[] ? T : never
type A = Array<number> extends Array<any> ? Array<number> extends Array<infer T> ? T : never : never | {
"end_byte": 187,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/nongenericConditionalNotPartiallyComputed.ts"
} |
TypeScript/tests/cases/compiler/inferenceShouldFailOnEvolvingArrays.ts_0_677 | // @strict: true
// repro from https://github.com/Microsoft/TypeScript/issues/25675
// The type of `arg` blocks inference but simplifies to T.
function logLength<T extends string, U extends string>(arg: { [K in U]: T }[U]): T {
console.log(arg.length);
return arg;
}
logLength(42); // error
let z;
z = logLength(42); // no error; T is inferred as `any`
function logFirstLength<T extends string[], U extends string>(arg: { [K in U]: T }[U]): T {
console.log(arg[0].length);
return arg;
}
logFirstLength([42]); // error
let zz = [];
zz.push(logLength(42)); // no error; T is inferred as `any`
zz = logFirstLength([42]); // no error; T is inferred as `any[]` | {
"end_byte": 677,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inferenceShouldFailOnEvolvingArrays.ts"
} |
TypeScript/tests/cases/compiler/narrowingTypeofFunction.ts_0_417 | // @strict: true
type Meta = { foo: string }
interface F { (): string }
function f1(a: (F & Meta) | string) {
if (typeof a === "function") {
a;
}
else {
a;
}
}
function f2<T>(x: (T & F) | T & string) {
if (typeof x === "function") {
x;
}
else {
x;
}
}
function f3(x: { _foo: number } & number) {
if (typeof x === "function") {
x;
}
} | {
"end_byte": 417,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowingTypeofFunction.ts"
} |
TypeScript/tests/cases/compiler/isolatedDeclarationErrorTypes1.ts_0_385 | // @isolatedDeclarations: true
// @strict: true
// @declaration: true
// @moduleResolution: nodenext
// @module: nodenext
// https://github.com/microsoft/TypeScript/issues/60192
import { Unresolved } from "foo";
export const foo1 = (type?: Unresolved): void => {};
export const foo2 = (type?: Unresolved | undefined): void => {};
export const foo3 = (type: Unresolved): void => {};
| {
"end_byte": 385,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/isolatedDeclarationErrorTypes1.ts"
} |
TypeScript/tests/cases/compiler/declarationEmitComputedPropertyNameEnum3.ts_0_315 | // @strict: true
// @declaration: true
// @emitDeclarationOnly: true
// @filename: type.ts
export namespace Foo {
export enum Enum {
A = "a",
B = "b",
}
}
export type Type = { x?: { [Foo.Enum]: 0 } };
// @filename: index.ts
import { type Type } from "./type";
export const foo = { ...({} as Type) };
| {
"end_byte": 315,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitComputedPropertyNameEnum3.ts"
} |
TypeScript/tests/cases/compiler/enumsWithMultipleDeclarations1.ts_0_46 | enum E {
A
}
enum E {
B
}
enum E {
C
} | {
"end_byte": 46,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumsWithMultipleDeclarations1.ts"
} |
TypeScript/tests/cases/compiler/sourceMap-Comments.ts_0_456 | // @target: ES5
// @sourcemap: true
module sas.tools {
export class Test {
public doX(): void {
let f: number = 2;
switch (f) {
case 1:
break;
case 2:
//line comment 1
//line comment 2
break;
case 3:
//a comment
break;
}
}
}
}
| {
"end_byte": 456,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMap-Comments.ts"
} |
TypeScript/tests/cases/compiler/typeAliasDeclareKeyword01.d.ts_0_45 | type Foo = number;
declare type Bar = string; | {
"end_byte": 45,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeAliasDeclareKeyword01.d.ts"
} |
TypeScript/tests/cases/compiler/declarationMapsMultifile.ts_0_345 | // @declaration: true
// @declarationMap: true
// @filename: a.ts
export class Foo {
doThing(x: {a: number}) {
return {b: x.a};
}
static make() {
return new Foo();
}
}
// @filename: index.ts
import {Foo} from "./a";
const c = new Foo();
c.doThing({a: 42});
export let x = c.doThing({a: 12});
export { c, Foo };
| {
"end_byte": 345,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationMapsMultifile.ts"
} |
TypeScript/tests/cases/compiler/errorForConflictingExportEqualsValue.ts_0_74 | // @lib: es6
// @Filename: /a.ts
export var x;
export = x;
import("./a");
| {
"end_byte": 74,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/errorForConflictingExportEqualsValue.ts"
} |
TypeScript/tests/cases/compiler/controlFlowJavascript.ts_0_1831 | // @allowJs: true
// @Filename: controlFlowJavascript.js
// @outFile: out.js
let cond = true;
// CFA for 'let' and no initializer
function f1() {
let x;
if (cond) {
x = 1;
}
if (cond) {
x = "hello";
}
const y = x; // string | number | undefined
}
// CFA for 'let' and 'undefined' initializer
function f2() {
let x = undefined;
if (cond) {
x = 1;
}
if (cond) {
x = "hello";
}
const y = x; // string | number | undefined
}
// CFA for 'let' and 'null' initializer
function f3() {
let x = null;
if (cond) {
x = 1;
}
if (cond) {
x = "hello";
}
const y = x; // string | number | null
}
// CFA for 'var' with no initializer
function f5() {
var x;
if (cond) {
x = 1;
}
if (cond) {
x = "hello";
}
const y = x; // string | number | undefined
}
// CFA for 'var' with 'undefined' initializer
function f6() {
var x = undefined;
if (cond) {
x = 1;
}
if (cond) {
x = "hello";
}
const y = x; // string | number | undefined
}
// CFA for 'var' with 'null' initializer
function f7() {
var x = null;
if (cond) {
x = 1;
}
if (cond) {
x = "hello";
}
const y = x; // string | number | null
}
// No CFA for captured outer variables
function f9() {
let x;
if (cond) {
x = 1;
}
if (cond) {
x = "hello";
}
const y = x; // string | number | undefined
function f() {
const z = x; // any
}
}
// No CFA for captured outer variables
function f10() {
let x;
if (cond) {
x = 1;
}
if (cond) {
x = "hello";
}
const y = x; // string | number | undefined
const f = () => {
const z = x; // any
};
}
| {
"end_byte": 1831,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/controlFlowJavascript.ts"
} |
TypeScript/tests/cases/compiler/declarationEmitNestedGenerics.ts_0_216 | // @declaration: true
function f<T>(p: T) {
let g: <T>(x: T) => typeof p = null as any;
return g;
}
function g<T>(x: T) {
let y: typeof x extends (infer T)[] ? T : typeof x = null as any;
return y;
} | {
"end_byte": 216,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitNestedGenerics.ts"
} |
TypeScript/tests/cases/compiler/jsdocRestParameter_es6.ts_0_159 | // @allowJs: true
// @checkJs: true
// @strict: true
// @noEmit: true
// @Filename: /a.js
/** @param {...number} a */
function f(...a) {
a; // number[]
}
| {
"end_byte": 159,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsdocRestParameter_es6.ts"
} |
TypeScript/tests/cases/compiler/unmetTypeConstraintInJSDocImportCall.ts_0_300 | // @allowJs: true
// @checkJs: true
// @noEmit: true
// @filename: file1.js
/**
* @template {string} T
* @typedef {{ foo: T }} Foo
*/
export default {};
// @allowJs: true
// @checkJs: true
// @noEmit: true
// @filename: file2.js
/**
* @template T
* @typedef {import('./file1').Foo<T>} Bar
*/
| {
"end_byte": 300,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unmetTypeConstraintInJSDocImportCall.ts"
} |
TypeScript/tests/cases/compiler/staticMemberOfClassAndPublicMemberOfAnotherClassAssignment.ts_0_335 | interface A {
prop();
}
class B {
public prop() { }
}
class C {
public static prop() { }
}
var a: A = new B();
a = new C(); // error prop is missing
a = B; // error prop is missing
a = C;
var b: B = new C(); // error prop is missing
b = B; // error prop is missing
b = C;
b = a;
var c: C = new B();
c = B;
c = C;
c = a;
| {
"end_byte": 335,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/staticMemberOfClassAndPublicMemberOfAnotherClassAssignment.ts"
} |
TypeScript/tests/cases/compiler/strictModeInConstructor.ts_0_903 | class A {
}
class B extends A {
public s: number = 9;
constructor () {
"use strict"; // No error
super();
}
}
class C extends A {
public s: number = 9;
constructor () {
super(); // No error
"use strict";
}
}
class D extends A {
public s: number = 9;
constructor () {
var x = 1; // No error
var y = this.s; // Error
super();
"use strict";
}
}
class Bs extends A {
public static s: number = 9;
constructor () {
"use strict"; // No error
super();
}
}
class Cs extends A {
public static s: number = 9;
constructor () {
super(); // No error
"use strict";
}
}
class Ds extends A {
public static s: number = 9;
constructor () {
var x = 1; // no Error
super();
"use strict";
}
} | {
"end_byte": 903,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/strictModeInConstructor.ts"
} |
TypeScript/tests/cases/compiler/identityForSignaturesWithTypeParametersSwitched.ts_0_63 | var f: <T, U>(x: T, y: U) => T;
var f: <T, U>(x: U, y: T) => U; | {
"end_byte": 63,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/identityForSignaturesWithTypeParametersSwitched.ts"
} |
TypeScript/tests/cases/compiler/detachedCommentAtStartOfConstructor2.ts_0_297 | class TestFile {
public message: string;
public name: string;
constructor(message: string) {
/// <summary>Test summary</summary>
/// <param name="message" type="String" />
var getMessage = () => message + this.name;
this.message = getMessage();
}
} | {
"end_byte": 297,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/detachedCommentAtStartOfConstructor2.ts"
} |
TypeScript/tests/cases/compiler/isDeclarationVisibleNodeKinds.ts_0_1428 | // @declaration: true
// @target: es5
// Function types
module schema {
export function createValidator1(schema: any): <T>(data: T) => T {
return undefined;
}
}
// Constructor types
module schema {
export function createValidator2(schema: any): new <T>(data: T) => T {
return undefined;
}
}
// union types
module schema {
export function createValidator3(schema: any): number | { new <T>(data: T): T; } {
return undefined;
}
}
// Array types
module schema {
export function createValidator4(schema: any): { new <T>(data: T): T; }[] {
return undefined;
}
}
// TypeLiterals
module schema {
export function createValidator5(schema: any): { new <T>(data: T): T } {
return undefined;
}
}
// Tuple types
module schema {
export function createValidator6(schema: any): [ new <T>(data: T) => T, number] {
return undefined;
}
}
// Paren Types
module schema {
export function createValidator7(schema: any): (new <T>(data: T)=>T )[] {
return undefined;
}
}
// Type reference
module schema {
export function createValidator8(schema: any): Array<{ <T>(data: T) : T}> {
return undefined;
}
}
module schema {
export class T {
get createValidator9(): <T>(data: T) => T {
return undefined;
}
set createValidator10(v: <T>(data: T) => T) {
}
}
} | {
"end_byte": 1428,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/isDeclarationVisibleNodeKinds.ts"
} |
TypeScript/tests/cases/compiler/implicitAnyDeclareVariablesWithoutTypeAndInit.ts_0_386 | // @noimplicitany: true
// this should be an error
var x; // no error, control flow typed
var y; // error because captured
declare var foo; // error at "foo"
function func(k) { y }; // error at "k"
func(x);
// this shouldn't be an error
var bar = 3;
var bar1: any;
declare var bar2: any;
var x1: any; var y1 = new x1; | {
"end_byte": 386,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/implicitAnyDeclareVariablesWithoutTypeAndInit.ts"
} |
TypeScript/tests/cases/compiler/declarationEmitMergedAliasWithConst.ts_0_182 | // @declaration: true
export const Color = {
Red: "Red",
Green: "Green",
Blue: "Blue"
} as const
export type Color = typeof Color
export type Colors = Color[keyof Color] | {
"end_byte": 182,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitMergedAliasWithConst.ts"
} |
TypeScript/tests/cases/compiler/systemModule18.ts_0_203 | // @module: system
// @filename: react.ts
export function createElement() {}
export function lazy() {}
export function useState() {}
// @filename: index.ts
export import React = require("./react.js");
| {
"end_byte": 203,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/systemModule18.ts"
} |
TypeScript/tests/cases/compiler/privacyGloGetter.ts_0_1752 | // @target: ES5
module m1 {
export class C1_public {
private f1() {
}
}
class C2_private {
}
export class C3_public {
private get p1_private() {
return new C1_public();
}
private set p1_private(m1_c3_p1_arg: C1_public) {
}
private get p2_private() {
return new C1_public();
}
private set p2_private(m1_c3_p2_arg: C1_public) {
}
private get p3_private() {
return new C2_private();
}
private set p3_private(m1_c3_p3_arg: C2_private) {
}
public get p4_public(): C2_private { // error
return new C2_private(); //error
}
public set p4_public(m1_c3_p4_arg: C2_private) { // error
}
}
class C4_private {
private get p1_private() {
return new C1_public();
}
private set p1_private(m1_c3_p1_arg: C1_public) {
}
private get p2_private() {
return new C1_public();
}
private set p2_private(m1_c3_p2_arg: C1_public) {
}
private get p3_private() {
return new C2_private();
}
private set p3_private(m1_c3_p3_arg: C2_private) {
}
public get p4_public(): C2_private {
return new C2_private();
}
public set p4_public(m1_c3_p4_arg: C2_private) {
}
}
}
class C6_public {
}
class C7_public {
private get p1_private() {
return new C6_public();
}
private set p1_private(m1_c3_p1_arg: C6_public) {
}
private get p2_private() {
return new C6_public();
}
private set p2_private(m1_c3_p2_arg: C6_public) {
}
} | {
"end_byte": 1752,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyGloGetter.ts"
} |
TypeScript/tests/cases/compiler/assignmentCompatability45.ts_0_117 | abstract class A {}
class B extends A {
constructor(x: number) {
super();
}
}
const b: typeof A = B;
| {
"end_byte": 117,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatability45.ts"
} |
TypeScript/tests/cases/compiler/enumAssignmentCompat3.ts_0_1564 | namespace First {
export enum E {
a, b, c,
}
}
namespace Abc {
export enum E {
a, b, c,
}
export enum Nope {
a, b, c,
}
}
namespace Abcd {
export enum E {
a, b, c, d,
}
}
namespace Ab {
export enum E {
a, b,
}
}
namespace Cd {
export enum E {
c, d,
}
}
namespace Const {
export const enum E {
a, b, c,
}
}
namespace Decl {
export declare enum E {
a, b, c = 3,
}
}
namespace Merged {
export enum E {
a, b,
}
export enum E {
c = 3, d,
}
}
namespace Merged2 {
export enum E {
a, b, c
}
export module E {
export let d = 5;
}
}
var abc: First.E;
var secondAbc: Abc.E;
var secondAbcd: Abcd.E;
var secondAb: Ab.E;
var secondCd: Cd.E;
var nope: Abc.Nope;
var k: Const.E;
var decl: Decl.E;
var merged: Merged.E;
var merged2: Merged2.E;
abc = secondAbc; // ok
abc = secondAbcd; // missing 'd'
abc = secondAb; // ok
abc = secondCd; // missing 'd'
abc = nope; // nope!
abc = decl; // bad - value of 'c' differs between these enums
secondAbc = abc; // ok
secondAbcd = abc; // ok
secondAb = abc; // missing 'c'
secondCd = abc; // missing 'a' and 'b'
nope = abc; // nope!
decl = abc; // bad - value of 'c' differs between these enums
// const is only assignable to itself
k = k;
abc = k; // error
k = abc;
// merged enums compare all their members
abc = merged; // missing 'd'
merged = abc; // bad - value of 'c' differs between these enums
abc = merged2; // ok
merged2 = abc; // ok | {
"end_byte": 1564,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/enumAssignmentCompat3.ts"
} |
TypeScript/tests/cases/compiler/interfaceClassMerging.ts_0_674 | interface Foo {
method(a: number): string;
optionalMethod?(a: number): string;
property: string;
optionalProperty?: string;
}
class Foo {
additionalProperty: string;
additionalMethod(a: number): string {
return this.method(0);
}
}
class Bar extends Foo {
method(a: number) {
return this.optionalProperty;
}
}
var bar = new Bar();
bar.method(0);
bar.optionalMethod(1);
bar.property;
bar.optionalProperty;
bar.additionalProperty;
bar.additionalMethod(2);
var obj: {
method(a: number): string;
property: string;
additionalProperty: string;
additionalMethod(a: number): string;
};
bar = obj;
obj = bar;
| {
"end_byte": 674,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/interfaceClassMerging.ts"
} |
TypeScript/tests/cases/compiler/parametersSyntaxErrorNoCrash1.ts_0_170 | // @strict: true
// @noEmit: true
// @noTypesAndSymbols: true
// https://github.com/microsoft/TypeScript/issues/59422
function identity<T>(arg: T: T {
return arg;
} | {
"end_byte": 170,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/parametersSyntaxErrorNoCrash1.ts"
} |
TypeScript/tests/cases/compiler/errorMessageOnIntersectionsWithDiscriminants01.ts_0_194 | // @noEmit: true
export type Common = { test: true } | { test: false };
export type A = Common & { foo: 1 };
export type B = Common & { bar: 1 };
declare const a: A;
declare let b: B;
b = a;
| {
"end_byte": 194,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/errorMessageOnIntersectionsWithDiscriminants01.ts"
} |
TypeScript/tests/cases/compiler/genericFunctionsNotContextSensitive.ts_0_216 | // @strict: true
// Repro from #37110
const f = <F extends (...args: any[]) => <G>(x: G) => void>(_: F): F => _;
const a = f(<K extends string>(_: K) => _ => ({})); // <K extends string>(_: K) => <G>(_: G) => {}
| {
"end_byte": 216,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/genericFunctionsNotContextSensitive.ts"
} |
TypeScript/tests/cases/compiler/decoratorInJsFile.ts_0_182 | // @experimentaldecorators: true
// @emitdecoratormetadata: true
// @allowjs: true
// @noEmit: true
// @filename: a.js
@SomeDecorator
class SomeClass {
foo(x: number) {
}
} | {
"end_byte": 182,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/decoratorInJsFile.ts"
} |
TypeScript/tests/cases/compiler/expandoFunctionExpressionsWithDynamicNames.ts_0_204 | // @strict: true
// @declaration: true
// https://github.com/microsoft/TypeScript/issues/54809
const s = "X";
export const expr = () => {}
expr[s] = 0
export const expr2 = function () {}
expr2[s] = 0
| {
"end_byte": 204,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/expandoFunctionExpressionsWithDynamicNames.ts"
} |
TypeScript/tests/cases/compiler/getAndSetNotIdenticalType.ts_0_82 | class C {
get x(): number {
return 1;
}
set x(v: string) { }
} | {
"end_byte": 82,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/getAndSetNotIdenticalType.ts"
} |
TypeScript/tests/cases/compiler/jsFileFunctionOverloads2.ts_0_1048 | // @allowJs: true
// @outDir: dist/
// @declaration: true
// @filename: jsFileFunctionOverloads2.js
// Also works if all @overload tags are combined in one comment.
/**
* @overload
* @param {number} x
* @returns {'number'}
*
* @overload
* @param {string} x
* @returns {'string'}
*
* @overload
* @param {boolean} x
* @returns {'boolean'}
*
* @param {unknown} x
* @returns {string}
*/
function getTypeName(x) {
return typeof x;
}
/**
* @template T
* @param {T} x
* @returns {T}
*/
const identity = x => x;
/**
* @template T
* @template U
* @overload
* @param {T[]} array
* @param {(x: T) => U[]} iterable
* @returns {U[]}
*
* @overload
* @param {T[][]} array
* @returns {T[]}
*
* @param {unknown[]} array
* @param {(x: unknown) => unknown} iterable
* @returns {unknown[]}
*/
function flatMap(array, iterable = identity) {
/** @type {unknown[]} */
const result = [];
for (let i = 0; i < array.length; i += 1) {
result.push(.../** @type {unknown[]} */(iterable(array[i])));
}
return result;
}
| {
"end_byte": 1048,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileFunctionOverloads2.ts"
} |
TypeScript/tests/cases/compiler/promiseChaining1.ts_0_504 | // same example but with constraints on each type parameter
class Chain2<T extends { length: number }> {
constructor(public value: T) { }
then<S extends Function>(cb: (x: T) => S): Chain2<S> {
var result = cb(this.value);
// should get a fresh type parameter which each then call
var z = this.then(x => result)/*S*/.then(x => "abc")/*Function*/.then(x => x.length)/*number*/; // Should error on "abc" because it is not a Function
return new Chain2(result);
}
} | {
"end_byte": 504,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/promiseChaining1.ts"
} |
TypeScript/tests/cases/compiler/jsFileCompilationDuplicateVariableErrorReported.ts_0_146 | // @allowJs: true
// @outFile: out.js
// @declaration: true
// @filename: b.js
var x = "hello";
// @filename: a.ts
var x = 10; // Error reported
| {
"end_byte": 146,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/jsFileCompilationDuplicateVariableErrorReported.ts"
} |
TypeScript/tests/cases/compiler/getAndSetNotIdenticalType2.ts_0_201 | class A<T> { foo: T; }
class C<T> {
data: A<T>;
get x(): A<T> {
return this.data;
}
set x(v: A<string>) {
this.data = v;
}
}
var x = new C();
var r = x.x;
x.x = r; | {
"end_byte": 201,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/getAndSetNotIdenticalType2.ts"
} |
TypeScript/tests/cases/compiler/readonlyPropertySubtypeRelationDirected.ts_0_3743 | // @strict: true
// @filename: one.ts
export {};
// When the non-readonly type is declared first, the unioned type of `three` in `doSomething` is never treated as readonly
const two: { a: string } = { a: 'two' };
const one: { readonly a: string } = { a: 'one' };
function doSomething(condition: boolean) {
// when `one` comes first in the conditional check, the return type of `doSomething` is inferred as `a` is readonly, but `a` is
// only treated as readonly (i.e. it will produce a diagnostic if you try to assign to it) based on the order of declarations of `one` and `two` above
const three = (condition) ? one : two;
three.a = 'foo';
// the inferred (displayed?) type of `a` also depends on the order of the condition above. When `one` comes first, the displayed type is `any`
// when `two` comes first, the displayed type is `string`, but the diagnostic will always correctly find that it's string
three.a = 'foo2';
return three;
}
// @filename: two.ts
export {};
// When the non-readonly type is declared first, the unioned type of `three` in `doSomething` is never treated as readonly
const two: { a: string } = { a: 'two' };
const one: { readonly a: string } = { a: 'one' };
function doSomething(condition: boolean) {
// when `two` comes first in the conditional check, the return type of `doSomething` is inferred as not readonly but produces the same diagnostics as above
// based on the declaration order of `one` and `two`
const three = (condition) ? two : one;
three.a = 'foo';
// the inferred (displayed?) type of `a` also depends on the order of the condition above. When `one` comes first, the displayed type is `any`
// when `two` comes first, the displayed type is `string`, but the diagnostic will always correctly find that it's string
three.a = 'foo2';
return three;
}
// @filename: three.ts
export {};
// When the readonly type is declared first, the unioned type of `three` in `doSomething` is always treated as readonly by the compiler
const one: { readonly a: string } = { a: 'one' };
const two: { a: string } = { a: 'two' };
function doSomething(condition: boolean) {
// when `one` comes first in the conditional check, the return type of `doSomething` is inferred as `a` is readonly, but `a` is
// only treated as readonly (i.e. it will produce a diagnostic if you try to assign to it) based on the order of declarations of `one` and `two` above
const three = (condition) ? one : two;
three.a = 'foo';
// the inferred (displayed?) type of `a` also depends on the order of the condition above. When `one` comes first, the displayed type is `any`
// when `two` comes first, the displayed type is `string`, but the diagnostic will always correctly find that it's string
three.a = 'foo2';
return three;
}
// @filename: four.ts
export {};
// When the readonly type is declared first, the unioned type of `three` in `doSomething` is always treated as readonly by the compiler
const one: { readonly a: string } = { a: 'one' };
const two: { a: string } = { a: 'two' };
function doSomething(condition: boolean) {
// when `two` comes first in the conditional check, the return type of `doSomething` is inferred as not readonly but produces the same diagnostics as above
// based on the declaration order of `one` and `two`
const three = (condition) ? two : one;
three.a = 'foo';
// the inferred (displayed?) type of `a` also depends on the order of the condition above. When `one` comes first, the displayed type is `any`
// when `two` comes first, the displayed type is `string`, but the diagnostic will always correctly find that it's string
three.a = 'foo2';
return three;
} | {
"end_byte": 3743,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/readonlyPropertySubtypeRelationDirected.ts"
} |
TypeScript/tests/cases/compiler/restParameterTypeInstantiation.ts_0_225 | // @strict: true
// Repro from #33823
interface TestGeneric<TG> {
f: string
g: TG
}
const removeF = <TX>({ f, ...rest }: TestGeneric<TX>) => {
return rest
}
const result: number = removeF<number>({ f: '', g: 3 }).g
| {
"end_byte": 225,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/restParameterTypeInstantiation.ts"
} |
TypeScript/tests/cases/compiler/assignmentCompatability14.ts_0_339 | 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 = {one: true};
export var __val__obj = obj;
}
__test2__.__val__obj = __test1__.__val__obj4 | {
"end_byte": 339,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatability14.ts"
} |
TypeScript/tests/cases/compiler/typeMatch1.ts_0_355 | interface I { z; }
interface I2 { z; }
var x1: { z: number; f(n: number): string; f(s: string): number; }
var x2: { z:number;f:{(n:number):string;(s:string):number;}; } = x1;
var i:I;
var i2:I2;
var x3:{ z; }= i;
var x4:{ z; }= i2;
var x5:I=i2;
class C { private x; }
class D { private x; }
var x6=new C();
var x7=new D();
x6 = x7;
x6=C;
C==D;
C==C;
| {
"end_byte": 355,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeMatch1.ts"
} |
TypeScript/tests/cases/compiler/intersectionTypeInference1.ts_0_286 | // Repro from #8801
function alert(s: string) {}
const parameterFn = (props:{store:string}) => alert(props.store)
const brokenFunction = <OwnProps>(f: (p: {dispatch: number} & OwnProps) => void) => (o: OwnProps) => o
export const Form3 = brokenFunction(parameterFn)({store: "hello"})
| {
"end_byte": 286,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/intersectionTypeInference1.ts"
} |
TypeScript/tests/cases/compiler/interfaceMergedUnconstrainedNoErrorIrrespectiveOfOrder.ts_0_488 | // @filename: working.ts
// minmal samples from #33395
export namespace ns {
interface Function<T extends (...args: any) => any> {
throttle(): Function<T>;
}
interface Function<T> {
unary(): Function<() => ReturnType<T>>;
}
}
// @filename: regression.ts
export namespace ns {
interface Function<T> {
unary(): Function<() => ReturnType<T>>;
}
interface Function<T extends (...args: any) => any> {
throttle(): Function<T>;
}
} | {
"end_byte": 488,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/interfaceMergedUnconstrainedNoErrorIrrespectiveOfOrder.ts"
} |
TypeScript/tests/cases/compiler/declarationEmitBundlePreservesHasNoDefaultLibDirective.ts_0_336 | // @declaration: true
// @outFile: mylib.js
// @filename: extensions.ts
/// <reference no-default-lib="true"/>
class Foo {
public: string;
}
// @filename: core.ts
interface Array<T> {}
interface Boolean {}
interface Function {}
interface IArguments {}
interface Number {}
interface Object {}
interface RegExp {}
interface String {}
| {
"end_byte": 336,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationEmitBundlePreservesHasNoDefaultLibDirective.ts"
} |
TypeScript/tests/cases/compiler/constEnumNoPreserveDeclarationReexport.ts_0_452 | // @filename: ConstEnum.d.ts
export const enum MyConstEnum {
Foo,
Bar
}
// @filename: ImportExport.d.ts
import { MyConstEnum } from './ConstEnum';
export default MyConstEnum;
// @filename: ReExport.d.ts
export { MyConstEnum as default } from './ConstEnum';
// @filename: usages.ts
import {MyConstEnum} from "./ConstEnum";
import AlsoEnum from "./ImportExport";
import StillEnum from "./ReExport";
MyConstEnum.Foo;
AlsoEnum.Foo;
StillEnum.Foo;
| {
"end_byte": 452,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constEnumNoPreserveDeclarationReexport.ts"
} |
TypeScript/tests/cases/compiler/InterfaceDeclaration8.ts_0_20 | interface string {
} | {
"end_byte": 20,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/InterfaceDeclaration8.ts"
} |
TypeScript/tests/cases/compiler/es5-asyncFunctionHoisting.ts_0_594 | // @lib: es5,es2015.promise
// @noEmitHelpers: true
// @target: ES5
declare var y;
async function hoisting() {
var a0, a1 = 1;
function z() {
var b0, b1 = 1;
}
if (true) {
var c0, c1 = 1;
}
for (var a = 0; y;) {
}
for (var b in y) {
}
for (var c of y) {
}
}
async function hoistingWithAwait() {
var a0, a1 = 1;
function z() {
var b0, b1 = 1;
}
await 0;
if (true) {
var c0, c1 = 1;
}
for (var a = 0; y;) {
}
for (var b in y) {
}
for (var c of y) {
}
}
| {
"end_byte": 594,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/es5-asyncFunctionHoisting.ts"
} |
TypeScript/tests/cases/compiler/objectLiteralWithGetAccessorInsideFunction.ts_0_139 | function bar() {
var x = {
get _extraOccluded() {
var occluded = 0;
return occluded;
},
}
} | {
"end_byte": 139,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/objectLiteralWithGetAccessorInsideFunction.ts"
} |
TypeScript/tests/cases/compiler/requireOfJsonFileWithEmptyObject.ts_0_258 | // @module: commonjs
// @outdir: out/
// @allowJs: true
// @fullEmitPaths: true
// @resolveJsonModule: true
// @Filename: file1.ts
import b1 = require('./b.json');
let x = b1;
import b2 = require('./b.json');
if (x) {
x = b2;
}
// @Filename: b.json
{
} | {
"end_byte": 258,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/requireOfJsonFileWithEmptyObject.ts"
} |
TypeScript/tests/cases/compiler/argumentsReferenceInMethod6_Js.ts_0_167 | // @declaration: true
// @allowJs: true
// @emitDeclarationOnly: true
// @filename: /a.js
class A {
m() {
/**
* @type object
*/
this.foo = arguments;
}
}
| {
"end_byte": 167,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/argumentsReferenceInMethod6_Js.ts"
} |
TypeScript/tests/cases/compiler/extendedUnicodePlaneIdentifiers.ts_0_776 | // @target: es2018
const 𝑚 = 4;
const 𝑀 = 5;
console.log(𝑀 + 𝑚); // 9
class K {
#𝑚 = 4;
#𝑀 = 5;
}
// lower 8 bits look like 'a'
const ၡ = 6;
console.log(ၡ ** ၡ);
// lower 8 bits aren't a valid unicode character
const ဒ = 7;
console.log(ဒ ** ဒ);
// a mix, for good measure
const ဒၡ𝑀 = 7;
console.log(ဒၡ𝑀 ** ဒၡ𝑀);
const ၡ𝑀ဒ = 7;
console.log(ၡ𝑀ဒ ** ၡ𝑀ဒ);
const 𝑀ဒၡ = 7;
console.log(𝑀ဒၡ ** 𝑀ဒၡ);
const 𝓱𝓮𝓵𝓵𝓸 = "𝔀𝓸𝓻𝓵𝓭";
const Ɐⱱ = "ok"; // BMP
const 𓀸𓀹𓀺 = "ok"; // SMP
const 𡚭𡚮𡚯 = "ok"; // SIP
const 𡚭𓀺ⱱ𝓮 = "ok";
const 𓀺ⱱ𝓮𡚭 = "ok";
const ⱱ𝓮𡚭𓀺 = "ok";
const 𝓮𡚭𓀺ⱱ = "ok";
| {
"end_byte": 776,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/extendedUnicodePlaneIdentifiers.ts"
} |
TypeScript/tests/cases/compiler/internalAliasWithDottedNameEmit.ts_0_98 | // @declaration: true
module a.b.c {
export var d;
}
module a.e.f {
import g = b.c;
}
| {
"end_byte": 98,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/internalAliasWithDottedNameEmit.ts"
} |
TypeScript/tests/cases/compiler/narrowByInstanceof.ts_0_1178 | // @strict: true
interface A { a: string }
interface B { b: string }
interface C { c: string }
type AA = {
(): void;
prototype: A;
}
type BB = {
new(): B;
}
function foo(x: A | B | C, A: AA, B: BB, AB: AA | BB) {
if (x instanceof A) {
x; // A
}
else {
x; // B | C
}
if (x instanceof B) {
x; // B
}
else {
x; // A | C
}
if (x instanceof AB) {
x; // A | B
}
else {
x; // A | B | C
}
}
function bar(target: any, Promise: any) {
if (target instanceof Promise) {
target.__then();
}
}
// Repro from #52571
class PersonMixin extends Function {
public check(o: any) {
return typeof o === "object" && o !== null && o instanceof Person;
}
}
const cls = new PersonMixin();
class Person {
work(): void { console.log("work") }
sayHi(): void { console.log("Hi") }
}
class Car {
sayHi(): void { console.log("Wof Wof") }
}
function test(o: Person | Car) {
if (o instanceof cls) {
console.log("Is Person");
(o as Person).work()
}
else {
console.log("Is Car")
o.sayHi();
}
}
| {
"end_byte": 1178,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/narrowByInstanceof.ts"
} |
TypeScript/tests/cases/compiler/unknownTypeArgOnCall.ts_0_112 | class Foo<T> {
public clone<U>() {
return null;
}
}
var f = new Foo<number>();
var r = f.clone<Uhhhh>()
| {
"end_byte": 112,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/unknownTypeArgOnCall.ts"
} |
TypeScript/tests/cases/compiler/functionCall4.ts_0_83 | function foo():any{return ""};
function bar():()=>any{return foo};
var x = bar(); | {
"end_byte": 83,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionCall4.ts"
} |
TypeScript/tests/cases/compiler/controlFlowDestructuringLoop.ts_0_484 | // @strict: true
// Repro from #28758
interface NumVal { val: number; }
interface StrVal { val: string; }
type Val = NumVal | StrVal;
function isNumVal(x: Val): x is NumVal {
return typeof x.val === 'number';
}
function foo(things: Val[]): void {
for (const thing of things) {
if (isNumVal(thing)) {
const { val } = thing;
val.toFixed(2);
}
else {
const { val } = thing;
val.length;
}
}
} | {
"end_byte": 484,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/controlFlowDestructuringLoop.ts"
} |
TypeScript/tests/cases/compiler/doesNotNarrowUnionOfConstructorsWithInstanceof.ts_0_551 | class A {
length: 1
constructor() {
this.length = 1
}
}
class B {
length: 2
constructor() {
this.length = 2
}
}
function getTypedArray(flag: boolean) {
return flag ? new A() : new B();
}
function getTypedArrayConstructor(flag: boolean) {
return flag ? A : B;
}
const a = getTypedArray(true); // A | B
const b = getTypedArrayConstructor(false); // A constructor | B constructor
if (!(a instanceof b)) {
console.log(a.length); // Used to be property 'length' does not exist on type 'never'.
}
| {
"end_byte": 551,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/doesNotNarrowUnionOfConstructorsWithInstanceof.ts"
} |
TypeScript/tests/cases/compiler/restArgMissingName.ts_0_23 | function sum (...) {}
| {
"end_byte": 23,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/restArgMissingName.ts"
} |
TypeScript/tests/cases/compiler/cachedContextualTypes.ts_0_534 | // @strict: true
// Repro from #52198
declare function createInstance<Ctor extends new (...args: any[]) => any, R extends InstanceType<Ctor>>(ctor: Ctor, ...args: ConstructorParameters<Ctor>): R;
export interface IMenuWorkbenchToolBarOptions {
toolbarOptions: {
foo(bar: string): string
};
}
class MenuWorkbenchToolBar {
constructor(
options: IMenuWorkbenchToolBarOptions | undefined,
) { }
}
createInstance(MenuWorkbenchToolBar, {
toolbarOptions: {
foo(bar) { return bar; }
}
});
| {
"end_byte": 534,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/cachedContextualTypes.ts"
} |
TypeScript/tests/cases/compiler/constEnumPreserveEmitReexport.ts_0_288 | // @preserveConstEnums: true
// @filename: ConstEnum.ts
export const enum MyConstEnum {
Foo,
Bar
};
// @filename: ImportExport.ts
import { MyConstEnum } from './ConstEnum';
export default MyConstEnum;
// @filename: ReExport.ts
export { MyConstEnum as default } from './ConstEnum'; | {
"end_byte": 288,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constEnumPreserveEmitReexport.ts"
} |
TypeScript/tests/cases/compiler/functionOverloads2.ts_0_132 | function foo(bar: string): string;
function foo(bar: number): number;
function foo(bar: any): any { return bar };
var x = foo(true); | {
"end_byte": 132,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/functionOverloads2.ts"
} |
TypeScript/tests/cases/compiler/constructorOverloads1.ts_0_342 | class Foo {
constructor(s: string);
constructor(n: number);
constructor(x: any) {
}
constructor(x: any) {
}
bar1() { /*WScript.Echo("bar1");*/ }
bar2() { /*WScript.Echo("bar1");*/ }
}
var f1 = new Foo("hey");
var f2 = new Foo(0);
var f3 = new Foo(f1);
var f4 = new Foo([f1,f2,f3]);
f1.bar1();
f1.bar2();
| {
"end_byte": 342,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/constructorOverloads1.ts"
} |
TypeScript/tests/cases/compiler/interfaceMemberValidation.ts_0_193 | interface i1 { name: string; }
interface i2 extends i1 { name: number; yo: string; }
interface foo {
bar():any;
bar():any;
new():void;
new():void;
[s:string]:number;
[s:string]:number;
} | {
"end_byte": 193,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/interfaceMemberValidation.ts"
} |
TypeScript/tests/cases/compiler/inferredIndexerOnNamespaceImport.ts_0_176 | // @filename: foo.ts
export const x = 3;
export const y = 5;
// @filename: bar.ts
import * as foo from "./foo";
function f(map: { [k: string]: number }) {
// ...
}
f(foo); | {
"end_byte": 176,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inferredIndexerOnNamespaceImport.ts"
} |
TypeScript/tests/cases/compiler/optionalChainWithInstantiationExpression2.ts_0_155 | // @target: es2019,es2020
declare interface A {
c: number;
<T>(): T;
}
type b = 'b type';
declare const a: A | undefined;
a?.<b>();
a<b>?.();
| {
"end_byte": 155,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/optionalChainWithInstantiationExpression2.ts"
} |
TypeScript/tests/cases/compiler/declFileForInterfaceWithRestParams.ts_0_147 | // @declaration: true
interface I {
foo(...x): typeof x;
foo2(a: number, ...x): typeof x;
foo3(b: string, ...x: string[]): typeof x;
} | {
"end_byte": 147,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declFileForInterfaceWithRestParams.ts"
} |
TypeScript/tests/cases/compiler/duplicateErrorAssignability.ts_0_182 | // @strict: true
interface A {
x: number;
}
interface B {
y: string;
}
declare let b: B;
declare let a: A;
const x = a = b;
let obj: { 3: string } = { 3: "three" };
obj[x]; | {
"end_byte": 182,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/duplicateErrorAssignability.ts"
} |
TypeScript/tests/cases/compiler/declarationTypecheckNoUseBeforeReferenceCheck.ts_0_115 | // @filename: index.d.ts
export class C extends Object {
static readonly p: unique symbol;
[C.p](): void;
} | {
"end_byte": 115,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/declarationTypecheckNoUseBeforeReferenceCheck.ts"
} |
TypeScript/tests/cases/compiler/typeVariableConstraintedToAliasNotAssignableToUnion.ts_0_722 | declare class TableClass<S = any> {
_field: S;
}
export type Table = TableClass;
interface Something {
prop: number;
}
interface SomethingElse {
prop2: string;
}
declare let aBoolean: boolean;
declare let aStringOrNumber: string | number;
declare let aStringOrSomething: string | Something;
declare let someUnion: Something | SomethingElse;
function fn<T extends Table>(o: T) {
aBoolean = o;
aStringOrNumber = o;
aStringOrSomething = o;
someUnion = o;
}
function fn2<T extends TableClass>(o: T) {
aBoolean = o;
aStringOrNumber = o;
aStringOrSomething = o;
someUnion = o;
}
declare const o: Table;
aBoolean = o;
aStringOrNumber = o;
aStringOrSomething = o;
someUnion = o;
| {
"end_byte": 722,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/typeVariableConstraintedToAliasNotAssignableToUnion.ts"
} |
TypeScript/tests/cases/compiler/internalImportInstantiatedModuleMergedWithClassNotReferencingInstanceNoConflict.ts_0_136 | class A {
aProp: string;
}
module A {
export interface X { s: string }
export var a = 10;
}
module B {
import Y = A;
}
| {
"end_byte": 136,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/internalImportInstantiatedModuleMergedWithClassNotReferencingInstanceNoConflict.ts"
} |
TypeScript/tests/cases/compiler/namedFunctionExpressionCall.ts_0_164 | var recurser = function foo() {
// using the local name
foo();
// using the globally visible name
recurser();
};
(function bar() {
bar();
}); | {
"end_byte": 164,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/namedFunctionExpressionCall.ts"
} |
TypeScript/tests/cases/compiler/styledComponentsInstantiaionLimitNotReached.ts_0_6005 | /// <reference path="/.lib/react16.d.ts" />
import * as React from "react";
interface REACT_STATICS {
childContextTypes: true;
contextType: true;
contextTypes: true;
defaultProps: true;
displayName: true;
getDefaultProps: true;
getDerivedStateFromError: true;
getDerivedStateFromProps: true;
mixins: true;
propTypes: true;
type: true;
}
interface KNOWN_STATICS {
name: true;
length: true;
prototype: true;
caller: true;
callee: true;
arguments: true;
arity: true;
}
interface MEMO_STATICS {
'$$typeof': true;
compare: true;
defaultProps: true;
displayName: true;
propTypes: true;
type: true;
}
interface FORWARD_REF_STATICS {
'$$typeof': true;
render: true;
defaultProps: true;
displayName: true;
propTypes: true;
}
type NonReactStatics<
S extends React.ComponentType<any>,
C extends {
[key: string]: true
} = {}
> = {
[key in Exclude<
keyof S,
S extends React.MemoExoticComponent<any>
? keyof MEMO_STATICS | keyof C
: S extends React.ForwardRefExoticComponent<any>
? keyof FORWARD_REF_STATICS | keyof C
: keyof REACT_STATICS | keyof KNOWN_STATICS | keyof C
>]: S[key]
};
export type AnyStyledComponent = StyledComponent<any, any, any, any> | StyledComponent<any, any, any>;
export type StyledComponent<
C extends keyof JSX.IntrinsicElements | React.ComponentType<any>,
T extends object,
O extends object = {},
A extends keyof any = never
> = // the "string" allows this to be used as an object key
// I really want to avoid this if possible but it's the only way to use nesting with object styles...
string &
StyledComponentBase<C, T, O, A> &
NonReactStatics<C extends React.ComponentType<any> ? C : never>;
export type StyledComponentProps<
// The Component from whose props are derived
C extends string | React.ComponentType<any>,
// The Theme from the current context
T extends object,
// The other props added by the template
O extends object,
// The props that are made optional by .attrs
A extends keyof any
> =
// Distribute O if O is a union type
O extends object
? WithOptionalTheme<
Omit<
ReactDefaultizedProps<
C,
React.ComponentPropsWithRef<
C extends IntrinsicElementsKeys | React.ComponentType<any> ? C : never
>
> &
O,
A
> &
Partial<
Pick<
React.ComponentPropsWithRef<
C extends IntrinsicElementsKeys | React.ComponentType<any> ? C : never
> &
O,
A
>
>,
T
> &
WithChildrenIfReactComponentClass<C>
: never;
type Defaultize<P, D> = P extends any
? string extends keyof P
? P
: Pick<P, Exclude<keyof P, keyof D>> &
Partial<Pick<P, Extract<keyof P, keyof D>>> &
Partial<Pick<D, Exclude<keyof D, keyof P>>>
: never;
type ReactDefaultizedProps<C, P> = C extends { defaultProps: infer D } ? Defaultize<P, D> : P;
type WithChildrenIfReactComponentClass<C extends string | React.ComponentType<any>> = C extends React.ComponentClass<
any
>
? { children?: React.ReactNode }
: {};
export type IntrinsicElementsKeys = keyof JSX.IntrinsicElements;
type WithOptionalTheme<P extends { theme?: T }, T> = Omit<P, 'theme'> & {
theme?: T;
};
type ForwardRefExoticBase<P> = Pick<React.ForwardRefExoticComponent<P>, keyof React.ForwardRefExoticComponent<any>>;
type StyledComponentPropsWithAs<
C extends string | React.ComponentType<any>,
T extends object,
O extends object,
A extends keyof any,
F extends string | React.ComponentType<any> = C
> = StyledComponentProps<C, T, O, A> & { as?: C; forwardedAs?: F };
export type StyledComponentInnerOtherProps<C extends AnyStyledComponent> = C extends StyledComponent<
any,
any,
infer O,
any
>
? O
: C extends StyledComponent<any, any, infer O>
? O
: never;
export type StyledComponentInnerAttrs<C extends AnyStyledComponent> = C extends StyledComponent<any, any, any, infer A>
? A
: never;
export interface StyledComponentBase<
C extends string | React.ComponentType<any>,
T extends object,
O extends object = {},
A extends keyof any = never
> extends ForwardRefExoticBase<StyledComponentProps<C, T, O, A>> {
// add our own fake call signature to implement the polymorphic 'as' prop
(props: StyledComponentProps<C, T, O, A> & { as?: never; forwardedAs?: never }): React.ReactElement<
StyledComponentProps<C, T, O, A>
>;
<AsC extends string | React.ComponentType<any> = C, FAsC extends string | React.ComponentType<any> = AsC>(
props: StyledComponentPropsWithAs<AsC, T, O, A, FAsC>,
): React.ReactElement<StyledComponentPropsWithAs<AsC, T, O, A, FAsC>>;
withComponent<WithC extends AnyStyledComponent>(
component: WithC,
): StyledComponent<
StyledComponentInnerComponent<WithC>,
T,
O & StyledComponentInnerOtherProps<WithC>,
A | StyledComponentInnerAttrs<WithC>
>;
withComponent<WithC extends keyof JSX.IntrinsicElements | React.ComponentType<any>>(
component: WithC,
): StyledComponent<WithC, T, O, A>;
}
export type StyledComponentInnerComponent<C extends React.ComponentType<any>> = C extends StyledComponent<
infer I,
any,
any,
any
>
? I
: C extends StyledComponent<infer I, any, any>
? I
: C;
export type StyledComponentPropsWithRef<
C extends keyof JSX.IntrinsicElements | React.ComponentType<any>
> = C extends AnyStyledComponent
? React.ComponentPropsWithRef<StyledComponentInnerComponent<C>> // shouldn't have an instantiation limit error
: React.ComponentPropsWithRef<C>; | {
"end_byte": 6005,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/styledComponentsInstantiaionLimitNotReached.ts"
} |
TypeScript/tests/cases/compiler/noDefaultLib.ts_0_216 | // @skipDefaultLibCheck: false
/// <reference no-default-lib="true"/>
var x;
interface Array {}
interface String {}
interface Number {}
interface Object {}
interface Date {}
interface Function {}
interface RegExp {} | {
"end_byte": 216,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noDefaultLib.ts"
} |
TypeScript/tests/cases/compiler/interfaceSubtyping.ts_0_144 | interface iface {
foo(): void;
}
class Camera implements iface{
constructor (public str: string) {
}
foo() { return "s"; }
}
| {
"end_byte": 144,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/interfaceSubtyping.ts"
} |
TypeScript/tests/cases/compiler/assignmentCompatability20.ts_0_340 | 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 = {one: ["1"]};
export var __val__obj = obj;
}
__test2__.__val__obj = __test1__.__val__obj4 | {
"end_byte": 340,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/assignmentCompatability20.ts"
} |
TypeScript/tests/cases/compiler/inferTypeParameterConstraints.ts_0_956 | // @strict: true
// Repro from #42636
type SubGuard<A, X extends [A]> = X;
type IsSub<M extends any[], S extends any[]> = M extends [...SubGuard<M[number], infer B>, ...S, ...any[]] ? B : never;
type E0 = IsSub<[1, 2, 3, 4], [2, 3, 4]>; // [1 | 2 | 3 | 4]
type E1 = [1, 2, 3, 4] extends [...infer B, 2, 3, 4, ...any[]] ? B : never; // unknown[]
// Repro from #42636
type Constrain<T extends C, C> = unknown;
type Foo<A> = A extends Constrain<infer X, A> ? X : never;
type T0 = Foo<string>; // string
// https://github.com/microsoft/TypeScript/issues/57286#issuecomment-1927920336
class BaseClass<V> {
protected fake(): V {
throw new Error("");
}
}
class Klass<V> extends BaseClass<V> {
child = true;
}
type Constructor<V, P extends BaseClass<V>> = new () => P;
type inferTest<V, T> = T extends Constructor<V, infer P> ? P : never;
type U = inferTest<number, Constructor<number, Klass<number>>>;
declare let m: U;
m.child; // ok
| {
"end_byte": 956,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/inferTypeParameterConstraints.ts"
} |
TypeScript/tests/cases/compiler/noImplicitSymbolToString.ts_0_805 | // Fix #19666
let symbol!: symbol;
let str = "hello ";
const templateStr = `hello ${symbol}`;
const appendStr = "hello " + symbol;
str += symbol;
let symbolUnionNumber!: symbol | number;
let symbolUnionString!: symbol | string;
const templateStrUnion = `union with number ${symbolUnionNumber} and union with string ${symbolUnionString}`;
// Fix #44462
type StringOrSymbol = string | symbol;
function getKey<S extends StringOrSymbol>(key: S) {
return `${key} is the key`;
}
function getKey1<S extends symbol>(key: S) {
let s1!: S;
`${s1}`;
s1 + '';
+s1;
let s2!: S | string;
`${s2}`;
s2 + '';
+s2;
}
function getKey2<S extends string>(key: S) {
let s1!: S;
`${s1}`;
s1 + '';
+s1;
let s2!: S | symbol;
`${s2}`;
s2 + '';
+s2;
}
| {
"end_byte": 805,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noImplicitSymbolToString.ts"
} |
TypeScript/tests/cases/compiler/privacyCheckTypeOfFunction.ts_0_106 | //@module: commonjs
//@declaration: true
function foo() {
}
export var x: typeof foo;
export var b = foo;
| {
"end_byte": 106,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/privacyCheckTypeOfFunction.ts"
} |
TypeScript/tests/cases/compiler/maxConstraints.ts_0_229 | interface Comparable<T> {
compareTo(other: T): number;
}
interface Comparer {
<T extends Comparable<T>>(x: T, y: T): T;
}
var max2: Comparer = (x, y) => { return (x.compareTo(y) > 0) ? x : y };
var maxResult = max2(1, 2); | {
"end_byte": 229,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/maxConstraints.ts"
} |
TypeScript/tests/cases/compiler/isolatedDeclarationLazySymbols.ts_0_387 | // @declaration: true
// @isolatedDeclarations: true
// @target: ESNext
export function foo() {
}
const o = {
["prop.inner"]: "a",
prop: {
inner: "b",
}
} as const
foo[o["prop.inner"]] ="A";
foo[o.prop.inner] = "B";
export class Foo {
[o["prop.inner"]] ="A"
[o.prop.inner] = "B"
}
export let oo = {
[o['prop.inner']]:"A",
[o.prop.inner]: "B",
} | {
"end_byte": 387,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/isolatedDeclarationLazySymbols.ts"
} |
TypeScript/tests/cases/compiler/noEmitAndIncremental.ts_0_152 | // @Filename: /a.ts
const x = 10;
// @Filename: /tsconfig.json
{
"compilerOptions": {
"noEmit": true,
"incremental": true
}
}
| {
"end_byte": 152,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/noEmitAndIncremental.ts"
} |
TypeScript/tests/cases/compiler/anyPlusAny1.ts_0_44 | var x: any;
x.name = "hello";
var z = x + x; | {
"end_byte": 44,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/anyPlusAny1.ts"
} |
TypeScript/tests/cases/compiler/argumentsObjectIterator02_ES6.ts_0_281 | //@target: ES6
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
let blah = arguments[Symbol.iterator];
let result = [];
for (let arg of blah()) {
result.push(arg + arg);
}
return <[any, any, any]>result;
}
| {
"end_byte": 281,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/argumentsObjectIterator02_ES6.ts"
} |
TypeScript/tests/cases/compiler/moduleSameValueDuplicateExportedBindings1.ts_0_163 | // @module: commonjs
// @filename: a.ts
export * from "./b";
export * from "./c";
// @filename: b.ts
export * from "./c";
// @filename: c.ts
export var foo = 42; | {
"end_byte": 163,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleSameValueDuplicateExportedBindings1.ts"
} |
TypeScript/tests/cases/compiler/moduleAugmentationGlobal1.ts_0_273 | // @module: commonjs
// @declaration: true
// @filename: f1.ts
export class A {x: number;}
// @filename: f2.ts
import {A} from "./f1";
// change the shape of Array<T>
declare global {
interface Array<T> {
getA(): A;
}
}
let x = [1];
let y = x.getA().x;
| {
"end_byte": 273,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/moduleAugmentationGlobal1.ts"
} |
TypeScript/tests/cases/compiler/mapConstructorOnReadonlyTuple.ts_0_99 | // @target: es2015
const pairs = [[{}, 1], [{}, 2]] as const;
new Map(pairs);
new WeakMap(pairs);
| {
"end_byte": 99,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/mapConstructorOnReadonlyTuple.ts"
} |
TypeScript/tests/cases/compiler/contextualTyping1.ts_0_31 | var foo: {id:number;} = {id:4}; | {
"end_byte": 31,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/contextualTyping1.ts"
} |
TypeScript/tests/cases/compiler/arrowFunctionsMissingTokens.ts_1_1142 | module missingArrowsWithCurly {
var a = () { };
var b = (): void { }
var c = (x) { };
var d = (x: number, y: string) { };
var e = (x: number, y: string): void { };
}
module missingCurliesWithArrow {
module withStatement {
var a = () => var k = 10;};
var b = (): void => var k = 10;}
var c = (x) => var k = 10;};
var d = (x: number, y: string) => var k = 10;};
var e = (x: number, y: string): void => var k = 10;};
var f = () => var k = 10;}
}
module withoutStatement {
var a = () => };
var b = (): void => }
var c = (x) => };
var d = (x: number, y: string) => };
var e = (x: number, y: string): void => };
var f = () => }
}
}
module ce_nEst_pas_une_arrow_function {
var a = ();
var b = (): void;
var c = (x);
var d = (x: number, y: string);
var e = (x: number, y: string): void;
}
module okay {
var a = () => { };
var b = (): void => { }
var c = (x) => { };
var d = (x: number, y: string) => { };
var e = (x: number, y: string): void => { };
} | {
"end_byte": 1142,
"start_byte": 1,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/arrowFunctionsMissingTokens.ts"
} |
TypeScript/tests/cases/compiler/destructuringWithConstraint.ts_0_193 | // @strict: true
// Repro from #22823
interface Props {
foo?: boolean;
}
function foo<P extends Props>(props: Readonly<P>) {
let { foo = false } = props;
if (foo === true) { }
}
| {
"end_byte": 193,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/destructuringWithConstraint.ts"
} |
TypeScript/tests/cases/compiler/overloadOnConstConstraintChecks1.ts_0_658 | class Base { foo() { } }
class Derived1 extends Base { bar() { } }
class Derived2 extends Base { baz() { } }
class Derived3 extends Base { biz() { } }
interface MyDoc { // Document
createElement(tagName: string): Base;
createElement(tagName: 'canvas'): Derived1;
createElement(tagName: 'div'): Derived2;
createElement(tagName: 'span'): Derived3;
// + 100 more
}
class D implements MyDoc {
createElement(tagName:string): Base;
createElement(tagName: 'canvas'): Derived1;
createElement(tagName: 'div'): Derived2;
createElement(tagName: 'span'): Derived3;
createElement(tagName:any): Base {
return null;
}
} | {
"end_byte": 658,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/overloadOnConstConstraintChecks1.ts"
} |
TypeScript/tests/cases/compiler/collisionExportsRequireAndModule.ts_0_1463 | //@module: amd
//@filename: collisionExportsRequireAndModule_externalmodule.ts
export module require {
export interface I {
}
export class C {
}
}
export function foo(): require.I {
return null;
}
export module exports {
export interface I {
}
export class C {
}
}
export function foo2(): exports.I {
return null;
}
module m1 {
module require {
export interface I {
}
export class C {
}
}
module exports {
export interface I {
}
export class C {
}
}
}
module m2 {
export module require {
export interface I {
}
export class C {
}
}
export module exports {
export interface I {
}
export class C {
}
}
}
//@filename: collisionExportsRequireAndModule_globalFile.ts
module require {
export interface I {
}
export class C {
}
}
module exports {
export interface I {
}
export class C {
}
}
module m3 {
module require {
export interface I {
}
export class C {
}
}
module exports {
export interface I {
}
export class C {
}
}
}
module m4 {
export module require {
export interface I {
}
export class C {
}
}
export module exports {
export interface I {
}
export class C {
}
}
}
| {
"end_byte": 1463,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/collisionExportsRequireAndModule.ts"
} |
TypeScript/tests/cases/compiler/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts_0_133 | // @sourcemap: true
class AbstractGreeter {
}
class Greeter extends AbstractGreeter {
public a = 10;
public nameA = "Ten";
} | {
"end_byte": 133,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/compiler/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.