Skip to content

Commit 65dcb06

Browse files
committed
fix(types): narrow unknown fileInput with Record cast after object guard
1 parent b4cfd29 commit 65dcb06

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

  • apps/sim/app/api/tools/file/manage

apps/sim/app/api/tools/file/manage/route.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,14 @@ export const POST = withRouteHandler(async (request: NextRequest) => {
5454
const selectedFileId =
5555
fileId ||
5656
(fileInput && typeof fileInput === 'object' && !Array.isArray(fileInput)
57-
? typeof fileInput.id === 'string'
58-
? fileInput.id
59-
: typeof fileInput.fileId === 'string'
60-
? fileInput.fileId
61-
: ''
57+
? (() => {
58+
const obj = fileInput as Record<string, unknown>
59+
return typeof obj.id === 'string'
60+
? obj.id
61+
: typeof obj.fileId === 'string'
62+
? obj.fileId
63+
: ''
64+
})()
6265
: '')
6366

6467
if (!selectedFileId) {

0 commit comments

Comments
 (0)