WIP(ApQuestionService.ts): non-null assertionを消す

エラーメッセージを考える必要がある。
This commit is contained in:
okayurisotto 2023-07-03 07:15:09 +09:00
parent 5e715b2105
commit d0e00c8d17

View File

@ -91,12 +91,14 @@ export class ApQuestionService {
if (question.type !== 'Question') throw new Error('object is not a Question'); if (question.type !== 'Question') throw new Error('object is not a Question');
const apChoices = question.oneOf ?? question.anyOf; const apChoices = question.oneOf ?? question.anyOf;
if (apChoices == null) throw new Error(''); // TODO
let changed = false; let changed = false;
for (const choice of poll.choices) { for (const choice of poll.choices) {
const oldCount = poll.votes[poll.choices.indexOf(choice)]; const oldCount = poll.votes[poll.choices.indexOf(choice)];
const newCount = apChoices!.filter(ap => ap.name === choice)[0].replies!.totalItems; const newCount = apChoices.filter(ap => ap.name === choice).at(0)?.replies?.totalItems;
if (newCount == null) throw new Error(''); // TODO
if (oldCount !== newCount) { if (oldCount !== newCount) {
changed = true; changed = true;