【问题标题】:VS 2017 Intellisense for parameters of closures with javascriptVS 2017 Intellisense 用于使用 javascript 的闭包参数
【发布时间】:2018-07-19 02:25:34
【问题描述】:

我的 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

【问题讨论】:

    标签: javascript typescript visual-studio-2017 jsdoc languageservice


    【解决方案1】:

    我得到了微软的答复。这有效:

    (function (myHmi) {
        // Here VS2017 knows myGlobal()
        // Here VS2017 knows myHmi.bla.myStatic()
    
        main code...
    
    })(myHmi);
    
    // Here VS2017 knows myGlobal()
    // Here VS2017 knows myHmi.bla.myStatic()
    

    【讨论】:

      猜你喜欢
      • 2021-09-11
      • 1970-01-01
      • 2018-01-17
      • 2019-08-04
      • 1970-01-01
      • 2017-08-03
      • 2018-09-27
      • 1970-01-01
      • 2018-03-11
      相关资源
      最近更新 更多