Comments (4)
Thank you @wmonk for the answer. In the meantime I managed to rename everything in my project to .ts / .tsx and types. Since my project was not to big yet that was doable.
As I understand it the option allowJs=true in tsconfig.json should theoretically allow to just "do a quick sanity check" on .js files and otherwise pass them through to the output folder to allow for a smooth transition. It didn't work for me though. But wouldn't that theoretically be an option for people wanting to add the benefits of typescript without the pain of having to rename / add types to everything in an existing project?
After all it is a great addition (imho) to have the types around. It already helped me catch and understand a couple of issues with my code.
Thanks again @wmonk for making using ts with react-scripts possible.
from create-react-app-typescript.
Hi @michabu, no problem 😄 !
You are correct, react-scripts-ts
will not compile js or jsx files. You can see in this commit that babel-loader was removed from the webpack config. You are still able to require js files, but they will not be run through babel. I suppose the reason for this is to keep the package as slim as possible, if you're writing typescript, it's unlikely you need the babel transpiler as well. I think CRA promotes starting new projects, rather than retrofitting into old projects.
If you want to add back in the babel loader, you can run npm run eject
, and then update the webpack config yourself. Be warned, this is a permanent action! However, you could do something clever with git, wherein you eject, update the config, and commit in one go. Then to use react-scripts-ts
again in the future, you could revert that commit. I've not tried this myself, and is only a thought, so take it with a pinch of salt 😄
from create-react-app-typescript.
@michabu, glad you got it sorted! Not sure about getting it to work incrementally, I suppose updating the webpack config should be enough though.
from create-react-app-typescript.
@wmonk sorry for commenting on an old bug, but i didnt want to create a new one. we are looking at migrating a big jsx project to tsx as well. and we would love to use your infrastructure. is it not possible to have babel as an optional dependency (or some other way to run jsx ) ?
having a large single cutover is going to be extremely hard for a lot of projects like us.
from create-react-app-typescript.
Related Issues (20)
- Browserlist error
- CRA 2.0 HOT 31
- Include nodejs v8 for for Travis CI build
- Remove dependency on babel HOT 2
- Using jest-extended? HOT 1
- Husky hooks not working HOT 1
- Update webpack-dev-server HOT 10
- Add documentation detailing differences between CRA 2.0 and CRA-TS HOT 10
- Source Maps don't work for `js` or `jsx` files in live dev mode.
- Version 4.0.8: Internet Explorer no working anymore HOT 2
- Build process is almost 20 minutes long HOT 1
- postcss support? HOT 1
- Why is Jest's version hard coded to "20.0.4"? HOT 1
- Jest doesn't work when I add lint-staged
- Maintenance
- Tslint rules are barriers to entry HOT 2
- [Help] Compatibility IE + Firefox old versions problems
- Are 4.X.X versions are legit? HOT 1
- Jest doesn't resolve absolute paths from tsconfig HOT 1
- npm start dont work on freeBSD
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from create-react-app-typescript.