我的 TypeScript 生成一个 .d.ts 文件。非常适合 TS 项目:
declare function myGlobal(html: string): string;
declare module myHmi {
class bla {
static myStatic(bla: string): string;
}
}
但是其他团队正在使用 JS,并希望使用我们的漂亮类型。他们在项目中有 .d.ts 文件。VS2017 在新的 JS 语言服务 (Salsa) 中检测到它。
var myHmi;
(function (myHmi) {
// Here VS2017 knows myGlobal()
// Here VS2017 detected myHmi as any. So it has no knowledge of myHmi.bla.myStatic()
main code...
})(myHmi || (myHmi = {}));
// Here VS2017 knows myGlobal()
// Here VS2017 knows myHmi.bla.myStatic()
我们可以使用提示(@jsdoc 魔术?)告诉 VS 内部 myHmi 是外部 myHmi 的扩展吗?
编辑:几天后报告为https://github.com/Microsoft/TypeScript/issues/21877