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

Default generics are ignored #72

Open
joachimvh opened this issue Feb 8, 2022 · 1 comment
Open

Default generics are ignored #72

joachimvh opened this issue Feb 8, 2022 · 1 comment
Labels

Comments

@joachimvh
Copy link
Member

Issue type:

  • 🐛 Bug

Description:

This could be solved in either the generator or components.js. No idea which one would be easier.

There is a class AsyncHandler defined as

export abstract class AsyncHandler<TIn = void, TOut = void>

There is a class HttpHandler defined as

export abstract class HttpHandler extends AsyncHandler<HttpHandlerInput>

Building that class with the components.js generator generates the following extends predicate for the HttpHandler:

        {
          "@type": "GenericComponentExtension",
          "component": "scs:dist/util/handlers/AsyncHandler.jsonld#AsyncHandler",
          "genericTypeInstances": [
            "scs:dist/server/HttpHandler.jsonld#HttpHandlerInput"
          ]
        }

Trying to run a config with an instance of that class gives the following error:

ErrorResourcesContext: Invalid generic type instantiation: a different amount of generic types are passed (1) than are defined on the component (2).

Changing the HttpHandler to extend AsyncHandler<HttpHandlerInput, void> generates 2 entries in the genericTypeInstances array and makes the error go away.


Environment:

Components.js version 5.0.0-beta.5
Components.js generator version 3.0.0-beta.7

@github-actions
Copy link

github-actions bot commented Feb 8, 2022

Thanks for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants