【发布时间】:2016-12-02 11:43:39
【问题描述】:
我想使用键值对来定义 Object 字面量的类型,如下所示。无论如何都无法做到这一点。请帮忙。
export const endPoints: {name: string: {method: string; url: string;}} = {
allFeed: {
method: 'GET',
url: 'https://www.yammer.com/api/v1/messages.json'
},
topFeed: {
method: 'GET',
url: 'https://www.yammer.com/api/v1/messages/algo.json'
},
followingFeed: {
method: 'GET',
url: 'https://www.yammer.com/api/v1/messages/following.json'
},
defaultFeed: {
method: 'GET',
url: 'https://www.yammer.com/api/v1/messages.json/my_feed.json'
}
};
【问题讨论】:
标签: object types typescript