【发布时间】:2020-07-17 19:14:15
【问题描述】:
如何使用接口在下面键入函数的参数并保持它们干净(没有 Typescript)?
// external file
export interface TSomeFunctionArgs {
someKey: string
// also here should be a type for a function
}
// main file
import { TSomeFunctionArgs } from "pathToFile"
const someFunction = (args: TSomeFunctionArgs) => {
// ... function's logic
}
someFunction({ someKey: "some string" }, someAnotherFunction)
在我的示例中,我传递了两个参数,第一个是具有特定键值对的对象,第二个是函数(可以是任何函数)。
如何在上面的界面中描述?
【问题讨论】:
标签: javascript typescript