TypeScript版本:3.3.0-dev.20181206
代码:
type WithId = {
id: number
}
type WithNumber = {
number: number
}
type User = WithId | WithNumber
const user: User = {
id: 1,
number: 1 // here should be an error that I can't use both properties in one object
};
我希望user
具有id
或number
,而不要同时具有两个属性
谢谢
P.S。我见过this comment,但没有用