Wk-notes-11-21-Add-Typescript
Attempt to add typescript progressively into a js project
Add
.d.ts, in the js file, using@typedefand JSDocimportto refer to the interface/type you defined
/** @typedef {import('./index').InitialState} InitialState */
/** @typedef {import('./index').Props} Props */Use
@extendsto 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?