-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(types): adds ESM export of types #1457
Conversation
Fixes #1456; see also microsoft/TypeScript#47792
✅ Deploy Preview for vue-router canceled.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot!
Confirmed, eve-val/eve-roster#1262 applied cleanly now. |
I think this may have introduced a problem with the types for the Imports of "vue-router" under the node16 module resolution setting when the importing module is ESM (its extension is .mts or .mjs, or it has a .ts or .js extension and is in scope of a package.json that contains "type": "module") resolved to CJS types, but ESM implementations. |
What is the problem? The tool isn't clear on whether this is a problem or not. If you have a boiled down reproduction showing a problem, that would help! |
Chatting with @andrewbranch (the author of Are The Types Wrong?), it appears that there is more context in the readme on GitHub. I believe this is the relevant bit:
|
I see, thanks a lot! Since we have no default export, it should be fine. I want to avoid having to add yet another file to the dist folder, it's a maintainer's nightmare 💀 |
I think it's still indicating there is a problem here to be fixed. Often you can reproduce this with a simple StackBlitz with |
I'm not sure how to use StackBlitz demo: https://stackblitz.com/edit/node-ozajfl?file=tsconfig.json&file=index.ts%3AL6
|
Ah, looking at this file in the playground, looks like I am doing things wrong. Maybe this is more along the lines of a normal usage of import { createRouter, createWebHistory } from 'vue-router';
const routerHistory = createWebHistory();
const router = createRouter({
history: routerHistory,
routes: [{ path: '/', component: null }],
}); StackBlitz demo: https://stackblitz.com/edit/node-d5yw9g?file=tsconfig.json&file=index.ts @andrewbranch is this a false positive of Are The Types Wrong? in this case? Or is it:
|
Here’s the concrete repro. // Importing from ESM in Node
import VueRouter from 'vue-router';
const routerHistory = VueRouter.createWebHistory();
const router = VueRouter.createRouter({
history: routerHistory,
routes: [{ path: '/', component: null }],
}); Because the types indicate the module is CommonJS, a default import is allowed, and points to the I always advocate for types to correctly represent their module kind, and consider this to be a problem worth fixing. But you can kind of see that you often have to go against conventional usage of the package in order to get yourself in real trouble with this issue. |
Yeah, agree. I don’t think it’s worth complicating the build step and marking the package bigger to make an error for this. It’s already complicated enough 😆 |
Fixes #1456; see also microsoft/TypeScript#47792