jsconfig.json gives broken intellisense for js files with module.exports
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 30/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- javascript, typescript, vscode
调研方向
使用所示的 index.js、jsconfig.json、浏览器用法和 Node require 用法,在 VSCode 1.38.0 和 TypeScript 3.6.2 中复现该行为。比较直接的 module.exports 与替代别名的 IntelliSense,并在 jsconfig.json 和 require 都能一致地提供该库及其属性时,认为该 issue 已完成。
由索引模型根据 Issue 内容生成。
描述
- 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 .
- 主要语言
- Go
- 星标
- 111k
- 派生
- 14.4k
- 平均合并
- 1 天 19 小时
- 30 天内合并 PR
- 117
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/TypeScript 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 88/100
microsoft/TypeScript#64322 · 2 条评论 · 1 个 reaction · 已指派 2 人 ·
-
Possible Improvement
难度 2/5 1-3 小时 新手友好度 78/100
microsoft/TypeScript#64278 · 1 条评论 · 1 个 reaction ·
-
Docs
难度 2/5 1-3 小时 新手友好度 70/100
microsoft/TypeScript#64118 · 1 条评论 ·
-
难度 1/5 1 小时以内 新手友好度 88/100
microsoft/TypeScript#64094 ·
-
Docs
难度 2/5 1-3 小时 新手友好度 76/100
microsoft/TypeScript#63959 · 5 条评论 ·
查看 microsoft/TypeScript 的全部 Issue
相似的 Issue
-
kind/bug
难度 2/5 1-3 小时 新手友好度 88/100
kubernetes-sigs/prow#953 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
caddyserver/caddy#8046 ·
-
难度 2/5 1-3 小时 新手友好度 86/100
-
L1 recommended for recruits
难度 2/5 1-3 小时 新手友好度 88/100
-
area/entangle bug
难度 1/5 1 小时以内 新手友好度 92/100