Optional static typing
DefinitelyTyped @types
Enhanced IDE support
Documenting code through types
Code easier to refactor
Why?
Types can be used as documentation
Good IDE support directly affect dev speed
Types can help catch bugs faster and thus develop features faster
TypeScript types as documentation
--checkJs
/** @type {number | undefined} */
let x;
/** @param {...number} args */
function sum(/* numbers */) {
// ...
}
import { Component } from "react";
/**
* @augments {Component<{a: number}, State>}
*/
class MyComponent extends Component {
render() {
// ...
}
}
You may already have them in some places
Rename all files to .ts
Loose settings
Strict settings
Generate .d.ts files for your untyped files
This trade-off comes with a price -- you'll see a lot of anys
(...)
dts-gen is meant to be a starting point for writing a high-quality definition file.
No types in Button.js
Strict settings
Use --allowJs
Gradually convert files from JS to TS
❗️It may take some time to see all the TypeScript benefits
*or don't spend time on stupid bugs
JavaScript file
Same day as beta release
Pagination should be there
Feb
First
conversations
Decision to go with TypeScript
Added TS support
March
April
May
June
20+ outisde contributions
More contributions
First big feature in TS
217 (!) files
Comparison with other langs:
https://hasura.io/blog/why-we-chose-typescript-for-hasura-console/
We still need help: https://github.com/hasura/graphql-engine/issues/4314