Skip to content

Navigation Menu

Sign in
Sign up

Types from *.d.ts files are not parsed in node_modules #929

Open
Labels

Description

If an installed package would deliver type informations with d.ts files, it won't parse these files and interface informations are missing in the props.

It could be fixed in the makeFsImporter.ts file with a simple addition:

if (!nextFile) {
 // Customization: try to read from a "d.ts" file instead, if it exists
 if (resolvedSource.includes("node_modules")) {
 const dtsPath = resolvedSource.replace(".js", ".d.ts");
 if (fs.existsSync(dtsPath)) {
 resolvedSource = dtsPath;
 }
 }
 // Customization: end
 // Read and parse the code
 const src = fs.readFileSync(resolvedSource, "utf8");
 nextFile = file.parse(src, resolvedSource);
 parseCache.set(resolvedSource, nextFile);
}

But i didn't want to make another pull request because i'm not sure if this is a nice way to solve it.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      AltStyle によって変換されたページ (->オリジナル) /