Skip to content

Commit 00d434f

Browse files
fix: jsx should be included for tsx files but not for ts fixed #1359 (#1373)
ts has conflict syntax with casting type. It is valid TS but not valid TSX
1 parent df7b399 commit 00d434f

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/input/dependency.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const smartGlob = require('../smart_glob.js');
88

99
const STANDARD_BABEL_CONFIG = {
1010
compact: false,
11-
parserOpts: { plugins: [...standardBabelParserPlugins, 'flow'] }
11+
parserOpts: { plugins: [...standardBabelParserPlugins, 'flow', 'jsx'] }
1212
};
1313

1414
/**

src/parsers/parse_to_ast.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ const babelParser = require('@babel/parser');
22
const path = require('path');
33

44
const TYPESCRIPT_EXTS = {
5-
'.ts': true,
6-
'.tsx': true
5+
'.ts': ['typescript'],
6+
'.tsx': ['typescript', 'jsx']
77
};
88

99
const standardBabelParserPlugins = [
@@ -14,7 +14,6 @@ const standardBabelParserPlugins = [
1414
'exportDefaultFrom',
1515
'exportExtensions',
1616
'functionBind',
17-
'jsx',
1817
'partialApplication',
1918
['pipelineOperator', { proposal: 'minimal' }],
2019
'throwExpressions'
@@ -29,7 +28,7 @@ function getParserOpts(file) {
2928
plugins: [
3029
...standardBabelParserPlugins,
3130
['decorators', { decoratorsBeforeExport: false }],
32-
TYPESCRIPT_EXTS[path.extname(file || '')] ? 'typescript' : 'flow'
31+
...(TYPESCRIPT_EXTS[path.extname(file || '')] || ['flow', 'jsx'])
3332
]
3433
};
3534
}

0 commit comments

Comments
 (0)