You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 existsif(resolvedSource.includes("node_modules")){constdtsPath=resolvedSource.replace(".js",".d.ts");if(fs.existsSync(dtsPath)){resolvedSource=dtsPath;}}// Customization: end// Read and parse the codeconstsrc=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.
The text was updated successfully, but these errors were encountered:
There are currently two issues with types that are imported from .d.ts files:
import resolution: resolve that's used in the built-in fs importer is not built to locate type declaration files. Simply replacing .js with .d.ts is not a reliable solution, as it's quite likely for the type declaration file to be named something else, which is then specified in types or typings key of the package.json file. To make the matters worse, many packages have started to use package.json exports, which can include a types mapping too (example).
With an increasing number of reusable hooks and headless components, it is becoming common for component libraries to extend prop interfaces exported from third-party packages. Looking forward to improvements in this area, and I could also look into possible solutions for the first point.
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:But i didn't want to make another pull request because i'm not sure if this is a nice way to solve it.
The text was updated successfully, but these errors were encountered: