【发布时间】:2017-12-25 15:59:03
【问题描述】:
我有一个文件actions.ts,它声明了一堆动作类型。
actions.ts
export interface Action1 extends Action {
type: types.Action1Type
}
export interface Action2 extends Action {
type: types.Action2Type
}
export interface Action3 extends Action {
type: types.Action3Type
}
我在 index.ts 中导入这些操作:
import * as actions from './actions';
index.ts 文件中actions变量的类型是什么?我希望能够在 actions.ts 文件本身中创建此构造并将其导出。类似于以下内容:
actions.ts
interface Action1 extends Action {
type: types.Action1Type
}
interface Action2 extends Action {
type: types.Action2Type
}
interface Action3 extends Action {
type: types.Action3Type
}
export const Actions = {
Action1,
Action2,
Action3,
}
但这给了我一个错误:
Action1仅指一种类型,但在这里用作值。
【问题讨论】:
标签: typescript interface