atomico
atomico copied to clipboard
Using TypeScript moduleResolution NodeNext throws errors
Describe the bug
Just an example error:
packages/html/src/hooks/useAria.ts:3:25 - error TS7016: Could not find a declaration file for module 'atomico/core'. '/Users/eike.foken/Code/barmer-puls/node_modules/atomico/src/core.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/atomico` if it exists or add a new declaration (.d.ts) file containing `declare module 'atomico/core';`
3 import { useMemo } from 'atomico/core';
To Reproduce
- Add to tsconfig.json
{
"compilerOptions": {
"moduleResolution": "nodenext"
}
}
- Import something, for example
import { useMemo } from 'atomico/core' - Get TypeScript errors
Solution
The exports field in package.json has to be updated to contain types
Hi @efoken , I have added support for this type of configuration in the new version of [email protected], along with new enhancements such as:
- Custom types.
- Support for tsconfig with moduleResolution set to nodeNext.
- New hook, useAbortController.
- New function for value configuration for props, now the value will always be the default.
- Improved inference of props, assigning value to its configuration makes them no longer optional.
I hope all of this proves useful to you. You can learn about these changes in the release notes.
https://github.com/atomicojs/atomico/releases/tag/1.73.0