Script type: Array <Object> vs Object []

In Typescript, what's the difference between these assignments:

var Object[];
var Array<Object>

Do generics in Type Script have the same meanings as languages ​​like Java, or is it just syntactic sugar?

+4
source share
1 answer

It is just sugar. Object[]and Array<Object>exactly match in TypeScript.

One way to verify this is to write this code:

var x: Object[];
var x: Array<Object>;

Duplicate variable declarations must be of exactly the same type, so the absence of an error here means that the types are identical.

+7
source

Source: https://habr.com/ru/post/1614477/


All Articles