microsoft / microsoft/TypeScript
JavaScript Intellisense doesn't detect types of properties defined in async constructors
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 2 T. 4 Std.
- Gemergte PRs (30 T.)
- 132
Beschreibung
# JavaScript Intellisense doesn't detect types of properties defined in async constructors
## Summary
A popular asynchronous constructor pattern in JavaScript is using an async IIFE in the constructor which returns `this` at the end. E.g.
```javascript
constructor() {
return (async () => {
this.#x = 42;
this.y = 42;
return this;
})();
}
```
However, VSCode Intellisense does not infer the types for properties defined in such a constructor.
## Steps to reproduce
1. Open a blank JavaScript, and paste in the following code:
```javascript
class Class1 {
#x;
y;
constructor() {
this.#x = 42;
this.y = 42;
}
}
class Class2 {
#x;
y;
constructor() {
return (async () => {
this.#x = 42;
this.y = 42;
return this;
})();
}
}
```
2. Hover over `y` in `Class1` and observe the tooltip: `(property) Class1.y: number`
3. Hover over `y` in `Class2` and observe the tooltip: `(property) Class2.y: any`
Does this issue occur when all extensions are disabled?: **Yes**
- VS Code Version: 1.97.0
- OS Version: Windows 11
Beitragsleitfaden
Rechercherichtung
Reproduziere das Problem in VS Code mit den bereitgestellten Beispielen für Class1 und Class2 und vergleiche die Hover-Typen bei deaktivierten Erweiterungen. Verfolge die Verarbeitung von JavaScript IntelliSense für asynchrone Konstruktoren durch den TypeScript-Sprachdienst und füge anschließend eine Regressionstestabdeckung hinzu; als erledigt gilt die Aufgabe, wenn Class2.y wie Class1.y als number abgeleitet wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, typescript, vscode
- Bereich
- developer-experience, tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 42/100