Skip to content

Commit

Permalink
fix: jsx should be included for tsx files but not for ts fixed #1359 (#…
Browse files Browse the repository at this point in the history
…1373)

ts has conflict syntax with casting type. It is valid TS but not valid TSX
  • Loading branch information
anthony-redFox committed Apr 22, 2021
1 parent df7b399 commit 00d434f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/input/dependency.js
Expand Up @@ -8,7 +8,7 @@ const smartGlob = require('../smart_glob.js');

const STANDARD_BABEL_CONFIG = {
compact: false,
parserOpts: { plugins: [...standardBabelParserPlugins, 'flow'] }
parserOpts: { plugins: [...standardBabelParserPlugins, 'flow', 'jsx'] }
};

/**
Expand Down
7 changes: 3 additions & 4 deletions src/parsers/parse_to_ast.js
Expand Up @@ -2,8 +2,8 @@ const babelParser = require('@babel/parser');
const path = require('path');

const TYPESCRIPT_EXTS = {
'.ts': true,
'.tsx': true
'.ts': ['typescript'],
'.tsx': ['typescript', 'jsx']
};

const standardBabelParserPlugins = [
Expand All @@ -14,7 +14,6 @@ const standardBabelParserPlugins = [
'exportDefaultFrom',
'exportExtensions',
'functionBind',
'jsx',
'partialApplication',
['pipelineOperator', { proposal: 'minimal' }],
'throwExpressions'
Expand All @@ -29,7 +28,7 @@ function getParserOpts(file) {
plugins: [
...standardBabelParserPlugins,
['decorators', { decoratorsBeforeExport: false }],
TYPESCRIPT_EXTS[path.extname(file || '')] ? 'typescript' : 'flow'
...(TYPESCRIPT_EXTS[path.extname(file || '')] || ['flow', 'jsx'])
]
};
}
Expand Down

0 comments on commit 00d434f

Please sign in to comment.