vite-pwa / docs

Documentation: PWA integrations for Vite and the ecosystem
https://vite-pwa-org.netlify.app/
MIT License
197 stars 44 forks source link

React - Cannot find DTS #59

Closed C0ZEN closed 1 year ago

C0ZEN commented 1 year ago

I followed the React type declarations docs. Since migrating to Nx 16.4.0 (which adds type check to vite builder), I have the following error while building my app:

Cannot find type definition file for 'vite-plugin-pwa/react'.
  The file is in the program because:
    Entry point of type library 'vite-plugin-pwa/react' specified in compilerOptions

With a config as simple as:

"compilerOptions": {
  "types": ["node", "vite/client", "vitest", "vite-plugin-pwa/react"],
},
userquin commented 1 year ago

@C0ZEN you can check examples folder, there is an example for react. Try adding src/vite-env.d.ts to your project using refs https://github.com/vite-pwa/vite-plugin-pwa/blob/main/examples/react-router/src/vite-env.d.ts

C0ZEN commented 1 year ago

@C0ZEN you can check examples folder, there is an example for react. Try adding src/vite-env.d.ts to your project using refs https://github.com/vite-pwa/vite-plugin-pwa/blob/main/examples/react-router/src/vite-env.d.ts

I used this syntax to solve the issue because I tend to avoid the triple slash references:

import 'vite-plugin-pwa/react';
import 'vite-plugin-pwa/info';

Thank you.