fix(types): emit auto-import paths as files, not directories#4333
Conversation
|
@danielroe is attempting to deploy a commit to the Nitro Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughThe PR fixes node module path resolution in Nitro's ChangesNode module subpath resolution in type declarations
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
commit: |
🔗 Linked issue
originally reported against Nuxt: nuxt/nuxt#35248, but it reproduces in pure Nitro
also related: #1528, #4297
❓ Type of change
📚 Description
writeTypesemitsconst foo: typeof import('<path>').fooper auto-imported bindingfor some packages, the path ends up being the package directory rather than a file; this works fine for TypeScript with
moduleResolution: bundler, but Deno's TS host doesn't apply Node directory resolution to relative specifiers and bailsthis PR treats
./the same as an empty subpath & falls back to resolvedPath, which ends up having its extension strippedboth typescript + deno should resolve this equally well.
note: packages with different
exports.typesvsexports.imports(eg #2384) won't work correctly, either before or after this fix (but the error slightly changes 😆)📝 Checklist