IceAge2OnDVD
IceAge2OnDVD
Explore posts from servers
TTCTheo's Typesafe Cult
Created by IceAge2OnDVD on 6/12/2023 in #questions
Whats going on with these type errors? (Challenge, TSPlayground Included)
No mater how hard I try I can't seem to fix these Typescript errors. Tbh I'm not much of a typescript wizard and I've mostly been guessing at the types, any pointers in the right direction would be greatly appreciated. I seem to fix one error and three more pop up 🤦‍♂️ Playground (Test-cases & example included): https://tsplay.dev/Wzxn2N The aim of the function is to turn an array of objects with a sibling relationship to one with a parent-child relationship. The example input & output in the TSPlayground should make it clearer. Currently the function works, its just the types are strange.
// This
[
{
keyA: objA,
keyB: objB
},
{
keyA: objA,
keyB: objC
},
{
keyA: objA,
keyB: objD
},
]
// To
[
{
...objA,
allKeyBs: [objB, objC, objD]
}
]
// This
[
{
keyA: objA,
keyB: objB
},
{
keyA: objA,
keyB: objC
},
{
keyA: objA,
keyB: objD
},
]
// To
[
{
...objA,
allKeyBs: [objB, objC, objD]
}
]
13 replies