在node.d.ts中,它声明为
declare module "util" {
export function inspect(object: any, showHidden?: boolean, depth?: number | null, color?: boolean): string;
export function inspect(object: any, options: InspectOptions): string;
}所以我不能扩展它
我试过了
declare module 'util' {
export interface inspect {
defaultOptions: InspectOptions;
}
}但是它一直在错误地运行Property 'defaultOptions' does not exist on type '{ (object: any, showHidden?: boolean, depth?: number, color?: boolean): string; (object: any, opt...'.
发布于 2017-10-11 14:32:05
使用namespace扩展函数。
并且它已经在@type/节点中修复了。
https://stackoverflow.com/questions/46596485
复制相似问题