DEV Community

Discussion on: What ever happened to putting the object type on the left?

Collapse
 
sammyisa profile image
Sammy Israwi

I used to think that it was normal and preferred to have types definitions on the left of the variable or function name, I think it may be because of the languages that I learned to program with at first (C, C++, Java).

But as I started to work with TypeScript it became easier to read type definitions on the right. For variables, I read them as "X is of type Y", for functions "Function A returns type B" but that may have more to do with conditioning after TypeScript.

As of the reason, when I first saw type definition on the right was in TypeScript. Back then, I thought it may be a limitation of the language since it was a wrapper around JavaScript, but I have nothing but a gut feeling to back that up.

Collapse
 
ben profile image
Ben Halpern

This makes sense