Skip to content
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

lib/index.d.ts file on npm contains a node_modules path for unist-util-is dependency #6

Closed
4 tasks done
jamesgeorgewilliams opened this issue Jan 1, 2025 · 4 comments
Labels
💪 phase/solved Post is done

Comments

@jamesgeorgewilliams
Copy link

Initial checklist

Affected package

[email protected]

Steps to reproduce

The following example is a vanilla TS project running the example from this repo's README.md. The error is encountered when trying to build the project with npm run build.

https://stackblitz.com/edit/vitejs-vite-a7aqha48?file=src%2Fmain.ts

  1. Open the stackblitz demo.
  2. ctrl + c in terminal to stop vite dev server.
  3. npm run build to view error.

Actual behavior

The following error is observed after running npm run build in the terminal on the Stackblitz link above.

node_modules/unist-util-find-before/lib/index.d.ts:14:86 - error TS2307: Cannot find module '../node_modules/unist-util-is/lib/index.js' or its corresponding type declarations.

14 export const findBefore: (<Kind extends import("unist").Parent, Check extends import("../node_modules/unist-util-is/lib/index.js").Test>(parent: Kind, index: number | Child<Kind>, test: Check) => Matches<Child<Kind>, Check> | undefined) & (<Kind_1 extends import("unist").Parent>(parent: Kind_1, index: number | Child<Kind_1>, test?: null | undefined) => Child<Kind_1> | undefined);
                                                              
Found 1 error in node_modules/unist-util-find-before/lib/index.d.ts:14

Expected behavior

Running npm run build in unist-util-find-before repository produces the following on line:14 of lib/index.d.ts.

export const findBefore: ((<Kind extends UnistParent, Check extends Test>(parent: Kind, index: Child<Kind> | number, test: Check) => Matches<Child<Kind>, Check> | undefined) & (<Kind extends UnistParent>(parent: Kind, index: Child<Kind> | number, test?: null | undefined) => Child<Kind> | undefined));

The npm version of this file contains a path on line:14.
https://www.npmjs.com/package/unist-util-find-before?activeTab=code

Runtime

[email protected]

Package manager

[email protected]

Operating system

macOS Sequoia 15.1

Build and bundle tools

Vite

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Jan 1, 2025
@ChristianMurphy
Copy link
Member

The dependency is declared

"unist-util-is": "^6.0.0"

The import looks correct in the source

* Test from `unist-util-is`.

But I do see the update path on NPM https://www.npmjs.com/package/unist-util-find-before?activeTab=code

This feels like a tsc bug.
Maybe one that would be fixed by rebuilding the declarations with a newer version

@wooorm
Copy link
Member

wooorm commented Jan 2, 2025

tsc sometimes used to generate that. It is often better now. But not always. Let me see

@wooorm
Copy link
Member

wooorm commented Jan 2, 2025

new release should work! https://github.com/syntax-tree/unist-util-find-before/releases/tag/4.0.1

@wooorm wooorm closed this as completed Jan 2, 2025
@wooorm wooorm added the 💪 phase/solved Post is done label Jan 2, 2025
@github-actions github-actions bot removed the 🤞 phase/open Post is being triaged manually label Jan 2, 2025
@jamesgeorgewilliams
Copy link
Author

Great. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💪 phase/solved Post is done
Development

No branches or pull requests

3 participants