Skip to content

Move imports from deno.json to package.json - #3

Open
niLPotential wants to merge 3 commits into
denoland:mainfrom
niLPotential:main
Open

Move imports from deno.json to package.json#3
niLPotential wants to merge 3 commits into
denoland:mainfrom
niLPotential:main

Conversation

@niLPotential

Copy link
Copy Markdown

As the template is as of now, when I typecheck with deno check . the following error shows.

// linux
TS7026 [ERROR]: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists.
at file:///path/react-vite-ts-template/client/src/App.tsx

// windows
error: TS2307 [ERROR]: Cannot find module 'npm:/react@18.3.1'.
TS2307 [ERROR]: Cannot find module 'npm:/react-dom@18.3.1'.

These errors imply that deno fails to locate the libraries, despite them being installed.
The same errors appear when setting nodeModulesDir to auto in deno.json.
But the error changes to the following when setting nodeModulesDir to manual.

error: Failed resolving types. [ERR_TYPES_NOT_FOUND] Could not find types for 'file:///path/react-vite-ts-template/node_modules/.deno/react@18.3.1/node_modules/react/index.js' imported from 'file:///path/react-vite-ts-template/client/src/App.tsx'
    at file:///path/react-vite-ts-template/client/src/App.tsx:1:26

Finally, only when the imports are moved to a seperate package.json, the typecheck passes.
This probably is a node compatibility issue, which I hope will be addressed soon.
In the mean time, I propose to add this band-aid package.json to avoid confusion.

Also, @types/react-dom is added as dep and deno.lock is updated.

@karanveersp

Copy link
Copy Markdown

This solved the npm TS2307 errors for me. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants