From 2ba3bb9e143bef703acfb8e0d74c136a94cf402d Mon Sep 17 00:00:00 2001 From: Johnson Chu Date: Fri, 31 Jan 2025 18:58:29 +0800 Subject: [PATCH] refactor(language-core): destructure options --- .../language-core/lib/codegen/globalTypes.ts | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/packages/language-core/lib/codegen/globalTypes.ts b/packages/language-core/lib/codegen/globalTypes.ts index c2623a0779..da8debd067 100644 --- a/packages/language-core/lib/codegen/globalTypes.ts +++ b/packages/language-core/lib/codegen/globalTypes.ts @@ -1,13 +1,19 @@ import type { VueCompilerOptions } from '../types'; import { getSlotsPropertyName } from '../utils/shared'; -export function getGlobalTypesFileName(options: VueCompilerOptions) { +export function getGlobalTypesFileName({ + lib, + target, + checkUnknownProps, + checkUnknownEvents, + checkUnknownComponents, +}: VueCompilerOptions) { return [ - options.lib, - options.target, - options.checkUnknownProps, - options.checkUnknownEvents, - options.checkUnknownComponents, + lib, + target, + checkUnknownProps, + checkUnknownEvents, + checkUnknownComponents, ].map(v => { if (typeof v === 'boolean') { return v ? 1 : 0; @@ -16,8 +22,13 @@ export function getGlobalTypesFileName(options: VueCompilerOptions) { }).join('_') + '.d.ts'; } -export function generateGlobalTypes(options: VueCompilerOptions) { - const { lib, target, checkUnknownProps, checkUnknownEvents, checkUnknownComponents } = options; +export function generateGlobalTypes({ + lib, + target, + checkUnknownProps, + checkUnknownEvents, + checkUnknownComponents, +}: VueCompilerOptions) { const fnPropsType = `(K extends { $props: infer Props } ? Props : any)${checkUnknownProps ? '' : ' & Record'}`; let text = ``; if (target < 3.5) {