mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Added a test.
This commit is contained in:
+27
@@ -0,0 +1,27 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user