NSwag: This member must have an 'override' modifier because it overrides a member in the base class 'Error'.
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
Version:

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
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 5
- Comments: 15 (2 by maintainers)
You need to use
"typeScriptVersion": 4.3in your nswag configuration for theoverridekeyword to be generated.I’ve got the same issue with the latest versions. But there’s a workaround.
In your
tsconfig.jsonyou can turn off this setting:"noImplicitOverride": false,then it will work.
The issue is already known since novembre 2021. => https://github.com/RicoSuter/NSwag/issues/3685
Here, many people are waiting for it resolution.
Same issue as @ranouf
Hi @sander1095 , we managed to fix this issue by upgrading the NSwag packages from version 13.14.8 to 13.15.10.