Re:First look: adding type annotations to JavaScript
by danielvaughn on Thursday March 10, 2022 @11:20AM
(#30628635)
Yes exactly. There must be some good reason why TS chose the syntax they did, because a lot of it feels very old-school-java.
[ Parent
| on HN ]
Re:First look: adding type annotations to JavaScript
by stasm on Thursday March 10, 2022 @12:11PM
(#30629368)
Type inference is one good reason. Similar syntax exists in a few modern languages, too: e.g. Rust and Swift. In languages with type inference it can be convenient that type annotations are in the postfix position relative to variable names:
let user = new User();
let user: User = new User();