Added "type" entry for package exports#759
Conversation
|
| Name | Link |
|---|---|
| 🔨 Latest commit | 978aca6 |
|
@rachaeldawn Thank you for this important fix! You need to change this file: https://github.com/effector/effector/blob/master/tools/builder/packages.config.ts after that call: |
|
Hey @sergeysova, this was already done. The package.json changes were performed automatically using Please reference the changed files, ignoring the |
|
Thank you, @sergeysova! I'm introducing effector into some project, and this fix is a major help. I had to copy-paste the types files I need and wrap it in a |
zerobias
left a comment
There was a problem hiding this comment.
Amazing, thanks! I’ll publish new releases at this week (need to check something before that)
Conventions
Issue: #757
Overview
When
moduleResolutionis set toNodeNextwithin atsconfig.json, it seemingly ignores the legacytypesfield completely, despiteindex.d.tsactually 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
.jsand.cjs, the exports were updated to have at least atypes,require, anddefaultentry..mjsentries, the exports were updated to have atypes,import, anddefaultentry.umdentries, the exports were updated to have atypes, anddefault..d.tsare left unchangedDemo
Please check this link on branch
fix-demo. Runnpm run demoto 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:
effectoreffector-reacteffector-solideffector-vueeffector-solidforestModifying
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 themasterbranch and try running thenpm run buildcommand. Thetscoutput will complain that it cannot find the types, and Intellisense will also detect nothing.Risks + Notes
typesentry was filled-in by referencing thenode_modulesof a new install, and using those specific files as thetypesvalue.Links
This link is the Typescript manual's overview for the type exports