usnistgov / h5wasm

A WebAssembly HDF5 reader/writer library
Other
87 stars 12 forks source link

Support TS 5's `moduleResolution: "bundler"` #50

Closed axelboc closed 1 year ago

axelboc commented 1 year ago

With this new module resolution option, TypeScript looks at the exports field of packages.

H5Wasm already defines an exports field but without a types entry for TypeScript. As a result, I think that TS looks at the import entry, which points to a JS file, and then tries to infer the types from that, which doesn't work as well as looking at the generated types and leads to any warnings with strict: true.

To be honest, this behaviour feels quite unintuitive to me, as I would have expected TS to fall back to reading the root types property in package.json ... but :shrug:

While I'm at it, I'm also re-exporting a couple of helper types that we use in H5Web and were previously importing with a hacky path (which no longer works with moduleResolution: "bundler"... :sweat_smile:)

bmaranville commented 1 year ago

This seems pretty straightforward... would you want a new release after accepting the PR?

axelboc commented 1 year ago

That'd be ideal, but no worries if you prefer to bunch this up with other things later :blush:

bmaranville commented 1 year ago

Merged manually.