I am using TypeScript in my React Native Project where we are also using Redux.I have defined my action types
like this inActionTypes.ts
/** @format */const REQUEST = 'REQUEST';const LOADING = 'LOADING';const SUCCESS = 'SUCCESS';const FAILED = 'FAILED';const PREFIX = 'KB';const SUFFIX = [REQUEST, LOADING, SUCCESS, FAILED];const getRequiredAction = ( prefix: string, actions: string[], suffixes: string[]) => { const req: any = {}; actions.forEach((action: string) => { suffixes.forEach((suffix) => { req[`${action}_${suffix}`] = `${prefix}_${action}_${suffix}`; }); }); return req;};/* * * Actions related to server */export const ACTION = getRequiredAction( PREFIX, ['INIT_APP', 'SET_CURRENT_SCREEN', 'DISABLE_POPUP', 'LOGIN', 'USER_PROFILE'], SUFFIX);
when i am trying to call ACTION
in some other .ts
file
import { ACTION } from '../../constants';interface AppLoadingAction { type: ACTION.INIT_APP_LOADING; payload: undefined;}
I am getting error Cannot find namespace 'Action'
It seems that this has something to do with how i defined my ACTION function. But i am getting this error only in TypeScript. Any Idea what i am doing wrong here?