Hey people,
Given the following two types:
interface A {
[id: string]: number;
}
interface B {
detail: string;
}
I want to be able to narrow down a type for a variable that is abc: A | B. For example in a function like this:
const fn = (v: A | B) => {
if (!("detail" in v)) {
// v is type A here
}
}
I can type narrow to get all instances where v is A. But I can't figure out if it's possible to type narrow to get v: B considering detail is a subset of [id: string]?