microsoft / microsoft/TypeScript
Preserve `set`-only accessors in declaration emit
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
Related to https://github.com/microsoft/TypeScript/issues/58112#issuecomment-2043419380
export let same = {
set x(value: string) {
},
get x(): string {
throw new Error("Not implemented.")
},
};
export let divergent = {
set x(value: string) {
},
get x(): number {
throw new Error("Not implemented.")
},
};
export let readonly = {
get x(): string {
throw new Error("Not implemented.")
},
};
export let writeonly = {
set x(value: string) {
},
};
Current
Notice that in the declaration of writeonly, we don't preserve the accessor at all.
export declare let same: {
x: string;
};
export declare let divergent: {
get x(): number;
set x(value: string);
};
export declare let readonly: {
readonly x: string;
};
export declare let writeonly: {
x: string;
};
Expected
If we had a writeonly modifier, I'd argue we could just use that as a parallel to the readonly declaration; however, we do support accessors in declaration emit, and we could emit that in the case of a write-only accessor.
It is technically a breaking change though for consumers of older TypeScript versions, and the only way to opt out would be to declare a no-op get accessor.
export declare let same: {
x: string;
};
export declare let divergent: {
get x(): number;
set x(value: string);
};
export declare let readonly: {
readonly x: string;
};
export declare let writeonly: {
set x(): string;
};
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
Beginne mit dem verlinkten Playground und reproduziere die Deklarationsausgabe für dieselben, abweichenden, readonly- und writeonly-Accessoren. Verfolge den TypeScript-Pfad zur Deklarationserzeugung für Objekt-Accessoren und vergleiche vorhandene accessorbezogene Tests oder Baselines; als erledigt gilt, wenn ein write-only-Accessor in der erzeugten Deklaration erhalten bleibt, ohne die anderen gezeigten Ausgaben zu ändern.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- compilers
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 48/100