PersistGate missing declarations - TypeScript
See original GitHub issueimport { PersistGate } from 'redux-persist/integration/react';
Throws an error “TS7016: Could not find a declaration file for module ‘redux-persist/integration/react’.”
Version:
"redux-persist": "^6.0.0"
Currently using:
declare module 'redux-persist/integration/react';
as workaround. Do you plan to add typings for this?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:10
- Comments:7
Top Results From Across the Web
React Native 'PersistGate' cannot be used as a JSX ...
I am using @redux/toolkit with redux-persist in a react native application with TypeScript . store.ts import { configureStore } from '@reduxjs/ ...
Read more >React Native 'PersistGate' cannot be used as a JSX ...
[Solved]-React Native 'PersistGate' cannot be used as a JSX component. Its instance type 'PersistGate' is not a valid JSX element-React Native.
Read more >redux-persist
TypeScript icon, indicating that this package has built-in type declarations ... you use the provided PersistGate component for integration.
Read more >redux-persist
But, when I try to include PersistGate I get this error. ... Throws an error "TS7016: Could not find a declaration file for...
Read more >CS50's Mobile App Development with React Native 2018
... stuff jammed into that single file, · 0:16:38but we were missing one key thing. ... called a persistStore, a persistReducer, · 1:16:56and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
To elaborate on the workaround mentioned by @webcoderkz , in general, when you don’t have Typescript typings you can define your own in a file like
declarations.d.ts
. This general strategy is described here as “Plan C”. https://medium.com/@steveruiz/using-a-javascript-library-without-type-declarations-in-a-typescript-project-3643490015f3In this case, the typings are in
node_modules/redux-persist/types/integration/react.d.ts
, but for some reason the compiler seems to have some difficulty finding the typings when you specify the path normally, likeSo, you can simply copy the typings from
react.d.ts
to somewhere easier for the compiler to find, like your owndeclarations.d.ts
. It seemed to work for me when I just copied this partAnother alternative workaround seems to be to import anything else from
redux-persist
( notredux-persist/lib
orredux-persist/integration
), such asThis seems to make the compiler search
redux-persist
properly, so that it also findsredux-persist/integration/react
. This even seems to work when the import fromredux-persist
is not in the same file as the import fromredux-persist/integration/react
. I’m not sure if compiler settings matter, but FWIW I am using VSCode and Babel, with thistsconfig.json
:TLDR;
@katsimoto your tip set me on the right track, thank you for that, but the
files
property seems better for that.From this discussion: https://github.com/Microsoft/TypeScript/issues/17228