gpt4 book ai didi

typescript - TS2322 : Type  'File'  is not assignable to type  'typeof File'

转载 作者:行者123 更新时间:2023-12-02 17:08:46 24 4
gpt4 key购买 nike

TS2322: Type 'File' is not assignable to type 'typeof File'. Property 'prototype' is missing in type 'File'.

我收到这个错误。我不知道为什么会得到它,也不知道如何解决它。如果有人愿意帮助我,我将不胜感激!

我有这个公共(public)类属性:

registry = File;

getRegistryFile 函数:

private async getRegistryFile(): Promise<File> {
if (this.files === undefined || this.files.length === 0) {
return Promise.reject('No files where returned from the server.');
}

const registryFileName = await this.createRegistryFileName();

this.files.forEach((element) => {
if (element === registryFileName) {
console.log('File registry found.');
return Promise.resolve(element);
}
});
}

我正在构建的函数:

public WorkInProgress(file: File) {
this.getRegistryFile().then((file) => this.registry = file);
}

最佳答案

I have this public class property:

registry = File;

这是 registry 属性的声明,应该有 File 类型吗?那么应该是

registry: File;

或者它是保存 File 类构造函数的属性的初始化?那么它的类型真的是typeof File,不能作为File的实例。

关于typescript - TS2322 : Type  'File'  is not assignable to type  'typeof File' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50374252/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com