这是我的类型声明:
declare module 'client-types' {
// Request body types
export interface IRequestBody { type: 'request' }
export interface CreateProjectRequestBody extends IRequestBody { cmd: 'otii_create_project' }
export interface GetArcsRequestBody extends IRequestBody { cmd: 'otii_get_devices' }
export interface OpenProjectRequestBody extends IRequestBody { cmd: 'otii_open_project', payload: { value: string, force: boolean, progress: boolean } }
...
// Response types
export interface IResponse {}
export interface CreateProjectResponse extends IResponse { payload: { project_id: number } }
export interface GetArcsResponse extends IResponse { payload: { devices: [ { device_id: number, name: string, type: string } ] } }
export interface OpenProjectResponse extends IResponse { payload: { project_id: string } }
...
// Response data types
export interface CreateProjectResponseData { id: number }
export interface GetArcsResponseData { [index: number]: {id: number, name: string} }
export interface OpenProjectResponseData { id: number }
...
// Types for recurring parts of response data
export interface ResponseDataDevice { device_id: number, name: string, type: string }
...
}
我想为该列表的读者提供更多结构。我应该如何看待这个话题。这是我看到的一些替代方法: