-
Notifications
You must be signed in to change notification settings - Fork 9
Description
Description
The GetFile() function in the codebase references the File type. However, due to the presence of the ITHit.WebDAV.Client.File type in the ITHit WebDAV client library, TypeScript resolves File to the library's type instead of the global File type provided by the browser.
In my codebase, I am receiving objects of the global File type (e.g., from file uploads or other browser APIs). However, the library-defined File type causes TypeScript to infer incorrectly, leading to type mismatches and confusion.
Steps to Reproduce
- Inspect the
GetFile()function located on line 3216 of the codebase. - Note that
Fileresolves toITHit.WebDAV.Client.Fileinstead of the browser's globalFiletype.
Expected Behavior
The GetFile() function should reference the global File type provided by the browser, ensuring compatibility with browser APIs and consistent type inference.
Actual Behavior
TypeScript resolves File to ITHit.WebDAV.Client.File, shadowing the global type. This results in incorrect type inference when handling browser File objects in my project.
Suggested Fix
Update the GetFile() function's return type in the index.d.ts file to explicitly reference the global File type and handle cases where no file is returned. For example:
GetFile(): globalThis.File | null; This change ensures that any reference to File in the library correctly points to the global File type. It prevents downstream consumers from experiencing type shadowing or conflicts.
Additional Context
- The global
Filetype is a key part of my codebase, as it is used to handle files from user inputs (e.g.,<input type="file">) and other browser APIs. - The shadowing issue has caused confusion and type mismatches, requiring workarounds that could be avoided with the proposed fix.
Environment
- TypeScript Version: 5.5.3
- Library: ITHit WebDAV Client v5.21.6001.0