Check types with Are the Types Wrong
Test that TypeScript resolves your package's types under node10, node16 and bundler settings with the attw CLI before you publish to npm.
A package can build fine and still hand TypeScript the wrong declaration file under one of its resolution modes. @arethetypeswrong/cli packs your project and tries each mode.
npx @arethetypeswrong/cli --pack . my-lib v1.0.0
No problems found š
āāāāāāāāāāāāāāāāāāāāā¬āāāāāāāāāāā
ā ā "my-lib" ā
āāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāā¤
ā node10 ā š¢ ā
āāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāā¤
ā node16 (from CJS) ā š¢ (CJS) ā
āāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāā¤
ā node16 (from ESM) ā š¢ (ESM) ā
āāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāā¤
ā bundler ā š¢ ā
āāāāāāāāāāāāāāāāāāāāā“āāāāāāāāāāāA red row names the problem, such as "Masquerading as CJS", where an ESM-only .d.ts is reached through require. Each problem has an explanation page in the project repository.
The tool only checks that types resolve to a sensible file. It does not compare the declarations to the real runtime behavior, so tests still matter.