我有一个像下面这样的抽象类。
export abstract class BaseAPI {
static readonly [key: string]:
| ApiCall<unknown> // Defines a single API call with a generic response type
| { [subKey: string]: ApiCall<unknown> } // Nested API call definitions
| undefined; // Supports optional static members
// Static method example
static myStaticMethod(): string {
return 'This is a static method';
}
}
在类中添加方法后,我收到此打字稿错误...
Property 'myStaticMethod' of type '() => string' is not assignable to 'string' index type 'ApiCall<unknown> | { [subKey: string]: ApiCall<unknown>; } | undefined'.ts(2411)
我该如何处理这个问题?