mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 04:43:37 -05:00
Add failing repro
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
// @strictNullChecks: true
|
||||
|
||||
// Type guards involving type parameters produce intersection types
|
||||
|
||||
class C {
|
||||
prop: string;
|
||||
}
|
||||
|
||||
function f1<T>(x: T) {
|
||||
if (x instanceof C) {
|
||||
let v1: T = x;
|
||||
let v2: C = x;
|
||||
x.prop;
|
||||
}
|
||||
}
|
||||
|
||||
function f2<T>(x: T) {
|
||||
if (typeof x === "string") {
|
||||
let v1: T = x;
|
||||
let v2: string = x;
|
||||
x.length;
|
||||
}
|
||||
}
|
||||
|
||||
// Repro from #13872
|
||||
|
||||
function fun<T>(item: { [P in keyof T]: T[P] }) {
|
||||
const strings: string[] = [];
|
||||
for (const key in item) {
|
||||
const value = item[key];
|
||||
if (typeof value === "string") {
|
||||
strings.push(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user