@@ -9,6 +9,7 @@ import { createScriptCodegenContext, ScriptCodegenContext } from './context';
9
9
import { generateScriptSetup , generateScriptSetupImports } from './scriptSetup' ;
10
10
import { generateSrc } from './src' ;
11
11
import { generateTemplate } from './template' ;
12
+ import { generateGlobalTypes } from '../globalTypes' ;
12
13
13
14
export const codeFeatures = {
14
15
all : {
@@ -51,7 +52,12 @@ export interface ScriptCodegenOptions {
51
52
export function * generateScript ( options : ScriptCodegenOptions ) : Generator < Code , ScriptCodegenContext > {
52
53
const ctx = createScriptCodegenContext ( options ) ;
53
54
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
+ }
55
61
56
62
if ( options . sfc . script ?. src ) {
57
63
yield * generateSrc ( options . sfc . script , options . sfc . script . src ) ;
@@ -136,6 +142,9 @@ export function* generateScript(options: ScriptCodegenOptions): Generator<Code,
136
142
yield `type __VLS_IntrinsicElementsCompletion = __VLS_IntrinsicElements${ endOfLine } ` ;
137
143
}
138
144
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
+ }
139
148
140
149
if ( options . sfc . scriptSetup ) {
141
150
yield [ '' , 'scriptSetup' , options . sfc . scriptSetup . content . length , codeFeatures . verification ] ;
0 commit comments