我在 af 模塊中有這個函式宣告:
declare module 'picoapp' {
export function component(node?: HTMLElement): void
}
然后在.ts檔案中像這樣使用它
export default component((node: HTMLElement) => {
// All sorts of TS/JS here
})
但VSCode給了我這樣的警告:Argument of type '(node: HTMLElement) => void' is not assignable to parameter of type 'HTMLElement'。
那么函式的回傳型別應該是什么?我沒有回傳值,而只是使用節點作為參考。
uj5u.com熱心網友回復:
如果您的組件函式的使用是正確的,則型別應宣告如下,其中回呼可以是您喜歡的任何名稱。
declare module 'picoapp' {
export function component(callback:(node?: HTMLElement)=>void): void
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/375621.html
上一篇:如何序列化可觀察陣列的執行
下一篇:等到內心的承諾完成
