@@ -21,37 +21,63 @@ function createLanguage(
2121 const tsconfig = normalizePath ( tsconfigPath ) ;
2222
2323 return createLanguageWorker (
24- ( ) => vue . createParsedCommandLine ( ts , ts . sys , tsconfigPath , true ) ,
25- path . dirname ( tsconfig ) ,
2624 ts ,
25+ ( ) => {
26+ const commandLine = vue . createParsedCommandLine ( ts , ts . sys , tsconfig ) ;
27+ const { fileNames } = ts . parseJsonSourceFileConfigFileContent (
28+ ts . readJsonConfigFile ( tsconfig , ts . sys . readFile ) ,
29+ ts . sys ,
30+ path . dirname ( tsconfig ) ,
31+ { } ,
32+ tsconfig ,
33+ undefined ,
34+ vue . getAllExtensions ( commandLine . vueOptions ) . map ( ( extension ) => ( {
35+ extension : extension . slice ( 1 ) ,
36+ isMixedContent : true ,
37+ scriptKind : ts . ScriptKind . Deferred ,
38+ } ) ) ,
39+ ) ;
40+
41+ return [ commandLine , fileNames ] ;
42+ } ,
43+ path . dirname ( tsconfig ) ,
2744 ) ;
2845}
2946
3047function createLanguageWorker (
31- loadParsedCommandLine : ( ) => vue . ParsedCommandLine ,
32- rootPath : string ,
3348 ts : typeof import ( "typescript/lib/tsserverlibrary" ) ,
49+ getConfigAndFiles : ( ) => [
50+ commandLine : vue . ParsedCommandLine ,
51+ fileNames : string [ ] ,
52+ ] ,
53+ rootPath : string ,
3454) {
35- let parsedCommandLine = loadParsedCommandLine ( ) ;
36- let fileNames = new Set (
37- parsedCommandLine . fileNames . map ( ( fileName ) => normalizePath ( fileName ) ) ,
55+ let [ { vueOptions, options, projectReferences } , fileNames ] =
56+ getConfigAndFiles ( ) ;
57+ let fileNamesSet = new Set (
58+ fileNames . map ( ( fileName ) => normalizePath ( fileName ) ) ,
3859 ) ;
3960 let projectVersion = 0 ;
4061
62+ vueOptions . globalTypesPath = vue . createGlobalTypesWriter (
63+ vueOptions ,
64+ ts . sys . writeFile ,
65+ ) ;
66+
4167 const projectHost : TypeScriptProjectHost = {
4268 getCurrentDirectory : ( ) => rootPath ,
4369 getProjectVersion : ( ) => projectVersion . toString ( ) ,
44- getCompilationSettings : ( ) => parsedCommandLine . options ,
45- getScriptFileNames : ( ) => [ ...fileNames ] ,
46- getProjectReferences : ( ) => parsedCommandLine . projectReferences ,
70+ getCompilationSettings : ( ) => options ,
71+ getScriptFileNames : ( ) => [ ...fileNamesSet ] ,
72+ getProjectReferences : ( ) => projectReferences ,
4773 } ;
4874
4975 const scriptSnapshots = new Map < string , ts . IScriptSnapshot | undefined > ( ) ;
5076
5177 const vueLanguagePlugin = vue . createVueLanguagePlugin < string > (
5278 ts ,
5379 projectHost . getCompilationSettings ( ) ,
54- parsedCommandLine . vueOptions ,
80+ vueOptions ,
5581 ( id ) => id ,
5682 ) ;
5783
@@ -112,31 +138,29 @@ function createLanguageWorker(
112138 const program = tsLs . getProgram ( ) ! ;
113139 const typeChecker = program . getTypeChecker ( ) ;
114140
115- const helpers = createHelpers (
116- language ,
117- program ,
118- parsedCommandLine . vueOptions ,
119- ts ,
120- ) ;
141+ const helpers = createHelpers ( language , program , vueOptions , ts ) ;
121142
122143 return {
123144 ...helpers ,
124145 updateFile ( fileName : string , text : string ) {
125146 fileName = normalizePath ( fileName ) ;
126147 scriptSnapshots . set ( fileName , ts . ScriptSnapshot . fromString ( text ) ) ;
127- fileNames . add ( fileName ) ;
148+ fileNamesSet . add ( fileName ) ;
128149 projectVersion ++ ;
129150 } ,
130151 deleteFile ( fileName : string ) {
131152 fileName = normalizePath ( fileName ) ;
132- fileNames . delete ( fileName ) ;
153+ fileNamesSet . delete ( fileName ) ;
133154 projectVersion ++ ;
134155 } ,
135156 reload ( ) {
136- parsedCommandLine = loadParsedCommandLine ( ) ;
137- fileNames = new Set (
138- parsedCommandLine . fileNames . map ( ( fileName ) => normalizePath ( fileName ) ) ,
157+ [ { vueOptions, options, projectReferences } , fileNames ] =
158+ getConfigAndFiles ( ) ;
159+ vueOptions . globalTypesPath = vue . createGlobalTypesWriter (
160+ vueOptions ,
161+ ts . sys . writeFile ,
139162 ) ;
163+ fileNamesSet = new Set ( fileNames . map ( normalizePath ) ) ;
140164 this . clearCache ( ) ;
141165 } ,
142166 clearCache ( ) {
0 commit comments