我有一个从FileWithPath
扩展到File
的接口lib.dom.d.ts
export interface FileWithPath extends File {
readonly path?: string;
}
[在独立库中使用时,可以正常工作,并且可以从lib.dom.d.ts
正确解析类型:
/** Provides information about files and allows JavaScript in a web page to access their content. */
interface File extends Blob {
readonly lastModified: number;
readonly name: string;
}
但是,电子具有冲突的File
类型:
interface File {
/**
* The real path to the file on the users filesystem
*/
path: string;
}
当我在电子项目旁边使用库时,会错误地解析电子类型并给出错误:Interface 'FileWithPath' incorrectly extends interface 'File'.
Property 'path' is optional in type 'FileWithPath' but required in type 'File'
我是否可以在库中进行任何更改以正确指定我要从lib.dom而不是电子中扩展File
?
谢谢!
您可以将此选项添加到tsconfig.json以使此错误发生:
{
compilerOptions: {
skipLibCheck: true
}
}