mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-04-17 01:49:41 -05:00
Accepted baselines.
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
//// [narrowingGenericTypeFromInstanceof01.ts]
|
||||
class A<T> {
|
||||
constructor(private a: string) { }
|
||||
}
|
||||
|
||||
class B<T> {
|
||||
}
|
||||
|
||||
function acceptA<T>(a: A<T>) { }
|
||||
function acceptB<T>(b: B<T>) { }
|
||||
|
||||
function test<T>(x: A<T> | B<T>) {
|
||||
if (x instanceof B) {
|
||||
acceptA(x);
|
||||
}
|
||||
|
||||
if (x instanceof A) {
|
||||
acceptA(x);
|
||||
}
|
||||
|
||||
if (x instanceof B) {
|
||||
acceptB(x);
|
||||
}
|
||||
|
||||
if (x instanceof B) {
|
||||
acceptB(x);
|
||||
}
|
||||
}
|
||||
|
||||
//// [narrowingGenericTypeFromInstanceof01.js]
|
||||
var A = (function () {
|
||||
function A(a) {
|
||||
this.a = a;
|
||||
}
|
||||
return A;
|
||||
}());
|
||||
var B = (function () {
|
||||
function B() {
|
||||
}
|
||||
return B;
|
||||
}());
|
||||
function acceptA(a) { }
|
||||
function acceptB(b) { }
|
||||
function test(x) {
|
||||
if (x instanceof B) {
|
||||
acceptA(x);
|
||||
}
|
||||
if (x instanceof A) {
|
||||
acceptA(x);
|
||||
}
|
||||
if (x instanceof B) {
|
||||
acceptB(x);
|
||||
}
|
||||
if (x instanceof B) {
|
||||
acceptB(x);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
=== tests/cases/conformance/types/typeRelationships/instanceOf/narrowingGenericTypeFromInstanceof01.ts ===
|
||||
class A<T> {
|
||||
>A : Symbol(A, Decl(narrowingGenericTypeFromInstanceof01.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 0, 8))
|
||||
|
||||
constructor(private a: string) { }
|
||||
>a : Symbol(A.a, Decl(narrowingGenericTypeFromInstanceof01.ts, 1, 16))
|
||||
}
|
||||
|
||||
class B<T> {
|
||||
>B : Symbol(B, Decl(narrowingGenericTypeFromInstanceof01.ts, 2, 1))
|
||||
>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 4, 8))
|
||||
}
|
||||
|
||||
function acceptA<T>(a: A<T>) { }
|
||||
>acceptA : Symbol(acceptA, Decl(narrowingGenericTypeFromInstanceof01.ts, 5, 1))
|
||||
>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 7, 17))
|
||||
>a : Symbol(a, Decl(narrowingGenericTypeFromInstanceof01.ts, 7, 20))
|
||||
>A : Symbol(A, Decl(narrowingGenericTypeFromInstanceof01.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 7, 17))
|
||||
|
||||
function acceptB<T>(b: B<T>) { }
|
||||
>acceptB : Symbol(acceptB, Decl(narrowingGenericTypeFromInstanceof01.ts, 7, 32))
|
||||
>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 8, 17))
|
||||
>b : Symbol(b, Decl(narrowingGenericTypeFromInstanceof01.ts, 8, 20))
|
||||
>B : Symbol(B, Decl(narrowingGenericTypeFromInstanceof01.ts, 2, 1))
|
||||
>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 8, 17))
|
||||
|
||||
function test<T>(x: A<T> | B<T>) {
|
||||
>test : Symbol(test, Decl(narrowingGenericTypeFromInstanceof01.ts, 8, 32))
|
||||
>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 14))
|
||||
>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17))
|
||||
>A : Symbol(A, Decl(narrowingGenericTypeFromInstanceof01.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 14))
|
||||
>B : Symbol(B, Decl(narrowingGenericTypeFromInstanceof01.ts, 2, 1))
|
||||
>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 14))
|
||||
|
||||
if (x instanceof B) {
|
||||
>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17))
|
||||
>B : Symbol(B, Decl(narrowingGenericTypeFromInstanceof01.ts, 2, 1))
|
||||
|
||||
acceptA(x);
|
||||
>acceptA : Symbol(acceptA, Decl(narrowingGenericTypeFromInstanceof01.ts, 5, 1))
|
||||
>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17))
|
||||
}
|
||||
|
||||
if (x instanceof A) {
|
||||
>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17))
|
||||
>A : Symbol(A, Decl(narrowingGenericTypeFromInstanceof01.ts, 0, 0))
|
||||
|
||||
acceptA(x);
|
||||
>acceptA : Symbol(acceptA, Decl(narrowingGenericTypeFromInstanceof01.ts, 5, 1))
|
||||
>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17))
|
||||
}
|
||||
|
||||
if (x instanceof B) {
|
||||
>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17))
|
||||
>B : Symbol(B, Decl(narrowingGenericTypeFromInstanceof01.ts, 2, 1))
|
||||
|
||||
acceptB(x);
|
||||
>acceptB : Symbol(acceptB, Decl(narrowingGenericTypeFromInstanceof01.ts, 7, 32))
|
||||
>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17))
|
||||
}
|
||||
|
||||
if (x instanceof B) {
|
||||
>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17))
|
||||
>B : Symbol(B, Decl(narrowingGenericTypeFromInstanceof01.ts, 2, 1))
|
||||
|
||||
acceptB(x);
|
||||
>acceptB : Symbol(acceptB, Decl(narrowingGenericTypeFromInstanceof01.ts, 7, 32))
|
||||
>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
=== tests/cases/conformance/types/typeRelationships/instanceOf/narrowingGenericTypeFromInstanceof01.ts ===
|
||||
class A<T> {
|
||||
>A : A<T>
|
||||
>T : T
|
||||
|
||||
constructor(private a: string) { }
|
||||
>a : string
|
||||
}
|
||||
|
||||
class B<T> {
|
||||
>B : B<T>
|
||||
>T : T
|
||||
}
|
||||
|
||||
function acceptA<T>(a: A<T>) { }
|
||||
>acceptA : <T>(a: A<T>) => void
|
||||
>T : T
|
||||
>a : A<T>
|
||||
>A : A<T>
|
||||
>T : T
|
||||
|
||||
function acceptB<T>(b: B<T>) { }
|
||||
>acceptB : <T>(b: B<T>) => void
|
||||
>T : T
|
||||
>b : B<T>
|
||||
>B : B<T>
|
||||
>T : T
|
||||
|
||||
function test<T>(x: A<T> | B<T>) {
|
||||
>test : <T>(x: A<T> | B<T>) => void
|
||||
>T : T
|
||||
>x : A<T> | B<T>
|
||||
>A : A<T>
|
||||
>T : T
|
||||
>B : B<T>
|
||||
>T : T
|
||||
|
||||
if (x instanceof B) {
|
||||
>x instanceof B : boolean
|
||||
>x : A<T> | B<T>
|
||||
>B : typeof B
|
||||
|
||||
acceptA(x);
|
||||
>acceptA(x) : void
|
||||
>acceptA : <T>(a: A<T>) => void
|
||||
>x : A<T>
|
||||
}
|
||||
|
||||
if (x instanceof A) {
|
||||
>x instanceof A : boolean
|
||||
>x : A<T> | B<T>
|
||||
>A : typeof A
|
||||
|
||||
acceptA(x);
|
||||
>acceptA(x) : void
|
||||
>acceptA : <T>(a: A<T>) => void
|
||||
>x : A<any>
|
||||
}
|
||||
|
||||
if (x instanceof B) {
|
||||
>x instanceof B : boolean
|
||||
>x : A<T> | B<T>
|
||||
>B : typeof B
|
||||
|
||||
acceptB(x);
|
||||
>acceptB(x) : void
|
||||
>acceptB : <T>(b: B<T>) => void
|
||||
>x : A<T>
|
||||
}
|
||||
|
||||
if (x instanceof B) {
|
||||
>x instanceof B : boolean
|
||||
>x : A<T> | B<T>
|
||||
>B : typeof B
|
||||
|
||||
acceptB(x);
|
||||
>acceptB(x) : void
|
||||
>acceptB : <T>(b: B<T>) => void
|
||||
>x : A<T>
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user