How to export a collection of Interfaces in typescript

Viewed 4736

I have a file actions.ts that declares a bunch of action types.

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
}

I import these actions in index.ts with:

import * as actions from './actions';

What is the type of the actionsvariable in the index.ts file? I would like to be able to create this construct in the actions.ts file itself and export it. Similar to the following:

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,
}

but this gives me an error:

Action1 only refers to a type, but is being used as a value here.

1 Answers
Related