@@ -5,7 +5,23 @@ import { findChildContainingExactPosition } from './utils'
55export default ( proxy : ts . LanguageService , languageService : ts . LanguageService , languageServiceHost : ts . LanguageServiceHost , c : GetConfig ) => {
66 proxy . getDefinitionAndBoundSpan = ( fileName , position ) => {
77 const prior = languageService . getDefinitionAndBoundSpan ( fileName , position )
8- if ( ! prior ) {
8+
9+ if ( c ( 'removeModuleFileDefinitions' ) ) {
10+ prior . definitions = prior . definitions ?. filter ( def => {
11+ if (
12+ def . kind === ts . ScriptElementKind . moduleElement &&
13+ def . name . slice ( 1 , - 1 ) . startsWith ( '*.' ) &&
14+ def . containerKind === undefined &&
15+ ( def as import ( 'typescript-full' ) . DefinitionInfo ) . isAmbient
16+ ) {
17+ return false
18+ }
19+ return true
20+ } )
21+ }
22+
23+ // Definition fallbacks
24+ if ( ! prior || prior . definitions . length === 0 ) {
925 const program = languageService . getProgram ( ) !
1026 const sourceFile = program . getSourceFile ( fileName ) !
1127 const node = findChildContainingExactPosition ( sourceFile , position )
@@ -144,20 +160,6 @@ export default (proxy: ts.LanguageService, languageService: ts.LanguageService,
144160 prior . definitions = prior . definitions . filter ( definition => definition . containerName !== '__VLS_componentsOption' )
145161 }
146162
147- if ( c ( 'removeModuleFileDefinitions' ) ) {
148- prior . definitions = prior . definitions ?. filter ( def => {
149- if (
150- def . kind === ts . ScriptElementKind . moduleElement &&
151- def . name . slice ( 1 , - 1 ) . startsWith ( '*.' ) &&
152- def . containerKind === undefined &&
153- def [ 'isAmbient' ]
154- ) {
155- return false
156- }
157- return true
158- } )
159- }
160-
161163 return prior
162164 }
163165}
0 commit comments