@@ -17,7 +17,7 @@ import { tsConfigLoader } from 'tsconfig-paths/lib/tsconfig-loader'
17
17
18
18
import includes from 'array-includes'
19
19
20
- import { parseConfigFileTextToJson } from 'typescript'
20
+ let parseConfigFileTextToJson
21
21
22
22
const log = debug ( 'eslint-plugin-import:ExportMap' )
23
23
@@ -459,6 +459,10 @@ ExportMap.parse = function (path, content, context) {
459
459
try {
460
460
if ( tsConfigInfo . tsConfigPath !== undefined ) {
461
461
const jsonText = fs . readFileSync ( tsConfigInfo . tsConfigPath ) . toString ( )
462
+ if ( ! parseConfigFileTextToJson ) {
463
+ // this is because projects not using TypeScript won't have typescript installed
464
+ ( { parseConfigFileTextToJson} = require ( 'typescript' ) )
465
+ }
462
466
const tsConfig = parseConfigFileTextToJson ( tsConfigInfo . tsConfigPath , jsonText ) . config
463
467
return tsConfig . compilerOptions . esModuleInterop
464
468
}
@@ -552,7 +556,9 @@ ExportMap.parse = function (path, content, context) {
552
556
const isEsModuleInteropTrue = isEsModuleInterop ( )
553
557
554
558
const exports = [ 'TSExportAssignment' ]
555
- isEsModuleInteropTrue && exports . push ( 'TSNamespaceExportDeclaration' )
559
+ if ( isEsModuleInteropTrue ) {
560
+ exports . push ( 'TSNamespaceExportDeclaration' )
561
+ }
556
562
557
563
// This doesn't declare anything, but changes what's being exported.
558
564
if ( includes ( exports , n . type ) ) {
0 commit comments