mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 21:55:11 +00:00
fix(nuxt): do not override inferred type of <NuxtPage>
(#18495)
This commit is contained in:
parent
6e7ebc4484
commit
9751c9dab7
@ -1,5 +1,5 @@
|
|||||||
import { computed, defineComponent, h, provide, reactive, onMounted, nextTick, Suspense, Transition } from 'vue'
|
import { computed, defineComponent, h, provide, reactive, onMounted, nextTick, Suspense, Transition } from 'vue'
|
||||||
import type { DefineComponent, VNode, KeepAliveProps, TransitionProps } from 'vue'
|
import type { VNode, KeepAliveProps, TransitionProps } from 'vue'
|
||||||
import { RouterView } from 'vue-router'
|
import { RouterView } from 'vue-router'
|
||||||
import { defu } from 'defu'
|
import { defu } from 'defu'
|
||||||
import type { RouteLocationNormalized, RouteLocationNormalizedLoaded, RouteLocation } from 'vue-router'
|
import type { RouteLocationNormalized, RouteLocationNormalizedLoaded, RouteLocation } from 'vue-router'
|
||||||
@ -62,14 +62,7 @@ export default defineComponent({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}) as DefineComponent<{
|
})
|
||||||
name?: string
|
|
||||||
transition?: boolean | TransitionProps
|
|
||||||
keepalive?: boolean | KeepAliveProps
|
|
||||||
route?: RouteLocationNormalized
|
|
||||||
pageKey?: string | ((route: RouteLocationNormalizedLoaded) => string)
|
|
||||||
[key: string]: any
|
|
||||||
}>
|
|
||||||
|
|
||||||
function _toArray (val: any) {
|
function _toArray (val: any) {
|
||||||
return Array.isArray(val) ? val : (val ? [val] : [])
|
return Array.isArray(val) ? val : (val ? [val] : [])
|
||||||
|
@ -11,7 +11,6 @@ import {
|
|||||||
} from 'vue-router'
|
} from 'vue-router'
|
||||||
import { createError } from 'h3'
|
import { createError } from 'h3'
|
||||||
import { withoutBase, isEqual } from 'ufo'
|
import { withoutBase, isEqual } from 'ufo'
|
||||||
import type NuxtPage from '../page'
|
|
||||||
import { callWithNuxt, defineNuxtPlugin, useRuntimeConfig, showError, clearError, navigateTo, useError, useState, useRequestEvent } from '#app'
|
import { callWithNuxt, defineNuxtPlugin, useRuntimeConfig, showError, clearError, navigateTo, useError, useState, useRequestEvent } from '#app'
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import _routes from '#build/routes'
|
import _routes from '#build/routes'
|
||||||
@ -20,12 +19,6 @@ import routerOptions from '#build/router.options'
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { globalMiddleware, namedMiddleware } from '#build/middleware'
|
import { globalMiddleware, namedMiddleware } from '#build/middleware'
|
||||||
|
|
||||||
declare module '@vue/runtime-core' {
|
|
||||||
export interface GlobalComponents {
|
|
||||||
NuxtPage: typeof NuxtPage
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// https://github.com/vuejs/router/blob/4a0cc8b9c1e642cdf47cc007fa5bbebde70afc66/packages/router/src/history/html5.ts#L37
|
// https://github.com/vuejs/router/blob/4a0cc8b9c1e642cdf47cc007fa5bbebde70afc66/packages/router/src/history/html5.ts#L37
|
||||||
function createCurrentLocation (
|
function createCurrentLocation (
|
||||||
base: string,
|
base: string,
|
||||||
|
2
packages/nuxt/types.d.ts
vendored
2
packages/nuxt/types.d.ts
vendored
@ -1,7 +1,7 @@
|
|||||||
/// <reference types="nitropack" />
|
/// <reference types="nitropack" />
|
||||||
export * from './dist/index'
|
export * from './dist/index'
|
||||||
|
|
||||||
import type { Schema, SchemaDefinition } from '@nuxt/schema'
|
import type { SchemaDefinition } from '@nuxt/schema'
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
const defineNuxtConfig: typeof import('nuxt/config')['defineNuxtConfig']
|
const defineNuxtConfig: typeof import('nuxt/config')['defineNuxtConfig']
|
||||||
|
7
test/fixtures/basic/types.ts
vendored
7
test/fixtures/basic/types.ts
vendored
@ -6,6 +6,7 @@ import type { AppConfig } from '@nuxt/schema'
|
|||||||
import type { FetchError } from 'ofetch'
|
import type { FetchError } from 'ofetch'
|
||||||
import type { NavigationFailure, RouteLocationNormalizedLoaded, RouteLocationRaw, useRouter as vueUseRouter } from 'vue-router'
|
import type { NavigationFailure, RouteLocationNormalizedLoaded, RouteLocationRaw, useRouter as vueUseRouter } from 'vue-router'
|
||||||
import { callWithNuxt, isVue3 } from '#app'
|
import { callWithNuxt, isVue3 } from '#app'
|
||||||
|
import NuxtPage from '~~/../../../packages/nuxt/src/pages/runtime/page'
|
||||||
import type { NavigateToOptions } from '~~/../../../packages/nuxt/dist/app/composables/router'
|
import type { NavigateToOptions } from '~~/../../../packages/nuxt/dist/app/composables/router'
|
||||||
import { defineNuxtConfig } from '~~/../../../packages/nuxt/config'
|
import { defineNuxtConfig } from '~~/../../../packages/nuxt/config'
|
||||||
import { useRouter } from '#imports'
|
import { useRouter } from '#imports'
|
||||||
@ -155,6 +156,12 @@ describe('head', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('components', () => {
|
||||||
|
it('includes types for NuxtPage', () => {
|
||||||
|
expectTypeOf(NuxtPage).not.toBeAny()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('composables', () => {
|
describe('composables', () => {
|
||||||
it('allows providing default refs', () => {
|
it('allows providing default refs', () => {
|
||||||
expectTypeOf(useState('test', () => ref('hello'))).toEqualTypeOf<Ref<string>>()
|
expectTypeOf(useState('test', () => ref('hello'))).toEqualTypeOf<Ref<string>>()
|
||||||
|
Loading…
Reference in New Issue
Block a user