microsoft / microsoft/TypeScript
Module.exports = {} not recognized by IntelliSense
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 2 T. 4 Std.
- Gemergte PRs (30 T.)
- 132
Beschreibung
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.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Reproduziere das Verhalten mit den bereitgestellten Dateien lib.js und myCode.js, verwende module.exports = {} und überprüfe die Importvorschläge für showText in myCode.js. Untersuche das IntelliSense-Verhalten für dieses CommonJS-Muster; abgeschlossen ist die Aufgabe, wenn der Vorschlag erscheint, ohne den Export in die ES6-Syntax umzuwandeln oder das Format seiner Eigenschaften zu ändern.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, typescript, vscode
- Bereich
- developer-experience, tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100