DEV Community

Discussion on: This is why I hate Typescript

Collapse
 
djmisterjon profile image
DjMisterJon

TS should using only by IDE to provide good type for vanilla dev.
TS is good if you build API logic.
But is hell for use in project.
Use js+jsdoc if your IDE support.
in most case you get all reference in your project.
If your IDE not understand your js file, add some jsdoc +ts logic.
And if is not work , well , create a .ts file !
But ts is the last choice.

Learn jsdoc plz, this is the good way to doc and make ref to your logic.
/**
* App
* @param {object} props Component props
* @param {React.ReactNode} [props.children] Childrens passed by parents
* @param {function(MouseEvent|React.PointerEvent):void} [props.onChange] - Using function():return
* @param {import('csstype').Property.FlexDirection} [props.FlexDirection] - Using Import()
* @param {React.CSSProperties['flexDirection']} [props.FlexDirection] - Using array ['propkey']
* @param {Container.prototype['props']['orientation']} [props.orientation] - Using componment propTypes
*/

Microsoft with vscode (IDE) work hard to give good jsdoc support mixed with TS logic.
typescriptlang.org/docs/handbook/j...