【发布时间】:2018-12-27 21:37:35
【问题描述】:
为什么下面的代码有错误?
我想知道这是 TypeScript 编译器的错误。
type A =
| {
type: 'a';
a: string;
}
| {
type: 'b';
b: string;
};
type X = {
x: string;
} & A;
type XX = Pick<X, Exclude<keyof X, 'x'>> & {
x: number;
};
const x: XX = {} as any;
if (x.type === 'a') {
// Property 'a' does not exist on type 'XX'
console.log(x.a);
}
【问题讨论】:
标签: typescript