_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
TypeScript/tests/cases/conformance/types/any/narrowExceptionVariableInCatchClause.ts_0_587 | declare function isFooError(x: any): x is { type: 'foo'; dontPanic(); };
function tryCatch() {
try {
// do stuff...
}
catch (err) { // err is implicitly 'any' and cannot be annotated
if (isFooError(err)) {
err.dontPanic(); // OK
err.doPanic(); // ERROR: Property 'do... | {
"end_byte": 587,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/any/narrowExceptionVariableInCatchClause.ts"
} |
TypeScript/tests/cases/conformance/types/any/assignEveryTypeToAny.ts_0_481 | // all of these are valid
var x: any;
x = 1;
var a = 2;
x = a;
x = true;
var b = true;
x = b;
x = "";
var c = "";
x = c;
var d: void;
x = d;
var e = undefined;
x = e;
var e2: typeof undefined;
x = e2;
enum E {
A
}
x = E.A;
var f = E.A;
x = f;
interface I {
foo: string;
}
var g: I;
x = g;
class C {
... | {
"end_byte": 481,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/any/assignEveryTypeToAny.ts"
} |
TypeScript/tests/cases/conformance/types/namedTypes/optionalMethods.ts_0_864 | // @strictNullChecks: true
// @declaration: true
interface Foo {
a: number;
b?: number;
f(): number;
g?(): number;
}
function test1(x: Foo) {
x.a;
x.b;
x.f;
x.g;
let f1 = x.f();
let g1 = x.g && x.g();
let g2 = x.g ? x.g() : 0;
}
class Bar {
a: number;
b?: number;
... | {
"end_byte": 864,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/namedTypes/optionalMethods.ts"
} |
TypeScript/tests/cases/conformance/types/namedTypes/classWithOnlyPublicMembersEquivalentToInterface.ts_0_416 | // @target: es5
// no errors expected
class C {
public x: string;
public y(a: number): number { return null; }
public get z() { return 1; }
public set z(v) { }
[x: string]: Object;
[x: number]: Object;
0: number;
}
interface I {
x: string;
y(b: number): number;
z: number;
[... | {
"end_byte": 416,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/namedTypes/classWithOnlyPublicMembersEquivalentToInterface.ts"
} |
TypeScript/tests/cases/conformance/types/namedTypes/classWithOnlyPublicMembersEquivalentToInterface2.ts_0_478 | // @target: es5
// no errors expected
class C {
public x: string;
public y(a: number): number { return null; }
public get z() { return 1; }
public set z(v) { }
[x: string]: Object;
[x: number]: Object;
0: number;
public static foo: string; // doesn't effect equivalence
}
interface I {... | {
"end_byte": 478,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/namedTypes/classWithOnlyPublicMembersEquivalentToInterface2.ts"
} |
TypeScript/tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts_0_204 | // @allowUnusedLabels: true
// interfaces do not permit private members, these are errors
interface I {
private x: string;
}
interface I2<T> {
private y: T;
}
var x: {
private y: string;
} | {
"end_byte": 204,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts"
} |
TypeScript/tests/cases/conformance/types/namedTypes/classWithOptionalParameter.ts_0_147 | // classes do not permit optional parameters, these are errors
class C {
x?: string;
f?() {}
}
class C2<T> {
x?: T;
f?(x: T) {}
} | {
"end_byte": 147,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/namedTypes/classWithOptionalParameter.ts"
} |
TypeScript/tests/cases/conformance/types/namedTypes/genericInstantiationEquivalentToObjectLiteral.ts_0_259 | interface Pair<T1, T2> { first: T1; second: T2; }
var x: Pair<string, number>
var y: { first: string; second: number; }
x = y;
y = x;
declare function f<T, U>(x: Pair<T, U>);
declare function f2<T, U>(x: { first: T; second: U; });
f(x);
f(y);
f2(x);
f2(y); | {
"end_byte": 259,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/namedTypes/genericInstantiationEquivalentToObjectLiteral.ts"
} |
TypeScript/tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration02.ts_0_800 | // @noImplicitAny: true
interface A {
numProp: number;
}
interface B {
strProp: string;
}
interface Foo {
new (): Bar;
}
interface Bar {
method1(arg: A): void;
method2(arg: B): void;
}
function getFoo1(): Foo {
return class {
method1(arg) {
arg.numProp = 10;
}
... | {
"end_byte": 800,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration02.ts"
} |
TypeScript/tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedObjectLiteralMethodDeclaration01.ts_0_745 | // @noImplicitAny: true
interface A {
numProp: number;
}
interface B {
strProp: string;
}
interface Foo {
method1(arg: A): void;
method2(arg: B): void;
}
function getFoo1(): Foo {
return {
method1(arg) {
arg.numProp = 10;
},
method2(arg) {
arg.str... | {
"end_byte": 745,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedObjectLiteralMethodDeclaration01.ts"
} |
TypeScript/tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts_0_698 | // @noImplicitAny: true
interface Show {
show: (x: number) => string;
}
function f({ show: showRename = v => v }: Show) {}
function f2({ "show": showRename = v => v }: Show) {}
function f3({ ["show"]: showRename = v => v }: Show) {}
interface Nested {
nested: Show
}
function ff({ nested: nestedRename = { show:... | {
"end_byte": 698,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts"
} |
TypeScript/tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializer.ts_0_715 | // @noImplicitAny: true
interface Show {
show: (x: number) => string;
}
function f({ show = v => v.toString() }: Show) {}
function f2({ "show": showRename = v => v.toString() }: Show) {}
function f3({ ["show"]: showRename = v => v.toString() }: Show) {}
interface Nested {
nested: Show
}
function ff({ nested = ... | {
"end_byte": 715,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializer.ts"
} |
TypeScript/tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration01.ts_0_806 | // @noImplicitAny: true
interface A {
numProp: number;
}
interface B {
strProp: string;
}
interface Foo {
method1(arg: A): void;
method2(arg: B): void;
}
function getFoo1(): Foo {
return class {
static method1(arg) {
arg.numProp = 10;
}
static method2(arg) {
... | {
"end_byte": 806,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration01.ts"
} |
TypeScript/tests/cases/conformance/types/contextualTypes/partiallyAnnotatedFunction/partiallyAnnotatedFunctionWitoutTypeParameter.ts_0_162 | // @noImplicitAny: true
// simple case
declare function simple(f: (a: number, b: number) => void): {}
simple((a: number, b) => {})
simple((a, b: number) => {})
| {
"end_byte": 162,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/contextualTypes/partiallyAnnotatedFunction/partiallyAnnotatedFunctionWitoutTypeParameter.ts"
} |
TypeScript/tests/cases/conformance/types/contextualTypes/partiallyAnnotatedFunction/partiallyAnnotatedFunctionInferenceError.ts_0_249 | class C {
test: string
}
class D extends C {
test2: string
}
declare function testError<T extends C>(a: (t: T, t1: T) => void): T
// more args
testError((t1: D, t2, t3) => {})
testError((t1, t2: D, t3) => {})
testError((t1, t2, t3: D) => {})
| {
"end_byte": 249,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/contextualTypes/partiallyAnnotatedFunction/partiallyAnnotatedFunctionInferenceError.ts"
} |
TypeScript/tests/cases/conformance/types/contextualTypes/partiallyAnnotatedFunction/partiallyAnnotatedFunctionInferenceWithTypeParameter.ts_0_608 | class C {
test: string
}
class D extends C {
test2: string
}
declare function test<T extends C>(a: (t: T, t1: T) => void): T
declare function testRest<T extends C>(a: (t: T, t1: T, ...ts: T[]) => void): T
// exactly
test((t1: D, t2) => { t2.test2 })
test((t1, t2: D) => { t2.test2 })
// zero arg
test(() => {})... | {
"end_byte": 608,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/contextualTypes/partiallyAnnotatedFunction/partiallyAnnotatedFunctionInferenceWithTypeParameter.ts"
} |
TypeScript/tests/cases/conformance/types/contextualTypes/commaOperator/contextuallyTypeCommaOperator03.ts_0_108 | // @allowUnreachableCode: true
// @noImplicitAny: true
let x: (a: string) => string;
x = (a => a, b => b); | {
"end_byte": 108,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/contextualTypes/commaOperator/contextuallyTypeCommaOperator03.ts"
} |
TypeScript/tests/cases/conformance/types/contextualTypes/commaOperator/contextuallyTypeCommaOperator02.ts_0_146 | // @allowUnreachableCode: true
// @noImplicitAny: true
let x: (a: string) => string;
x = (100, a => {
const b: number = a;
return b;
}); | {
"end_byte": 146,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/contextualTypes/commaOperator/contextuallyTypeCommaOperator02.ts"
} |
TypeScript/tests/cases/conformance/types/contextualTypes/commaOperator/contextuallyTypeCommaOperator01.ts_0_105 | // @allowUnreachableCode: true
// @noImplicitAny: true
let x: (a: string) => string;
x = (100, a => a); | {
"end_byte": 105,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/contextualTypes/commaOperator/contextuallyTypeCommaOperator01.ts"
} |
TypeScript/tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes01.tsx_0_379 | // @jsx: preserve
// @declaration: true
namespace JSX {
export interface IntrinsicElements {
span: {};
}
export interface Element {
something?: any;
}
}
const FooComponent = (props: { foo: "A" | "B" | "C" }) => <span>{props.foo}</span>;
<FooComponent foo={"A"} />;
<FooComponent foo="A" /... | {
"end_byte": 379,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes01.tsx"
} |
TypeScript/tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes02.tsx_0_1529 | // @filename: file.tsx
// @jsx: preserve
// @module: amd
// @noLib: true
// @skipLibCheck: true
// @libFiles: react.d.ts,lib.d.ts
import React = require('react')
export interface ClickableProps {
children?: string;
className?: string;
}
export interface ButtonProps extends ClickableProps {
onClick: (k: ... | {
"end_byte": 1529,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes02.tsx"
} |
TypeScript/tests/cases/conformance/types/contextualTypes/asyncFunctions/contextuallyTypeAsyncFunctionAwaitOperand.ts_0_293 | // @target: esnext
// @noImplicitAny: true
// @noEmit: true
interface Obj { key: "value"; }
async function fn1(): Promise<Obj> {
const obj1: Obj = await { key: "value" };
const obj2: Obj = await new Promise(resolve => resolve({ key: "value" }));
return await { key: "value" };
}
| {
"end_byte": 293,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/contextualTypes/asyncFunctions/contextuallyTypeAsyncFunctionAwaitOperand.ts"
} |
TypeScript/tests/cases/conformance/types/contextualTypes/asyncFunctions/contextuallyTypeAsyncFunctionReturnType.ts_0_1881 | // @target: esnext
// @noImplicitAny: true
// @noEmit: true
interface Obj { key: "value"; }
async function fn1(): Promise<Obj> {
return { key: "value" };
}
async function fn2(): Promise<Obj> {
return new Promise(resolve => {
resolve({ key: "value" });
});
}
async function fn3(): Promise<Obj> {
... | {
"end_byte": 1881,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/contextualTypes/asyncFunctions/contextuallyTypeAsyncFunctionReturnType.ts"
} |
TypeScript/tests/cases/conformance/types/contextualTypes/jsdoc/contextualTypeFromJSDoc.ts_0_557 | // @allowJs: true
// @checkJs: true
// @noEmit: true
// @filename: index.js
// @target: esnext
/** @type {Array<[string, {x?:number, y?:number}]>} */
const arr = [
['a', { x: 1 }],
['b', { y: 2 }]
];
/** @return {Array<[string, {x?:number, y?:number}]>} */
function f() {
return [
['a', { x: 1 }],
... | {
"end_byte": 557,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/contextualTypes/jsdoc/contextualTypeFromJSDoc.ts"
} |
TypeScript/tests/cases/conformance/types/contextualTypes/logicalAnd/contextuallyTypeLogicalAnd01.ts_0_88 | // @noImplicitAny: true
let x: (a: string) => string;
let y = true;
x = y && (a => a); | {
"end_byte": 88,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/contextualTypes/logicalAnd/contextuallyTypeLogicalAnd01.ts"
} |
TypeScript/tests/cases/conformance/types/contextualTypes/logicalAnd/contextuallyTypeLogicalAnd02.ts_0_129 | // @noImplicitAny: true
let x: (a: string) => string;
let y = true;
x = y && (a => {
const b: number = a;
return b;
}); | {
"end_byte": 129,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/contextualTypes/logicalAnd/contextuallyTypeLogicalAnd02.ts"
} |
TypeScript/tests/cases/conformance/types/contextualTypes/logicalAnd/contextuallyTypeLogicalAnd03.ts_0_95 | // @noImplicitAny: true
let x: (a: string) => string;
let y = true;
x = (a => a) && (b => b); | {
"end_byte": 95,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/contextualTypes/logicalAnd/contextuallyTypeLogicalAnd03.ts"
} |
TypeScript/tests/cases/conformance/types/union/unionTypeCallSignatures4.ts_3_590 | pe F1 = (a: string, b?: string) => void;
type F2 = (a: string, b?: string, c?: string) => void;
type F3 = (a: string, ...rest: string[]) => void;
type F4 = (a: string, b?: string, ...rest: string[]) => void;
type F5 = (a: string, b: string) => void;
var f12: F1 | F2;
f12("a");
f12("a", "b");
f12("a", "b", "c"); // ok... | {
"end_byte": 590,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/union/unionTypeCallSignatures4.ts"
} |
TypeScript/tests/cases/conformance/types/union/contextualTypeWithUnionTypeObjectLiteral.ts_3_2148 | r str: string;
var num: number;
var strOrNumber: string | number = str || num;
var objStr: { prop: string };
var objNum: { prop: number };
var objStrOrNum1: { prop: string } | { prop: number } = objStr || objNum;
var objStrOrNum2: { prop: string | number } = objStr || objNum;
// Below is error because :
// Spec says:
/... | {
"end_byte": 2148,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/union/contextualTypeWithUnionTypeObjectLiteral.ts"
} |
TypeScript/tests/cases/conformance/types/union/unionTypeCallSignatures5.ts_0_185 | // #31485
interface A {
(this: void, b?: number): void;
}
interface B {
(this: number, b?: number): void;
}
interface C {
(i: number): void;
}
declare const fn: A | B | C;
fn(0);
| {
"end_byte": 185,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/union/unionTypeCallSignatures5.ts"
} |
TypeScript/tests/cases/conformance/types/union/unionTypeEquivalence.ts_3_496 | A | B is equivalent to A if B is a subtype of A
class C { }
class D extends C { foo() { } }
var x: C;
var x : C | D;
// A | B is equivalent to B | A.
var y: string | number;
var y : number | string;
// AB | C is equivalent to A | BC, where AB is A | B and BC is B | C.
var z : string | number | boolean;
var z : (stri... | {
"end_byte": 496,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/union/unionTypeEquivalence.ts"
} |
TypeScript/tests/cases/conformance/types/union/unionTypeCallSignatures.ts_3_4543 | r numOrDate: number | Date;
var strOrBoolean: string | boolean;
var strOrNum: string | number;
// If each type in U has call signatures and the sets of call signatures are identical ignoring return types,
// U has the same set of call signatures, but with return types that are unions of the return types of the respec... | {
"end_byte": 4543,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/union/unionTypeCallSignatures.ts"
} |
TypeScript/tests/cases/conformance/types/union/unionTypeReduction.ts_0_281 | interface I2 {
(): number;
(q): boolean;
}
interface I3 {
(): number;
}
var i2: I2, i3: I3;
var e1: I2 | I3;
var e2 = i2 || i3; // Type of e2 immediately reduced to I3
var r1 = e1(); // Type of e1 reduced to I3 upon accessing property or signature
var r2 = e2();
| {
"end_byte": 281,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/union/unionTypeReduction.ts"
} |
TypeScript/tests/cases/conformance/types/union/unionTypeReadonly.ts_0_736 | interface Base {
readonly value: number;
}
interface Identical {
readonly value: number;
}
interface Mutable {
value: number;
}
interface DifferentType {
readonly value: string;
}
interface DifferentName {
readonly other: number;
}
let base: Base;
base.value = 12 // error, lhs can't be a readonly pr... | {
"end_byte": 736,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/union/unionTypeReadonly.ts"
} |
TypeScript/tests/cases/conformance/types/union/discriminatedUnionTypes3.ts_0_303 | // @strict: true
// Repro from #44435
type Correct = {
code: string
property: true
err: undefined
}
type Err = {
err: `${string} is wrong!`
}
type SomeReturnType = Correct | Err;
const example: SomeReturnType = {} as SomeReturnType;
if (example.err === undefined) {
example.property; // true
} | {
"end_byte": 303,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/union/discriminatedUnionTypes3.ts"
} |
TypeScript/tests/cases/conformance/types/union/contextualTypeWithUnionTypeIndexSignatures.ts_3_2964 | When used as a contextual type, a union type U has those members that are present in any of
// its constituent types, with types that are unions of the respective members in the constituent types.
interface SomeType {
(a: number): number;
}
interface SomeType2 {
(a: number): string;
}
interface IWithNoString... | {
"end_byte": 2964,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/union/contextualTypeWithUnionTypeIndexSignatures.ts"
} |
TypeScript/tests/cases/conformance/types/union/discriminatedUnionTypes2.ts_0_2626 | // @strict: true
function f10(x : { kind: false, a: string } | { kind: true, b: string } | { kind: string, c: string }) {
if (x.kind === false) {
x.a;
}
else if (x.kind === true) {
x.b;
}
else {
x.c;
}
}
function f11(x : { kind: false, a: string } | { kind: true, b: str... | {
"end_byte": 2626,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/union/discriminatedUnionTypes2.ts"
} |
TypeScript/tests/cases/conformance/types/union/discriminatedUnionTypes1.ts_0_2960 | interface Square {
kind: "square";
size: number;
}
interface Rectangle {
kind: "rectangle";
width: number;
height: number;
}
interface Circle {
kind: "circle";
radius: number;
}
type Shape = Square | Rectangle | Circle;
function area1(s: Shape) {
if (s.kind === "square") {
re... | {
"end_byte": 2960,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/union/discriminatedUnionTypes1.ts"
} |
TypeScript/tests/cases/conformance/types/union/unionTypeReduction2.ts_0_1422 | // @strict: true
function f1(x: { f(): void }, y: { f(x?: string): void }) {
let z = !!true ? x : y; // { f(x?: string): void }
z.f();
z.f('hello');
}
function f2(x: { f(x: string | undefined): void }, y: { f(x?: string): void }) {
let z = !!true ? x : y; // { f(x?: string): void }
z.f();
z.... | {
"end_byte": 1422,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/union/unionTypeReduction2.ts"
} |
TypeScript/tests/cases/conformance/types/union/unionTypePropertyAccessibility.ts_0_793 | class Default {
member: string;
}
class Public {
public member: string;
}
class Protected {
protected member: string;
}
class Private {
private member: number;
}
var v1: Default;
var v2: Public;
var v3: Protected;
var v4: Private;
var v5: Default | Public;
var v6: Default | Protected;
var v7: Defaul... | {
"end_byte": 793,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/union/unionTypePropertyAccessibility.ts"
} |
TypeScript/tests/cases/conformance/types/union/unionTypeIndexSignature.ts_3_1238 | r numOrDate: number | Date;
var anyVar: number;
// If each type in U has a string index signature,
// U has a string index signature of a union type of the types of the string index signatures from each type in U.
var unionOfDifferentReturnType: { [a: string]: number; } | { [a: string]: Date; };
numOrDate = unionOfD... | {
"end_byte": 1238,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/union/unionTypeIndexSignature.ts"
} |
TypeScript/tests/cases/conformance/types/union/contextualTypeWithUnionTypeMembers.ts_3_3561 | When used as a contextual type, a union type U has those members that are present in any of
// its constituent types, with types that are unions of the respective members in the constituent types.
interface I1<T> {
commonMethodType(a: string): string;
commonPropertyType: string;
commonMethodWithTypeParame... | {
"end_byte": 3561,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/union/contextualTypeWithUnionTypeMembers.ts"
} |
TypeScript/tests/cases/conformance/types/union/unionTypeConstructSignatures.ts_3_4717 | r numOrDate: number | Date;
var strOrBoolean: string | boolean;
var strOrNum: string | number;
// If each type in U has construct signatures and the sets of construct signatures are identical ignoring return types,
// U has the same set of construct signatures, but with return types that are unions of the return types... | {
"end_byte": 4717,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/union/unionTypeConstructSignatures.ts"
} |
TypeScript/tests/cases/conformance/types/union/unionTypeCallSignatures6.ts_0_835 | type A = { a: string };
type B = { b: number };
type C = { c: string };
type D = { d: number };
type F0 = () => void;
// #31547
type F1 = (this: A) => void;
type F2 = (this: B) => void;
declare var f1: F1 | F2;
f1(); // error
declare var f2: F0 | F1;
f2(); // error
interface F3 {
(this: A): void;
(this: B): void;... | {
"end_byte": 835,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/union/unionTypeCallSignatures6.ts"
} |
TypeScript/tests/cases/conformance/types/union/unionTypeFromArrayLiteral.ts_3_1148 | The resulting type an array literal expression is determined as follows:
// If the array literal is empty, the resulting type is an array type with the element type Undefined.
// Otherwise, if the array literal is contextually typed by a type that has a property with the numeric name ‘0’, the resulting type is a tuple... | {
"end_byte": 1148,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/union/unionTypeFromArrayLiteral.ts"
} |
TypeScript/tests/cases/conformance/types/union/unionTypeCallSignatures2.ts_3_830 | terface A {
(x: number): number;
(x: string, y?: string): boolean;
(x: Date): void;
<T>(x: T[]): T[];
}
interface B {
(x: number): number;
(x: string): string;
(x: Date): void;
<T>(x: T[]): T[];
}
interface C {
(x: string, ...y: string[]): number;
(x: number, s?: string): numbe... | {
"end_byte": 830,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/union/unionTypeCallSignatures2.ts"
} |
TypeScript/tests/cases/conformance/types/union/unionTypeWithIndexSignature.ts_0_851 | // @target: esnext
// @strict: true
type Two = { foo: { bar: true }, baz: true } | { [s: string]: string };
declare var u: Two
u.foo = 'bye'
u.baz = 'hi'
type Three = { foo: number } | { [s: string]: string } | { [s: string]: boolean };
declare var v: Three
v.foo = false
type Missing = { foo: number, bar: true } | { [s... | {
"end_byte": 851,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/union/unionTypeWithIndexSignature.ts"
} |
TypeScript/tests/cases/conformance/types/union/contextualTypeWithUnionTypeCallSignatures.ts_3_1503 | When used as a contextual type, a union type U has those members that are present in any of
// its constituent types, with types that are unions of the respective members in the constituent types.
// Let S be the set of types in U that have call signatures.
// If S is not empty and the sets of call signatures of the... | {
"end_byte": 1503,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/union/contextualTypeWithUnionTypeCallSignatures.ts"
} |
TypeScript/tests/cases/conformance/types/union/unionTypeCallSignatures3.ts_3_432 | nction f1(s: string) { }
function f2(s?: string) { }
function f3(...s: string[]) { }
function f4(s: string, s2?: string) { }
function f5(s?: string, n?: number) { }
function f6(s?: string, ...n: number[]) { }
function f7(s: string, ...sRest: string[]) { }
var fUnion: typeof f1 | typeof f2 | typeof f3 | typeof f4 | typ... | {
"end_byte": 432,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/union/unionTypeCallSignatures3.ts"
} |
TypeScript/tests/cases/conformance/types/union/unionTypeMembers.ts_3_2092 | terface I1<T> {
commonMethodType(a: string): string;
commonPropertyType: string;
commonMethodDifferentParameterType(a: string): string;
commonMethodDifferentReturnType(a: string): string;
commonPropertyDifferenType: string;
commonMethodWithTypeParameter(a: T): T;
commonMethodWithOwnTypePar... | {
"end_byte": 2092,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/union/unionTypeMembers.ts"
} |
TypeScript/tests/cases/conformance/types/union/unionTypeCallSignatures7.ts_0_271 | // @strict: true
// @noEmit: true
// https://github.com/microsoft/TypeScript/issues/55203
interface Callable<Name extends string> {
(): `${Name} without id`;
(id: number): `${Name} with id`;
}
declare const f: Callable<"A"> | Callable<"B">;
const result = f(123);
| {
"end_byte": 271,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/union/unionTypeCallSignatures7.ts"
} |
TypeScript/tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts_0_4018 | class Shape {
name: string;
width: number;
height: number;
visible: boolean;
}
type Dictionary<T> = { [x: string]: T };
type T00 = keyof K0; // Error
type T01 = keyof Object;
type T02 = keyof keyof Object;
type T03 = keyof keyof keyof Object;
type T04 = keyof keyof keyof keyof Object;
type T05 = key... | {
"end_byte": 4018,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts"
} |
TypeScript/tests/cases/conformance/types/keyof/keyofIntersection.ts_0_985 | // @strict: true
// @declaration: true
type A = { a: string };
type B = { b: string };
type T01 = keyof (A & B); // "a" | "b"
type T02<T> = keyof (T & B); // "b" | keyof T
type T03<U> = keyof (A & U); // "a" | keyof U
type T04<T, U> = keyof (T & U); // keyof T | keyof U
type T05 = T02<A>; // "a" | "b"
type T06 =... | {
"end_byte": 985,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/keyof/keyofIntersection.ts"
} |
TypeScript/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts_0_6351 | // @strictNullChecks: true
// @declaration: true
class Shape {
name: string;
width: number;
height: number;
visible: boolean;
}
class TaggedShape extends Shape {
tag: string;
}
class Item {
name: string;
price: number;
}
class Options {
visible: "yes" | "no";
}
type Dictionary<T> = ... | {
"end_byte": 6351,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts"
} |
TypeScript/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts_6353_11727 | function f55<T, K extends keyof T>(obj: T, key: K) {
for (let s in obj[key]) {
}
const b = "foo" in obj[key];
}
function f60<T>(source: T, target: T) {
for (let k in source) {
target[k] = source[k];
}
}
function f70(func: <T, U>(k1: keyof (T | U), k2: keyof (T & U)) => void) {
func<{ a... | {
"end_byte": 11727,
"start_byte": 6353,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts"
} |
TypeScript/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts_11729_17415 | interface Options1<Data, Computed> {
data?: Data
computed?: Computed;
}
declare class Component1<Data, Computed> {
constructor(options: Options1<Data, Computed>);
get<K extends keyof (Data & Computed)>(key: K): (Data & Computed)[K];
}
let c1 = new Component1({
data: {
hello: ""
}
});
... | {
"end_byte": 17415,
"start_byte": 11729,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts"
} |
TypeScript/tests/cases/conformance/types/keyof/keyofAndForIn.ts_0_701 | // @declaration: true
// Repro from #12513
function f1<K extends string, T>(obj: { [P in K]: T }, k: K) {
const b = k in obj;
let k1: K;
for (k1 in obj) {
let x1 = obj[k1];
}
for (let k2 in obj) {
let x2 = obj[k2];
}
}
function f2<T>(obj: { [P in keyof T]: T[P] }, k: keyof T) ... | {
"end_byte": 701,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/keyof/keyofAndForIn.ts"
} |
TypeScript/tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts_0_4416 | // @strict: true
// @target: esnext
function f1(obj: { a: number, b: 0 | 1, c: string }, k0: 'a', k1: 'a' | 'b', k2: 'a' | 'b' | 'c') {
obj[k0] = 1;
obj[k0] = 2;
obj[k0] = 'x'; // Error
obj[k1] = 1;
obj[k1] = 2; // Error
obj[k1] = 'x'; // Error
obj[k2] = 1; // Error
obj[k2] = 2;... | {
"end_byte": 4416,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts"
} |
TypeScript/tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts_0_515 | // @declaration: true
type T1 = {
x: T1["x"]; // Error
};
type T2<K extends "x" | "y"> = {
x: T2<K>[K]; // Error
y: number;
}
declare let x2: T2<"x">;
let x2x = x2.x;
interface T3<T extends T3<T>> {
x: T["x"];
}
interface T4<T extends T4<T>> {
x: T4<T>["x"]; // Error
}
class C1 {
x: C1[... | {
"end_byte": 515,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts"
} |
TypeScript/tests/cases/conformance/types/members/typesWithSpecializedCallSignatures.ts_0_665 | // basic uses of specialized signatures without errors
class Base { foo: string }
class Derived1 extends Base { bar: string }
class Derived2 extends Base { baz: string }
class C {
foo(x: 'hi'): Derived1;
foo(x: 'bye'): Derived2;
foo(x: string): Base;
foo(x) {
return x;
}
}
var c = new C();... | {
"end_byte": 665,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/typesWithSpecializedCallSignatures.ts"
} |
TypeScript/tests/cases/conformance/types/members/objectTypeWithCallSignatureHidingMembersOfFunction.ts_0_618 | // object types with call signatures can override members of Function
// no errors expected below
interface I {
(): void;
apply(a: any, b?: any): void;
call(thisArg: number, ...argArray: number[]): any;
}
var i: I;
var r1: (a: any, b?: any) => void = i.apply;
var r1b: (thisArg: number, ...argArray: numbe... | {
"end_byte": 618,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/objectTypeWithCallSignatureHidingMembersOfFunction.ts"
} |
TypeScript/tests/cases/conformance/types/members/duplicateNumericIndexers.ts_0_512 | // @skipDefaultLibCheck: false
// it is an error to have duplicate index signatures of the same kind in a type
interface Number {
[x: number]: string;
[x: number]: string;
}
interface String {
[x: number]: string;
[x: number]: string;
}
interface Array<T> {
[x: number]: T;
[x: number]: T;
}
... | {
"end_byte": 512,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/duplicateNumericIndexers.ts"
} |
TypeScript/tests/cases/conformance/types/members/duplicatePropertyNames.ts_0_551 | // duplicate property names are an error in all types
interface Number {
foo: string;
foo: string;
}
interface String {
foo(): string;
foo(): string;
}
interface Array<T> {
foo: T;
foo: T;
}
class C {
foo: string;
foo: string;
bar(x) { }
bar(x) { }
baz = () => { }
b... | {
"end_byte": 551,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/duplicatePropertyNames.ts"
} |
TypeScript/tests/cases/conformance/types/members/objectTypeWithConstructSignatureHidingMembersOfFunction.ts_0_528 | interface I {
new(): number;
apply(a: any, b?: any): void;
call(thisArg: number, ...argArray: number[]): any;
}
var i: I;
var r1: (a: any, b?: any) => void = i.apply;
var r1b: (thisArg: number, ...argArray: number[]) => void = i.call;
var r1c = i.arguments;
var x: {
new(): number;
apply(a: any, b?... | {
"end_byte": 528,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/objectTypeWithConstructSignatureHidingMembersOfFunction.ts"
} |
TypeScript/tests/cases/conformance/types/members/objectTypeWithCallSignatureHidingMembersOfFunctionAssignmentCompat.ts_0_108 | interface I {
(): void;
}
var i: I;
var f: Object;
f = i;
i = f;
var a: {
(): void
}
f = a;
a = f; | {
"end_byte": 108,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/objectTypeWithCallSignatureHidingMembersOfFunctionAssignmentCompat.ts"
} |
TypeScript/tests/cases/conformance/types/members/objectTypePropertyAccess.ts_0_452 | // Index notation should resolve to the type of a declared property with that same name
class C {
foo: string;
}
var c: C;
var r1 = c.toString();
var r2 = c['toString']();
var r3 = c.foo;
var r4 = c['foo'];
interface I {
bar: string;
}
var i: I;
var r4 = i.toString();
var r5 = i['toString']();
var r6 = i.bar;... | {
"end_byte": 452,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/objectTypePropertyAccess.ts"
} |
TypeScript/tests/cases/conformance/types/members/duplicateStringIndexers.ts_0_592 | // it is an error to have duplicate index signatures of the same kind in a type
module test {
interface Number {
[x: string]: string;
[x: string]: string;
}
interface String {
[x: string]: string;
[x: string]: string;
}
interface Array<T> {
[x: string]: T;
... | {
"end_byte": 592,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/duplicateStringIndexers.ts"
} |
TypeScript/tests/cases/conformance/types/members/indexSignatures1.ts_0_5383 | // @strict: true
// @declaration: true
// @target: esnext
// Symbol index signature checking
const sym = Symbol();
function gg3(x: { [key: string]: string }, y: { [key: symbol]: string }, z: { [sym]: number }) {
x = z;
y = z; // Error
}
// Overlapping index signatures
function gg1(x: { [key: `a${string}`]... | {
"end_byte": 5383,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/indexSignatures1.ts"
} |
TypeScript/tests/cases/conformance/types/members/indexSignatures1.ts_5385_6838 | let case2 = foo({
addOne: (x: number) => x + 1,
double: (x: number) => x + x,
[directive]: (x: string) => 'str',
});
let case3 = foo({
[directive]: 'str',
addOne: (x: number) => x + 1,
double: (x: number) => x + x,
});
// Repros from #42192
type Pseudo = `&:${string}`;
const AmIPseudo1: Pseu... | {
"end_byte": 6838,
"start_byte": 5385,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/indexSignatures1.ts"
} |
TypeScript/tests/cases/conformance/types/members/objectTypeWithCallSignatureAppearsToBeFunctionType.ts_0_312 | // objects with call signatures should be permitted where function types are expected
// no errors expected below
interface I {
(): void;
}
var i: I;
var r2: void = i();
var r2b: (x: any, y?: any) => any = i.apply;
var b: {
(): void;
}
var r4: void = b();
var rb4: (x: any, y?: any) => any = b.apply; | {
"end_byte": 312,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/objectTypeWithCallSignatureAppearsToBeFunctionType.ts"
} |
TypeScript/tests/cases/conformance/types/members/typesWithPublicConstructor.ts_0_304 | // public is allowed on a constructor but is not meaningful
class C {
public constructor() { }
}
var c = new C();
var r: () => void = c.constructor;
class C2 {
public constructor(x: number);
public constructor(x: any) { }
}
var c2 = new C2();
var r2: (x: number) => void = c2.constructor; | {
"end_byte": 304,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/typesWithPublicConstructor.ts"
} |
TypeScript/tests/cases/conformance/types/members/classWithProtectedProperty.ts_0_634 | // accessing any protected outside the class is an error
class C {
protected x;
protected a = '';
protected b: string = '';
protected c() { return '' }
protected d = () => '';
protected static e;
protected static f() { return '' }
protected static g = () => '';
}
class D extends C {
... | {
"end_byte": 634,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/classWithProtectedProperty.ts"
} |
TypeScript/tests/cases/conformance/types/members/objectTypeWithConstructSignatureAppearsToBeFunctionType.ts_0_295 | // no errors expected below
interface I {
new(): number;
}
var i: I;
var r2: number = i();
var r2b: number = new i();
var r2c: (x: any, y?: any) => any = i.apply;
var b: {
new(): number;
}
var r4: number = b();
var r4b: number = new b();
var r4c: (x: any, y?: any) => any = b.apply; | {
"end_byte": 295,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/objectTypeWithConstructSignatureAppearsToBeFunctionType.ts"
} |
TypeScript/tests/cases/conformance/types/members/objectTypeWithNumericProperty.ts_0_486 | // no errors here
class C {
1: number;
1.1: string;
}
var c: C;
var r1 = c[1];
var r2 = c[1.1];
var r3 = c['1'];
var r4 = c['1.1'];
interface I {
1: number;
1.1: string;
}
var i: I;
var r1 = i[1];
var r2 = i[1.1];
var r3 = i['1'];
var r4 = i['1.1'];
var a: {
1: number;
1.1: string;
}
var r... | {
"end_byte": 486,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/objectTypeWithNumericProperty.ts"
} |
TypeScript/tests/cases/conformance/types/members/typesWithSpecializedConstructSignatures.ts_0_650 | // basic uses of specialized signatures without errors
class Base { foo: string }
class Derived1 extends Base { bar: string }
class Derived2 extends Base { baz: string }
class C {
constructor(x: 'hi');
constructor(x: 'bye');
constructor(x: string);
constructor(x) {
return x;
}
}
var c = ne... | {
"end_byte": 650,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/typesWithSpecializedConstructSignatures.ts"
} |
TypeScript/tests/cases/conformance/types/members/typesWithProtectedConstructor.ts_0_324 | // @declaration: true
class C {
protected constructor() { }
}
var c = new C(); // error C is protected
var r: () => void = c.constructor;
class C2 {
protected constructor(x: number);
protected constructor(x: any) { }
}
var c2 = new C2(); // error C2 is protected
var r2: (x: number) => void = c2.construc... | {
"end_byte": 324,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/typesWithProtectedConstructor.ts"
} |
TypeScript/tests/cases/conformance/types/members/augmentedTypeAssignmentCompatIndexSignature.ts_0_281 | interface Foo { a }
interface Bar { b }
interface Object {
[n: number]: Foo;
}
interface Function {
[n: number]: Bar;
}
var o = {};
var f = () => { };
var v1: {
[n: number]: Foo
} = o; // Should be allowed
var v2: {
[n: number]: Bar
} = f; // Should be allowed | {
"end_byte": 281,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/augmentedTypeAssignmentCompatIndexSignature.ts"
} |
TypeScript/tests/cases/conformance/types/members/objectTypeWithConstructSignatureHidingMembersOfFunctionAssignmentCompat.ts_0_112 | interface I {
new(): any;
}
var i: I;
var f: Object;
f = i;
i = f;
var a: {
new(): any
}
f = a;
a = f; | {
"end_byte": 112,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/objectTypeWithConstructSignatureHidingMembersOfFunctionAssignmentCompat.ts"
} |
TypeScript/tests/cases/conformance/types/members/objectTypeWithStringIndexerHidingObjectIndexer.ts_0_530 | // @skipDefaultLibCheck: false
// object types can define string indexers that are more specific than the default 'any' that would be returned
// no errors expected below
interface Object {
[x: string]: Object;
}
var o = {};
var r = o['']; // should be Object
class C {
foo: string;
[x: string]: string;
}... | {
"end_byte": 530,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/objectTypeWithStringIndexerHidingObjectIndexer.ts"
} |
TypeScript/tests/cases/conformance/types/members/objectTypeHidingMembersOfObjectAssignmentCompat.ts_0_235 | interface I {
toString(): void;
}
var i: I;
var o: Object;
o = i; // error
i = o; // ok
class C {
toString(): void { }
}
var c: C;
o = c; // error
c = o; // ok
var a = {
toString: () => { }
}
o = a; // error
a = o; // ok | {
"end_byte": 235,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/objectTypeHidingMembersOfObjectAssignmentCompat.ts"
} |
TypeScript/tests/cases/conformance/types/members/objectTypeHidingMembersOfObjectAssignmentCompat2.ts_0_255 | interface I {
toString(): number;
}
var i: I;
var o: Object;
o = i; // error
i = o; // error
class C {
toString(): number { return 1; }
}
var c: C;
o = c; // error
c = o; // error
var a = {
toString: () => { }
}
o = a; // error
a = o; // ok | {
"end_byte": 255,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/objectTypeHidingMembersOfObjectAssignmentCompat2.ts"
} |
TypeScript/tests/cases/conformance/types/members/augmentedTypeBracketAccessIndexSignature.ts_0_203 | interface Foo { a }
interface Bar { b }
interface Object {
[n: number]: Foo;
}
interface Function {
[n: number]: Bar;
}
var a = {}[0]; // Should be Foo
var b = (() => { })[0]; // Should be Bar | {
"end_byte": 203,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/augmentedTypeBracketAccessIndexSignature.ts"
} |
TypeScript/tests/cases/conformance/types/members/objectTypeWithCallSignatureHidingMembersOfExtendedFunction.ts_0_798 | // object types with call signatures can override members of Function
// no errors expected below
interface Function {
data: number;
[x: string]: Object;
}
interface I {
(): void;
apply(a: any, b?: any): void;
call(thisArg: number, ...argArray: number[]): any;
}
var i: I;
var r1: (a: any, b?: an... | {
"end_byte": 798,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/objectTypeWithCallSignatureHidingMembersOfExtendedFunction.ts"
} |
TypeScript/tests/cases/conformance/types/members/classWithPrivateProperty.ts_0_480 | // accessing any private outside the class is an error
class C {
private x;
private a = '';
private b: string = '';
private c() { return '' }
private d = () => '';
private static e;
private static f() { return '' }
private static g = () => '';
}
var c = new C();
var r1: string = c.x;
v... | {
"end_byte": 480,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/classWithPrivateProperty.ts"
} |
TypeScript/tests/cases/conformance/types/members/objectTypeHidingMembersOfObject.ts_0_366 | // all of these valueOf calls should return the type shown in the overriding signatures here
class C {
valueOf() { }
}
var c: C;
var r1: void = c.valueOf();
interface I {
valueOf(): void;
}
var i: I;
var r2: void = i.valueOf();
var a = {
valueOf: () => { }
}
var r3: void = a.valueOf();
var b: {
v... | {
"end_byte": 366,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/objectTypeHidingMembersOfObject.ts"
} |
TypeScript/tests/cases/conformance/types/members/typesWithOptionalProperty.ts_0_358 | // basic uses of optional properties without errors
interface I {
foo: string;
bar?: number;
baz? (): string;
}
var a: {
foo: string;
bar?: number;
baz? (): string;
};
var b = { foo: '' };
var c = { foo: '', bar: 3 };
var d = { foo: '', bar: 3, baz: () => '' };
var i: I;
i = b;
i = c;
i = d... | {
"end_byte": 358,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/typesWithOptionalProperty.ts"
} |
TypeScript/tests/cases/conformance/types/members/objectTypeHidingMembersOfExtendedObject.ts_0_844 | // @skipDefaultLibCheck: false
class A {
foo: string;
}
class B extends A {
bar: string;
}
interface Object {
data: A;
[x: string]: Object;
}
class C {
valueOf() { }
data: B;
[x: string]: any;
}
var c: C;
var r1: void = c.valueOf();
var r1b: B = c.data;
var r1c = r1b['hm']; // should be ... | {
"end_byte": 844,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/objectTypeHidingMembersOfExtendedObject.ts"
} |
TypeScript/tests/cases/conformance/types/members/typesWithPrivateConstructor.ts_0_314 | // @declaration: true
class C {
private constructor() { }
}
var c = new C(); // error C is private
var r: () => void = c.constructor;
class C2 {
private constructor(x: number);
private constructor(x: any) { }
}
var c2 = new C2(); // error C2 is private
var r2: (x: number) => void = c2.constructor; | {
"end_byte": 314,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/typesWithPrivateConstructor.ts"
} |
TypeScript/tests/cases/conformance/types/members/classWithPublicProperty.ts_0_442 | class C {
public x;
public a = '';
public b: string = '';
public c() { return '' }
public d = () => '';
public static e;
public static f() { return '' }
public static g = () => '';
}
// all of these are valid
var c = new C();
var r1: string = c.x;
var r2: string = c.a;
var r3: string = ... | {
"end_byte": 442,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/classWithPublicProperty.ts"
} |
TypeScript/tests/cases/conformance/types/members/objectTypeWithConstructSignatureHidingMembersOfExtendedFunction.ts_0_708 | interface Function {
data: number;
[x: string]: Object;
}
interface I {
new(): number;
apply(a: any, b?: any): void;
call(thisArg: number, ...argArray: number[]): any;
}
var i: I;
var r1: (a: any, b?: any) => void = i.apply;
var r1b: (thisArg: number, ...argArray: number[]) => void = i.call;
var r... | {
"end_byte": 708,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/objectTypeWithConstructSignatureHidingMembersOfExtendedFunction.ts"
} |
TypeScript/tests/cases/conformance/types/members/objectTypeWithDuplicateNumericProperty.ts_0_300 | // numeric properties must be distinct after a ToNumber operation
// so the below are all errors
class C {
1;
1.0;
1.;
1.00;
}
interface I {
1;
1.0;
1.;
1.00;
}
var a: {
1;
1.0;
1.;
1.00;
}
var b = {
1: 1,
1.0: 1,
1.: 1,
1.00: 1
}
| {
"end_byte": 300,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/objectTypeWithDuplicateNumericProperty.ts"
} |
TypeScript/tests/cases/conformance/types/members/objectTypeWithStringNamedPropertyOfIllegalCharacters.ts_0_896 | class C {
" ": number;
"a b": string;
"~!@#$%^&*()_+{}|:'<>?\/.,`": number;
"a\a": number;
static "a ": number
}
var c: C;
var r = c[" "];
var r2 = c[" "];
var r3 = c["a b"];
// BUG 817263
var r4 = c["~!@#$%^&*()_+{}|:'<>?\/.,`"];
interface I {
" ": number;
"a b": string;
... | {
"end_byte": 896,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/objectTypeWithStringNamedPropertyOfIllegalCharacters.ts"
} |
TypeScript/tests/cases/conformance/types/members/objectTypeWithStringAndNumberIndexSignatureToAny.ts_0_2158 | // @strict: true
// When checking compatibility between two types,
// TypeScript should not require an index signature if
// the target side index signature maps to `any` *and*
// the target side has *any* string index signature to `any`.
//
// So an index signature like in
//
// { [x: number]: any }
//
// is still r... | {
"end_byte": 2158,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/objectTypeWithStringAndNumberIndexSignatureToAny.ts"
} |
TypeScript/tests/cases/conformance/types/members/objectTypeWithStringNamedNumericProperty.ts_0_2473 | // @target: ES5
// string named numeric properties are legal and distinct when indexed by string values
// indexed numerically the value is converted to a number
// no errors expected below
class C {
"0.1": void;
".1": Object;
"1": number;
"1.": string;
"1..": boolean;
"1.0": Date;
"-1.0":... | {
"end_byte": 2473,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/members/objectTypeWithStringNamedNumericProperty.ts"
} |
TypeScript/tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.1.ts_0_4041 | // @target: es2018
// @lib: esnext
// @noEmit: true
async function * inferReturnType1() {
}
async function * inferReturnType2() {
yield;
}
async function * inferReturnType3() {
yield 1;
}
async function * inferReturnType4() {
yield Promise.resolve(1);
}
async function * inferReturnType5() {
yield 1;
... | {
"end_byte": 4041,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.1.ts"
} |
TypeScript/tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts_0_2404 | // @target: es2018
// @lib: esnext
// @noEmit: true
async function * inferReturnType1() {
yield* {};
}
async function * inferReturnType2() {
yield* inferReturnType2();
}
async function * inferReturnType3() {
yield* Promise.resolve([1, 2]);
}
const assignability1: () => AsyncIterableIterator<number> = async ... | {
"end_byte": 2404,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts"
} |
TypeScript/tests/cases/conformance/types/unknown/unknownType2.ts_0_5451 | // @strict: true
type isUnknown<T> = unknown extends T ? true : false;
type isTrue<T extends true> = T;
type SomeResponse = 'yes' | 'no' | 'idk';
let validate: (x: unknown) => SomeResponse = x => (x === 'yes' || x === 'no') ? x : 'idk'; // No error
const u: unknown = undefined;
declare const symb: unique symbol;
de... | {
"end_byte": 5451,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/unknown/unknownType2.ts"
} |
TypeScript/tests/cases/conformance/types/unknown/unknownType1.ts_0_4518 | // @strict: true
// In an intersection everything absorbs unknown
type T00 = unknown & null; // null
type T01 = unknown & undefined; // undefined
type T02 = unknown & null & undefined; // never
type T03 = unknown & string; // string
type T04 = unknown & string[]; // string[]
type T05 = unknown & unknown; // unk... | {
"end_byte": 4518,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/unknown/unknownType1.ts"
} |
TypeScript/tests/cases/conformance/types/unknown/unknownControlFlow.ts_0_6142 | // @strict: true
// @declaration: true
type T01 = {} & string; // {} & string
type T02 = {} & 'a'; // 'a'
type T03 = {} & object; // object
type T04 = {} & { x: number }; // { x: number }
type T05 = {} & null; // never
type T06 = {} & undefined; // never
type T07 = undefined & void; // undefined
type T10 = str... | {
"end_byte": 6142,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/unknown/unknownControlFlow.ts"
} |
TypeScript/tests/cases/conformance/types/unknown/unknownControlFlow.ts_6143_9009 | type NullableFoo = Foo | undefined;
type Bar<T extends NullableFoo> = NonNullable<T>[string];
// Generics and intersections with {}
function fx0<T>(value: T & ({} | null)) {
if (value === 42) {
value; // T & {}
}
else {
value; // T & ({} | null)
}
}
function fx1<T extends unknown>(... | {
"end_byte": 9009,
"start_byte": 6143,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/unknown/unknownControlFlow.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.