Skip to content

Default generics are ignored #72

@joachimvh

Description

@joachimvh

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions