undefined
06/18/2021, 8:03 AMtype ExampleType {
val1: string;
val2: number;
};
type TargetList = (ExampleType | null)[];
const targetList: TargetList = [{...}, {...}, ...];
const result = targetList.map(({ val1 }) => (...));
이런식으로 쓰려고 하는데 targetList.map
에서 val1
의 타입추론이 안되네요. 이런 경우엔 for
문 써서 빼내는 수밖에 없을까요?Hyeseong Kim
06/18/2021, 8:05 AMtargetList.map(target => {
if (target === null) return null;
const { val1 } = target;
// 여기서 map
})
이우찬
06/18/2021, 8:06 AMundefined
06/18/2021, 8:07 AMHyeseong Kim
06/18/2021, 8:08 AMHyeseong Kim
06/18/2021, 8:08 AMundefined
06/18/2021, 8:13 AM