Skip to content

unist-util-map types Node and MapFunction stopped to be exported between v3 and v3.1.1 #6

Closed
@revelt

Description

@revelt

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 and Node (and Parent) types are not exported any more

but 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 the unist-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:

export type Node = import('unist').Node
export type Parent = import('unist').Parent
export type MapFunction = (node: Node, index?: number, parent?: Parent) => Node

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 use esbuild to bundle ESM (and sometimes optionally IIFE too) and rollup with rollup-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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions