Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client.upload TS definition error results in potential "TypeError: Cannot read properties of undefined (reading 'altText')" #574

Open
nawrotw opened this issue Oct 14, 2024 · 1 comment

Comments

@nawrotw
Copy link

nawrotw commented Oct 14, 2024

file src/lib/client.ts
function definition:
upload(file: InputFile, options?: UploadOption...)
TS definition mark options as optional parameter,
however on version v3.33.3, v3.34.3 and current master (2023-10-14) on line 478 we have code:
return upload.upload(file, options.altText);
which will throw
TypeError: Cannot read properties of undefined (reading 'altText')
if options aren't passed.

last proper version: v3.32.3
return upload.upload(file);

Expected Behavior

add ? to return upload.upload(file, options?.altText);
or options assert above

Current Behavior

If options aren't passed error TypeError: Cannot read properties of undefined (reading 'altText') is thrown

@chefhasteeth
Copy link

chefhasteeth commented Oct 23, 2024

I had opened a PR to fix this, but didn't receive any comments or feedback and it wasn't merged. Regardless, it looks like this is now fixed on latest master, so I just closed my PR. In the meantime, the way we fixed it at my work was just to pass an empty object as the second argument, but it appears to be fixed in 3.34.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants