mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 20:14:01 -06:00
Accepted baselines.
This commit is contained in:
parent
5cbf17d989
commit
2efa69773d
@ -0,0 +1,50 @@
|
||||
tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags02.ts(18,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature.
|
||||
tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags02.ts(19,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags02.ts (2 errors) ====
|
||||
|
||||
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;
|
||||
~~~~~~~
|
||||
!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature.
|
||||
function hasKind(entity: Entity, kind: "B"): entity is B;
|
||||
~~~~~~~
|
||||
!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature.
|
||||
function hasKind(entity: Entity, kind: Kind): entity is (A | B) {
|
||||
return entity.kind === kind;
|
||||
}
|
||||
|
||||
let x: A = {
|
||||
kind: "A",
|
||||
a: 100,
|
||||
}
|
||||
|
||||
if (hasKind(x, "A")) {
|
||||
let a = x;
|
||||
}
|
||||
else {
|
||||
let b = x;
|
||||
}
|
||||
|
||||
if (!hasKind(x, "B")) {
|
||||
let c = x;
|
||||
}
|
||||
else {
|
||||
let d = x;
|
||||
}
|
||||
81
tests/baselines/reference/stringLiteralTypesAsTags02.js
Normal file
81
tests/baselines/reference/stringLiteralTypesAsTags02.js
Normal file
@ -0,0 +1,81 @@
|
||||
//// [stringLiteralTypesAsTags02.ts]
|
||||
|
||||
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 B;
|
||||
function hasKind(entity: Entity, kind: Kind): entity is (A | B) {
|
||||
return entity.kind === kind;
|
||||
}
|
||||
|
||||
let x: A = {
|
||||
kind: "A",
|
||||
a: 100,
|
||||
}
|
||||
|
||||
if (hasKind(x, "A")) {
|
||||
let a = x;
|
||||
}
|
||||
else {
|
||||
let b = x;
|
||||
}
|
||||
|
||||
if (!hasKind(x, "B")) {
|
||||
let c = x;
|
||||
}
|
||||
else {
|
||||
let d = x;
|
||||
}
|
||||
|
||||
//// [stringLiteralTypesAsTags02.js]
|
||||
function hasKind(entity, kind) {
|
||||
return entity.kind === kind;
|
||||
}
|
||||
var x = {
|
||||
kind: "A",
|
||||
a: 100
|
||||
};
|
||||
if (hasKind(x, "A")) {
|
||||
var a = x;
|
||||
}
|
||||
else {
|
||||
var b = x;
|
||||
}
|
||||
if (!hasKind(x, "B")) {
|
||||
var c = x;
|
||||
}
|
||||
else {
|
||||
var d = x;
|
||||
}
|
||||
|
||||
|
||||
//// [stringLiteralTypesAsTags02.d.ts]
|
||||
declare type Kind = "A" | "B";
|
||||
interface Entity {
|
||||
kind: Kind;
|
||||
}
|
||||
interface A extends Entity {
|
||||
kind: "A";
|
||||
a: number;
|
||||
}
|
||||
interface B extends Entity {
|
||||
kind: "B";
|
||||
b: string;
|
||||
}
|
||||
declare function hasKind(entity: Entity, kind: "A"): entity is A;
|
||||
declare function hasKind(entity: Entity, kind: "B"): entity is B;
|
||||
declare let x: A;
|
||||
85
tests/baselines/reference/stringLiteralTypesAsTags03.js
Normal file
85
tests/baselines/reference/stringLiteralTypesAsTags03.js
Normal file
@ -0,0 +1,85 @@
|
||||
//// [stringLiteralTypesAsTags03.ts]
|
||||
|
||||
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 "specialized" signatures.
|
||||
// That way, we can avoid the need to look for a compatible overload
|
||||
// signature and simply check compatibility with the implementation.
|
||||
function hasKind(entity: Entity, kind: "A" | "A"): entity is A;
|
||||
function hasKind(entity: Entity, kind: "B" | "B"): entity is B;
|
||||
function hasKind(entity: Entity, kind: Kind): entity is Entity {
|
||||
return entity.kind === kind;
|
||||
}
|
||||
|
||||
let x: A = {
|
||||
kind: "A",
|
||||
a: 100,
|
||||
}
|
||||
|
||||
if (hasKind(x, "A")) {
|
||||
let a = x;
|
||||
}
|
||||
else {
|
||||
let b = x;
|
||||
}
|
||||
|
||||
if (!hasKind(x, "B")) {
|
||||
let c = x;
|
||||
}
|
||||
else {
|
||||
let d = x;
|
||||
}
|
||||
|
||||
//// [stringLiteralTypesAsTags03.js]
|
||||
function hasKind(entity, kind) {
|
||||
return entity.kind === kind;
|
||||
}
|
||||
var x = {
|
||||
kind: "A",
|
||||
a: 100
|
||||
};
|
||||
if (hasKind(x, "A")) {
|
||||
var a = x;
|
||||
}
|
||||
else {
|
||||
var b = x;
|
||||
}
|
||||
if (!hasKind(x, "B")) {
|
||||
var c = x;
|
||||
}
|
||||
else {
|
||||
var d = x;
|
||||
}
|
||||
|
||||
|
||||
//// [stringLiteralTypesAsTags03.d.ts]
|
||||
declare type Kind = "A" | "B";
|
||||
interface Entity {
|
||||
kind: Kind;
|
||||
}
|
||||
interface A extends Entity {
|
||||
kind: "A";
|
||||
a: number;
|
||||
}
|
||||
interface B extends Entity {
|
||||
kind: "B";
|
||||
b: string;
|
||||
}
|
||||
declare function hasKind(entity: Entity, kind: "A" | "A"): entity is A;
|
||||
declare function hasKind(entity: Entity, kind: "B" | "B"): entity is B;
|
||||
declare let x: A;
|
||||
109
tests/baselines/reference/stringLiteralTypesAsTags03.symbols
Normal file
109
tests/baselines/reference/stringLiteralTypesAsTags03.symbols
Normal file
@ -0,0 +1,109 @@
|
||||
=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags03.ts ===
|
||||
|
||||
type Kind = "A" | "B"
|
||||
>Kind : Symbol(Kind, Decl(stringLiteralTypesAsTags03.ts, 0, 0))
|
||||
|
||||
interface Entity {
|
||||
>Entity : Symbol(Entity, Decl(stringLiteralTypesAsTags03.ts, 1, 21))
|
||||
|
||||
kind: Kind;
|
||||
>kind : Symbol(kind, Decl(stringLiteralTypesAsTags03.ts, 3, 18))
|
||||
>Kind : Symbol(Kind, Decl(stringLiteralTypesAsTags03.ts, 0, 0))
|
||||
}
|
||||
|
||||
interface A extends Entity {
|
||||
>A : Symbol(A, Decl(stringLiteralTypesAsTags03.ts, 5, 1))
|
||||
>Entity : Symbol(Entity, Decl(stringLiteralTypesAsTags03.ts, 1, 21))
|
||||
|
||||
kind: "A";
|
||||
>kind : Symbol(kind, Decl(stringLiteralTypesAsTags03.ts, 7, 28))
|
||||
|
||||
a: number;
|
||||
>a : Symbol(a, Decl(stringLiteralTypesAsTags03.ts, 8, 14))
|
||||
}
|
||||
|
||||
interface B extends Entity {
|
||||
>B : Symbol(B, Decl(stringLiteralTypesAsTags03.ts, 10, 1))
|
||||
>Entity : Symbol(Entity, Decl(stringLiteralTypesAsTags03.ts, 1, 21))
|
||||
|
||||
kind: "B";
|
||||
>kind : Symbol(kind, Decl(stringLiteralTypesAsTags03.ts, 12, 28))
|
||||
|
||||
b: string;
|
||||
>b : Symbol(b, Decl(stringLiteralTypesAsTags03.ts, 13, 14))
|
||||
}
|
||||
|
||||
// Currently (2015-12-14), we write '"A" | "A"' and '"B" | "B"' to avoid
|
||||
// interpreting respective overloads as "specialized" signatures.
|
||||
// That way, we can avoid the need to look for a compatible overload
|
||||
// signature and simply check compatibility with the implementation.
|
||||
function hasKind(entity: Entity, kind: "A" | "A"): entity is A;
|
||||
>hasKind : Symbol(hasKind, Decl(stringLiteralTypesAsTags03.ts, 15, 1), Decl(stringLiteralTypesAsTags03.ts, 21, 63), Decl(stringLiteralTypesAsTags03.ts, 22, 63))
|
||||
>entity : Symbol(entity, Decl(stringLiteralTypesAsTags03.ts, 21, 17))
|
||||
>Entity : Symbol(Entity, Decl(stringLiteralTypesAsTags03.ts, 1, 21))
|
||||
>kind : Symbol(kind, Decl(stringLiteralTypesAsTags03.ts, 21, 32))
|
||||
>entity : Symbol(entity, Decl(stringLiteralTypesAsTags03.ts, 21, 17))
|
||||
>A : Symbol(A, Decl(stringLiteralTypesAsTags03.ts, 5, 1))
|
||||
|
||||
function hasKind(entity: Entity, kind: "B" | "B"): entity is B;
|
||||
>hasKind : Symbol(hasKind, Decl(stringLiteralTypesAsTags03.ts, 15, 1), Decl(stringLiteralTypesAsTags03.ts, 21, 63), Decl(stringLiteralTypesAsTags03.ts, 22, 63))
|
||||
>entity : Symbol(entity, Decl(stringLiteralTypesAsTags03.ts, 22, 17))
|
||||
>Entity : Symbol(Entity, Decl(stringLiteralTypesAsTags03.ts, 1, 21))
|
||||
>kind : Symbol(kind, Decl(stringLiteralTypesAsTags03.ts, 22, 32))
|
||||
>entity : Symbol(entity, Decl(stringLiteralTypesAsTags03.ts, 22, 17))
|
||||
>B : Symbol(B, Decl(stringLiteralTypesAsTags03.ts, 10, 1))
|
||||
|
||||
function hasKind(entity: Entity, kind: Kind): entity is Entity {
|
||||
>hasKind : Symbol(hasKind, Decl(stringLiteralTypesAsTags03.ts, 15, 1), Decl(stringLiteralTypesAsTags03.ts, 21, 63), Decl(stringLiteralTypesAsTags03.ts, 22, 63))
|
||||
>entity : Symbol(entity, Decl(stringLiteralTypesAsTags03.ts, 23, 17))
|
||||
>Entity : Symbol(Entity, Decl(stringLiteralTypesAsTags03.ts, 1, 21))
|
||||
>kind : Symbol(kind, Decl(stringLiteralTypesAsTags03.ts, 23, 32))
|
||||
>Kind : Symbol(Kind, Decl(stringLiteralTypesAsTags03.ts, 0, 0))
|
||||
>entity : Symbol(entity, Decl(stringLiteralTypesAsTags03.ts, 23, 17))
|
||||
>Entity : Symbol(Entity, Decl(stringLiteralTypesAsTags03.ts, 1, 21))
|
||||
|
||||
return entity.kind === kind;
|
||||
>entity.kind : Symbol(Entity.kind, Decl(stringLiteralTypesAsTags03.ts, 3, 18))
|
||||
>entity : Symbol(entity, Decl(stringLiteralTypesAsTags03.ts, 23, 17))
|
||||
>kind : Symbol(Entity.kind, Decl(stringLiteralTypesAsTags03.ts, 3, 18))
|
||||
>kind : Symbol(kind, Decl(stringLiteralTypesAsTags03.ts, 23, 32))
|
||||
}
|
||||
|
||||
let x: A = {
|
||||
>x : Symbol(x, Decl(stringLiteralTypesAsTags03.ts, 27, 3))
|
||||
>A : Symbol(A, Decl(stringLiteralTypesAsTags03.ts, 5, 1))
|
||||
|
||||
kind: "A",
|
||||
>kind : Symbol(kind, Decl(stringLiteralTypesAsTags03.ts, 27, 12))
|
||||
|
||||
a: 100,
|
||||
>a : Symbol(a, Decl(stringLiteralTypesAsTags03.ts, 28, 14))
|
||||
}
|
||||
|
||||
if (hasKind(x, "A")) {
|
||||
>hasKind : Symbol(hasKind, Decl(stringLiteralTypesAsTags03.ts, 15, 1), Decl(stringLiteralTypesAsTags03.ts, 21, 63), Decl(stringLiteralTypesAsTags03.ts, 22, 63))
|
||||
>x : Symbol(x, Decl(stringLiteralTypesAsTags03.ts, 27, 3))
|
||||
|
||||
let a = x;
|
||||
>a : Symbol(a, Decl(stringLiteralTypesAsTags03.ts, 33, 7))
|
||||
>x : Symbol(x, Decl(stringLiteralTypesAsTags03.ts, 27, 3))
|
||||
}
|
||||
else {
|
||||
let b = x;
|
||||
>b : Symbol(b, Decl(stringLiteralTypesAsTags03.ts, 36, 7))
|
||||
>x : Symbol(x, Decl(stringLiteralTypesAsTags03.ts, 27, 3))
|
||||
}
|
||||
|
||||
if (!hasKind(x, "B")) {
|
||||
>hasKind : Symbol(hasKind, Decl(stringLiteralTypesAsTags03.ts, 15, 1), Decl(stringLiteralTypesAsTags03.ts, 21, 63), Decl(stringLiteralTypesAsTags03.ts, 22, 63))
|
||||
>x : Symbol(x, Decl(stringLiteralTypesAsTags03.ts, 27, 3))
|
||||
|
||||
let c = x;
|
||||
>c : Symbol(c, Decl(stringLiteralTypesAsTags03.ts, 40, 7))
|
||||
>x : Symbol(x, Decl(stringLiteralTypesAsTags03.ts, 27, 3))
|
||||
}
|
||||
else {
|
||||
let d = x;
|
||||
>d : Symbol(d, Decl(stringLiteralTypesAsTags03.ts, 43, 7))
|
||||
>x : Symbol(x, Decl(stringLiteralTypesAsTags03.ts, 27, 3))
|
||||
}
|
||||
118
tests/baselines/reference/stringLiteralTypesAsTags03.types
Normal file
118
tests/baselines/reference/stringLiteralTypesAsTags03.types
Normal file
@ -0,0 +1,118 @@
|
||||
=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags03.ts ===
|
||||
|
||||
type Kind = "A" | "B"
|
||||
>Kind : "A" | "B"
|
||||
|
||||
interface Entity {
|
||||
>Entity : Entity
|
||||
|
||||
kind: Kind;
|
||||
>kind : "A" | "B"
|
||||
>Kind : "A" | "B"
|
||||
}
|
||||
|
||||
interface A extends Entity {
|
||||
>A : A
|
||||
>Entity : Entity
|
||||
|
||||
kind: "A";
|
||||
>kind : "A"
|
||||
|
||||
a: number;
|
||||
>a : number
|
||||
}
|
||||
|
||||
interface B extends Entity {
|
||||
>B : B
|
||||
>Entity : Entity
|
||||
|
||||
kind: "B";
|
||||
>kind : "B"
|
||||
|
||||
b: string;
|
||||
>b : string
|
||||
}
|
||||
|
||||
// Currently (2015-12-14), we write '"A" | "A"' and '"B" | "B"' to avoid
|
||||
// interpreting respective overloads as "specialized" signatures.
|
||||
// That way, we can avoid the need to look for a compatible overload
|
||||
// signature and simply check compatibility with the implementation.
|
||||
function hasKind(entity: Entity, kind: "A" | "A"): entity is A;
|
||||
>hasKind : { (entity: Entity, kind: "A"): entity is A; (entity: Entity, kind: "B"): entity is B; }
|
||||
>entity : Entity
|
||||
>Entity : Entity
|
||||
>kind : "A"
|
||||
>entity : any
|
||||
>A : A
|
||||
|
||||
function hasKind(entity: Entity, kind: "B" | "B"): entity is B;
|
||||
>hasKind : { (entity: Entity, kind: "A"): entity is A; (entity: Entity, kind: "B"): entity is B; }
|
||||
>entity : Entity
|
||||
>Entity : Entity
|
||||
>kind : "B"
|
||||
>entity : any
|
||||
>B : B
|
||||
|
||||
function hasKind(entity: Entity, kind: Kind): entity is Entity {
|
||||
>hasKind : { (entity: Entity, kind: "A"): entity is A; (entity: Entity, kind: "B"): entity is B; }
|
||||
>entity : Entity
|
||||
>Entity : Entity
|
||||
>kind : "A" | "B"
|
||||
>Kind : "A" | "B"
|
||||
>entity : any
|
||||
>Entity : Entity
|
||||
|
||||
return entity.kind === kind;
|
||||
>entity.kind === kind : boolean
|
||||
>entity.kind : "A" | "B"
|
||||
>entity : Entity
|
||||
>kind : "A" | "B"
|
||||
>kind : "A" | "B"
|
||||
}
|
||||
|
||||
let x: A = {
|
||||
>x : A
|
||||
>A : A
|
||||
>{ kind: "A", a: 100,} : { kind: "A"; a: number; }
|
||||
|
||||
kind: "A",
|
||||
>kind : "A"
|
||||
>"A" : "A"
|
||||
|
||||
a: 100,
|
||||
>a : number
|
||||
>100 : number
|
||||
}
|
||||
|
||||
if (hasKind(x, "A")) {
|
||||
>hasKind(x, "A") : entity is A
|
||||
>hasKind : { (entity: Entity, kind: "A"): entity is A; (entity: Entity, kind: "B"): entity is B; }
|
||||
>x : A
|
||||
>"A" : "A"
|
||||
|
||||
let a = x;
|
||||
>a : A
|
||||
>x : A
|
||||
}
|
||||
else {
|
||||
let b = x;
|
||||
>b : A
|
||||
>x : A
|
||||
}
|
||||
|
||||
if (!hasKind(x, "B")) {
|
||||
>!hasKind(x, "B") : boolean
|
||||
>hasKind(x, "B") : entity is B
|
||||
>hasKind : { (entity: Entity, kind: "A"): entity is A; (entity: Entity, kind: "B"): entity is B; }
|
||||
>x : A
|
||||
>"B" : "B"
|
||||
|
||||
let c = x;
|
||||
>c : A
|
||||
>x : A
|
||||
}
|
||||
else {
|
||||
let d = x;
|
||||
>d : A
|
||||
>x : A
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user