TypeScript version 2.4.2, compiled with --target ES6
The line of code:
var coins: { coin: number}[] = [1,1,1]
causes TypeScript to throw
error TS2322: Type 'number[]' is not assignable to type '{ coin: number; }[]'
However, the line:
var coins: { coin: number}[] = Array(3).fill(1)
compiles successfully, without errors.
Is this a TypeScript bug, or is it intended behavior (not type checking an array declared in this manner)?. If so, why?
.fill()is really the stockArray.prototype.fillfunction. When the code runs, it could be anything.