Why push shows argument of type 'any[]' is not assignable to parameter of type 'never' error? Why push shows argument of type 'any[]' is not assignable to parameter of type 'never' error? typescript typescript

Why push shows argument of type 'any[]' is not assignable to parameter of type 'never' error?


Change this :

const a = [];

By this :

const a = Array();


With var markers: [] you are declaring the markers array as having the type of a permanently empty array. You probably meant var markers = [] to initialize it to empty but allow items to be added.


The never type is a subtype of, and assignable to, every type; however, no type is a subtype of, or assignable to, never (except never itself). Even any isn’t assignable to never.

From the TypeScript docs