@@ -52,11 +52,16 @@ export function initialize(
52
52
project . vue = { compilerOptions : vueCompilerOptions } ;
53
53
54
54
if ( project . typescript ) {
55
- const globalTypesName = `${ vueCompilerOptions . lib } _${ vueCompilerOptions . target } _${ vueCompilerOptions . strictTemplates } .d.ts` ;
56
55
const directoryExists = project . typescript . languageServiceHost . directoryExists ?. bind ( project . typescript . languageServiceHost ) ;
57
56
const fileExists = project . typescript . languageServiceHost . fileExists . bind ( project . typescript . languageServiceHost ) ;
58
57
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
+ } ;
60
65
if ( directoryExists ) {
61
66
project . typescript . languageServiceHost . directoryExists = path => {
62
67
if ( path . endsWith ( '.vue-global-types' ) ) {
@@ -66,22 +71,14 @@ export function initialize(
66
71
} ;
67
72
}
68
73
project . typescript . languageServiceHost . fileExists = path => {
69
- if ( path . endsWith ( globalTypesName ) ) {
74
+ if ( path . endsWith ( `.vue-global-types/ ${ globalTypesName } ` ) || path . endsWith ( `.vue-global-types\\ ${ globalTypesName } ` ) ) {
70
75
return true ;
71
76
}
72
77
return fileExists ( path ) ;
73
78
} ;
74
79
project . typescript . languageServiceHost . getScriptSnapshot = path => {
75
80
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 ;
85
82
}
86
83
return getScriptSnapshot ( path ) ;
87
84
} ;
0 commit comments