Я пытаюсь найти правильный синтаксис для интерфейса, где массив содержит другой массив. Внешний массив содержит внутренний массив.
Я не ищу логи c в коде
export function deleteNestedArrayItem<U, T<U> >(
outerArray: T[],
outerIndex: number,
innerIndex: number
) {
//code does here
}
Не могу обернуть голову вокруг синтаксиса для обобщенного c <U, T<U> >
.
Связанные структуры данных:
export class Item {
constructor(public title: string, public description: string) {}
}
export class Skill {
constructor(public id: string, public name: Item, public proficiency: number) {}
}
export class Category {
constructor(public id: string, public name: string, public skills: Skill[]) {}
}
Здесь представлены:
const skill1 = new Skill(uuid(), new Item('HTML', ''), 9);
const skill2 = new Skill(uuid(), new Item('TypeScript', ''), 5);
const skill3 = new Skill(uuid(), new Item('Unix', ''), 7);
const skill4 = new Skill(uuid(), new Item('Windows', ''), 9);
const skill5 = new Skill(uuid(), new Item('Illustrator', ''), 9);
const skill6 = new Skill(uuid(), new Item('Latex', ''), 9);
const cat1 = new Category(uuid(), 'Languages', [skill1, skill2]);
const cat2 = new Category(uuid(), 'Operating Systems', [skill3, skill4]);
const cat3 = new Category(uuid(), 'Miscellaneous', [skill5, skill6]);
const initialState: State = {
categoryList: [cat1, cat2, cat3],
};