Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typescript for Facebook React

I've been looking into React lately and was hoping to use JSX and typescript. I haven't been able to find any resources on this or type definitions for React.

Can you use Typescript with JSX and are type definitions available?

like image 905
Michael Coleman Avatar asked Dec 11 '13 19:12

Michael Coleman


People also ask

Does Facebook use TypeScript with react?

Yes, sure. Take a look at the React + TypeScript quick start guide .

Should I use TypeScript?

In terms of software development, TypeScript offers many advantages over JavaScript: Optional static typing. JavaScript is a dynamically typed language, which means that types are checked, and data type errors are only detected at runtime. This can be very dangerous and can create errors during production.


3 Answers

The React team is currently discussing making Typescript annotations an internally used thing. This may be changing on the official for you, soon.

like image 56
John Haugeland Avatar answered Oct 13 '22 05:10

John Haugeland


React jsx will be available in upcomming TypeScript 1.6. Here's more info.

like image 6
shadeglare Avatar answered Oct 13 '22 06:10

shadeglare


François de Campredon created a type definition for React: https://github.com/fdecampredon/react-observe-todomvc/blob/typescript/src/declarations/react.d.ts

It does not support JSX obviously, since it is another language with a syntax different from TypeScript.

like image 4
thSoft Avatar answered Oct 13 '22 07:10

thSoft