microsoft / microsoft/TypeScript
jsconfig.json gives broken intellisense for js files with module.exports
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
- VSCode Version: 1.38.0
- TS Version: 3.6.2
- OS Version: Ubuntu 18.04 LTS bionic beaver
- Tested with no extensions
- Can not really find a solution to this problem after a lot of searching
I have a personal js library that I use both in browser-side and node-side for a lot of my personal projects . In fact the library itself has its own project . The js library looks like this :
const library = {};
library.foo = function() {/*browser code*/}
if (typeof module === 'object') {
library.bar = function() {/*node code*/}
module.exports = library;
}
For a browser project (library is used via script tag) If I try to get intellisense via jscofig.json for such a file I get broken intellisense (by typing f or b I get suggestions for foo or bar respectively , but there is no library suggestion when I type l , and even if I type library I get no suggestion about its properties ) .
For a node project everything works fine regarding intellisense using require .
The issue here is with module.exports . If I change it to var substitute = module; substitute.exports = library; then I get intellisense for browser project via jsconfig.json but broken intellisense (as described before) for node via require .
How can I get intellisense to work for both require and jsconfig.json ?
Before you attempt to check intellisense you should know the following :
I open index.js in a project that does not have any other js file and no
jsconfig.jsonfile . Then I view in the same VScode session some other , completely unrelated to my project , js files . For whatever file I view I get intellisense (of the globally scoped variables that have been defined vialet,varorconst) when I am editing index.js . If the unrelated js file happens to have module.exports then the intellisense that I get in index.js for that file is broken like it has been described before .
I stop getting intellisense for files that I view when I create ajsconfig.jsonfile file in the folder of index.js . But still there is the same broken behavior with intellisense for files that are included viajsconfig.jsonand have module.exports .
Please restart vscode to test if intellisense really works .
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
示されている index.js、jsconfig.json、ブラウザーでの使用方法、および Node の require の使用方法を使って、VSCode 1.38.0 と TypeScript 3.6.2 での動作を再現します。直接の module.exports と代替エイリアスについて IntelliSense を比較し、jsconfig.json と require の両方でライブラリとそのプロパティが一貫して提供されることを確認できたら、Issue は完了とみなします。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, typescript, vscode
- 領域
- developer-experience, tooling
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 30/100