fix(schema): add vueCompilerOptions property to tsConfig (#25924)

This commit is contained in:
Andrea Basile 2024-02-27 16:31:46 +01:00 committed by GitHub
parent 15a4a080ac
commit 3258cacc28
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 12 additions and 2 deletions

View File

@ -53,6 +53,7 @@ export default defineBuildConfig({
'sass-loader',
'c12',
'unenv',
'@vue/language-core',
// Implicit
'@vue/compiler-core',
'@vue/shared',

View File

@ -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",

View File

@ -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: {},

View File

@ -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'
@ -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
@ -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

View File

@ -493,6 +493,9 @@ importers:
'@vue/compiler-core':
specifier: 3.4.20
version: 3.4.20
'@vue/language-core':
specifier: ^1.8.27
version: 1.8.27(typescript@5.3.3)
c12:
specifier: 1.9.0
version: 1.9.0