admin管理员组文章数量:1432566
I have a react app with mostly .js files for every ponent. However I would like to use typescript files for a certain group of ponents I am using. Does this cause issues down the road?
I have a react app with mostly .js files for every ponent. However I would like to use typescript files for a certain group of ponents I am using. Does this cause issues down the road?
Share Improve this question asked Jul 25, 2021 at 22:58 AmandaCondaAmandaConda 2434 silver badges18 bronze badges 3- 1 Personally, I prefer to use one certain language, is either to use JavaScript Or TypeScript but it is your opinion at the end but I think there is no problem when you use two languages in the same ReactJS project. – Ghost Commented Jul 25, 2021 at 23:07
- 1 It doesn't cause issues (as TypeScript is essentially a superset of JavaScript), though I'd say it is probably poor practice to use both, as there is really no need to, and you'd have to manage two separate types of files. – Obsidian Age Commented Jul 25, 2021 at 23:08
- 2 Although I agree it would be better to stick to one language, you can save a lot of time by adding TS and keeping your existing JS code (instead of having to rewrite all your JS to TS). – noahro Commented Jul 25, 2021 at 23:12
1 Answer
Reset to default 5TypeScript works well mixed with JavaScript, it shouldn't be a problem to introduce TypeScript while keeping your existing codebase.
I would say it's a good idea to keep your working JavaScript app, and just add new TypeScript ponents. So you don't have to rewrite your already working JS code.
Later on, when you have time, you can always go back and rewrite your JS to TS.
The only problems I've faced doing this is, when you import JavaScript in your TypeScript, the imported types will often be of type any
, which removes the type-safety benefits.
本文标签: javascriptIs it bad convention to use tsx and js files in the same react applicationStack Overflow
版权声明:本文标题:javascript - Is it bad convention to use .tsx and .js files in the same react application? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745577035a2664394.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论