@@ -234,24 +234,31 @@ function* generateScriptWithExportDefault(
234234 yield * generateSfcBlockSection ( script , exportDefault . end , script . content . length , codeFeatures . all ) ;
235235}
236236
237- function * generateGlobalTypesReference ( vueCompilerOptions : VueCompilerOptions , fileName : string ) : Generator < Code > {
238- const globalTypesPath = vueCompilerOptions . globalTypesPath ( fileName ) ;
239- if ( ! globalTypesPath ) {
240- yield `/* placeholder */ ${ newLine } ` ;
241- }
242- else if ( path . isAbsolute ( globalTypesPath ) ) {
243- let relativePath = path . relative ( path . dirname ( fileName ) , globalTypesPath ) ;
237+ function * generateGlobalTypesReference (
238+ { typesRoot , lib , target , checkUnknownProps } : VueCompilerOptions ,
239+ fileName : string ,
240+ ) : Generator < Code > {
241+ let typesPath : string ;
242+ if ( path . isAbsolute ( typesRoot ) ) {
243+ let relativePath = path . relative ( path . dirname ( fileName ) , typesRoot ) ;
244244 if (
245- relativePath !== globalTypesPath
245+ relativePath !== typesRoot
246246 && ! relativePath . startsWith ( './' )
247247 && ! relativePath . startsWith ( '../' )
248248 ) {
249249 relativePath = './' + relativePath ;
250250 }
251- yield `/// <reference types=" ${ relativePath } " /> ${ newLine } ` ;
251+ typesPath = relativePath ;
252252 }
253253 else {
254- yield `/// <reference types="${ globalTypesPath } " />${ newLine } ` ;
254+ typesPath = typesRoot ;
255+ }
256+ yield `/// <reference types=${ JSON . stringify ( typesPath + '/template-helpers.d.ts' ) } />${ newLine } ` ;
257+ if ( ! checkUnknownProps ) {
258+ yield `/// <reference types=${ JSON . stringify ( typesPath + '/props-fallback.d.ts' ) } />${ newLine } ` ;
259+ }
260+ if ( lib === 'vue' && target < 3.5 ) {
261+ yield `/// <reference types=${ JSON . stringify ( typesPath + '/vue-3.4-shims.d.ts' ) } />${ newLine } ` ;
255262 }
256263}
257264
0 commit comments