Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(schema): add vueCompilerOptions property to TSConfig in defineNuxtConfig #25924

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/schema/build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default defineBuildConfig({
'sass-loader',
'c12',
'unenv',
'@vue/language-core',
// Implicit
'@vue/compiler-core',
'@vue/shared',
Expand Down
3 changes: 2 additions & 1 deletion packages/schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"@vitejs/plugin-vue": "5.0.4",
"@vitejs/plugin-vue-jsx": "3.1.0",
"@vue/compiler-core": "3.4.20",
"@vue/language-core": "^1.8.27",
"c12": "1.9.0",
"esbuild-loader": "4.0.3",
"h3": "1.11.1",
Expand Down Expand Up @@ -75,4 +76,4 @@
"engines": {
"node": "^14.18.0 || >=16.10.0"
}
}
}
2 changes: 1 addition & 1 deletion packages/schema/src/config/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default defineUntypedSchema({

/**
* You can extend generated `.nuxt/tsconfig.json` using this option.
* @type {typeof import('pkg-types')['TSConfig']}
* @type {0 extends 1 & VueCompilerOptions ? typeof import('pkg-types')['TSConfig'] : typeof import('pkg-types')['TSConfig'] & { vueCompilerOptions?: typeof import('@vue/language-core')['VueCompilerOptions']}}
*/
tsConfig: {},

Expand Down
7 changes: 6 additions & 1 deletion packages/schema/src/types/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { Compiler, Configuration, Stats } from 'webpack'
import type { Nitro, NitroConfig } from 'nitropack'
import type { Schema, SchemaDefinition } from 'untyped'
import type { RouteLocationRaw } from 'vue-router'
import type { VueCompilerOptions } from '@vue/language-core'
import type { NuxtCompatibility, NuxtCompatibilityIssues, ViteConfig } from '..'
import type { Component, ComponentsOptions } from './components'
import type { Nuxt, NuxtApp, ResolvedNuxtTemplate } from './nuxt'
Expand All @@ -20,6 +21,10 @@ export type TSReference = { types: string } | { path: string }

export type WatchEvent = 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir'

// If the user does not have `@vue/language-core` installed, VueCompilerOptions will be typed as `any`,
// thus making the whole `VueTSConfig` type `any`. We only augment TSConfig if VueCompilerOptions is available.
export type VueTSConfig = 0 extends 1 & VueCompilerOptions ? TSConfig : TSConfig & { vueCompilerOptions?: VueCompilerOptions }

export type NuxtPage = {
name?: string
path: string
Expand Down Expand Up @@ -282,7 +287,7 @@ export interface NuxtHooks {
* @param options Objects containing `references`, `declarations`, `tsConfig`
* @returns Promise
*/
'prepare:types': (options: { references: TSReference[], declarations: string[], tsConfig: TSConfig }) => HookResult
'prepare:types': (options: { references: TSReference[], declarations: string[], tsConfig: VueTSConfig }) => HookResult
/**
* Called when the dev server is loading.
* @param listenerServer The HTTP/HTTPS server object
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.