Stack Overflow Asked on December 13, 2021
interface Itype {
type: number;
name?: string;
}
function makeEqualArrays(arr1: Itype[], arr2: Itype[]): void {
arr2 = arr2.concat([].fill({ type: 2 }, len1 - len2));
}
Why I can not fill array by object?
Type ‘number’ is not assignable to type ‘never’.
You have to type the new array you are creating []
like :
([] as Itype[])
interface Itype {
type: number;
name?: string;
}
function makeEqualArrays(arr1: Itype[], arr2: Itype[]): void {
arr2 = arr2.concat(([] as Itype[]).fill({
type: 2,name
}, 5));
}
Answered by Orelsanpls on December 13, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP