@@ -6,7 +6,7 @@ export default (proxy: ts.LanguageService, languageService: ts.LanguageService,
66 proxy . getDefinitionAndBoundSpan = ( fileName , position ) => {
77 const prior = languageService . getDefinitionAndBoundSpan ( fileName , position )
88
9- if ( c ( 'removeModuleFileDefinitions' ) ) {
9+ if ( c ( 'removeModuleFileDefinitions' ) && prior ) {
1010 prior . definitions = prior . definitions ?. filter ( def => {
1111 if (
1212 def . kind === ts . ScriptElementKind . moduleElement &&
@@ -21,7 +21,7 @@ export default (proxy: ts.LanguageService, languageService: ts.LanguageService,
2121 }
2222
2323 // Definition fallbacks
24- if ( ! prior || prior . definitions . length === 0 ) {
24+ if ( ! prior || prior . definitions ? .length === 0 ) {
2525 const program = languageService . getProgram ( ) !
2626 const sourceFile = program . getSourceFile ( fileName ) !
2727 const node = findChildContainingExactPosition ( sourceFile , position )
@@ -156,8 +156,22 @@ export default (proxy: ts.LanguageService, languageService: ts.LanguageService,
156156 return true
157157 } )
158158 }
159+
159160 if ( c ( 'removeVueComponentsOptionDefinition' ) && prior . definitions ) {
160- prior . definitions = prior . definitions . filter ( definition => definition . containerName !== '__VLS_componentsOption' )
161+ const program = languageService . getProgram ( ) !
162+ const sourceFile = program . getSourceFile ( fileName ) !
163+
164+ const lines = sourceFile . getFullText ( ) . split ( '\n' )
165+ const { line : curLine } = ts . getLineAndCharacterOfPosition ( sourceFile , position )
166+
167+ const VLS_COMPONENT_STRING = `__VLS_templateComponents`
168+ const isTemplateComponent = lines [ curLine ] ?. startsWith ( VLS_COMPONENT_STRING )
169+ if ( ! isTemplateComponent ) return
170+
171+ const componentName = lines [ curLine ] ?. match ( / \. ( \w + ) ; ? / ) ?. [ 1 ]
172+ if ( ! componentName ) return
173+
174+ prior . definitions = prior . definitions . filter ( ( { name } ) => ! ( componentName === name && lines [ curLine - 2 ] === '// @ts-ignore' ) )
161175 }
162176
163177 return prior
0 commit comments