11import { ensureArray } from '@zardoy/utils'
2- import { getCancellationToken , isTs5 , nodeModules } from './utils'
2+ import { getCancellationToken , isTs5 , isTs5And5 , nodeModules } from './utils'
33import { createLanguageService } from './dummyLanguageService'
44import { getCannotFindCodes } from './utils/cannotFindCodes'
55
@@ -11,8 +11,9 @@ type AdditionalFeatures = Record<'arraysTuplesNumberedItems', boolean>
1111const getPatchedNavModule = ( additionalFeatures : AdditionalFeatures ) : { getNavigationTree ( ...args ) } => {
1212 // what is happening here: grabbing & patching NavigationBar module contents from actual running JS
1313 const tsServerPath = typeof __TS_SEVER_PATH__ === 'undefined' ? require . main ! . filename : __TS_SEVER_PATH__
14+ const typescriptFilePath = `${ nodeModules ! . path . dirname ( tsServerPath ) } /typescript.js`
1415 // current lib/tsserver.js
15- const mainScript = nodeModules ! . fs . readFileSync ( tsServerPath , 'utf8' )
16+ const mainScript = nodeModules ! . fs . readFileSync ( isTs5And5 ( ) ? typescriptFilePath : tsServerPath , 'utf8' )
1617 type PatchData = {
1718 markerModuleStart : string
1819 skipStartMarker ?: boolean
@@ -173,7 +174,7 @@ export const getNavTreeItems = (
173174 fileName : string ,
174175 additionalFeatures : AdditionalFeatures ,
175176) => {
176- if ( ! navModule ) navModule = getPatchedNavModule ( additionalFeatures )
177+ navModule = getPatchedNavModule ( additionalFeatures )
177178 const sourceFile =
178179 ( languageService as unknown as import ( 'typescript-full' ) . LanguageService ) . getNonBoundSourceFile ?.( fileName ) ??
179180 languageService . getProgram ( ) ! . getSourceFile ( fileName )
0 commit comments