r/reactjs • • Oct 10 '18

Featured Typescript - people's thoughts.

I have just started looking at typescript with react. So far it is a bit painful with all the errors, but I understand at the beginning of learning anything things can be slightly painful.

The main purpose of this post is what people here think of typescript. Is it just as useful/better to use flow/or prop types (if equivalent)? What are the pros/cons.

Also, I have been told by a colleague if you are writing your project in typescript and wish to use a third party library that isn't written in typescript this would cause errors. Is this also true?

Also, have people found that when creating a standard react setup with redux and some react dev tool extensions that this can lead to lots of errors and tends to make things a bit painful?

Also, have had issues with importing files as it says Imports should be capitalized. I assume this is a linter setting in create-react-app. Have people decided to disable certain ts linting?

14 Upvotes

37 comments sorted by

View all comments

Show parent comment

1

u/flanaganpete Oct 10 '18

thanks! Left an example below addressing Mark's comment. Also, have had issues with importing files as it says Imports should be capitalized. I assume this is a linter setting in create-react-app. Have you decided to disable certain ts linting?

1

u/scottbob3 Oct 11 '18

Looks like /u/acemarke 's comment is spot on, personally for linters I just cheat and grab AirBnb's Eslint rules. They seems to be everyone's favorite.

2

u/acemarke Oct 11 '18

I used to like Airbnb's config, but it's gotten horribly restrictive over the last couple years as well, so I now advise against using it.

Personally, I'd suggest using eslint-config-react-app , which just warns about things that are actually likely to cause bugs, and use something like Prettier to handle any formatting concerns.