From 18a85050b6a50c5483003895c74b687d1a257462 Mon Sep 17 00:00:00 2001 From: Tobbe Lundberg Date: Wed, 25 Oct 2023 07:39:27 +0200 Subject: [PATCH] RSC: test-project-rsa: Fix TS type error in onSend --- __fixtures__/test-project-rsa/web/src/chat.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/__fixtures__/test-project-rsa/web/src/chat.ts b/__fixtures__/test-project-rsa/web/src/chat.ts index 45602d2fd76c..b2095706ab95 100644 --- a/__fixtures__/test-project-rsa/web/src/chat.ts +++ b/__fixtures__/test-project-rsa/web/src/chat.ts @@ -3,7 +3,13 @@ import { randomWords } from './words' export async function onSend(formData: FormData) { - console.log('message', formData.get('message')) + const message = formData.get('message') + + console.log('message', message) + + if (typeof message !== 'string') { + throw new Error('message must be a string') + } // Locally you could do this: // const words = await fetch( @@ -12,5 +18,6 @@ export async function onSend(formData: FormData) { // But in CI we don't want to hit an external API, so we just do this instead: const words = await randomWords(5) - return { messages: [formData.get('message'), words.join(' ')] } + return { messages: [message, words.join(' ')] } } +