microsoft / microsoft/TypeScript
Expando function declarations cant emit non-identifier properties
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
🔎 Search Terms
expando properties function declaration symbol computed
🕗 Version & Regression Information
- This is the behavior in every version I tried
⏯ Playground Link
Playground link with relevant code
💻 Code
export const sym = Symbol()
const dashes = 'my-prop'
export function decl() {}
decl.foo = 1
decl[sym] = 2
decl[dashes] = ''
decl[10] = ''
decl["100"] = ''
export const arrow = () => {}
arrow.foo = 1
arrow[sym] = 2
arrow[dashes] = ''
arrow[10] = ''
arrow["100"] = ''
🙁 Actual behavior
export declare const sym: unique symbol;
export declare function decl(): void;
export declare namespace decl {
var foo: number;
}
export declare const arrow: {
(): void;
foo: number;
10: string;
"100": string;
[sym]: number;
"my-prop": string;
};
🙂 Expected behavior
I'd expect decl to be transformed into an object instead of a namespace. That would allow the same properties to be emitted for decl as the ones that are emitted for arrow.
The object variant was the first choice by @sandersn here but then it got changed to a namespace. I didn't find any reason given for this change/decision in the PR comments though. Is there anything that the namespace can deliver here that the object variant can't?
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 TypeScript Playground und vergleiche die Deklarationsausgabe für decl mit der Ausgabe für arrow. Sieh dir den im Issue verlinkten historischen PR zur Namespace-Entscheidung an; als erledigt gilt die Aufgabe, wenn Funktionsdeklarationen dieselben Nicht-Identifier-Eigenschaften wie der reproduzierte Arrow-Function-Fall ausgeben, ohne die anderen Deklarationen zu beeinträchtigen.
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
- 35/100