Skip to content

"Expando assingment" for Javascript namespace stopped working. #49944

Closed
@mpawelski

Description

@mpawelski

Looks that the "declare a namespace with a function inside and expand the function with expando assignments" workaround for my "JS namespaces" stopped working in TS 4.5

💻 Code

declare namespace app {
  function foo(): void;
}

app.foo.bar = (function () {
  const someFun = (arg: number) => {};
  return { someFun };
})();

app.foo.bar.someFun(1);

This works in 4.4.2.
This doesn't work in 4.5.5

🙁 Actual behavior

Compiler error:

 Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.

🙂 Expected behavior

No error with proper inference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions