DEV Community

Tomohiko Himura
Tomohiko Himura

Posted on

3 1 1

create-react-appのTypeScript対応方法について調べた - How create-react-app supports TypeScript

Summary

  • use @babel/preset-typescript through @babel/preset-react-app
  • type checking within webpack using ForkTsCheckerWebpackPlugin

Motivation

  1. TypScriptでReactするおすすめの方法はなんだろう
  2. ReactのサイトにTypeScriptの使い方って載ってない
  3. create-react-appのドキュメントにはある
  4. どんな設定になっているんだろう?

Detail

v3.2.0で確認

感想

確認はしてないが、tscをつかうより@babel/plugin-transform-typescriptを使うほうがトランスパイルするのは早そうに感じる。すべての文法に対応しているかどうかわからない点が気になるといえば気になるが、型チェックのみTypeScriptを使うのはクリーンで良さそう。
babelを利用した場合は型チェックはされないがどうしているか確認したらForkTsCheckerWebpackを利用しているだけだった。ts-loaderを利用する場合もこちらをつかって、型チェックするほうが効率的な気がする。(未確認)

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay