Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Cannot find namespace 'React/TypeScript'

$
0
0

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'

Error

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?


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>