Re:Convert React JavaScript Code to TypeScript with Proper T...
by ggregoire on Tuesday January 16, 2018 @12:53PM
(#16160241)
The following example written in TS works in Flow too:
type MyComponentProps = {
prop1: string;
prop2?: number;
}
type MyComponentState = {
foo: number;
bar: string;
baz: number;
}
class MyComponent extends Component<MyComponentProps, MyComponentState> {
Same syntax.Also, not sure how this could be more straightforward.
Re:Convert React JavaScript Code to TypeScript with Proper T...
by ralmidani on Tuesday January 16, 2018 @01:00PM
(#16160321)
Thank you. I edited my comment after looking at the Flow website. My incorrect understanding came from seeing the atrocious "block comment Flow annotations" in CoffeeScript 2 (an otherwise adorable language) and thinking that was how you had to specify parameter types with Flow.
Edit: I just took another look. I thought parameters had to be annotated via block comments (that's how you have to do it if using CoffeeScript 2). I was wrong.
[0] http://www.lightscript.org/