Wk-notes-11-21-Add-Typescript
Attempt to add typescript progressively into a js project
Add
.d.ts
, in the js file, using@typedef
and JSDocimport
to refer to the interface/type you defined
/** @typedef {import('./index').InitialState} InitialState */
/** @typedef {import('./index').Props} Props */
Use
@extends
to infer a class, and now you have the type for props and state
/** @extends {PureComponent<Props,InitialState>} */
/** @extends {Component<Props,InitialState>} */
Last updated
Was this helpful?