fix(nuxt): type auto-imported $fetch with nitro's $Fetch - #35704
#35704Merged
danielroe merged 3 commits intoJul 19, 2026
nuxt:mainnuxt/nuxt:mainfrom
KealanAU:fix/dollar-fetch-type-templateKealanAU/nuxt:fix/dollar-fetch-type-templateCopy head branch name to clipboard
Merged
fix(nuxt): type auto-imported $fetch with nitro's $Fetch#35704danielroe merged 3 commits intonuxt:mainnuxt/nuxt:mainfrom KealanAU:fix/dollar-fetch-type-templateKealanAU/nuxt:fix/dollar-fetch-type-templateCopy head branch name to clipboard
danielroe merged 3 commits into
nuxt:mainnuxt/nuxt:mainfrom
KealanAU:fix/dollar-fetch-type-templateKealanAU/nuxt:fix/dollar-fetch-type-templateCopy head branch name to clipboard
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
Contributor
Author
|
This fixes the Nuxt's auto-imported $fetch was typed as ofetch's $fetch, causing it to lose Nitro's route-aware typing and fall back to Maybe not worth merging till then?
|
KealanAU
marked this pull request as ready for review
July 19, 2026 17:34
This comment has been minimized.
This comment has been minimized.
danielroe
reviewed
Jul 19, 2026
danielroe
approved these changes
Jul 19, 2026
@nuxt/kit
@nuxt/nitro-server
nuxt
@nuxt/rspack-builder
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
danielroe
pushed a commit
that referenced
this pull request
Jul 20, 2026
(cherry picked from commit ba27379)
Merged
danielroe
pushed a commit
that referenced
this pull request
Jul 20, 2026
(cherry picked from commit ba27379)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Since #35582, the auto-imported
$fetchis typed by thefetch.d.tstemplate as ofetch's plain$fetch, so every call returnsPromise<any>with no typed-route inference. This types it as nitro's route-aware$Fetch, matching the runtime cast in#app/composables/fetch.export declare const $fetch: import('nitro/types').$FetchfromdollarFetchTypeTemplatebuild-stub-fetch.d.tsin sync with the template$fetch's type andPromise<unknown>for unmatched routesfetch/$fetchand routes nitrojs/nitro#2758While investigating #22488 I found the remaining blocker is upstream: nitro's generated
nitro-imports.d.tsemits import paths like.../node_modules/nitro/h3(package dir joined with the exports subpath), which doesn't exist on disk. TS can't resolve it andskipLibCheckhides the error, sodefineEventHandlerbecomesanyand poisons allInternalApiroute types. With that patched locally plus this fix,$fetch(/api/posts/${id})correctly infersPromise<number | string>.🔗 Linked issue: #22488