_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
TypeScript/tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts_0_301 | // @declaration: true
type T = "foo" | "bar" | "baz";
var x: "foo" | "bar" | "baz" = undefined;
var y: T = undefined;
if (x === "foo") {
let a = x;
}
else if (x !== "bar") {
let b = x || y;
}
else {
let c = x;
let d = y;
let e: (typeof x) | (typeof y) = c || d;
}
x = y;
y = x; | {
"end_byte": 301,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts"
} |
TypeScript/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads05.ts_3_362 | @declaration: true
interface Animal { animal: {} };
interface Dog extends Animal { dog: {} }
interface Cat extends Animal { cat: {} }
interface Moose extends Animal { moose: {} }
function doThing(x: "dog"): Dog;
function doThing(x: "cat"): Cat;
function doThing(x: string): Animal;
function doThing(x: string, y?: str... | {
"end_byte": 362,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads05.ts"
} |
TypeScript/tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndTuples01.ts_0_445 | // @declaration: true
// Should all be strings.
let [hello, brave, newish, world] = ["Hello", "Brave", "New", "World"];
type RexOrRaptor = "t-rex" | "raptor"
let [im, a, dinosaur]: ["I'm", "a", RexOrRaptor] = ['I\'m', 'a', 't-rex'];
rawr(dinosaur);
function rawr(dino: RexOrRaptor) {
if (dino === "t-rex") {
... | {
"end_byte": 445,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndTuples01.ts"
} |
TypeScript/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts_0_1658 | // @declaration: true
type PrimitiveName = 'string' | 'number' | 'boolean';
function getFalsyPrimitive(x: "string"): string;
function getFalsyPrimitive(x: "number"): number;
function getFalsyPrimitive(x: "boolean"): boolean;
function getFalsyPrimitive(x: "boolean" | "string"): boolean | string;
function getFalsyPrimi... | {
"end_byte": 1658,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads01.ts"
} |
TypeScript/tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes04.ts_0_336 | // @declaration: true
type T = "" | "foo";
let x: T = undefined;
let y: T = undefined;
if (x === "") {
let a = x;
}
if (x !== "") {
let b = x;
}
if (x == "") {
let c = x;
}
if (x != "") {
let d = x;
}
if (x) {
let e = x;
}
if (!x) {
let f = x;
}
if (!!x) {
let g = x;
}
if (!!!x) {
... | {
"end_byte": 336,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes04.ts"
} |
TypeScript/tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts_0_291 | // @declaration: true
type T = number | "foo" | "bar";
var x: "foo" | "bar" | number;
var y: T = undefined;
if (x === "foo") {
let a = x;
}
else if (x !== "bar") {
let b = x || y;
}
else {
let c = x;
let d = y;
let e: (typeof x) | (typeof y) = c || d;
}
x = y;
y = x; | {
"end_byte": 291,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts"
} |
TypeScript/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts_0_1565 | // @declaration: true
function getFalsyPrimitive(x: "string"): string;
function getFalsyPrimitive(x: "number"): number;
function getFalsyPrimitive(x: "boolean"): boolean;
function getFalsyPrimitive(x: "boolean" | "string"): boolean | string;
function getFalsyPrimitive(x: "boolean" | "number"): boolean | number;
functi... | {
"end_byte": 1565,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts"
} |
TypeScript/tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts_0_3551 | // @declaration: true
declare function randBool(): boolean;
declare function takeReturnString(str: string): string;
declare function takeReturnHello(str: "Hello"): "Hello";
declare function takeReturnHelloWorld(str: "Hello" | "World"): "Hello" | "World";
function fun1<T>(x: T, y: T) {
return randBool() ? x : y;
}... | {
"end_byte": 3551,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts"
} |
TypeScript/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads03.ts_3_898 | @declaration: true
interface Base {
x: string;
y: number;
}
interface HelloOrWorld extends Base {
p1: boolean;
}
interface JustHello extends Base {
p2: boolean;
}
interface JustWorld extends Base {
p3: boolean;
}
let hello: "hello";
let world: "world";
let helloOrWorld: "hello" | "world";
fun... | {
"end_byte": 898,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads03.ts"
} |
TypeScript/tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts_0_319 | // @declaration: true
type T = string | "foo" | "bar" | "baz";
var x: "foo" | "bar" | "baz" | string = undefined;
var y: T = undefined;
if (x === "foo") {
let a = x;
}
else if (x !== "bar") {
let b = x || y;
}
else {
let c = x;
let d = y;
let e: (typeof x) | (typeof y) = c || d;
}
x = y;
y = x; | {
"end_byte": 319,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts"
} |
TypeScript/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloadAssignability04.ts_3_218 | @declaration: true
function f(x: "foo"): number;
function f(x: "foo"): number {
return 0;
}
function g(x: "foo"): number;
function g(x: "foo"): number {
return 0;
}
let a = f;
let b = g;
a = b;
b = a; | {
"end_byte": 218,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloadAssignability04.ts"
} |
TypeScript/tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts_3_534 | @declaration: true
let abc: "ABC" = "ABC";
let xyz: "XYZ" = "XYZ";
let abcOrXyz: "ABC" | "XYZ" = abc || xyz;
let abcOrXyzOrNumber: "ABC" | "XYZ" | number = abcOrXyz || 100;
let a = abcOrXyzOrNumber + 100;
let b = 100 + abcOrXyzOrNumber;
let c = abcOrXyzOrNumber + abcOrXyzOrNumber;
let d = abcOrXyzOrNumber + true;
le... | {
"end_byte": 534,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts"
} |
TypeScript/tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithTemplateStrings01.ts_3_146 | @declaration: true
let ABC: "ABC" = `ABC`;
let DE_NEWLINE_F: "DE\nF" = `DE
F`;
let G_QUOTE_HI: 'G"HI';
let JK_BACKTICK_L: "JK`L" = `JK\`L`; | {
"end_byte": 146,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithTemplateStrings01.ts"
} |
TypeScript/tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags03.ts_0_886 | // @declaration: true
type Kind = "A" | "B"
interface Entity {
kind: Kind;
}
interface A extends Entity {
kind: "A";
a: number;
}
interface B extends Entity {
kind: "B";
b: string;
}
// Currently (2015-12-14), we write '"A" | "A"' and '"B" | "B"' to avoid
// interpreting respective overloads as... | {
"end_byte": 886,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags03.ts"
} |
TypeScript/tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts_0_224 | // @declaration: true
let a: "";
var b: "foo";
let c: "bar";
const d: "baz";
a = "";
b = "foo";
c = "bar";
let e: "" = "";
var f: "foo" = "foo";
let g: "bar" = "bar";
const h: "baz" = "baz";
e = "";
f = "foo";
g = "bar"; | {
"end_byte": 224,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/stringLiteral/stringLiteralTypesInVariableDeclarations01.ts"
} |
TypeScript/tests/cases/conformance/types/stringLiteral/stringLiteralCheckedInIf02.ts_4_219 | pe S = "a" | "b";
type T = S[] | S;
function isS(t: T): t is S {
return t === "a" || t === "b";
}
function f(foo: T) {
if (isS(foo)) {
return foo;
}
else {
return foo[0];
}
} | {
"end_byte": 219,
"start_byte": 4,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/stringLiteral/stringLiteralCheckedInIf02.ts"
} |
TypeScript/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloadAssignability01.ts_3_220 | @declaration: true
function f(x: "foo"): number;
function f(x: string): number {
return 0;
}
function g(x: "bar"): number;
function g(x: string): number {
return 0;
}
let a = f;
let b = g;
a = b;
b = a; | {
"end_byte": 220,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloadAssignability01.ts"
} |
TypeScript/tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags02.ts_0_598 | // @declaration: true
type Kind = "A" | "B"
interface Entity {
kind: Kind;
}
interface A extends Entity {
kind: "A";
a: number;
}
interface B extends Entity {
kind: "B";
b: string;
}
function hasKind(entity: Entity, kind: "A"): entity is A;
function hasKind(entity: Entity, kind: "B"): entity is... | {
"end_byte": 598,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags02.ts"
} |
TypeScript/tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTypeParameterConstraint01.ts_3_322 | @declaration: true
function foo<T extends "foo">(f: (x: T) => T) {
return f;
}
function bar<T extends "foo" | "bar">(f: (x: T) => T) {
return f;
}
let f = foo(x => x);
let fResult = f("foo");
let g = foo((x => x));
let gResult = g("foo");
let h = bar(x => x);
let hResult = h("foo");
hResult = h("bar"); | {
"end_byte": 322,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTypeParameterConstraint01.ts"
} |
TypeScript/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloadAssignability05.ts_3_251 | @declaration: true
function f(x: "foo"): number;
function f(x: string): number;
function f(x: string): number {
return 0;
}
function g(x: "foo"): number;
function g(x: string): number {
return 0;
}
let a = f;
let b = g;
a = b;
b = a; | {
"end_byte": 251,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloadAssignability05.ts"
} |
TypeScript/tests/cases/conformance/types/spread/spreadUnion2.ts_0_564 | // @strictNullChecks: true
declare const undefinedUnion: { a: number } | undefined;
declare const nullUnion: { b: number } | null;
var o1: {} | { a: number };
var o1 = { ...undefinedUnion };
var o2: {} | { b: number };
var o2 = { ...nullUnion };
var o3: {} | { a: number } | { b: number } | { a: number, b: number };... | {
"end_byte": 564,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/spread/spreadUnion2.ts"
} |
TypeScript/tests/cases/conformance/types/spread/spreadMethods.ts_0_659 | // @target: esnext
// @useDefineForClassFields: false
class K {
p = 12;
m() { }
get g() { return 0; }
}
interface I {
p: number;
m(): void;
readonly g: number;
}
let k = new K()
let sk = { ...k };
let ssk = { ...k, ...k };
sk.p;
sk.m(); // error
sk.g; // error
ssk.p;
ssk.m(); // error
ssk.g; /... | {
"end_byte": 659,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/spread/spreadMethods.ts"
} |
TypeScript/tests/cases/conformance/types/spread/objectSpreadRepeatedComplexity.ts_0_1876 | // @strict: true
function f(cnd: Record<number, boolean>){
// Type is a union of 2^(n-1) members, where n is the number of spread objects
return {
// Without this one, it collapses to {} ?
...(cnd[1] &&
cnd[2] && {
prop0: 0,
}),
// With one prop each, it ... | {
"end_byte": 1876,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/spread/objectSpreadRepeatedComplexity.ts"
} |
TypeScript/tests/cases/conformance/types/spread/spreadUnion3.ts_0_511 | // @strictNullChecks: true
function f(x: { y: string } | undefined): { y: string } {
return { y: 123, ...x } // y: string | number
}
f(undefined)
function g(t?: { a: number } | null): void {
let b = { ...t };
let c: number = b.a; // might not have 'a'
}
g()
g(undefined)
g(null)
// spreading nothing but ... | {
"end_byte": 511,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/spread/spreadUnion3.ts"
} |
TypeScript/tests/cases/conformance/types/spread/spreadDuplicateExact.ts_0_738 | // @strict: true
// @exactOptionalPropertyTypes: true
// @declaration: true
// Repro from #44438
declare let a: { a: string };
declare let b: { a?: string };
declare let c: { a: string | undefined };
declare let d: { a?: string | undefined };
declare let t: boolean;
let a1 = { a: 123, ...a }; // string (Error)
let... | {
"end_byte": 738,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/spread/spreadDuplicateExact.ts"
} |
TypeScript/tests/cases/conformance/types/spread/objectSpreadRepeatedNullCheckPerf.ts_0_2477 | // @strict: true
interface Props {
readonly a?: string
readonly b?: string
readonly c?: string
readonly d?: string
readonly e?: string
readonly f?: string
readonly g?: string
readonly h?: string
readonly i?: string
readonly j?: string
readonly k?: string
readonly l?: stri... | {
"end_byte": 2477,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/spread/objectSpreadRepeatedNullCheckPerf.ts"
} |
TypeScript/tests/cases/conformance/types/spread/spreadOverwritesProperty.ts_0_383 | // without strict null checks, none of these should be an error
declare var ab: { a: number, b: number };
declare var abq: { a: number, b?: number };
var unused1 = { b: 1, ...ab }
var unused2 = { ...ab, ...ab }
var unused3 = { b: 1, ...abq }
function g(obj: { x: number | undefined }) {
return { x: 1, ...obj };
}
f... | {
"end_byte": 383,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/spread/spreadOverwritesProperty.ts"
} |
TypeScript/tests/cases/conformance/types/spread/spreadExcessProperty.ts_0_164 | type A = { a: string, b: string };
const extra1 = { a: "a", b: "b", extra: "extra" };
const a1: A = { ...extra1 }; // spread should not give excess property errors
| {
"end_byte": 164,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/spread/spreadExcessProperty.ts"
} |
TypeScript/tests/cases/conformance/types/spread/objectSpreadComputedProperty.ts_0_229 | // fixes #12200
function f() {
let n: number = 12;
let m: number = 13;
let a: any = null;
const o1 = { ...{}, [n]: n };
const o2 = { ...{}, [a]: n };
const o3 = { [a]: n, ...{}, [n]: n, ...{}, [m]: m };
}
| {
"end_byte": 229,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/spread/objectSpreadComputedProperty.ts"
} |
TypeScript/tests/cases/conformance/types/spread/objectSpreadStrictNull.ts_0_1880 | // @strictNullChecks: true
function f(
definiteBoolean: { sn: boolean },
definiteString: { sn: string },
optionalString: { sn?: string },
optionalNumber: { sn?: number },
undefinedString: { sn: string | undefined },
undefinedNumber: { sn: number | undefined }) {
// optional
let optional... | {
"end_byte": 1880,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/spread/objectSpreadStrictNull.ts"
} |
TypeScript/tests/cases/conformance/types/spread/spreadUnion.ts_0_293 | var union: { a: number } | { b: string };
var o3: { a: number } | { b: string };
var o3 = { ...union };
var o4: { a: boolean } | { b: string , a: boolean};
var o4 = { ...union, a: false };
var o5: { a: number } | { b: string } | { a: number, b: string };
var o5 = { ...union, ...union }; | {
"end_byte": 293,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/spread/spreadUnion.ts"
} |
TypeScript/tests/cases/conformance/types/spread/objectSpreadIndexSignature.ts_0_559 | // @strict: true
declare let indexed1: { [n: string]: number; a: number; };
declare let indexed2: { [n: string]: boolean; c: boolean; };
declare let indexed3: { [n: string]: number };
let i = { ...indexed1, b: 11 };
// only indexed has indexer, so i[101]: any
i[101];
let ii = { ...indexed1, ...indexed2 };
// both have ... | {
"end_byte": 559,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/spread/objectSpreadIndexSignature.ts"
} |
TypeScript/tests/cases/conformance/types/spread/spreadNonPrimitive.ts_0_81 | declare let o: object;
const x: { a: number, b: number } = { a: 1, ...o, b: 2 };
| {
"end_byte": 81,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/spread/spreadNonPrimitive.ts"
} |
TypeScript/tests/cases/conformance/types/spread/spreadObjectOrFalsy.ts_0_906 | // @strict: true
// @declaration: true
function f1<T>(a: T & undefined) {
return { ...a }; // Error
}
function f2<T>(a: T | T & undefined) {
return { ...a };
}
function f3<T extends undefined>(a: T) {
return { ...a }; // Error
}
function f4<T extends undefined>(a: object | T) {
return { ...a };
}
... | {
"end_byte": 906,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/spread/spreadObjectOrFalsy.ts"
} |
TypeScript/tests/cases/conformance/types/spread/spreadContextualTypedBindingPattern.ts_0_267 | // #18308
interface Person {
naam: string,
age: number
}
declare const bob: Person
declare const alice: Person
// [ts] Initializer provides no value for this binding element and the binding element has no default value.
const { naam, age } = {...bob, ...alice}
| {
"end_byte": 267,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/spread/spreadContextualTypedBindingPattern.ts"
} |
TypeScript/tests/cases/conformance/types/spread/spreadDuplicate.ts_0_665 | // @strict: true
// @declaration: true
// Repro from #44438
declare let a: { a: string };
declare let b: { a?: string };
declare let c: { a: string | undefined };
declare let d: { a?: string | undefined };
declare let t: boolean;
let a1 = { a: 123, ...a }; // string (Error)
let b1 = { a: 123, ...b }; // string | ... | {
"end_byte": 665,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/spread/spreadDuplicate.ts"
} |
TypeScript/tests/cases/conformance/types/spread/spreadOverwritesPropertyStrict.ts_0_1219 | // @strict: true
declare var ab: { a: number, b: number };
declare var abq: { a: number, b?: number };
var unused1 = { b: 1, ...ab } // error
var unused2 = { ...ab, ...ab } // ok, overwritten error doesn't apply to spreads
var unused3 = { b: 1, ...abq } // ok, abq might have b: undefined
var unused4 = { ...ab, b: 1 } /... | {
"end_byte": 1219,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/spread/spreadOverwritesPropertyStrict.ts"
} |
TypeScript/tests/cases/conformance/types/spread/objectSpreadNegative.ts_0_2657 | // @target: es5
// @strictNullChecks: true
let o = { a: 1, b: 'no' }
/// private propagates
class PrivateOptionalX {
private x?: number;
}
class PublicX {
public x: number;
}
declare let publicX: PublicX;
declare let privateOptionalX: PrivateOptionalX;
let o2 = { ...publicX, ...privateOptionalX };
let sn: numb... | {
"end_byte": 2657,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/spread/objectSpreadNegative.ts"
} |
TypeScript/tests/cases/conformance/types/spread/spreadNonObject1.ts_0_204 | // @strict: true
// @noEmit: true
// https://github.com/microsoft/TypeScript/issues/45493
type S = `${number}`;
const b = {
c: (["4"] as S[]).map(function (s) {
const a = { ...s, y: 6 };
}),
};
| {
"end_byte": 204,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/spread/spreadNonObject1.ts"
} |
TypeScript/tests/cases/conformance/types/spread/spreadUnion4.ts_0_98 | declare const a: { x: () => void }
declare const b: { x?: () => void }
const c = { ...a, ...b };
| {
"end_byte": 98,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/spread/spreadUnion4.ts"
} |
TypeScript/tests/cases/conformance/types/spread/objectSpread.ts_0_4749 | // @strictNullChecks: true
// @target: es5
let o = { a: 1, b: 'no' }
let o2 = { b: 'yes', c: true }
let swap = { a: 'yes', b: -1 };
let addAfter: { a: number, b: string, c: boolean } =
{ ...o, c: false }
let addBefore: { a: number, b: string, c: boolean } =
{ c: false, ...o }
let override: { a: number, b: stri... | {
"end_byte": 4749,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/spread/objectSpread.ts"
} |
TypeScript/tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts_0_126 | // @lib: es5
let o7 = { ...o? };
let o8 = { ...*o };
let o9 = { ...matchMedia() { }};
let o10 = { ...get x() { return 12; }};
| {
"end_byte": 126,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts"
} |
TypeScript/tests/cases/conformance/types/spread/objectSpreadNoTransform.ts_0_122 | // @target: esnext
const y = { a: 'yes', b: 'no' };
const o = { x: 1, ...y };
var b;
var rest: any;
({ b, ...rest } = o);
| {
"end_byte": 122,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/spread/objectSpreadNoTransform.ts"
} |
TypeScript/tests/cases/conformance/types/spread/spreadTypeVariable.ts_0_429 | function f1<T extends number>(arg: T) {
return { ...arg };
}
function f2<T extends string[]>(arg: T) {
return { ...arg }
}
function f3<T extends number | string[]>(arg: T) {
return { ...arg }
}
function f4<T extends number | { [key: string]: any }>(arg: T) {
return { ...arg }
}
function f5<T extends string[... | {
"end_byte": 429,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/spread/spreadTypeVariable.ts"
} |
TypeScript/tests/cases/conformance/types/spread/objectSpreadSetonlyAccessor.ts_0_199 | // @strict: true
// @target: esnext
const o1: { foo: number, bar: undefined } = { foo: 1, ... { set bar(_v: number) { } } }
const o2: { foo: undefined } = { foo: 1, ... { set foo(_v: number) { } } }
| {
"end_byte": 199,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/spread/objectSpreadSetonlyAccessor.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithOptionalParameters.ts_0_2399 | // call signatures in derived types must have the same or fewer optional parameters as the base type
interface Base {
a: () => number;
a2: (x?: number) => number;
a3: (x: number) => number;
a4: (x: number, y?: number) => number;
a5: (x?: number, y?: number) => number;
a6: (x: number, y: number... | {
"end_byte": 2399,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithOptionalParameters.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithEnumIndexer.ts_0_47 | enum E {
A
}
let foo: Record<E, any> = {}
| {
"end_byte": 47,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithEnumIndexer.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance5.ts_0_2656 | // checking subtype relations for function types as it relates to contextual signature instantiation
// same as subtypingWithConstructSignatures2 just with an extra level of indirection in the inheritance chain
class Base { foo: string; }
class Derived extends Base { bar: string; }
class Derived2 extends Derived { baz... | {
"end_byte": 2656,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance5.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality.ts_0_1310 | // Derived member is not optional but base member is, should be ok
class Base { foo: string; }
class Derived extends Base { bar: string; }
class Derived2 extends Derived { baz: string; }
module TargetHasOptional {
// targets
interface C {
opt?: Base
}
var c: C;
var a: { opt?: Base; }
... | {
"end_byte": 1310,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/unionTypesAssignability.ts_3_1448 | r unionNumberString: number | string;
class C { }
class D extends C { foo1() { } }
class E extends C { foo2() { } }
var unionDE: D | E;
var num: number;
var str: string;
var c: C;
var d: D;
var e: E;
// A union type U is assignable to a type T if each type in U is assignable to T
c = d;
c = e;
c = unionDE; // ok
d = ... | {
"end_byte": 1448,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/unionTypesAssignability.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance4.ts_0_1880 | // checking subtype relations for function types as it relates to contextual signature instantiation
class Base { foo: string; }
class Derived extends Base { bar: string; }
class Derived2 extends Derived { baz: string; }
class OtherDerived extends Base { bing: string; }
interface A { // T
// M's
a: <T>(x: T) ... | {
"end_byte": 1880,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance4.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignatures4.ts_0_319 | // some complex cases of assignment compat of generic signatures.
interface I2<T> {
p: T
}
var x: <T extends I2<T>>(z: T) => void
var y: <T extends I2<I2<T>>>(z: T) => void
// These both do not make sense as we would eventually be comparing I2<T> to I2<I2<T>>, and they are self referencing anyway
x = y
y = x
| {
"end_byte": 319,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignatures4.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts_0_726 | // void returning call signatures can be assigned a non-void returning call signature that otherwise matches
interface T {
(x: number): void;
}
var t: T;
var a: { (x: number): void };
t = a;
a = t;
interface S {
(x: number): string;
}
var s: S;
var a2: { (x: number): string };
t = s;
t = a2;
a = s;
a = a2;
... | {
"end_byte": 726,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts_0_1436 | // M is optional and S contains no property with the same name as M
// N is optional and T contains no property with the same name as N
class Base { foo: string; }
class Derived extends Base { bar: string; }
class Derived2 extends Derived { baz: string; }
module TargetHasOptional {
// targets
interface C {
... | {
"end_byte": 1436,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance.ts_0_1800 | // Checking basic subtype relations with construct signatures
module ConstructSignature {
interface Base { // T
// M's
new (x: number): void; // BUG 842221
new (x: number, y: number): number;
}
// S's
interface I extends Base {
// N's
new (x: number): number; //... | {
"end_byte": 1800,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/anyAssignabilityInInheritance.ts_0_2368 | // any is not a subtype of any other types, errors expected on all the below derived classes unless otherwise noted
interface I {
[x: string]: any;
foo: any; // ok, any identical to itself
}
var a: any;
declare function foo2(x: number): number;
declare function foo2(x: any): any;
var r3 = foo2(a); // any, no... | {
"end_byte": 2368,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/anyAssignabilityInInheritance.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer.ts_0_1034 | // index signatures must be compatible in assignments
interface Base { foo: string; }
interface Derived extends Base { bar: string; }
interface Derived2 extends Derived { baz: string; }
class A {
[x: string]: Base;
}
var a: A;
var b: { [x: string]: Derived; }
a = b; // ok
b = a; // error
var b2: { [x: string]:... | {
"end_byte": 1034,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer.ts_0_840 | // Derived type indexer must be subtype of base type indexer
interface Base { foo: string; }
interface Derived extends Base { bar: string; }
interface Derived2 extends Derived { baz: string; }
class A {
[x: number]: Base;
}
var a: A;
var b: { [x: number]: Derived; }
a = b;
b = a; // error
var b2: { [x: number]:... | {
"end_byte": 840,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/nullAssignedToUndefined.ts_0_81 | var x = undefined = null; // error
var y: typeof undefined = null; // ok, widened | {
"end_byte": 81,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/nullAssignedToUndefined.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance4.ts_0_2407 | // checking subtype relations for function types as it relates to contextual signature instantiation
class Base { foo: string; }
class Derived extends Base { bar: string; }
class Derived2 extends Derived { baz: string; }
class OtherDerived extends Base { bing: string; }
interface A { // T
// M's
a: new <T>(x:... | {
"end_byte": 2407,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance4.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignatures.ts_0_237 | // some complex cases of assignment compat of generic signatures that stress contextual signature instantiation
var f: <S extends { p: string }[]>(x: S) => void
var g: <T extends { p: string }>(x: T[]) => void
f = g; // ok
g = f; // ok | {
"end_byte": 237,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignatures.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance5.ts_0_2535 | // checking subtype relations for function types as it relates to contextual signature instantiation
// same as subtypingWithCallSignatures2 just with an extra level of indirection in the inheritance chain
class Base { foo: string; }
class Derived extends Base { bar: string; }
class Derived2 extends Derived { baz: str... | {
"end_byte": 2535,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance5.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures6.ts_0_1066 | // checking assignment compatibility relations for function types. All valid
class Base { foo: string; }
class Derived extends Base { bar: string; }
class Derived2 extends Derived { baz: string; }
class OtherDerived extends Base { bing: string; }
interface A {
a: <T>(x: T) => T[];
a2: <T>(x: T) => string[];
... | {
"end_byte": 1066,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures6.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures.ts_0_595 | // void returning call signatures can be assigned a non-void returning call signature that otherwise matches
interface T {
new (x: number): void;
}
var t: T;
var a: { new (x: number): void };
t = a;
a = t;
interface S {
new (x: number): string;
}
var s: S;
var a2: { new (x: number): string };
t = s;
t = a2;
... | {
"end_byte": 595,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covariantCallbacks.ts_0_2047 | // @target: es2015
// @strict: true
// Test that callback parameters are related covariantly
interface P<T> {
then(cb: (value: T) => void): void;
};
interface A { a: string }
interface B extends A { b: string }
function f1(a: P<A>, b: P<B>) {
a = b;
b = a; // Error
}
function f2(a: Promise<A>, b: Prom... | {
"end_byte": 2047,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covariantCallbacks.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/optionalPropertyAssignableToStringIndexSignature.ts_0_666 | // @strict: true
declare let optionalProperties: { k1?: string };
declare let undefinedProperties: { k1: string | undefined };
declare let stringDictionary: { [key: string]: string };
stringDictionary = optionalProperties; // ok
stringDictionary = undefinedProperties; // error
declare let probablyArray: { [key: num... | {
"end_byte": 666,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/optionalPropertyAssignableToStringIndexSignature.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures5.ts_0_1872 | // checking assignment compat for function types. All valid
class Base { foo: string; }
class Derived extends Base { bar: string; }
class Derived2 extends Derived { baz: string; }
class OtherDerived extends Base { bing: string; }
var a: new <T>(x: T) => T[];
var a2: new <T>(x: T) => string[];
var a3: new <T>(x: T) =>... | {
"end_byte": 1872,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures5.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatBetweenTupleAndArray.ts_3_409 | r numStrTuple: [number, string];
var numNumTuple: [number, number];
var numEmptyObjTuple: [number, {}];
var emptyObjTuple: [{}];
var numArray: number[];
var emptyObjArray: {}[];
// no error
numArray = numNumTuple;
emptyObjArray = emptyObjTuple;
emptyObjArray = numStrTuple;
emptyObjArray = numNumTuple;
emptyObjArray =... | {
"end_byte": 409,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatBetweenTupleAndArray.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/nullAssignableToEveryType.ts_0_742 | class C {
foo: string;
}
var ac: C;
interface I {
foo: string;
}
var ai: I;
enum E { A }
var ae: E;
var b: number = null;
var c: string = null;
var d: boolean = null;
var e: Date = null;
var f: any = null;
var g: void = null;
var h: Object = null;
var i: {} = null;
var j: () => {} = null;
var k: Function = nu... | {
"end_byte": 742,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/nullAssignableToEveryType.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembers2.ts_0_629 | // members N and M of types S and T have the same name, same accessibility, same optionality, and N is assignable M
// additional optional properties do not cause errors
class S { foo: string; }
class T { foo: string; }
var s: S;
var t: T;
interface S2 { foo: string; bar?: string }
interface T2 { foo: string; baz?: s... | {
"end_byte": 629,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembers2.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/numberAssignableToEnum.ts_0_51 | enum E { A }
var n: number;
var e: E;
e = n;
n = e; | {
"end_byte": 51,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/numberAssignableToEnum.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts_0_916 | // void returning call signatures can be assigned a non-void returning call signature that otherwise matches
interface T {
f(x: number): void;
}
var t: T;
var a: { f(x: number): void };
t = a;
a = t;
interface S {
f(x: number): string;
}
var s: S;
var a2: { f(x: number): string };
t = s;
t = a2;
a = s;
a = a... | {
"end_byte": 916,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/everyTypeAssignableToAny.ts_0_736 | var a: any;
class C {
foo: string;
}
var ac: C;
interface I {
foo: string;
}
var ai: I;
enum E { A }
var ae: E;
var b: number;
var c: string;
var d: boolean;
var e: Date;
var f: any;
var g: void;
var h: Object;
var i: {};
var j: () => {};
var k: Function;
var l: (x: number) => string;
var m: number[];
var n:... | {
"end_byte": 736,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/everyTypeAssignableToAny.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithDiscriminatedUnion.ts_0_5717 | // see 'typeRelatedToDiscriminatedType' in checker.ts:
// IteratorResult
namespace Example1 {
type S = { done: boolean, value: number };
type T =
| { done: true, value: number } // T0
| { done: false, value: number }; // T1
declare let s: S;
declare let t: T;
// S is assigna... | {
"end_byte": 5717,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithDiscriminatedUnion.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability.ts_0_185 | // type parameters are not assignable to one another unless directly or indirectly constrained to one another
function foo<T, U>(t: T, u: U) {
t = u; // error
u = t; // error
} | {
"end_byte": 185,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembers3.ts_0_665 | // members N and M of types S and T have the same name, same accessibility, same optionality, and N is assignable M
// additional optional properties do not cause errors
class S implements S2 { foo: string; }
class T implements T2 { foo: string; }
var s: S;
var t: T;
interface S2 { foo: string; bar?: string }
interfa... | {
"end_byte": 665,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembers3.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts_0_2996 | // these are all permitted with the current rules, since we do not do contextual signature instantiation
class Base { foo: string; }
class Derived extends Base { bar: string; }
class Derived2 extends Derived { baz: string; }
class OtherDerived extends Base { bing: string; }
var a: (x: number) => number[];
var a2: (x:... | {
"end_byte": 2996,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembers.ts_0_1232 | // members N and M of types S and T have the same name, same accessibility, same optionality, and N is assignable M
// no errors expected
module SimpleTypes {
class S { foo: string; }
class T { foo: string; }
var s: S;
var t: T;
interface S2 { foo: string; }
interface T2 { foo: string; }
v... | {
"end_byte": 1232,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembers.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/intersectionIncludingPropFromGlobalAugmentation.ts_0_400 | // @strict: true
// @noEmit: true
// repro from https://github.com/microsoft/TypeScript/issues/54345
interface Test1 { toString: null | 'string'; }
type Test2 = Test1 & { optional?: unknown };
declare const source: Test1;
const target: Test2 = { ...source };
const toString = target.toString;
const hasOwn = target.ha... | {
"end_byte": 400,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/intersectionIncludingPropFromGlobalAugmentation.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersNumericNames.ts_0_630 | // members N and M of types S and T have the same name, same accessibility, same optionality, and N is assignable M
// numeric named properties work correctly, no errors expected
class S { 1: string; }
class T { 1.: string; }
var s: S;
var t: T;
interface S2 { 1: string; bar?: string }
interface T2 { 1.0: string; baz... | {
"end_byte": 630,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersNumericNames.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts_0_3329 | // checking assignment compatibility relations for function types.
module Errors {
class Base { foo: string; }
class Derived extends Base { bar: string; }
class Derived2 extends Derived { baz: string; }
class OtherDerived extends Base { bing: string; }
module WithNonGenericSignaturesInBaseType {
... | {
"end_byte": 3329,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersStringNumericNames.ts_0_1618 | // members N and M of types S and T have the same name, same accessibility, same optionality, and N is assignable M
// string named numeric properties work correctly, errors below unless otherwise noted
module JustStrings {
class S { '1': string; }
class T { '1.': string; }
var s: S;
var t: T;
int... | {
"end_byte": 1618,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersStringNumericNames.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability3.ts_0_488 | // type parameters are not assignable to one another unless directly or indirectly constrained to one another
class Foo { foo: string; }
function foo<T extends Foo, U extends Foo>(t: T, u: U) {
var a: T;
var b: U;
t = a; // ok
a = t; // ok
b = u; // ok
u = b; // ok
t = u; // error
u ... | {
"end_byte": 488,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability3.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts_0_3174 | // checking assignment compatibility relations for function types. All of these are valid.
class Base { foo: string; }
class Derived extends Base { bar: string; }
class Derived2 extends Derived { baz: string; }
class OtherDerived extends Base { bing: string; }
var a: new (x: number) => number[];
var a2: new (x: numbe... | {
"end_byte": 3174,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignabilityInInheritance.ts_0_2183 | // enum is only a subtype of number, no types are subtypes of enum, all of these except the first are errors
enum E { A }
interface I0 {
[x: string]: E;
foo: E; // identical and subtype, ok
}
declare function foo(x: E): E;
declare function foo(x: number): number;
declare function foo(x: any): any;
var r = ... | {
"end_byte": 2183,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignabilityInInheritance.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembers4.ts_0_1815 | // members N and M of types S and T have the same name, same accessibility, same optionality, and N is not assignable M
module OnlyDerived {
class Base { foo: string; }
class Derived extends Base { bar: string; }
class Derived2 extends Base { baz: string; }
class S { foo: Derived; }
class T { foo:... | {
"end_byte": 1815,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembers4.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer3.ts_0_750 | // Derived type indexer must be subtype of base type indexer
interface Base { foo: string; }
interface Derived extends Base { bar: string; }
interface Derived2 extends Derived { baz: string; }
class A {
[x: number]: Derived;
}
var a: A;
var b: { [x: number]: Base; };
a = b; // error
b = a; // ok
class B2 exten... | {
"end_byte": 750,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer3.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/genericCallWithObjectTypeArgsAndInitializers.ts_0_477 | // Generic typed parameters with initializers
function foo<T>(x: T = null) { return x; } // ok
function foo2<T>(x: T = undefined) { return x; } // ok
function foo3<T extends Number>(x: T = 1) { } // error
function foo4<T, U extends T>(x: T, y: U = x) { } // error
function foo5<T, U extends T>(x: U, y: T = x) { } // ok... | {
"end_byte": 477,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/genericCallWithObjectTypeArgsAndInitializers.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignaturesWithOptionalParameters.ts_0_1204 | // call signatures in derived types must have the same or fewer optional parameters as the base type
interface Base {
a: new () => number;
a2: new (x?: number) => number;
a3: new (x: number) => number;
a4: new (x: number, y?: number) => number;
a5: new (x?: number, y?: number) => number;
a6: n... | {
"end_byte": 1204,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignaturesWithOptionalParameters.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts_0_3140 | // These are mostly permitted with the current loose rules. All ok unless otherwise noted.
module Errors {
class Base { foo: string; }
class Derived extends Base { bar: string; }
class Derived2 extends Derived { baz: string; }
class OtherDerived extends Base { bing: string; }
module WithNonGeneric... | {
"end_byte": 3140,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/undefinedAssignableToEveryType.ts_0_866 | class C {
foo: string;
}
var ac: C;
interface I {
foo: string;
}
var ai: I;
enum E { A }
var ae: E;
var b: number = undefined;
var c: string = undefined;
var d: boolean = undefined;
var e: Date = undefined;
var f: any = undefined;
var g: void = undefined;
var h: Object = undefined;
var i: {} = undefined;
var ... | {
"end_byte": 866,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/undefinedAssignableToEveryType.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer2.ts_0_1050 | // index signatures must be compatible in assignments
interface Base { foo: string; }
interface Derived extends Base { bar: string; }
interface Derived2 extends Derived { baz: string; }
interface A {
[x: string]: Base;
}
var a: A;
var b: { [x: string]: Derived; }
a = b; // ok
b = a; // error
var b2: { [x: stri... | {
"end_byte": 1050,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer2.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembers5.ts_0_118 | class C {
foo: string;
}
var c: C;
interface I {
fooo: string;
}
var i: I;
c = i; // error
i = c; // error | {
"end_byte": 118,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembers5.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer2.ts_0_852 | // Derived type indexer must be subtype of base type indexer
interface Base { foo: string; }
interface Derived extends Base { bar: string; }
interface Derived2 extends Derived { baz: string; }
interface A {
[x: number]: Base;
}
var a: A;
var b: { [x: number]: Derived; }
a = b;
b = a; // error
var b2: { [x: numb... | {
"end_byte": 852,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer2.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures5.ts_0_1753 | // checking assignment compat for function types. No errors in this file
class Base { foo: string; }
class Derived extends Base { bar: string; }
class Derived2 extends Derived { baz: string; }
class OtherDerived extends Base { bing: string; }
var a: <T>(x: T) => T[];
var a2: <T>(x: T) => string[];
var a3: <T>(x: T) =... | {
"end_byte": 1753,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures5.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures6.ts_0_1133 | // checking assignment compatibility relations for function types. All valid.
class Base { foo: string; }
class Derived extends Base { bar: string; }
class Derived2 extends Derived { baz: string; }
class OtherDerived extends Base { bing: string; }
interface A {
a: new <T>(x: T) => T[];
a2: new <T>(x: T) => st... | {
"end_byte": 1133,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures6.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer3.ts_0_514 | // Derived type indexer must be subtype of base type indexer
interface Base { foo: string; }
interface Derived extends Base { bar: string; }
interface Derived2 extends Derived { baz: string; }
var a: A;
var b1: { [x: string]: string; }
a = b1; // error
b1 = a; // error
module Generics {
class A<T extends Derived... | {
"end_byte": 514,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer3.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/anyAssignableToEveryType.ts_0_694 | var a: any;
class C {
foo: string;
}
var ac: C;
interface I {
foo: string;
}
var ai: I;
enum E { A }
var ae: E;
var b: number = a;
var c: string = a;
var d: boolean = a;
var e: Date = a;
var f: any = a;
var g: void = a;
var h: Object = a;
var i: {} = a;
var j: () => {} = a;
var k: Function = a;
var l: (x: nu... | {
"end_byte": 694,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/anyAssignableToEveryType.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts_0_1333 | // type parameters are not assignable to one another unless directly or indirectly constrained to one another
function foo<T, U extends T>(t: T, u: U) {
t = u; // error
u = t; // ok
}
function foo2<T extends U, U>(t: T, u: U) {
t = u; // error
u = t; // ok
}
function foo3<T extends U, U extends V, V>... | {
"end_byte": 1333,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts"
} |
TypeScript/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts_0_734 | // void returning call signatures can be assigned a non-void returning call signature that otherwise matches
interface T {
f: new (x: number) => void;
}
var t: T;
var a: { f: new (x: number) => void };
t = a;
a = t;
interface S {
f: new (x: number) => string;
}
var s: S;
var a2: { f: new (x: number) => strin... | {
"end_byte": 734,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.