rt2zz / redux-persist

persist and rehydrate a redux store
MIT License
12.94k stars 866 forks source link

Can't install in typescript #1363

Open bsor-dev opened 2 years ago

bsor-dev commented 2 years ago

Latest version

@types/redux-persist redux-persist

Could not find a declaration file for module 'redux-persist/lib/storage'.

Try npm i --save-dev @types/redux-persist if it exists or add a new declaration (.d.ts) file containing `declare module 'redux-persist/lib/storage';

Can't find the solution in the whole internet. Even you modify the tsconfig, still getting same that error

My TS config

{
  "compilerOptions": {
    "lib": ["dom", "dom.iterable", "esnext"],
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "removeComments": true,
    "preserveConstEnums": true,
    "strict": true,
    "alwaysStrict": true,
    "strictNullChecks": true,
    "noUncheckedIndexedAccess": true,

    "noImplicitAny": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "allowUnreachableCode": false,
    "noFallthroughCasesInSwitch": true,

    "target": "es5",
    "outDir": "out",
    "declaration": true,
    "sourceMap": true,

    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "allowJs": false,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,

    "jsx": "preserve",
    "noEmit": true,
    "isolatedModules": true,
    "incremental": true,

    "baseUrl": ".",
    "paths": {
      "@/*": ["./src/*"],
      "@/public/*": ["./public/*"]
    }
  },
  "exclude": ["./out/**/*", "./node_modules/**/*"],
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
}
TheToto commented 2 years ago

Delete @types/redux-persist, redux-persist has builtin typings.

algorithm-sam commented 2 years ago

add /// <reference types="redux-persist" /> to your next-env.d.ts file and you should be fine.