Added "type" entry for package exports #759
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Conventions
Issue: #757
Overview
When
moduleResolution
is set toNodeNext
within atsconfig.json
, it seemingly ignores the legacytypes
field completely, despiteindex.d.ts
actually being correct in this case. I think it has to do with import specificity, but I can't be certain. The docs say that it looks for a co-located file (effector.mjs
->effector.mjs.d.ts
), but it definitely does not work that way, or the file output works in a way that doesn't allow Typescript to resolve the types.Whatever the problem, I'm not an active contributor to Effector and want to make minimally intrusive changes.
Changes
.js
and.cjs
, the exports were updated to have at least atypes
,require
, anddefault
entry..mjs
entries, the exports were updated to have atypes
,import
, anddefault
entry.umd
entries, the exports were updated to have atypes
, anddefault
..d.ts
are left unchangedDemo
Please check this link on branch
fix-demo
. Runnpm run demo
to prep the repo (Node V16.16.0
+ yarn pre-req).The demo works by using this repo as a git submodule, and file-importing the
npm/{package}
paths.Paths imported:
effector
effector-react
effector-solid
effector-vue
effector-solid
forest
Modifying
src/index.ts
, and using Intellisense for each of the imports in that file, will demonstrate that the types do work. If you would like to contrast this with the broken version, checkout themaster
branch and try running thenpm run build
command. Thetsc
output will complain that it cannot find the types, and Intellisense will also detect nothing.Risks + Notes
types
entry was filled-in by referencing thenode_modules
of a new install, and using those specific files as thetypes
value.Links
This link is the Typescript manual's overview for the type exports