microsoft / microsoft/TypeScript
Module.exports = {} not recognized by IntelliSense
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript version: 3.5.1
The CommonJS construct module.exports = {} does not provide import suggestions in JS files via VSCode IntelliSense.
IntelliSense provides a TS error handle on the module.exports = {} construct:
File is a CommonJS module; it may be converted to an ES6 module.ts(80001)
Pressing the Quick Fix option converts the exports to ES6 format. After this, IntelliSense import suggestions work in other scripts.
What also works is formatting the export as follows:
module.exports.showText = showtext;
My files are:
lib.js
function showText() {
console.log('Text');
}
module.exports = {
showText: showText,
}
myCode.js
showTe...; // <- no import suggestion provided
Project structure:
./lib.js
./myCode.js
I would like to get the IntelliSense import suggestion without change of the module.exports = {} construct (I do not have the authorization to do this for the entire project code base).
I am not using a jsconfig.json file.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the behavior with the provided lib.js and myCode.js files, using module.exports = {} and checking import suggestions for showText in myCode.js. Investigate the IntelliSense behavior for this CommonJS pattern; done means the suggestion appears without converting the export to ES6 syntax or changing its property format.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript, vscode
- Domain
- developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100