The FileWithPath interface defines both its path and relativePath properties as optional:
|
export interface FileWithPath extends File { |
|
readonly path?: string; |
|
readonly handle?: FileSystemFileHandle; |
|
readonly relativePath?: string; |
|
} |
indicating they could be undefined.
Looking at the implementation of toFileWithPath, however, it looks like there's no code path where either could be undefined. In particular, if file.path isn't already a string, it's set to a variable which is definitely a string by that point. relativePath is unconditionally set to the same variable mentioned above that's definitely a string.
This seems like a bug with the definition of FileWithPath: if neither path nor relativePath can ever be undefined, then marking them as optional isn't accurate.
I came across this as I was trying to figure out which situations could cause path or relativePath to be undefined so I could account for those situations in my web app.
The
FileWithPathinterface defines both itspathandrelativePathproperties as optional:file-selector/src/file.ts
Lines 1233 to 1237 in f159a4a
indicating they could be
undefined.Looking at the implementation of
toFileWithPath, however, it looks like there's no code path where either could beundefined. In particular, iffile.pathisn't already a string, it's set to a variable which is definitely a string by that point.relativePathis unconditionally set to the same variable mentioned above that's definitely a string.This seems like a bug with the definition of
FileWithPath: if neitherpathnorrelativePathcan ever beundefined, then marking them as optional isn't accurate.I came across this as I was trying to figure out which situations could cause
pathorrelativePathto beundefinedso I could account for those situations in my web app.