News for hackers. Stuff that matters.
Re:TypeScript at Google by Vinnl on Sunday September 02, 2018 @04:25AM (#17896168)
Although it's clear that Facebook's libraries, among which React, favour Flow, there's strong community demand for TypeScript even around React. Thus, the type definitions that are available for React are excellent, Redux even includes its type definitions natively, and most of the large tools in the React ecosystem work pretty well with TypeScript.

The main large project you're likely to use that does not really play well with TypeScript yet is create-react-app. There's a TypeScript fork [1] which works reasonably well, but "reasonable" is not really what you'd hope.

That said, the strong community push means that they're at least considering it. [2]

[1] https://github.com/wmonk/create-react-app-typescript [2] https://github.com/facebook/create-react-app/pull/2815

Re:TypeScript at Google by acemarke on Sunday September 02, 2018 @11:06AM (#17897224)
We're actually looking at removing the type definitions from the Redux core and punting them over to DefinitelyTyped, because neither of us primary maintainers use TS ourselves and we don't have the experience to maintain the type definitions.

Also, the CRA-TS fork runs, but the one time I played with it was when I tried to help another team set up their project, and that's when I found out it has _ridiculously_ restrictive default linting rules. Every lint error is a compile error, and it flags things like using arrow functions in render methods, which is absurd (see discussion at https://github.com/wmonk/create-react-app-typescript/issues/... ).

Re:TypeScript at Google by joshtynjala on Sunday September 02, 2018 @06:14PM (#17898975)
The first thing I do in a new CRA-TS project is make the tslint.json rules default to warnings instead. Or just disable them completely. After that, it's great! I'm actually surprised that they still haven't loosened the rules after Dan called it out a month or two ago. Seems like an easy enough fix to at least make them warnings until they choose better defaults.
Re:TypeScript at Google by Vinnl on Sunday September 02, 2018 @04:31PM (#17898496)
Haha right, it's still the case that the type definitions for Redux are very much usable though :)
Re:TypeScript at Google by styfle on Sunday September 02, 2018 @07:49AM (#17896654)
I agree, the TypeScript team loves React and one of the reasons I started using React was because JSX/TSX is one of the few ways to type check views.

I have been maintaining some boilerplate to demonstrate TypeScript + React SSR that should point the reader in the right direction https://github.com/styfle/react-server-example-tsx

Re:TypeScript at Google by ggregoire on Sunday September 02, 2018 @03:36PM (#17898242)
Here is another PR, more recent, based on Babel 7 and its TS support: https://github.com/facebook/create-react-app/pull/4837

I'm waiting it to be merged to switch to TS.

Re:TypeScript at Google by Raphael on Sunday September 02, 2018 @05:23AM (#17896321)
Create React App is the first link that TS gives you in "getting started". Is there something wrong with it?

https://github.com/Microsoft/TypeScript-React-Starter#typesc...

Re:TypeScript at Google by pmoleri on Sunday September 02, 2018 @10:33AM (#17897114)
CRA is a set of packages, among which the most important is react-scripts (contains all build and publish commands). For Typescript you use rect-scripts-ts, a fork that usually is some versions behind the main one.

It does work fine, but sometimes you don't get some of the gooddies that you get in the latest js version.