This fails on the playground, and I believe it also fails on typescript@3.4.0-dev.20190323
TypeScript Version: typescript@3.4.0-dev.20190323
Search Terms: unknown intersection failure types narrow
Code
interface TypeA {
Name: "TypeA";
Value1: "Cool stuff!";
}
interface TypeB {
Name: "TypeB";
Value2: 0;
}
type Type = TypeA | TypeB;
declare function isType(x: unknown): x is Type;
function WorksProperly(data: Type) {
if (data.Name === "TypeA") {
// data: TypeA
const value1 = data.Value1;
}
}
function DoesNotWork(data: unknown) {
if (isType(data)) {
if (data.Name === "TypeA") {
// data: Type
// data should be TypeA
const value1 = data.Value1; // type error!
}
}
}
Expected behavior: in DoesNotWork, data should be TypeA after we can guarentee it is named "TypeA"
Actual behavior: data is still only a Type
Playground Link: Here
Related Issues: I looked through several pages of issues and did not find anything similar.
This fails on the playground, and I believe it also fails on typescript@3.4.0-dev.20190323
TypeScript Version: typescript@3.4.0-dev.20190323
Search Terms: unknown intersection failure types narrow
Code
Expected behavior: in
DoesNotWork,datashould be TypeA after we can guarentee it is named "TypeA"Actual behavior:
datais still only aTypePlayground Link: Here
Related Issues: I looked through several pages of issues and did not find anything similar.