TypeScript version 2.4.2 compiled with --target ES6
Line of code:
var coins: { coin: number}[] = [1,1,1]
calls TypeScript to quit
error TS2322: Type 'number []' is not assigned to type '{coin: number; } [] '
However, the line:
var coins: { coin: number}[] = Array(3).fill(1)
compiles successfully without errors.
Is this a TypeScript error, or is this the intended behavior (and not a check of the type of the array declared in this way)? If so, why?
source
share