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
File resolves to ITHit.WebDAV.Client.File instead of the browser's global File type.
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
File type 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
Description
The
GetFile()function in the codebase references theFiletype. However, due to the presence of theITHit.WebDAV.Client.Filetype in the ITHit WebDAV client library, TypeScript resolvesFileto the library's type instead of the globalFiletype provided by the browser.In my codebase, I am receiving objects of the global
Filetype (e.g., from file uploads or other browser APIs). However, the library-definedFiletype causes TypeScript to infer incorrectly, leading to type mismatches and confusion.Steps to Reproduce
GetFile()function located on line 3216 of the codebase.Fileresolves toITHit.WebDAV.Client.Fileinstead of the browser's globalFiletype.Expected Behavior
The
GetFile()function should reference the globalFiletype provided by the browser, ensuring compatibility with browser APIs and consistent type inference.Actual Behavior
TypeScript resolves
FiletoITHit.WebDAV.Client.File, shadowing the global type. This results in incorrect type inference when handling browserFileobjects in my project.Suggested Fix
Update the
GetFile()function's return type in theindex.d.tsfile to explicitly reference the globalFiletype and handle cases where no file is returned. For example:This change ensures that any reference to
Filein the library correctly points to the globalFiletype. It prevents downstream consumers from experiencing type shadowing or conflicts.Additional Context
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.Environment