microsoft / microsoft/TypeScript
Please Allow Mixins to function properly with new-able types
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
Bug Report
If we declare a new-able type, that is a mixin with the generic parameter it uses, the whole type is not processed.
For example, doing this, won't work
// In types.d.ts
namespace test.ts.bug{
var MyType: {
new <T>(): T & {
additional: "somevalue"
};
}
}
// Then, in VS code, we make use of the type as such
/** @extends {test.ts.bug.MyType<{tsc: "cool"|"sweet"}>} */
class SomeClass extends Object{
}
const myVar = new SomeClass()
Suppose you try to use myVar, you won't see the any of the properties corrected listed, and auto-completed.
However, if you declared it like this
// In types.d.ts
namespace test.ts.working{
var MyType: {
new <T>(): {
additional: "somevalue";
main: T
};
}
}
And obviously, did the following in js
// Then, in VS code, we make use of the type as such
/** @extends {test.ts.working.MyType<{tsc: "cool"|"sweet"}>} */
class SomeClass extends Object{
}
const myVar = new SomeClass()
then with const myVar = new SomeClass(), the properties additional, and main.tsc are auto-completed very well.
🔎 Search Terms
mixins new-able newable types
🕗 Version & Regression Information
Same version with vs code
⏯ Playground Link
Playground link with relevant code
🙁 Actual behavior
const myVar = new SomeClass() doesn't auto-complete in VS code
🙂 Expected behavior
const myVar = new SomeClass() is supposed to have the tsc, and additional set to true
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
Öffne den verlinkten TypeScript Playground und reproduziere den Unterschied zwischen den nicht funktionierenden und den funktionierenden Deklarationen in types.d.ts. Verfolge zunächst, wie der JSDoc-Ausdruck @extends eine generische Konstruktorsignatur verwendet, und überprüfe anschließend, dass new SomeClass() wie erwartet tsc und additional über die Autovervollständigung bereitstellt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, typescript
- Bereich
- compilers
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Aktiv
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 55/100