vuejs / router

🚦 The official router for Vue.js
https://router.vuejs.org/
MIT License
3.88k stars 1.18k forks source link

Changed behaviour for meta #2319

Closed jashaj closed 1 month ago

jashaj commented 1 month ago

Reproduction

https://play.vuejs.org/#eNqlVVtv2zYU/itn6gA7WCw6btEHzfWSFkWzYu2KZNtL1Qdaom0mFCmQlOPA8H/fIalr7BZo68SwdC7fufLjPiool/GdiZKIF6XSFvaQaUYtuypLOMBKqwJG24qNUlkbaFVZpmtNTMJrp3Z+jY6WZRx8U9mijvF7lkqAuDJsHNzDe6EqacejZ+g2OovOo9odc5tbVpQC/RfOcL65WFwzIZQL9suc4KsXl/4HH4zVSq4XbyqtmawzhpLaTTIntQ72e/jVK+JVJcQnVMLh4GFIwJlLum0Ab3yWf3F5D1a9SiOSRot3Cp/hWhVsTjr9Vz3oEiWt25V7O/Kbkybm3M1liPUfZw9AartaPSdtY7BfoZexPTHND6xQ+vGaG4s/57Uw4PanPGmn2c7TFehDN0NtBPVkm7G7ggZ2rWRouAcf9oZlSuc39OFU+N9d/JxlgmoGhcorwQZ62LsuEAJScWlKllmuJLy//VfiSuXvhFpScftYLJUwzpBLdFrRjIXQH5ilAQHAcitYArgUXK4xrJNteM5eY4PyTFfF0vyRwFIpwaj0etwR/Md9VtLUq2WSYUmfv8Ar+OyM92HrYERG2HSFHZC4kEnb1HMoMJkE7epERk6Dtk9ySMDqimGrDudDWL9VQ+y278fgXjXqYEK9LZa2PBPMOLgNFzmenSSU4T61cc9h5EHCp47UCdrWjq4a2E4ZwocPTvGjsmA3DGhmKypgi7l3+lOVNdoO5zg7kvC8n+GPxPmuAk/W5xkF4Eu9Ofg72ByNi9I/i2MfYBOOaXLq7I7PPHbYO3w8IHWmku382crZilaiwUZG6J9VR6Mm07y0YJitShBUrpGZrEFWclQSlPiIL0/4drZokJBtZ0fEMzjqPxenhToZKHDIpKAl3llKYijfsLRWYIR2RmnUEYYTp9HG2tIkhFSyvF/HOG/SWVy+iJ/HU5Jjk3vSmJlistTqweDzHaLXc02jSzQiOdtaZAYzoSX/Wogjw8uX8cv4ggi+JIhOOPLczmM35IJlWoM7suLrJ0W6FeWC6b9Lx3fDYilehw/vvcxRRZtotmHZ/Qn5ndmFlD9phtVtWa84S/Wa4V3l1G9vP7IdPrfKQMffVN4wo0TlcgxmryuZY9o9O5/tn35myLv/mLc7y6RpinKJ+m54ez/IN98ovUv3efyi10VjH5F24sy4+xAvVuRDvDWD3xKZmukEZuUOMFmew7PpdOoJvkA4LidLZa0qEriYljsvL2meY7KtxN8CCAsLoPAbfj1w7S3YComkb7mZ9SN38F0CWZb1Ekhgin+zGiE6/A/dvDHF

Steps to reproduce the bug

Existing route configuration in TypeScript. There's an interface RouteMeta that has both required and optional fields. Some routes have meta defined, some have not. The ones that don't have meta defined are parent routes without their own component.

Expected behavior

In vue-router 4.4.0 this passed the build

Actual behavior

In vue-router 4.4.1 meta became required when at least one field is required. Now I either have to make all fields in RouteMeta optional or add dummy meta to the routes without their own rendering component. This is a breaking change in a patch version.

Additional information

No response

mityaua commented 1 month ago

Same ("typescript": "~5.5.4",) Screenshot 2024-08-01 104133

posva commented 1 month ago

There are indeed a lot of edge cases that are not covered with this stricter meta so let's revert it for now and figure out a better approach in the future

WarpedPixel commented 1 month ago

Still running into type break updating from 4.4.0 to 4.4.2, haven't root caused yet, but code has worked that way for 3 months. It must be something introduced in 4.4.1, or our code had a latent break. Maybe it rings an immediate bell for one of you:

src/components/user-menu.vue(115,63): error TS2339: Property '$route' does not exist on type 'CreateComponentPublicInstance<Readonly<ExtractPropTypes<{}>>, { ThemeSwitch: typeof ThemeSwitch; AccountAvatar: typeof AccountAvatar; handleLogout: typeof handleLogout; ... 5 more ...; clickOnLoggedInPerson: typeof clickOnLoggedInPerson; }, ... 17 more ..., {}>'.
src/components/user-menu.vue(127,47): error TS2339: Property '$route' does not exist on type 'CreateComponentPublicInstance<Readonly<ExtractPropTypes<{}>>, { ThemeSwitch: typeof ThemeSwitch; AccountAvatar: typeof AccountAvatar; handleLogout: typeof handleLogout; ... 5 more ...; clickOnLoggedInPerson: typeof clickOnLoggedInPerson; }, ... 17 more ..., {}>'.
src/App.vue(53,21): error TS2339: Property '$route' does not exist on type 'CreateComponentPublicInstance<Readonly<ExtractPropTypes<{}>>, { RouterView: typeof RouterView; AppBar: typeof AppBar; NavBar: typeof NavBar; authStore: typeof authStore; state: typeof state; }, ... 17 more ..., {}>'.
src/App.vue(54,22): error TS2339: Property '$route' does not exist on type 'CreateComponentPublicInstance<Readonly<ExtractPropTypes<{}>>, { RouterView: typeof RouterView; AppBar: typeof AppBar; NavBar: typeof NavBar; authStore: typeof authStore; state: typeof state; }, ... 17 more ..., {}>'.
ERROR: "type-check" exited with 2.
posva commented 1 month ago

@WarpedPixel This issue is unrelated. I think you were searching for #2321