1
- import TsServerLibrary , { CodeFixAction , ScriptElementKind } from 'typescript/lib/tsserverlibrary' ;
2
1
import * as namespaceImportPlugin from './lib/import' ;
3
2
4
3
declare global {
@@ -9,7 +8,7 @@ declare global {
9
8
}
10
9
}
11
10
12
- function init ( { typescript : ts } : { typescript : typeof TsServerLibrary } ) {
11
+ function init ( ) {
13
12
function create ( info : ts . server . PluginCreateInfo ) {
14
13
const log = ( ...params : unknown [ ] ) => {
15
14
const text = params . map ( ( p ) => ( p ? JSON . stringify ( p ) : p ) ) . join ( ' ' ) ;
@@ -27,18 +26,17 @@ function init({ typescript: ts }: { typescript: typeof TsServerLibrary }) {
27
26
}
28
27
29
28
original . entries = [ ...original . entries , ...namespaceImportPlugin . getCompletionEntries ( info ) ] ;
30
-
31
29
return original ;
32
30
} ;
33
31
34
32
const getCompletionEntryDetails = info . languageService . getCompletionEntryDetails ;
35
33
info . languageService . getCompletionEntryDetails = ( fileName , position , name , options , source , preferences , data ) => {
36
34
log ( 'getCompletionEntryDetails' , { fileName, position, name, options, source } ) ;
37
- if ( data ?. modulePath ) {
38
- return namespaceImportPlugin . getCompletionEntryDetails ( name , fileName , data . modulePath ) ;
35
+ if ( data ?. modulePath == null ) {
36
+ return getCompletionEntryDetails ( fileName , position , name , options , source , preferences , data ) ;
39
37
}
40
38
41
- return getCompletionEntryDetails ( fileName , position , name , options , source , preferences , data ) ;
39
+ return namespaceImportPlugin . getCompletionEntryDetails ( name , fileName , data . modulePath ) ;
42
40
} ;
43
41
}
44
42
0 commit comments