atomicojs / atomico

Atomico a micro-library for creating webcomponents using only functions, hooks and virtual-dom.
https://atomicojs.dev
MIT License
1.15k stars 43 forks source link

Using TypeScript moduleResolution NodeNext throws errors #109

Closed efoken closed 3 weeks ago

efoken commented 1 year ago

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

UpperCod commented 1 year ago

Hi @efoken , I have added support for this type of configuration in the new version of atomico@1.73.0, along with new enhancements such as:

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