Skip to content

Commit

Permalink
chore(deps): update all non-major dependencies (nuxt#4914)
Browse files Browse the repository at this point in the history
* chore(deps): update all non-major dependencies

* update lock

* fix: update types

* fix: update error type

* test: update useFetch url

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Pooya Parsa <pyapar@gmail.com>
Co-authored-by: Daniel Roe <daniel@roe.dev>
  • Loading branch information
4 people authored May 11, 2022
1 parent 5c8c045 commit 7e89fe8
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 184 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"@types/rimraf": "^3",
"@unocss/reset": "^0.33.2",
"case-police": "^0.5.3",
"changelogen": "^0.0.5",
"changelogen": "^0.0.6",
"eslint": "^8.15.0",
"eslint-plugin-jsdoc": "^39.2.9",
"execa": "^6.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"knitwork": "^0.1.1",
"magic-string": "^0.26.1",
"mlly": "^0.5.2",
"nitropack": "^0.4.2",
"nitropack": "^0.4.3",
"nuxi": "^3.0.0-rc.3",
"ohash": "^0.1.0",
"ohmyfetch": "^0.4.16",
Expand Down
14 changes: 7 additions & 7 deletions packages/nuxt/src/app/composables/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { FetchOptions, FetchRequest } from 'ohmyfetch'
import type { TypedInternalResponse } from 'nitropack'
import type { TypedInternalResponse, NitroFetchRequest } from 'nitropack'
import { hash } from 'ohash'
import { computed, isRef, Ref } from 'vue'
import type { AsyncDataOptions, _Transform, KeyOfRes } from './asyncData'
import { useAsyncData } from './asyncData'

export type FetchResult<ReqT extends FetchRequest> = TypedInternalResponse<ReqT, unknown>
export type FetchResult<ReqT extends NitroFetchRequest> = TypedInternalResponse<ReqT, unknown>

export interface UseFetchOptions<
DataT,
Expand All @@ -18,7 +18,7 @@ export interface UseFetchOptions<
export function useFetch<
ResT = void,
ErrorT = Error,
ReqT extends FetchRequest = FetchRequest,
ReqT extends NitroFetchRequest = NitroFetchRequest,
_ResT = ResT extends void ? FetchResult<ReqT> : ResT,
Transform extends (res: _ResT) => any = (res: _ResT) => _ResT,
PickKeys extends KeyOfRes<Transform> = KeyOfRes<Transform>
Expand All @@ -30,12 +30,12 @@ export function useFetch<
console.warn('[nuxt] You should provide a key for `useFetch` when using a custom transform function.')
}
const key = '$f_' + (opts.key || hash([request, { ...opts, transform: null }]))
const _request = computed<FetchRequest>(() => {
let r = request
const _request = computed(() => {
let r = request as Ref<FetchRequest> | FetchRequest | (() => FetchRequest)
if (typeof r === 'function') {
r = r()
}
return isRef(r) ? r.value : r
return (isRef(r) ? r.value : r) as NitroFetchRequest
})

const _fetchOptions = {
Expand All @@ -61,7 +61,7 @@ export function useFetch<
export function useLazyFetch<
ResT = void,
ErrorT = Error,
ReqT extends string = string,
ReqT extends NitroFetchRequest = NitroFetchRequest,
_ResT = ResT extends void ? FetchResult<ReqT> : ResT,
Transform extends (res: _ResT) => any = (res: _ResT) => _ResT,
PickKeys extends KeyOfRes<Transform> = KeyOfRes<Transform>
Expand Down
4 changes: 2 additions & 2 deletions packages/nuxt/src/core/runtime/nitro/error.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { withQuery } from 'ufo'
import type { NitroErrorHandler } from 'nitropack'
import type { NitroErrorHandler, NitroFetchRequest } from 'nitropack'
// @ts-ignore TODO
import { normalizeError, isJsonRequest } from '#internal/nitro/utils'

Expand Down Expand Up @@ -36,7 +36,7 @@ export default <NitroErrorHandler> async function errorhandler (_error, event) {
}

// HTML response
const url = withQuery('/__nuxt_error', errorObject as any)
const url = withQuery('/__nuxt_error', errorObject as any) as NitroFetchRequest
const html = await $fetch(url).catch((error) => {
console.error('[nitro] Error while generating error response', error)
return errorObject.statusMessage
Expand Down
2 changes: 1 addition & 1 deletion packages/webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"url-loader": "^4.1.1",
"vue-loader": "^17.0.0",
"vue-style-loader": "^4.1.3",
"webpack": "^5.72.0",
"webpack": "^5.72.1",
"webpack-bundle-analyzer": "^4.5.0",
"webpack-dev-middleware": "^5.3.1",
"webpack-hot-middleware": "^2.25.1",
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/basic/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ describe('composables', () => {
// @ts-expect-error
expectTypeOf(useAsyncData('test', () => Promise.resolve('500'), { default: () => 500 }).data).toMatchTypeOf<Ref<number>>()

expectTypeOf(useFetch('test', { default: () => ref(500) }).data).toMatchTypeOf<Ref<number>>()
expectTypeOf(useFetch('test', { default: () => 500 }).data).toMatchTypeOf<Ref<number>>()
expectTypeOf(useFetch('/test', { default: () => ref(500) }).data).toMatchTypeOf<Ref<number>>()
expectTypeOf(useFetch('/test', { default: () => 500 }).data).toMatchTypeOf<Ref<number>>()
})
})
Loading

0 comments on commit 7e89fe8

Please sign in to comment.