You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
Description
The
GetFile()
function in the codebase references theFile
type. However, due to the presence of theITHit.WebDAV.Client.File
type in the ITHit WebDAV client library, TypeScript resolvesFile
to the library's type instead of the globalFile
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-definedFile
type causes TypeScript to infer incorrectly, leading to type mismatches and confusion.Steps to Reproduce
GetFile()
function located on line 3216 of the codebase.File
resolves toITHit.WebDAV.Client.File
instead of the browser's globalFile
type.Expected Behavior
The
GetFile()
function should reference the globalFile
type provided by the browser, ensuring compatibility with browser APIs and consistent type inference.Actual Behavior
TypeScript resolves
File
toITHit.WebDAV.Client.File
, shadowing the global type. This results in incorrect type inference when handling browserFile
objects in my project.Suggested Fix
Update the
GetFile()
function's return type in theindex.d.ts
file to explicitly reference the globalFile
type and handle cases where no file is returned. For example:This change ensures that any reference to
File
in the library correctly points to the globalFile
type. It prevents downstream consumers from experiencing type shadowing or conflicts.Additional Context
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.Environment
The text was updated successfully, but these errors were encountered: