From v18, Node.js the experimental File
interface has been added. It could conflict with DOM’s File
interface in full-stack projects.
Currently, the TypeScript correctly understand which File
means, but the ESLint could complain:
try {
// ESLint: The 'File' is still an experimental feature and is not supported until Node. js 20.0.0.
// The configured version range is '>=16.0.0'
newBase64EncodedFiles = await Promise.all(
newFiles.map(async (file: File): Promise<string> => encodeFileToBase64(file))
);
} catch (error: unknown) {
// ...
}
Besides persuading of ESLint, for the code readability it’s better to specify the full qualified name like NodeJS.File
and Window.File
. However, there is not Window
namespace.