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
Cannot find module 'date-fns-tz/format' or its corresponding type declarations.
There are types at './node_modules/date-fns-tz/dist/esm/format/index.d.ts', but this result could not be resolved under your current 'moduleResolution' setting. Consider updating to 'node16', 'nodenext', or 'bundler'.ts(2307)
Changing this to import { format } from 'date-fns-tz'; works, but it increases the bundle size significantly.
It appears that changing "moduleResolution" to nodenext, node16 or bundler fixes the import issue, although this isn't an option for me unfortunately. Also this wasn't the case in date-fns-tz@v1.3.7, nor it is mentioned in documentation anywhere, nor used in the library own tsconfig.
Bielousov
changed the title
Attempted import error: Cannot find module 'date-fns-tz/format' or its corresponding type declarations
Missing types condition to the package.json#exports: Cannot find module 'date-fns-tz/format' or its corresponding type declarations
Aug 8, 2024
Bielousov
changed the title
Missing types condition to the package.json#exports: Cannot find module 'date-fns-tz/format' or its corresponding type declarations
Attempted import error: Cannot find module 'date-fns-tz/format' or its corresponding type declarations
Aug 8, 2024
Potentially related issue: #291
Node: 18.20 (also tried 20.16)
TypeScript: 5.4.4
tsconfig:
Upgrading from v1.3.7
When attempting to import any exported submodule directly, e.g:
TS cannot resolve the path, even though it is listed in the
date-fns-tz/package.json
:Changing this to
import { format } from 'date-fns-tz';
works, but it increases the bundle size significantly.Consider exporting type declarations: https://stackoverflow.com/a/77566206 along with ems and commonjs modules.
The text was updated successfully, but these errors were encountered: