@@ -9,6 +9,7 @@ import { createScriptCodegenContext, ScriptCodegenContext } from './context';
99import { generateScriptSetup , generateScriptSetupImports } from './scriptSetup' ;
1010import { generateSrc } from './src' ;
1111import { generateTemplate } from './template' ;
12+ import { generateGlobalTypes } from '../globalTypes' ;
1213
1314export const codeFeatures = {
1415 all : {
@@ -51,7 +52,12 @@ export interface ScriptCodegenOptions {
5152export function * generateScript ( options : ScriptCodegenOptions ) : Generator < Code , ScriptCodegenContext > {
5253 const ctx = createScriptCodegenContext ( options ) ;
5354
54- yield `/// <reference types=".vue-global-types/${ options . vueCompilerOptions . lib } _${ options . vueCompilerOptions . target } _${ options . vueCompilerOptions . strictTemplates } .d.ts" />${ newLine } ` ;
55+ if ( options . vueCompilerOptions . __setupedGlobalTypes ?.( ) ) {
56+ yield `/// <reference types=".vue-global-types/${ options . vueCompilerOptions . lib } _${ options . vueCompilerOptions . target } _${ options . vueCompilerOptions . strictTemplates } .d.ts" />${ newLine } ` ;
57+ }
58+ else {
59+ yield `/* placeholder */` ;
60+ }
5561
5662 if ( options . sfc . script ?. src ) {
5763 yield * generateSrc ( options . sfc . script , options . sfc . script . src ) ;
@@ -136,6 +142,9 @@ export function* generateScript(options: ScriptCodegenOptions): Generator<Code,
136142 yield `type __VLS_IntrinsicElementsCompletion = __VLS_IntrinsicElements${ endOfLine } ` ;
137143 }
138144 yield * ctx . localTypes . generate ( [ ...ctx . localTypes . getUsedNames ( ) ] ) ;
145+ if ( ! options . vueCompilerOptions . __setupedGlobalTypes ?.( ) ) {
146+ yield generateGlobalTypes ( options . vueCompilerOptions . lib , options . vueCompilerOptions . target , options . vueCompilerOptions . strictTemplates ) ;
147+ }
139148
140149 if ( options . sfc . scriptSetup ) {
141150 yield [ '' , 'scriptSetup' , options . sfc . scriptSetup . content . length , codeFeatures . verification ] ;
0 commit comments