我正在尝试做一些不可能的事情?
我想通过名称动态导入一个类,然后将其用作新类的字段的类型:
export default async name => {
const plural = pluralize(name).toLowerCase();
const { [name]: Entity } = await import(`../schemas/${name}`);
class EntityResult {
[plural]!: Entity // Entity refers to a value but being used as a type
}