EthanStandel / deepsignal

113 stars 5 forks source link

fix: expose type declarations #14

Closed patricklizon closed 10 months ago

patricklizon commented 1 year ago

Hello 👋🏻

This PR fixes exports definition in package.json files.

When importing package TS is not able to resolve the path to the file with types declaration.

That results in following error:

src/modules/login/login.store.ts:1:28 - error TS7016: Could not find a declaration file for module '@deepsignal/preact'. '/Users/patryklizon/Developer/yallo/node_modules/@deepsignal/preact/dist/lib.es.js' implicitly has an 'any' type.
  There are types at '/Users/patryklizon/Developer/yallo/node_modules/@deepsignal/preact/dist/lib.d.ts', but this result could not be resolved when respecting package.json "exports". The '@deepsignal/preact' library may need to update its package.json or typings.

1 import { deepSignal } from "@deepsignal/preact";

Webpack docs on package exports: https://webpack.js.org/guides/package-exports/

EthanStandel commented 10 months ago

Hey, very sorry. I get so inundated with so many Github emails from work and this repo sat silent for so long that I just lost track of it entirely. Thank you for your addition, and I don't think there's any risk with it.

Notably, I was following TypeScripts recommendation for how to expose types from the package.json file.

https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html

This has been working for TypeScript itself and for Deno's compiler. But if Webpack has special constraints, I have no problem merging this in and running a release.