Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vuejs/router
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v4.4.1
Choose a base ref
...
head repository: vuejs/router
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v4.4.2
Choose a head ref
  • 3 commits
  • 5 files changed
  • 1 contributor

Commits on Jul 31, 2024

  1. chore: typos [skip ci]

    posva committed Jul 31, 2024
    Copy the full SHA
    5fef441 View commit details

Commits on Aug 1, 2024

  1. fix(types): revert stricter meta

    Close #2319
    posva committed Aug 1, 2024
    Copy the full SHA
    d4d0087 View commit details
  2. release: vue-router@4.4.2

    posva committed Aug 1, 2024
    Copy the full SHA
    001dd51 View commit details
Showing with 18 additions and 42 deletions.
  1. +7 −1 packages/router/CHANGELOG.md
  2. +1 −1 packages/router/package.json
  3. +0 −1 packages/router/src/index.ts
  4. +3 −37 packages/router/src/types/index.ts
  5. +7 −2 packages/router/test-dts/meta.test-d.ts
8 changes: 7 additions & 1 deletion packages/router/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
## [4.4.2](https://github.com/vuejs/router/compare/v4.4.1...v4.4.2) (2024-08-01)

### Bug Fixes

- **types:** revert stricter meta ([d4d0087](https://github.com/vuejs/router/commit/d4d0087eae5721f73bde445be33407875a92a1ca)), closes [#2319](https://github.com/vuejs/router/issues/2319)

## [4.4.1](https://github.com/vuejs/router/compare/v4.4.0...v4.4.1) (2024-07-31)

### Bug Fixes

- router typescript definations related to vue package ([#2295](https://github.com/vuejs/router/issues/2295)) ([a495ce0](https://github.com/vuejs/router/commit/a495ce0e1d545d521673d21af43e63a761b53e27))
- router typescript definitions related to vue package ([#2295](https://github.com/vuejs/router/issues/2295)) ([a495ce0](https://github.com/vuejs/router/commit/a495ce0e1d545d521673d21af43e63a761b53e27))
- **types:** stricter meta with required fields ([423d9f7](https://github.com/vuejs/router/commit/423d9f763ed033dd6687ce7687c859c92554a60d))

### Features
2 changes: 1 addition & 1 deletion packages/router/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-router",
"version": "4.4.1",
"version": "4.4.2",
"main": "index.js",
"unpkg": "dist/vue-router.global.js",
"jsdelivr": "dist/vue-router.global.js",
1 change: 0 additions & 1 deletion packages/router/src/index.ts
Original file line number Diff line number Diff line change
@@ -59,7 +59,6 @@ export type {
RouteRecordMultipleViewsWithChildren,
RouteRecordRedirect,
RouteMeta,
_RouteMetaBase,
RouteComponent,
// RawRouteComponent,
RouteParamsGeneric,
40 changes: 3 additions & 37 deletions packages/router/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -189,9 +189,7 @@ export type RawRouteComponent = RouteComponent | Lazy<RouteComponent>
/**
* Internal type for common properties among all kind of {@link RouteRecordRaw}.
*/
export interface _RouteRecordBase
extends PathParserOptions,
_RouteRecordBaseMeta {
export interface _RouteRecordBase extends PathParserOptions {
/**
* Path of the record. Should start with `/` unless the record is the child of
* another record.
@@ -230,7 +228,7 @@ export interface _RouteRecordBase
/**
* Arbitrary data attached to the record.
*/
// meta?: RouteMeta
meta?: RouteMeta

/**
* Array of nested routes.
@@ -243,12 +241,6 @@ export interface _RouteRecordBase
props?: _RouteRecordProps | Record<string, _RouteRecordProps>
}

/**
* Default type for RouteMeta when not augmented.
* @internal
*/
export type _RouteMetaBase = Record<string | number | symbol, unknown>

/**
* Interface to type `meta` fields in route records.
*
@@ -265,33 +257,7 @@ export type _RouteMetaBase = Record<string | number | symbol, unknown>
* }
* ```
*/
export interface RouteMeta extends _RouteMetaBase {}

/**
* Returns `true` if the passed `RouteMeta` type hasn't been augmented. Return `false` otherwise.
* @internal
*/
export type IsRouteMetaBase<RM> = _RouteMetaBase extends RM ? true : false
/**
* Returns `true` if the passed `RouteMeta` type has been augmented with required fields. Return `false` otherwise.
* @internal
*/
export type IsRouteMetaRequired<RM> = Partial<RM> extends RM ? false : true

export type _RouteRecordBaseMeta = IsRouteMetaRequired<RouteMeta> extends true
? {
/**
* Arbitrary data attached to the record. Required because the `RouteMeta` type has been augmented with required
* fields.
*/
meta: RouteMeta
}
: {
/**
* Arbitrary data attached to the record.
*/
meta?: RouteMeta
}
export interface RouteMeta extends Record<string | number | symbol, unknown> {}

/**
* Route Record defining one single component with the `component` option.
9 changes: 7 additions & 2 deletions packages/router/test-dts/meta.test-d.ts
Original file line number Diff line number Diff line change
@@ -7,8 +7,7 @@ const component = defineComponent({})
declare module '.' {
interface RouteMeta {
requiresAuth?: boolean
// TODO: it would be nice to be able to test required meta without polluting all tests
nested?: { foo: string }
nested: { foo: string }
}
}

@@ -28,6 +27,12 @@ describe('RouteMeta', () => {
},
},
},
{
path: '/hey',
component,
// @ts-expect-error: meta is missing `nested`
meta: {},
},
],
})