refine icon indicating copy to clipboard operation
refine copied to clipboard

[BUG] TypeScript 5 can't find the type definition of `@refinedev/inferencer`

Open acomagu opened this issue 1 year ago • 7 comments

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:

image

(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

acomagu avatar Jan 17 '24 11:01 acomagu

I think it can be resolved either by updating @refinedev/inferencer or manually update type definitions for @refinedev/inferencer/mantine.

arghyapolley avatar Jan 17 '24 20:01 arghyapolley

@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

acomagu avatar Jan 18 '24 01:01 acomagu

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 🤔

aliemir avatar Jan 18 '24 06:01 aliemir

We have a similar issue for @refinedev/nextjs-router package too.

BatuhanW avatar Jan 18 '24 07:01 BatuhanW

set "moduleResolution": "bundler" to "moduleResolution": "node" for your project to work, till the team finds the issue and fixes it @acomagu @aliemir

Issue:

Screenshot 2024-01-20 235045

Screenshot 2024-01-21 000109

Temporary Fix:

Screenshot 2024-01-20 235148

Screenshot 2024-01-21 000133

Conqxeror avatar Jan 20 '24 18:01 Conqxeror

@acomagu @aliemir Are we trying to import a specific Component/Module from @refinedev/inferencer/mantine?

pamnanaimanish169 avatar Jan 22 '24 06:01 pamnanaimanish169

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.

aliemir avatar Jan 23 '24 12:01 aliemir