Skip to content

Emit nested expando function assignments in declarations#4198

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-declaration-emit-expando-properties
Draft

Emit nested expando function assignments in declarations#4198
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-declaration-emit-expando-properties

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 4, 2026

Declaration emit only serialized expando function properties assigned as top-level expression statements. Assignments in initializers or blocks were bound but dropped from the generated namespace.

  • Declaration emit

    • Emit expando properties from the function declaration’s collected symbol properties.
    • Suppress duplicate namespace emission from assignment statements already covered by the function-level emit.
    • Preserve synthesized multi-statement output when replacing declarations.
  • Code actions

    • Deduplicate identical isolated-declaration expando namespace fixes across diagnostics.
  • Regression coverage

    • Added compiler coverage for expando assignments in a variable initializer and block.
function Foo(): void {}
Foo.top = 1;
let d: number = (Foo.inInitializer = 2);
if (true) {
    Foo.inBlock = 3;
}

now emits:

declare function Foo(): void;
declare namespace Foo {
    var top: number;
    var inInitializer: number;
    var inBlock: number;
}
declare let d: number;

Copilot AI and others added 2 commits June 4, 2026 11:12
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix declaration emit for expando function properties Emit nested expando function assignments in declarations Jun 4, 2026
Copilot AI requested a review from jakebailey June 4, 2026 11:19
@hkleungai
Copy link
Copy Markdown

Just curious, is this PR also solving the issue I raised in #4045? If not, also fine :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Declaration emit drops expando function properties whose assignments are not top-level expression statements

3 participants