News for hackers. Stuff that matters.
Re:Angular 2 Final Released by boubiyeah on Thursday September 15, 2016 @04:42AM (#12504391)
You can totally use typescript with React, in fact it's a game changer. It's actually way more beneficial than with angular, as you have properly typed components all the way down. No crappy string templates that are not checked by typescript.
Re:Angular 2 Final Released by k__ on Thursday September 15, 2016 @04:53AM (#12504435)
True story.

But how did you get rid of the implicit anys when using JSX?

I used this compiler flag that forbids them and suddnendly nothing worked anymore. It seemed that almost everything returned any per default.

Re:Angular 2 Final Released by boubiyeah on Thursday September 15, 2016 @05:11AM (#12504503)
That compiler flag is wonderful, and so is the newer 'strictNullChecks'

I use these typings: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/mast...

Then create my components like this:

interface Props {

}

interface State {

}

class MyComponent extends React.Component<Props, State> {

}

and everything is typed correctly (beside setState which is impossible to type exactly as of today)

Re:Angular 2 Final Released by woah on Thursday September 15, 2016 @07:14AM (#12505004)
How would you do something like this with stateless components? (Where the component is just a function that takes props)
Re:Angular 2 Final Released by cwmoo740 on Thursday September 15, 2016 @09:27AM (#12505916)
interface IMyComponentProps { x: number; }

function MyComponent(props: IMyComponentProps): JSX.Element { return <p>{props.x}</p>; }

Re:Angular 2 Final Released by k__ on Thursday September 15, 2016 @05:58AM (#12504672)
Maybe it was the type definition I used...
Re:Angular 2 Final Released by boubiyeah on Thursday September 15, 2016 @08:07AM (#12505364)
Stateless component:

  interface Props {
    bla: string
    ble: number
  }

  export default function MyComponent({ bla, ble }: Props) {

  }