microsoft / microsoft/TypeScript
VS Code Intellisense seems to wrongly infer revealing module pattern
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
From @lodybo on September 12, 2017 9:44
- VSCode Version: 1.16.0
- OS Version: Windows 10
Steps to Reproduce:
- Copy the code below into a file called
greeter.js - Run
node greeter.jsin a terminal
var Greeter = (function(country) {
// Private
this.country = country;
function getCountry() {
return country;
}
// Public
var performGreeting = function (name) {
var country = getCountry();
return 'Hello ' + name + ', from ' + country;
}
return {
greet: performGreeting
}
});
var greeter = new Greeter("The Netherlands");
console.log(greeter.greet("Lody"));
console.log(greeter.country);
Using the revelealing module pattern in VS Code seems to trip up Intellisense into suggesting the wrong members. The code above was tested in multiple browsers and consoles and run with Node v6.3.0 which behaved as expected. They ran the greet() function and returned undefined for greeter.country:
λ node greeter.js
Hello Lody, from The Netherlands
undefined
But VS Code's Intellisense reports that greeter only contains country:

It also reports the expected interface of greeter for the class itself (Greeter):

What is expected is VS Code correctly inferring greeter.greet to be a function of Greeter, with a parameter name.
This was reproduced in a clean folder of VS Code, with no extensions (launched with code --disable-extensions), and no jsconfig.json.
Copied from original issue: Microsoft/vscode#34214
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
Inizia riproducendo il problema con l’esempio greeter.js fornito in VS Code IntelliSense, quindi confronta i membri inferiti con l’output di Node.js. Il lavoro è completato quando IntelliSense identifica greeter.greet come una funzione che accetta name e non espone country come membro pubblico.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, vscode
- Ambito
- devtools
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 42/100