microsoft / microsoft/TypeScript
Module.exports = {} not recognized by IntelliSense
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
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.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Riproduci il comportamento con i file forniti lib.js e myCode.js, utilizzando module.exports = {} e verificando i suggerimenti di importazione per showText in myCode.js. Esamina il comportamento di IntelliSense per questo pattern CommonJS; il lavoro è completato quando il suggerimento viene visualizzato senza convertire l’esportazione nella sintassi ES6 né modificare il formato delle sue proprietà.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, typescript, vscode
- Ambito
- developer-experience, tooling
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100