mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-19 10:41:56 -05:00
Accepted baselines.
This commit is contained in:
@@ -1,51 +0,0 @@
|
||||
tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(20,10): error TS2394: Overload signature is not compatible with function implementation.
|
||||
tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts(22,21): error TS2304: Cannot find name 'is'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.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;
|
||||
function hasKind(entity: Entity, kind: "B"): entity is B;
|
||||
function hasKind(entity: Entity, kind: Kind): entity is Entity;
|
||||
~~~~~~~
|
||||
!!! error TS2394: Overload signature is not compatible with function implementation.
|
||||
function hasKind(entity: Entity, kind: Kind): boolean {
|
||||
return kind === is;
|
||||
~~
|
||||
!!! error TS2304: Cannot find name 'is'.
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -20,7 +20,7 @@ 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 Entity;
|
||||
function hasKind(entity: Entity, kind: Kind): boolean {
|
||||
return kind === is;
|
||||
return entity.kind === kind;
|
||||
}
|
||||
|
||||
let x: A = {
|
||||
@@ -44,7 +44,7 @@ else {
|
||||
|
||||
//// [stringLiteralTypesAsTags01.js]
|
||||
function hasKind(entity, kind) {
|
||||
return kind === is;
|
||||
return entity.kind === kind;
|
||||
}
|
||||
var x = {
|
||||
kind: "A",
|
||||
|
||||
112
tests/baselines/reference/stringLiteralTypesAsTags01.symbols
Normal file
112
tests/baselines/reference/stringLiteralTypesAsTags01.symbols
Normal file
@@ -0,0 +1,112 @@
|
||||
=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.ts ===
|
||||
|
||||
type Kind = "A" | "B"
|
||||
>Kind : Symbol(Kind, Decl(stringLiteralTypesAsTags01.ts, 0, 0))
|
||||
|
||||
interface Entity {
|
||||
>Entity : Symbol(Entity, Decl(stringLiteralTypesAsTags01.ts, 1, 21))
|
||||
|
||||
kind: Kind;
|
||||
>kind : Symbol(kind, Decl(stringLiteralTypesAsTags01.ts, 3, 18))
|
||||
>Kind : Symbol(Kind, Decl(stringLiteralTypesAsTags01.ts, 0, 0))
|
||||
}
|
||||
|
||||
interface A extends Entity {
|
||||
>A : Symbol(A, Decl(stringLiteralTypesAsTags01.ts, 5, 1))
|
||||
>Entity : Symbol(Entity, Decl(stringLiteralTypesAsTags01.ts, 1, 21))
|
||||
|
||||
kind: "A";
|
||||
>kind : Symbol(kind, Decl(stringLiteralTypesAsTags01.ts, 7, 28))
|
||||
|
||||
a: number;
|
||||
>a : Symbol(a, Decl(stringLiteralTypesAsTags01.ts, 8, 14))
|
||||
}
|
||||
|
||||
interface B extends Entity {
|
||||
>B : Symbol(B, Decl(stringLiteralTypesAsTags01.ts, 10, 1))
|
||||
>Entity : Symbol(Entity, Decl(stringLiteralTypesAsTags01.ts, 1, 21))
|
||||
|
||||
kind: "B";
|
||||
>kind : Symbol(kind, Decl(stringLiteralTypesAsTags01.ts, 12, 28))
|
||||
|
||||
b: string;
|
||||
>b : Symbol(b, Decl(stringLiteralTypesAsTags01.ts, 13, 14))
|
||||
}
|
||||
|
||||
function hasKind(entity: Entity, kind: "A"): entity is A;
|
||||
>hasKind : Symbol(hasKind, Decl(stringLiteralTypesAsTags01.ts, 15, 1), Decl(stringLiteralTypesAsTags01.ts, 17, 57), Decl(stringLiteralTypesAsTags01.ts, 18, 57), Decl(stringLiteralTypesAsTags01.ts, 19, 63))
|
||||
>entity : Symbol(entity, Decl(stringLiteralTypesAsTags01.ts, 17, 17))
|
||||
>Entity : Symbol(Entity, Decl(stringLiteralTypesAsTags01.ts, 1, 21))
|
||||
>kind : Symbol(kind, Decl(stringLiteralTypesAsTags01.ts, 17, 32))
|
||||
>entity : Symbol(entity, Decl(stringLiteralTypesAsTags01.ts, 17, 17))
|
||||
>A : Symbol(A, Decl(stringLiteralTypesAsTags01.ts, 5, 1))
|
||||
|
||||
function hasKind(entity: Entity, kind: "B"): entity is B;
|
||||
>hasKind : Symbol(hasKind, Decl(stringLiteralTypesAsTags01.ts, 15, 1), Decl(stringLiteralTypesAsTags01.ts, 17, 57), Decl(stringLiteralTypesAsTags01.ts, 18, 57), Decl(stringLiteralTypesAsTags01.ts, 19, 63))
|
||||
>entity : Symbol(entity, Decl(stringLiteralTypesAsTags01.ts, 18, 17))
|
||||
>Entity : Symbol(Entity, Decl(stringLiteralTypesAsTags01.ts, 1, 21))
|
||||
>kind : Symbol(kind, Decl(stringLiteralTypesAsTags01.ts, 18, 32))
|
||||
>entity : Symbol(entity, Decl(stringLiteralTypesAsTags01.ts, 18, 17))
|
||||
>B : Symbol(B, Decl(stringLiteralTypesAsTags01.ts, 10, 1))
|
||||
|
||||
function hasKind(entity: Entity, kind: Kind): entity is Entity;
|
||||
>hasKind : Symbol(hasKind, Decl(stringLiteralTypesAsTags01.ts, 15, 1), Decl(stringLiteralTypesAsTags01.ts, 17, 57), Decl(stringLiteralTypesAsTags01.ts, 18, 57), Decl(stringLiteralTypesAsTags01.ts, 19, 63))
|
||||
>entity : Symbol(entity, Decl(stringLiteralTypesAsTags01.ts, 19, 17))
|
||||
>Entity : Symbol(Entity, Decl(stringLiteralTypesAsTags01.ts, 1, 21))
|
||||
>kind : Symbol(kind, Decl(stringLiteralTypesAsTags01.ts, 19, 32))
|
||||
>Kind : Symbol(Kind, Decl(stringLiteralTypesAsTags01.ts, 0, 0))
|
||||
>entity : Symbol(entity, Decl(stringLiteralTypesAsTags01.ts, 19, 17))
|
||||
>Entity : Symbol(Entity, Decl(stringLiteralTypesAsTags01.ts, 1, 21))
|
||||
|
||||
function hasKind(entity: Entity, kind: Kind): boolean {
|
||||
>hasKind : Symbol(hasKind, Decl(stringLiteralTypesAsTags01.ts, 15, 1), Decl(stringLiteralTypesAsTags01.ts, 17, 57), Decl(stringLiteralTypesAsTags01.ts, 18, 57), Decl(stringLiteralTypesAsTags01.ts, 19, 63))
|
||||
>entity : Symbol(entity, Decl(stringLiteralTypesAsTags01.ts, 20, 17))
|
||||
>Entity : Symbol(Entity, Decl(stringLiteralTypesAsTags01.ts, 1, 21))
|
||||
>kind : Symbol(kind, Decl(stringLiteralTypesAsTags01.ts, 20, 32))
|
||||
>Kind : Symbol(Kind, Decl(stringLiteralTypesAsTags01.ts, 0, 0))
|
||||
|
||||
return entity.kind === kind;
|
||||
>entity.kind : Symbol(Entity.kind, Decl(stringLiteralTypesAsTags01.ts, 3, 18))
|
||||
>entity : Symbol(entity, Decl(stringLiteralTypesAsTags01.ts, 20, 17))
|
||||
>kind : Symbol(Entity.kind, Decl(stringLiteralTypesAsTags01.ts, 3, 18))
|
||||
>kind : Symbol(kind, Decl(stringLiteralTypesAsTags01.ts, 20, 32))
|
||||
}
|
||||
|
||||
let x: A = {
|
||||
>x : Symbol(x, Decl(stringLiteralTypesAsTags01.ts, 24, 3))
|
||||
>A : Symbol(A, Decl(stringLiteralTypesAsTags01.ts, 5, 1))
|
||||
|
||||
kind: "A",
|
||||
>kind : Symbol(kind, Decl(stringLiteralTypesAsTags01.ts, 24, 12))
|
||||
|
||||
a: 100,
|
||||
>a : Symbol(a, Decl(stringLiteralTypesAsTags01.ts, 25, 14))
|
||||
}
|
||||
|
||||
if (hasKind(x, "A")) {
|
||||
>hasKind : Symbol(hasKind, Decl(stringLiteralTypesAsTags01.ts, 15, 1), Decl(stringLiteralTypesAsTags01.ts, 17, 57), Decl(stringLiteralTypesAsTags01.ts, 18, 57), Decl(stringLiteralTypesAsTags01.ts, 19, 63))
|
||||
>x : Symbol(x, Decl(stringLiteralTypesAsTags01.ts, 24, 3))
|
||||
|
||||
let a = x;
|
||||
>a : Symbol(a, Decl(stringLiteralTypesAsTags01.ts, 30, 7))
|
||||
>x : Symbol(x, Decl(stringLiteralTypesAsTags01.ts, 24, 3))
|
||||
}
|
||||
else {
|
||||
let b = x;
|
||||
>b : Symbol(b, Decl(stringLiteralTypesAsTags01.ts, 33, 7))
|
||||
>x : Symbol(x, Decl(stringLiteralTypesAsTags01.ts, 24, 3))
|
||||
}
|
||||
|
||||
if (!hasKind(x, "B")) {
|
||||
>hasKind : Symbol(hasKind, Decl(stringLiteralTypesAsTags01.ts, 15, 1), Decl(stringLiteralTypesAsTags01.ts, 17, 57), Decl(stringLiteralTypesAsTags01.ts, 18, 57), Decl(stringLiteralTypesAsTags01.ts, 19, 63))
|
||||
>x : Symbol(x, Decl(stringLiteralTypesAsTags01.ts, 24, 3))
|
||||
|
||||
let c = x;
|
||||
>c : Symbol(c, Decl(stringLiteralTypesAsTags01.ts, 37, 7))
|
||||
>x : Symbol(x, Decl(stringLiteralTypesAsTags01.ts, 24, 3))
|
||||
}
|
||||
else {
|
||||
let d = x;
|
||||
>d : Symbol(d, Decl(stringLiteralTypesAsTags01.ts, 40, 7))
|
||||
>x : Symbol(x, Decl(stringLiteralTypesAsTags01.ts, 24, 3))
|
||||
}
|
||||
121
tests/baselines/reference/stringLiteralTypesAsTags01.types
Normal file
121
tests/baselines/reference/stringLiteralTypesAsTags01.types
Normal file
@@ -0,0 +1,121 @@
|
||||
=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTags01.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
|
||||
}
|
||||
|
||||
function hasKind(entity: Entity, kind: "A"): entity is A;
|
||||
>hasKind : { (entity: Entity, kind: "A"): entity is A; (entity: Entity, kind: "B"): entity is B; (entity: Entity, kind: "A" | "B"): entity is Entity; }
|
||||
>entity : Entity
|
||||
>Entity : Entity
|
||||
>kind : "A"
|
||||
>entity : any
|
||||
>A : A
|
||||
|
||||
function hasKind(entity: Entity, kind: "B"): entity is B;
|
||||
>hasKind : { (entity: Entity, kind: "A"): entity is A; (entity: Entity, kind: "B"): entity is B; (entity: Entity, kind: "A" | "B"): entity is Entity; }
|
||||
>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, kind: "A" | "B"): entity is Entity; }
|
||||
>entity : Entity
|
||||
>Entity : Entity
|
||||
>kind : "A" | "B"
|
||||
>Kind : "A" | "B"
|
||||
>entity : any
|
||||
>Entity : Entity
|
||||
|
||||
function hasKind(entity: Entity, kind: Kind): boolean {
|
||||
>hasKind : { (entity: Entity, kind: "A"): entity is A; (entity: Entity, kind: "B"): entity is B; (entity: Entity, kind: "A" | "B"): entity is Entity; }
|
||||
>entity : Entity
|
||||
>Entity : Entity
|
||||
>kind : "A" | "B"
|
||||
>Kind : "A" | "B"
|
||||
|
||||
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; (entity: Entity, kind: "A" | "B"): entity is Entity; }
|
||||
>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; (entity: Entity, kind: "A" | "B"): entity is Entity; }
|
||||
>x : A
|
||||
>"B" : "B"
|
||||
|
||||
let c = x;
|
||||
>c : A
|
||||
>x : A
|
||||
}
|
||||
else {
|
||||
let d = x;
|
||||
>d : A
|
||||
>x : A
|
||||
}
|
||||
@@ -45,7 +45,7 @@ var MyBase = (function () {
|
||||
configurable: true
|
||||
});
|
||||
return MyBase;
|
||||
})();
|
||||
}());
|
||||
var MyDerived = (function (_super) {
|
||||
__extends(MyDerived, _super);
|
||||
function MyDerived() {
|
||||
@@ -54,7 +54,7 @@ var MyDerived = (function (_super) {
|
||||
var f2 = _super.prototype.value;
|
||||
}
|
||||
return MyDerived;
|
||||
})(MyBase);
|
||||
}(MyBase));
|
||||
var d = new MyDerived();
|
||||
var f3 = d.value;
|
||||
var A = (function () {
|
||||
@@ -67,7 +67,7 @@ var A = (function () {
|
||||
configurable: true
|
||||
});
|
||||
return A;
|
||||
})();
|
||||
}());
|
||||
var B = (function (_super) {
|
||||
__extends(B, _super);
|
||||
function B() {
|
||||
@@ -81,4 +81,4 @@ var B = (function (_super) {
|
||||
configurable: true
|
||||
});
|
||||
return B;
|
||||
})(A);
|
||||
}(A));
|
||||
|
||||
Reference in New Issue
Block a user