#5468·uppy

Extend FileProgress type to support "already uploaded" files

Author: ninanatorCreated Sep 20, 2024Updated Aug 21, 2026
LabelsBug

Initial checklist

  • I understand this is a bug report and questions should be posted in the Community Forum
  • I searched issues and couldn’t find anything (or linked relevant results below)

Link to runnable example

No response

Steps to reproduce

The existing FileProgress type looks like:

typescript
// FileProgress is either started or not started. We want to make sure TS doesn't
// let us mix the two cases, and for that effect, we have one type for each case:
export type FileProgressStarted = FileProgressBase & {
  uploadStarted: number
  bytesUploaded: number
}
export type FileProgressNotStarted = FileProgressBase & {
  uploadStarted: null
  bytesUploaded: false
}
export type FileProgress = FileProgressStarted | FileProgressNotStarted

However, the Uppy documentation still states (and still appears to support) setting files as already uploaded:

uppy-documentation

Expected behavior

The FileProgress type may need to look more like:

typescript
// FileProgress is either started, not started, or pre-uploaded. We want to make sure TS doesn't
// let us mix the two cases, and for that effect, we have one type for each case:
export type FileProgressStarted = FileProgressBase & {
  uploadStarted: number
  bytesUploaded: number
}
export type FileProgressNotStarted = FileProgressBase & {
  uploadStarted: null
  bytesUploaded: false
}
// Q: should the FileProgressBase be added here? I don't think any of those base values get set in this situation
export type FileProgressPreUploaded = {
  uploadComplete: true
  uploadStarted: true
}

export type FileProgress = FileProgressStarted | FileProgressNotStarted | FileProgressPreUploaded

which would allow me to avoid writing a TypeScript exception and make it clear that this is supported behavior.

Actual behavior

Need to add a @ts-ignore or @ts-expect-error to allow (what appears to be) supported behavior

typescript
uppy.setFileState(fileId, {
  progress: {
    uploadComplete: true,
    // @ts-expect-error Incorrectly typed, allow setting as true
    uploadStarted: true,
  },
});