@@ -52,11 +52,16 @@ export function initialize(
5252 project . vue = { compilerOptions : vueCompilerOptions } ;
5353
5454 if ( project . typescript ) {
55- const globalTypesName = `${ vueCompilerOptions . lib } _${ vueCompilerOptions . target } _${ vueCompilerOptions . strictTemplates } .d.ts` ;
5655 const directoryExists = project . typescript . languageServiceHost . directoryExists ?. bind ( project . typescript . languageServiceHost ) ;
5756 const fileExists = project . typescript . languageServiceHost . fileExists . bind ( project . typescript . languageServiceHost ) ;
5857 const getScriptSnapshot = project . typescript . languageServiceHost . getScriptSnapshot . bind ( project . typescript . languageServiceHost ) ;
59- const snapshots = new Map < string , ts . IScriptSnapshot > ( ) ;
58+ const globalTypesName = `${ vueCompilerOptions . lib } _${ vueCompilerOptions . target } _${ vueCompilerOptions . strictTemplates } .d.ts` ;
59+ const globalTypesContents = generateGlobalTypes ( vueCompilerOptions . lib , vueCompilerOptions . target , vueCompilerOptions . strictTemplates ) ;
60+ const globalTypesSnapshot : ts . IScriptSnapshot = {
61+ getText : ( start , end ) => globalTypesContents . substring ( start , end ) ,
62+ getLength : ( ) => globalTypesContents . length ,
63+ getChangeRange : ( ) => undefined ,
64+ } ;
6065 if ( directoryExists ) {
6166 project . typescript . languageServiceHost . directoryExists = path => {
6267 if ( path . endsWith ( '.vue-global-types' ) ) {
@@ -66,22 +71,14 @@ export function initialize(
6671 } ;
6772 }
6873 project . typescript . languageServiceHost . fileExists = path => {
69- if ( path . endsWith ( globalTypesName ) ) {
74+ if ( path . endsWith ( `.vue-global-types/ ${ globalTypesName } ` ) || path . endsWith ( `.vue-global-types\\ ${ globalTypesName } ` ) ) {
7075 return true ;
7176 }
7277 return fileExists ( path ) ;
7378 } ;
7479 project . typescript . languageServiceHost . getScriptSnapshot = path => {
7580 if ( path . endsWith ( `.vue-global-types/${ globalTypesName } ` ) || path . endsWith ( `.vue-global-types\\${ globalTypesName } ` ) ) {
76- if ( ! snapshots . has ( path ) ) {
77- const contents = generateGlobalTypes ( vueCompilerOptions . lib , vueCompilerOptions . target , vueCompilerOptions . strictTemplates ) ;
78- snapshots . set ( path , {
79- getText : ( start , end ) => contents . substring ( start , end ) ,
80- getLength : ( ) => contents . length ,
81- getChangeRange : ( ) => undefined ,
82- } ) ;
83- }
84- return snapshots . get ( path ) ! ;
81+ return globalTypesSnapshot ;
8582 }
8683 return getScriptSnapshot ( path ) ;
8784 } ;
0 commit comments