Skip to content

Issue with immediately executed functions #1289

Closed
@DuncanUszkay1

Description

@DuncanUszkay1

Unless I'm missing something here, seems like inlining the creation of a function and calling it in this manner seems to be broken:

Here's a minimal example:

let normalFunc = (): (x:i32) => i32 => {
  let myFunc = (x: i32): i32 => {
    return 24 + x;
  }

  return myFunc;
}
assert(normalFunc()(1) == 25);

Compiler Error:

 ERROR TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'closure-common-js-patterns/normalFunc' has no compatible call signatures.

assert(normalFunc()(1) == 25);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions