nullthrows icon indicating copy to clipboard operation
nullthrows copied to clipboard

Make .d.ts work with TS 4.7 in "nodenext" (ESM) mode

Open ide opened this issue 2 years ago • 0 comments

The upcoming version of TypeScript adds support for ESM by specifying "module": "nodenext". When this is enabled, it interprets import nullthrows from 'nullthrows' to mean importing the entire exports object, not just the default export.

This new type declaration matches how nullthrow's JS is implemented: the function is exported both as the CJS exports object and as a property named default.

Tested by importing nullthrows (with these changes) in a TS 4.7 project configured to target nodenext. Verified that this fixes type checking. Verified the existing tests in this repo pass.

ide avatar May 20 '22 03:05 ide