'Create File object type in TypeScript

I have a function that should only accept JS File objects.

How do I create that type in TypeScript?

edit: sharing my tsconfig.json

{
"compilerOptions": {
    "outDir": "./ts-dist/",
    "sourceMap": true,
    "noImplicitAny": true,
    "module": "commonjs",
    "target": "es6",
    "jsx": "react",
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "lib": [
        "dom",
        "es2017"
    ]
},
"include": [
    "./src/**/*", "./test/**/*"
],
"exclude": [
    "node_modules", "dist"
]
}


Solution 1:[1]

TypeScript has a defined interface for File which represents the file object in JavaScript. Generally you should look for types named as their Javascript countertypes. You can use this type in a parameter annotation for the parameter:

function processFile(file: File) {
    
}

Source: microsoft/TypeScript

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nikita Fedyashev