Skip to content

Expando function declarations cant emit non-identifier propertiesΒ #55190

Open
@Andarist

Description

@Andarist

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs More InfoThe issue still hasn't been fully clarified

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions