This member must have an 'override' modifier because it overrides a member in the base class 'Error'.

See original GitHub issue

Hi,

When I generate the Typescript Api Services from a C# API, I have an issue with Exception class generated by NswagStudio:

export class ApiException extends Error {
    message: string; //here is the error
    status: number;
    response: string;
    headers: { [key: string]: any; };
    result: any;

    constructor(message: string, status: number, response: string, headers: { [key: string]: any; }, result: any) {
        super();

        this.message = message;
        this.status = status;
        this.response = response;
        this.headers = headers;
        this.result = result;
    }

    protected isApiException = true;

    static isApiException(obj: any): obj is ApiException {
        return obj.isApiException === true;
    }
}

Here is my configuration in NswagStudio for the exception image Version: image

And the error :

Error: src/app/services/api/api.services.ts:1915:5 - error TS4114: This member must have an ‘override’ modifier because it overrides a member in the base class ‘Error’.

1915 message: string; ~~~~~~~

I can’t see any option about that in nswag studio. As the file is automatically generated, I would like to avoid to modifiy the typescript api services files each time the file is updated.

Is there a specific option to fix the issue?

Thanks

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:2
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
ovskacommented, May 13, 2022

You need to use "typeScriptVersion": 4.3 in your nswag configuration for the override keyword to be generated.

3reactions
lilletechcommented, May 13, 2022

The issue is already known since novembre 2021. => https://github.com/RicoSuter/NSwag/issues/3685

Here, many people are waiting for it resolution.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tip #32[TS override keyword]
This member must have an 'override ' modifier because it overrides a member in the base class … It prevents you from accidentally...
Read more >
Why protected members can be overridden by public ...
It's private ; if the base class wanted you to have access to the field, they would have made it protected , after...
Read more >
Documentation - TypeScript 4.3
This member cannot have an 'override' modifier because it is not declared in the base class 'SomeComponent'.
Read more >
typescript: override parameter properties syntax is not ...
If this option is active, all methods and properties which override a similar method/property in the base class are forced to have the...
Read more >
Introducing Typescript `override` keyword
As the top quote explains, the override keyword will assert that the function it describes is present in the parent class.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found