Skip to content

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

Open
@nawrotw

Description

@nawrotw

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions