microsoft / microsoft/TypeScript

VS Code Intellisense seems to wrongly infer revealing module pattern

オープン
#18,496 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Domain: JavaScript In Discussion Suggestion VS Code Tracked
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
2日 4時間
マージ済み PR(30日)
132

説明

From @lodybo on September 12, 2017 9:44

  • VSCode Version: 1.16.0
  • OS Version: Windows 10

Steps to Reproduce:

  1. Copy the code below into a file called greeter.js
  2. Run node greeter.js in a terminal
var Greeter = (function(country) {
  // Private
  this.country = country;

  function getCountry() {
    return country;
  }
  
  // Public
  var performGreeting = function (name) {
    var country = getCountry();
    
    return 'Hello ' + name + ', from ' + country;
  }
  
  return {
    greet: performGreeting
  }
});

var greeter = new Greeter("The Netherlands");
console.log(greeter.greet("Lody"));
console.log(greeter.country);

Using the revelealing module pattern in VS Code seems to trip up Intellisense into suggesting the wrong members. The code above was tested in multiple browsers and consoles and run with Node v6.3.0 which behaved as expected. They ran the greet() function and returned undefined for greeter.country:

λ node greeter.js
Hello Lody, from The Netherlands
undefined

But VS Code's Intellisense reports that greeter only contains country:
image

It also reports the expected interface of greeter for the class itself (Greeter):
image

What is expected is VS Code correctly inferring greeter.greet to be a function of Greeter, with a parameter name.

This was reproduced in a clean folder of VS Code, with no extensions (launched with code --disable-extensions), and no jsconfig.json.

Copied from original issue: Microsoft/vscode#34214

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、VS Code IntelliSense で提供されている greeter.js の例を使って問題を再現し、推論されたメンバーを Node.js の出力と比較します。IntelliSense が greeter.greet を name を受け取る関数として識別し、country をパブリックメンバーとして公開しなければ、作業は完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, vscode
領域
devtools
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
42/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。