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.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Actually, that's not the only source of
any
. Some other sources areObject.entries
,Array.prototype.includes
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 have to enable either
// @ts-check
or somejsconfig.json
/tsconfig.json
settings, as well.No where as convenient as TypeScript's interface IMO. However, a competitor is indeed Flow.