gcanti / babel-plugin-tcomb

Babel plugin for static and runtime type checking using Flow and tcomb
MIT License
482 stars 22 forks source link

Redux actions with constant string values #161

Open mAAdhaTTah opened 7 years ago

mAAdhaTTah commented 7 years ago

I'm getting this error on page initialization with my current types:

Uncaught TypeError: [tcomb] Invalid argument props {
  "type": "THEME_CHANGE",
  "payload": "{value: String}"
} supplied to interface(props, [options]) combinator (expected a dictionary String -> Type)

The issue seems to be the use of an imported string constant in my type declaration:

import { THEME_CHANGE } from '../action';

export type ThemeChangeAction = {
    type : THEME_CHANGE;
    payload : {
        value : string;
    };
};

Where THEME_CHANGE is:

const THEME_CHANGE = 'THEME_CHANGE';

Flow doesn't seem to have a problem with it, but I'm not sure what I need to do to make tcomb happy.