4 ms·
Was that additional syntax in TypeScript actually neccessary for type inferrence? Or is it rather to avoid API hazards when you change some internal code and su
by est31 7y ago
Was that additional syntax in TypeScript actually neccessary for type inferrence? Or is it rather to avoid API hazards when you change some internal code and suddenly the API of your library breaks because the inferred type has changed.
- idle_zealot 7y agoYou can use TypeScript in a mode that only uses type inference and doesn't require type annotations or definitions. It works surprisingly well.
- matt_kantor 7y agoAdditionally, TypeScript will parse JSDoc comments into type annotations: https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html#jsdoc-types-are-used-for-type-information https://www.typescriptlang.org/docs/handbook/type-checking-j...
- loxs 7y agoIt is necessary because of some limitations, but IMO it's also a great idea nonetheless. Types' names are a great documentation, one which you can't get with pure inference. Even languages that have (close to) the best possible inference, like OCaml, still have additional syntax for defining types, because it 1. gives you documentation and 2. allows you to do things that are mathematically proven to be impossible via inference. TS is great, and also moving really fast and becoming better every 2-3 months.