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

Optionally handle interfaces like abstract classes #89

Open
laurensdeb opened this issue Mar 1, 2022 · 1 comment
Open

Optionally handle interfaces like abstract classes #89

laurensdeb opened this issue Mar 1, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@laurensdeb
Copy link

Problem description

When running the generator on parameters that implement an interface like below, we noticed that the generator produces errors like error: Unsupported field type TSMethodSignature in Handler. In the --lenient mode this does allow us to generate .jsonld files, but they miss all of the parameters deriving from the interface.

import type { Observable } from 'rxjs';

export interface Handler<T = void, S = void> {

  handle(input: T): Observable<S>;

}

Example code

HandlersJS - Handler.ts

Environment:

    "componentsjs": "5.0.0-beta.4",
    "componentsjs-generator": "3.0.0-beta.7",
@laurensdeb laurensdeb changed the title Suport for TSMethodSignature Support for TSMethodSignature Mar 1, 2022
@rubensworks
Copy link
Member

This issue is actually slightly more complex than I first thought.

Parameters that refer to interfaces are converted into nested record definitions, whereas this is a case where you actually want the param to accept instantiations of components that implement this interface. So we'll probably need a new TSDoc flag for this.

So basically, when this TSDoc flag is enabled on a param, an interface reference would behave just like an abstract class reference.

@rubensworks rubensworks added the enhancement New feature or request label Mar 1, 2022
@rubensworks rubensworks changed the title Support for TSMethodSignature Optionally handle interfaces like abstract classes Mar 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants