davidbonnet / astring

🌳 Tiny and fast JavaScript code generator from an ESTree-compliant AST.

Home Page:https://david.bonnet.cc/astring/demo/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add types to package exports

MI3Guy opened this issue · comments

commented

Motivation

When using TypeScript with "module": "ES2022" with a package that defines exports, the exports mapping takes priority over types. This means that the type definitions are looked up based on the .js (or .mjs) files under dist, causing them to not be found.

Expected behavior

TypeScript finds the type definitions.

Actual behavior

TypeScript complains about missing type definitions.

This can be fixed by adding

"types": "./astring.d.ts",

as the first entry under exports.

Added context:

Screenshot 2023-05-10 at 21 39 16

Thanks @MI3Guy for reporting this. It is fixed in 36c0029.