【发布时间】:2017-07-02 23:38:08
【问题描述】:
给定一个这样的模块:
export const a: string;
export const b: string;
您可以从外部生成一个类型 "a" | "b",如下所示:
import * as stuff from "./stuff";
type StuffKeys = keyof typeof stuff; // "a" | "b"
但我想从模块中生成并导出这种类型。比如:
export type MyKeys = keyof typeof this;
但这不起作用。
有没有办法做到这一点?
【问题讨论】: