【发布时间】:2021-01-26 05:14:39
【问题描述】:
打字稿编译显示此错误:
源有 X 个元素,但目标只允许 1 个。
export const FooMapping: [{id: FooOperation, display: string}] = [
{ id: FooOperation.Undefined, display: 'Nothing' },
{ id: FooOperation.A, display: 'I'm A' },
{ id: FooOperation.B, display: 'I'm B' }
];
export enum FooOperation {
Undefined = 0,
A = 1,
B = 2,
}
定义{id: FooOperation, display: string}的特殊对象数组的正确方法是什么?
【问题讨论】:
标签: angular typescript