preactjs / prefresh

Hot Module Reloading for Preact
MIT License
377 stars 48 forks source link

`@prefresh/vite` types can’t be resolved when project uses modern TypeScript resolution modes #518

Closed lemonmade closed 1 year ago

lemonmade commented 1 year ago

When a developer uses a TypeScript project configured to respect export conditions, @prefresh/vite can’t be resolved by TypeScript with the following error:

> tsc --pretty

index.ts:1:22 - error TS7016: Could not find a declaration file for module '@prefresh/vite'. '/Users/lemon/dev/temporary/23-10-30-prefresh-vite-type-fix/node_modules/.pnpm/@prefresh+vite@2.4.1_preact@10.18.1_vite@4.5.0/node_modules/@prefresh/vite/src/index.js' implicitly has an 'any' type.
  There are types at '/Users/lemon/dev/temporary/23-10-30-prefresh-vite-type-fix/node_modules/@prefresh/vite/index.d.ts', but this result could not be resolved when respecting package.json "exports". The '@prefresh/vite' library may need to update its package.json or typings.

1 import prefresh from '@prefresh/vite';
                       ~~~~~~~~~~~~~~~~

Found 1 error in index.ts:1

Here’s a repo that reproduces the problem: https://github.com/lemonmade/23-10-30-prefresh-vite-type-fix