Skip to content

Commit

Permalink
fix(schema): add vueCompilerOptions property to tsConfig (#25924)
Browse files Browse the repository at this point in the history
  • Loading branch information
Evobaso-J committed Feb 27, 2024
1 parent 15a4a08 commit 3258cac
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 2 deletions.
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
1 change: 1 addition & 0 deletions 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
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.

0 comments on commit 3258cac

Please sign in to comment.