Skip to content

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

@jamesgeorgewilliams

Description

@jamesgeorgewilliams

Initial checklist

  • I read the support docs
    I read the contributing guide
    I agree to follow the code of conduct
    I searched issues and discussions and couldn’t find anything (or linked relevant results below)

Affected package

unist-util-find-before@4.0.0

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

node@22.12.0

Package manager

npm@10.9.0

Operating system

macOS Sequoia 15.1

Build and bundle tools

Vite

Activity

added
👋 phase/newPost is being triaged automatically
🤞 phase/openPost is being triaged manually
and removed
👋 phase/newPost is being triaged automatically
on Jan 1, 2025
ChristianMurphy

ChristianMurphy commented on Jan 1, 2025

@ChristianMurphy
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

wooorm commented on Jan 2, 2025

@wooorm
Member

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

wooorm

wooorm commented on Jan 2, 2025

@wooorm
Member
jamesgeorgewilliams

jamesgeorgewilliams commented on Jan 2, 2025

@jamesgeorgewilliams
Author

Great. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @wooorm@ChristianMurphy@jamesgeorgewilliams

        Issue actions

          lib/index.d.ts file on npm contains a node_modules path for unist-util-is dependency · Issue #6 · syntax-tree/unist-util-find-before