DEV Community

Discussion on: What are some concepts in TypeScript that you'd like to know more about?

Collapse
 
stargator profile image
Stargator

Why the type definitions are on the right after a : instead of on the left where final, let, var are used? What was the reasoning behind that.

Collapse
 
nickytonline profile image
Nick Taylor

TypeScript is a superset of JavaScript, i.e. any valid plain JavaScript is also TypeScript and the types can be optional depending on how strict you make TypeScript in your project, so my guess would be that since they're optional, it's probably easier to parse the Abstract Syntax Tree (AST) when it's var/let/const variableName : SomeType vs. var/let/const SomeType : variableName. I know that @nektro is big into programming language design and is a fan of TS as well, so she might have some more insight into this as well.

Collapse
 
nektro profile image
Meghan (she/her) • Edited

Some feel it helps readability but Nick is right in that it also lies in that the type indicators for languages that put the type on the right are optional because the language has type inference.

You can read more about it here in a discussion I had a little while back