Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with Genrics on Lambda-functions #21

Open
misantronic opened this issue Aug 3, 2022 · 1 comment
Open

Problems with Genrics on Lambda-functions #21

misantronic opened this issue Aug 3, 2022 · 1 comment

Comments

@misantronic
Copy link

There is a problem when compiling files with generics on lambda-functions.
Example:

const fn = <T>(Dependency: Constructable<T>, hint?: string): T =>
        ensureInjector().get(Dependency, hint);

It transpiles to this:

const fn = React.createElement(
      T,
      null,
      "(Dependency: Constructable",
      React.createElement(
        T,
        null,
        ", hint?: string): T => ensureInjector().get(Dependency, hint); // function fn",
        React.createElement(
          T,
          null,
          "(Dependency: Constructable",
          React.createElement(
            T,
            null,
            ", hint?: string): T ",
            fn.reset = () => {
              injector = void 0;
            },
            "; return fn; })();"
          )
        )
      )
    );

When changing the function to this it works:

function fn<T>(Dependency: Constructable<T>, hint?: string): T {
    return ensureInjector().get(Dependency, hint);
}
@Brian-McBride
Copy link
Contributor

This just calls esbuild, so the issue is within that lib.

However, if I were to guess, I would suggest that maybe the tsconfig for the node app is configured with JSX.
That's a pretty weird issue though.
It has been a while, but I am pretty sure this plugin generates an esbuild.json file as well. You might turn off react options in there as well.

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

No branches or pull requests

2 participants