preactjs / preact-router

:earth_americas: URL router for Preact.
http://npm.im/preact-router
MIT License
1.01k stars 156 forks source link

Could not find a declaration file for module 'preact-router' #447

Closed ArtyomGinoyan closed 1 year ago

ArtyomGinoyan commented 1 year ago

I created a project on vite preact-typescript latest version , and installed preact-router , then when I tried to import Router, as in the example in Repo >>>>>>

this my code below

import Router from 'preact-router'; import Home from './Home'; import Guest from './Guest';

export const App = () => { return ( <> <Router> <Home path='/' /> <Guest path='guest' /> </Router> </> ) }

I got this response >>>>>>>>>

>>>>>>Could not find a declaration file for module 'preact-router'. 'c:/Users/user/Desktop/other/preact_1/node_modules/preact-router/dist/preact-router.mjs' implicitly has an 'any' type.
There are types at 'c:/Users/user/Desktop/other/preact_1/node_modules/preact-router/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'preact-router' library may need to update its package.json or typings
rschristian commented 1 year ago

Probably a duplicate of #443? What "moduleResolution" option are you using in your tsconfig.json?

ArtyomGinoyan commented 1 year ago

thanks, I had to change moduleResolution from bundler to Node in tsconfig.json