【发布时间】:2017-07-21 22:00:45
【问题描述】:
给定一个接口:
interface EPostageInsertExEvent_Parameter {
readonly Doc: Word.Document;
cpDeliveryAddrStart: number;
cpDeliveryAddrEnd: number;
readonly cpReturnAddrStart: number,
readonly cpReturnAddrEnd: number;
readonly xaWidth: number;
readonly yaHeight: number;
readonly bstrPrinterName: string;
readonly bstrPaperFeed: string;
readonly fPrint: boolean;
fCancel: boolean;
}
如何将由该接口的键组成的元组类型定义为字符串文字?换句话说,相当于以下内容:
type EPostageInsertExEvent_ArgNames = ['Doc', 'cpDeliveryAddrStart', 'cpDeliveryAddrEnd',
'cpReturnAddrStart', 'cpReturnAddrEnd', 'xaWidth', 'yaHeight', 'bstrPrinterName',
'bstrPaperFeed', 'fPrint', 'fCancel'];
【问题讨论】:
-
你想要一个元组还是一个字符串数组?您想要在设计或运行时使用它?
-
@RodrigoPedrosa 类型应该是元组类型,由字符串文字组成。我想要它在设计时。
-
我想你已经在你的问题中做到了。
-
@RodrigoPedrosa,这个想法不是自己写出来的。请参阅下面的答案。
标签: typescript