In Typescript what is the difference between these assignments:
var Object[];
var Array<Object>
Does generics in Type Script has the same semantic meaning as in languages like Java or is it simply syntactic sugar?
It's just sugar. Object[]
and Array<Object>
are exactly the same in TypeScript.
One way to check this is to write this code:
var x: Object[];
var x: Array<Object>;
Duplicate variable declarations must have exactly the same type, so the lack of error here implies that the types are identical.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With