atomico icon indicating copy to clipboard operation
atomico copied to clipboard

Using TypeScript moduleResolution NodeNext throws errors

Open efoken opened this issue 2 years ago • 1 comments

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

  1. Add to tsconfig.json
{
  "compilerOptions": {
    "moduleResolution": "nodenext"
  }
}
  1. Import something, for example import { useMemo } from 'atomico/core'
  2. Get TypeScript errors

Solution

The exports field in package.json has to be updated to contain types

efoken avatar Aug 14 '23 09:08 efoken

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

UpperCod avatar Aug 17 '23 19:08 UpperCod