-
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unist-util-map types Node and MapFunction stopped to be exported between v3 and v3.1.1 #6
Comments
While I agree the types are removed unexpectedly, but I'm a bit disagree we should consider types changes as major. I raised #7 to fix your usage. |
hi Joun! Thanks for the quick turnaround! |
This feels a bit like an instance of Hyrum's law. IMO, this should be fixed in
Unified uses plain JavaScript to avoid the issues needing layers of compilers/transpilers/bundlers. |
I particularly agree about To prevent that happening in the future, we now document what is part of the API: https://github.com/syntax-tree/unist-util-map#types. |
So missing I may need to remove https://github.com/syntax-tree/unist-util-map/pull/7/files#diff-e727e4bdf3657fd1d798edcd6b099d6e092f8573cba266154583a746bba0f346R3 in this case. |
TS treats JSDoc typedefs as exports, not imports. To assign every import to a typedef is a stylistic choice that leads to issues like this. Many of these issues would be resolved by microsoft/TypeScript#46407. Regardless, I agree people shouldn’t import these type aliases from packages like |
It is a choice, though I don’t think it’s just stylistic to import things from other files at the top of a file: that’s how a lot of languages work, and it works well. I am assuming that the @revelt does not care about the addition of I am personally open to expose |
It is supported, you can review my PR #7 |
Then I’d still wonder about the point that came after that: “If it is supported, then I don’t think it was earlier”, as in, I wonder which TS version started supporting this! |
I don't know. 😂 I just searched and found the solution. |
OK, I checked, it works in TS ^4.5, it does not work in 4.4 and lower. The root problem then is: index.js:6:21 - error TS1069: Unexpected token. A type parameter name was expected without curly braces.
6 * @template {Node} [Tree=Node] The last release of TS 4.4 was on 2021-12-10. Do we think it’s fine to break that? (I am open to it) |
I'm fine with it, and it should only affect contributors of this package, right? |
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [remark-directive-rehype](https://togithub.com/IGassmann/remark-directive-rehype) | [`^0.4.0` -> `^0.4.2`](https://renovatebot.com/diffs/npm/remark-directive-rehype/0.4.0/0.4.2) | [![age](https://badges.renovateapi.com/packages/npm/remark-directive-rehype/0.4.2/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/remark-directive-rehype/0.4.2/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/remark-directive-rehype/0.4.2/compatibility-slim/0.4.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/remark-directive-rehype/0.4.2/confidence-slim/0.4.0)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>IGassmann/remark-directive-rehype</summary> ### [`v0.4.2`](https://togithub.com/IGassmann/remark-directive-rehype/releases/tag/v0.4.2) [Compare Source](https://togithub.com/IGassmann/remark-directive-rehype/compare/v0.4.1...v0.4.2) #### What's Changed - refactor: import MapFunction type from root of package - build(deps): bump unist-util-map from 3.1.1 to 3.1.2 - build(deps-dev): bump typescript from 4.4.4 to 4.8.3 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/IGassmann/remark-directive-rehype/pull/6](https://togithub.com/IGassmann/remark-directive-rehype/pull/6) - build(deps-dev): bump unified from 10.1.0 to 10.1.2 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/IGassmann/remark-directive-rehype/pull/5](https://togithub.com/IGassmann/remark-directive-rehype/pull/5) - build(deps-dev): bump mdast-util-from-markdown from 1.0.4 to 1.2.0 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/IGassmann/remark-directive-rehype/pull/4](https://togithub.com/IGassmann/remark-directive-rehype/pull/4) - build(deps-dev): bump mdast-util-directive from 2.1.1 to 2.2.1 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/IGassmann/remark-directive-rehype/pull/3](https://togithub.com/IGassmann/remark-directive-rehype/pull/3) **Full Changelog**: IGassmann/remark-directive-rehype@v0.4.1...v0.4.2 ### [`v0.4.1`](https://togithub.com/IGassmann/remark-directive-rehype/releases/tag/v0.4.1) [Compare Source](https://togithub.com/IGassmann/remark-directive-rehype/compare/v0.4.0...v0.4.1) This patch release fixes [https://github.com/IGassmann/remark-directive-rehype/issues/2](https://togithub.com/IGassmann/remark-directive-rehype/issues/2) by updating the type imports for `MapFunction` and `Node`. See [https://github.com/syntax-tree/unist-util-map/issues/6](https://togithub.com/syntax-tree/unist-util-map/issues/6) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/BirthdayResearch/contented). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4yMDQuNSIsInVwZGF0ZWRJblZlciI6IjMyLjIwOC4yIn0=--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Initial checklist
Affected packages and versions
unist-util-map 3.1.1
Link to runnable example
https://stackblitz.com/edit/typescript-gjwbvb?file=index.ts
Steps to reproduce
Start a new sandbox and install the latest
unist-util-map
v3.1.1:https://stackblitz.com/edit/typescript-gjwbvb?file=index.ts
notice the
MapFunction
andNode
(andParent
) types are not exported any morebut they used to be exported on v3:
https://stackblitz.com/edit/typescript-qh1hrn?file=index.ts
which means, we introduced a breaking semver change during a minor bump!
Now, other consumers such as
remark-directive-rehype
are importing theunist-util-map
with a caret semver, which causes them to break on fresh installs (stale lockfiles still contain working v3 references, so everything seems fine for those who have stale lockfiles and their package manager uses exact stale version v3)https://github.com/IGassmann/remark-directive-rehype/blob/5dec9b98dcf8e071d2bd5b776f96123f459492f9/package.json#L34
Expected behavior
Let's restore the old type exports, specifically:
If we really want to remove the types, then issue a patch with types restored and bump the major version, publishing this program with types removed.
Generally, to prevent mishaps like this, it's best to migrate the source to
.ts
source files and let the TypeScript generate the types automatically, using a bundler. The JSDoc can be used for examples etc but not as a source of type definitions. That's the setup I use myself, I useesbuild
to bundle ESM (and sometimes optionally IIFE too) androllup
withrollup-plugin-dts
to bundle up the type definition files. The JSDoc-based types from.js
sources are a liability.Actual behavior
type exports are missing currently
Affected runtime and version
n/a
Affected package manager and version
tested on both yarn and npm
Affected OS and version
n/a
Build and bundle tools
Other (please specify in steps to reproduce)
The text was updated successfully, but these errors were encountered: