DEV Community

Discussion on: Is TypeScript the future of web development?

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt • Edited

TypeScript any type is a feature that can work wonders ... but if and only when used properly.

Actually, that's not the only source of any. Some other sources are

  • Non-typed source, where you have to type manually, if you have time -- e.g. API, SQL, deserialization
  • Mistyped. Despite TypeScript team's hard work, sometimes the inferred types are wrong, e.g. tuple, Object.entries, Array.prototype.includes
  • User (or even dev)'s input in Chrome DevTools, or generated JavaScript

IMO, always have to keep in mind, that TypeScript's typing is not perfect, and may lead to false sense of security and reliance on TypeScript's suggestion. Best way is to do testings as if it is JavaScript, and defensive programming / validators, when required (e.g. accepting user's input will always need validation).

No where as strongly typed as a true static typing language, e.g. Kotlin/JS.

You can achieve the same results with JSDoc

You have to enable either // @ts-check or some jsconfig.json / tsconfig.json settings, as well.

No where as convenient as TypeScript's interface IMO. However, a competitor is indeed Flow.