Unit test typescript types

Viewed 1282

I have the following export in one of my modules:

export class Action1 implements Action {}

export class Action2 implements Action {}

export type ActionsUnion =
  | Action1
  | Action2;

I am trying to work out the best way to test ActionsUnion to make sure it is of the types I have defined. For example:

it('should have the correct types', () => {
  expect(typeof Action1).toEqual(ActionsUnion);
  expect(typeof Action2).toEqual(ActionsUnion);
});

Of course the above doesn't work as I am using ActionsUnion as a variable. Any ideas on how to achieve the above?

For context, I am using angular, ngrx and jasmine.

1 Answers
Related