refine
refine copied to clipboard
[BUG] TypeScript 5 can't find the type definition of `@refinedev/inferencer`
Describe the bug
tsc can't find the type definition of @refinedev/inferencer/*
so that we couldn't import the packages. The error message is below:
TS7016: Could not find a declaration file for module '@refinedev/inferencer/mantine'. '/tmp/tmp.gIbEnmIS6x/node_modules/@refinedev/inferencer/dist/esm/mantine.js' implicitly has an 'any' type.
There are types at '/tmp/tmp.gIbEnmIS6x/node_modules/@refinedev/inferencer/dist/inferencers/mantine/index.d.ts', but this result could not be resolved when respecting package.json "exports". The '@refinedev/inferencer' library may need to update its package.json or typings.
Steps To Reproduce
First, cd $(mktemp -d)
Place these files:
package.json
:
{
"dependencies": {
"@refinedev/inferencer": "^4.5.17",
"typescript": "^5.3.3"
}
}
tsconfig.json
:
{
"compilerOptions": {
"esModuleInterop": true,
"lib": ["esnext", "dom"],
"module": "esnext",
"moduleResolution": "bundler",
"strict": true,
"target": "es2022"
}
}
index.ts
:
import { } from "@refinedev/inferencer/mantine";
Then, npm i && npx tsc
shows the compile error:
(BTW, I tried to find a tsconfig configuration that would work, but could not find one. "moduleResolution": "node16"
, "resolvePackageJsonExports": false
, all didn't help)
Expected behavior
TSC compilation works without error.
Screenshot
No response
Desktop
No response
Mobile
No response
Additional Context
No response
I think it can be resolved either by updating @refinedev/inferencer
or manually update type definitions for @refinedev/inferencer/mantine
.
@arghyapolley Thank you for your reply!
I think my @refinedev/inferencer
is already latest because NPM shows it(4.5.17
) as latest version.
https://www.npmjs.com/package/@refinedev/inferencer?activeTab=versions
Hey @acomagu sorry for the issue! Thank you for providing steps to reproduce, we'll look into it and deliver a solution soon. There might be some incompatibilities with our export definitions in package.json
of the inferencer package 🤔
We have a similar issue for @refinedev/nextjs-router
package too.
set "moduleResolution": "bundler"
to "moduleResolution": "node"
for your project to work, till the team finds the issue and fixes it @acomagu @aliemir
Issue:
Temporary Fix:
@acomagu @aliemir Are we trying to import a specific Component/Module from @refinedev/inferencer/mantine?
Just opened up a PR to fix this issue #5550. The issue was with our package.json
and its exports
field. Added types
fields to the items in the exports
field which fixes the issue when I tested it locally.