Commit f1adc53
committed
fix(build): pnpm build报错Error: src/components/score/ScoreCard.tsx(111,45): error TS18048: 'payload.scores' is possibly 'undefined'.
问题原因是 TypeScript 的类型收窄(narrowing)无法穿透到 .filter() 的回调闭包中。改为把 payload.scores 提前存入局部变量 scores,收窄后的类型在整个函数作用域内都有效。1 parent fdb79e5 commit f1adc53
1 file changed
Lines changed: 5 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
| 106 | + | |
106 | 107 | | |
107 | 108 | | |
108 | 109 | | |
109 | 110 | | |
110 | | - | |
111 | | - | |
| 111 | + | |
| 112 | + | |
112 | 113 | | |
113 | 114 | | |
114 | | - | |
| 115 | + | |
115 | 116 | | |
116 | 117 | | |
117 | 118 | | |
| |||
0 commit comments