Open
Description
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?