Closed antfu closed 4 years ago
Hey @antfu, I'm glad you're finding it useful. It's especially great to hear it from a developer that I am inspired by!
Thanks for the suggestion, I'll definitely look at this.
I use https://github.com/timocov/dts-bundle-generator in my typescript projects, for types generator, you should try it
@d0whc3r it's not about bundling. /@voie/pages
is a virtual path that linked to a generator, there is no actual path/module for TS to infer the types.
ah ok hehe
This is turning out to be an interesting issue... since the module name /@voie/pages
is not a valid package name, I'm not sure how I could go about using a package to declare types. TypeScript also isn't happy about using an ambient module declaration to declare /@voie/pages
This is turning out to be an interesting issue... since the module name
/@voie/pages
is not a valid package name, I'm not sure how I could go about using a package to declare types. TypeScript also isn't happy about using an ambient module declaration to declare/@voie/pages
Is that possible for you to rename it to something like @voie/pages
? I treat using absolute path a dangerous smell (though in this case it's actually a virtual path, my linter still complain about it 😅)
I've done some more work towards fixing this issue. I've created a PR but haven't merged it because I think it might still need to change.
One problem that I've found with creating a package with the name @voie/pages
for type definitions is that vite would complain that there was no entry point in the package, as it only contained a .d.ts
file. This problem can be resolved by publishing a @types
package for the generated routes, i.e. a @types/voie__pages
package.
What I need to understand now is do I need to create a PR in the DefinitelyTyped repo in order to publish the @types/voie__pages
package, or can I just publish it from this repo?
Sorry I missed the notification. I don't think you can publish @types/voie__pages
without merging into DefinitelyTyped. And that would make the maintenance hard I think.
Guess you can create an empty entry for @voie/pages
as something like
module.exports = []
And hijack the module resolution in the plugin. Like
Good luck :)
I agree that adding to DefinitelyTyped would not be ideal. I've done as you've suggested at it is working nicely! :)
Thanks for this lib, it's great and helped me a lot.
But the one small problem is that the
/@voie/pages
does not have types.I have made a vite plugin inspired by your implementation. To fix the same problem, I have published a package with the same name and install as a dependency to make the types inferring work.
Hope it would be helpful, and looking forward to seeing this project grows.