You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I checked there isn't already an issue for the bug I encountered.
Viem Version
2.19.6
Current Behavior
Goes through this error:
node_modules/viem/_types/account-abstraction/accounts/types.d.ts:2:63 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("webauthn-p256")' call instead.
2 import type { SignReturnType as WebAuthnSignReturnType } from 'webauthn-p256';
~~~~~~~~~~~~~~~
node_modules/webauthn-p256/_types/types.d.ts:27:67 - error TS2536: Type '_K' cannot be used to index type 'fallback'.
27 [_K in Exclude<keys, keyof Item>]?: fallback extends object ? fallback[_K] : undefined;
~~~~~~~~~~~~
Found 2 errors in 2 files.
Errors Files
1 node_modules/viem/_types/account-abstraction/accounts/types.d.ts:2
1 node_modules/webauthn-p256/_types/types.d.ts:27
Expected Behavior
It should be compiled when module: node16 or module: esnext and moduleResolution: bundler enabled.
The problem is on node16 you can not import directly from a cjs module during ESM spec. it seems webauthn-p256 is cjs and somewhere you are importing a type from a cjs module:
The text was updated successfully, but these errors were encountered:
mojtabast
changed the title
Viem can not compile with node16/bundle module resolution using tsc
Viem can not be compiled with node16/bundle module resolution by tsc
Aug 27, 2024
@jxom
This is not a good recommendation since it reduces type accuracy. Another problem is for library authors, any library depends on viem which is publishing their package should tell "skipLibCheck": true to their users.
Check existing issues
Viem Version
2.19.6
Current Behavior
Goes through this error:
Expected Behavior
It should be compiled when
module: node16
ormodule: esnext
andmoduleResolution: bundler
enabled.Steps To Reproduce
Try to run on my repo:
Link to Minimal Reproducible Example
https://github.com/mojtabast/viem-tsc-compile-node16-issue
Anything else?
The problem is on
node16
you can not import directly from a cjs module during ESM spec. it seemswebauthn-p256
is cjs and somewhere you are importing a type from a cjs module:Although, typescript should differentiate a normal import and a type import, but it doesn't do that. You can follow some discussion around this here:
The text was updated successfully, but these errors were encountered: