From 5541617bc80b017a8f7ff0e399be7c2e909ba2f5 Mon Sep 17 00:00:00 2001 From: Forrest Wolf Date: Wed, 25 May 2022 17:22:10 -0400 Subject: [PATCH] Cast results of removeUndefinedProps when neccessary --- common/new-contract.ts | 6 ++---- web/components/answers/answer-resolve-panel.tsx | 2 +- web/lib/firebase/comments.ts | 4 ++-- web/pages/api/v0/_types.ts | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/common/new-contract.ts b/common/new-contract.ts index b70dee37..6c57f876 100644 --- a/common/new-contract.ts +++ b/common/new-contract.ts @@ -42,7 +42,7 @@ export function getNewContract( ? getNumericProps(ante, bucketCount, min, max) : getFreeAnswerProps(ante) - const contract: Contract = removeUndefinedProps({ + return removeUndefinedProps({ id, slug, ...propsByOutcomeType, @@ -71,9 +71,7 @@ export function getNewContract( platformFee: 0, }, manaLimitPerUser, - }) - - return contract as Contract + }) as Contract } /* diff --git a/web/components/answers/answer-resolve-panel.tsx b/web/components/answers/answer-resolve-panel.tsx index 7de19b5d..8a9ea7fe 100644 --- a/web/components/answers/answer-resolve-panel.tsx +++ b/web/components/answers/answer-resolve-panel.tsx @@ -46,7 +46,7 @@ export function AnswerResolvePanel(props: { resolutions: resolveOption === 'CHOOSE_MULTIPLE' ? normalizedProbs : undefined, contractId: contract.id, - }) + }) as {outcome: string, contractId: string, resolutions: {[x: string]: number} | undefined} const result = await resolveMarket(resolutionProps).then((r) => r.data) diff --git a/web/lib/firebase/comments.ts b/web/lib/firebase/comments.ts index e96c080b..d1ebe785 100644 --- a/web/lib/firebase/comments.ts +++ b/web/lib/firebase/comments.ts @@ -30,7 +30,7 @@ export async function createComment( const ref = betId ? doc(getCommentsCollection(contractId), betId) : doc(getCommentsCollection(contractId)) - const comment: Comment = removeUndefinedProps({ + const comment = removeUndefinedProps({ id: ref.id, contractId, userId: commenter.id, @@ -42,7 +42,7 @@ export async function createComment( betId: betId, answerOutcome: answerOutcome, replyToCommentId: replyToCommentId, - }) + }) as Comment return await setDoc(ref, comment) } diff --git a/web/pages/api/v0/_types.ts b/web/pages/api/v0/_types.ts index 355b1973..e45145f9 100644 --- a/web/pages/api/v0/_types.ts +++ b/web/pages/api/v0/_types.ts @@ -94,5 +94,5 @@ export function toLiteMarket(contract: Contract): LiteMarket { isResolved, resolution, resolutionTime, - }) + }) as LiteMarket }