这就是那个物体
export const fieldMapping = {
'IP': { name: 'ipAddress', type: AirtableFieldType.STRING },
'IP Country': { name: 'country', type: AirtableFieldType.STRING },
'IP City': { name: 'city', type: AirtableFieldType.STRING },
'IP Continent': { name: 'continent', type: AirtableFieldType.STRING },
'Payment Processor': {
name: 'paymentProcessor',
type: AirtableFieldType.STRING,
},
};
目标是得到以下类型
type fieldNames = | 'ipAddress' | 'country' | 'city' | 'continent' | 'paymentProcessor';
任何帮助都很感激
1条答案
按热度按时间flseospp1#
一种方法是将其转换为
const
。演示TypeScript:
https://www.typescriptlang.org/play?#code/FAYw9gdgzgLgBAQQJYCcYEMBGAbApgMSV2wBMAVATwAdc4BeOAb2DlbgGUyAlASQDkA4gC44AcijoAtlTyjgAX2DBcADypg0ccNHgAzIqQCy6KlSQQA5vSYsxPAAqiRjOBCm4RopFQQkSKXCgoUQAaOBhqD0RUDBwCA3JIgDpOXkE4eRDbUQc4AGEwAFcIGBQKJyZXd09wYtLysIiaEWQ0LDxCYkSaFO5+AQys1hz7fKQIipc3SSjREHGG8MiWmPb4rsoe1P7B7NyCkvNcEsmqmZrIGCOTxuXotrjO0k3cXrSBzOz7dAoZkrh7CgwCBAlANJNbKxprMqD8-jBAcDQeChmwmlFWrEOgkXm9+qjPvI4OgoFpILAANxKYDouBPEgAaVwFFJDAA1sywLoljQuXB9F1jKZzBYaZE6QkhSLrAAKdF8gVGExmSwASgA2vSmSyALrq0TQ0Q64BAA