[英]Type '{}' is missing the following properties from type 'IResponseConfig'
[英]Type '{}' is missing the following properties from type ''
enter code here
我現在有一個類型為 any 的屬性。 它調用一個函數,然后在一個對象中返回 2 個字符串。
let datesByMSId: any = await this.entrybyMSId(msId)
日志結果如下所示。
{
start: '2022-07-20T00:00:00.0000000',
end: '2022-07-21T00:00:00.0000000'
}
我試圖定義一個如下所示的接口 DeleteVacationPayload:
export interface DeleteVacationPayload
{
start: string,
end: string
}
當我實現接口時,我得到這個錯誤:
Type '{}' is missing the following properties from type 'DeleteVacationPayload': start, end
這是 entrybyMSId 函數的片段:
request(options, async function (error, response, body) {
if (!error) {
let parsedBody = JSON.parse(body)
let values:Dates = {
start: parsedBody.start.dateTime,
end: parsedBody.end.dateTime
}
resolve(values)
}
}
我真的不明白為什么我會收到這個錯誤。
定義接口時需要使用分號。
嘗試這個:
export interface DeleteVacationPayload {
start: string;
end: string;
}
有關 Typescript 接口的更多信息: https ://www.typescriptlang.org/docs/handbook/interfaces.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.