This repository was archived by the owner on Jan 26, 2019. It is now read-only.
This repository was archived by the owner on Jan 26, 2019. It is now read-only.
Cannot mix JS and TS in a single project #266
Closed
Description
Is this a bug report?
Yes.
Can you also reproduce the problem with npm 4.x?
Yes
Which terms did you search for in User Guide?
"Mix JS and TS"
Environment
npm ls react-scripts-ts
(if you haven’t ejected): 2.13.0node -v
: 9.6.1npm -v
: 5.6.0yarn --version
(if you use Yarn):
Then, specify:
- Operating system: Windows 10 (Insider Fast 17107)
- Browser and version (if relevant): N/A
Steps to Reproduce
(Write your steps here:)
- Run
create-react-app my-app --scripts-version react-scripts-ts
- Rename
/my-app/src/App.tsx
toApp.js
- Run
npm run build
Expected Behavior
It should compile successfully. We should be able to write apps mixed with JSX and TSX. That's why in tsconfig.json
, we set jsx
to react
.
Actual Behavior
It failed with:
./src/App.js
Module parse failed: C:\Users\JohnDoe\Source\Repos\my-app\node_modules\source-map-loader\index.js!C:\Users\JohnDoe\Source\Repos\my-app\src\App.js Unexpected token (9:6)
You may need an appropriate loader to handle this file type.
| render() {
| return (
| <div className="App">
| <div className="App-header">
| <img src={logo} className="App-logo" alt="logo" />
This StackOverflow answer have some insights into the problem, by using react-app-rewired
. By running thru JS/X files with Babel (without eject).
Reproducible Demo
(Paste the link to an example project and exact instructions to reproduce the issue.)
Metadata
Metadata
Assignees
Labels
No labels