Typescript电子类型与Dom类型冲突

问题描述 投票:0回答:1

我有一个从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

谢谢!

typescript electron typescript-typings
1个回答
0
投票

您可以将此选项添加到tsconfig.json以使此错误发生:

{
    compilerOptions: {
        skipLibCheck: true
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.