命名空间中类的 typescript 定义

标签 typescript

如何使用构造函数参数(现有的 javascript 库)为命名空间内的类创建 typescript 定义文件“*.d.ts”。我尝试了几种带有嵌套接口(interface)的模块组合,但到目前为止没有任何效果。

例子:

var instance = new Namespace.TargetClass(arg1, arg2);
instance.someFunc(arg3);

最佳答案

declare module Namespace {
    class TargetClass {
        constructor(arg1: string, arg2: number);
        someFunc(arg3: any): void;
    }   
}

关于命名空间中类的 typescript 定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20318121/

相关文章:

typescript - 在 TypeScript 中将类函数作为参数传递并引用静态成员

typescript - 从对象中获取可选的通用值

javascript - 识别当前 for of 循环迭代 Typescript 中的下一项

typescript - VS Code 中 Vuex 商店的 Intellisense

angular - 如何在 Angular 数据类型上使用 ngSwitch?

node.js - TypeORM 获取多对多关系的一侧

typescript - 为什么 typescript 允许我使用数字作为字符串映射的索引值?

json - 如何将 typescript 定义解析为 json?

html - 动态设置ionic2组件的Style属性

typescript - 尝试在 typescript 项目中使用重新图表时出错