NJsonSchema
NJsonSchema copied to clipboard
Typescript: order of class / base class
With the latest version of NSwag v12.3.0.0 and NJsonSchema v9.14.1.0 I have an issue that not my abstract class is positioned lower than a class that extends it in TypeScript.
error TS2449: Class 'Calendar' used before its declaration
See https://github.com/RicoSuter/NSwag/issues/2184#
I am still struggling with these problem. (NSwag v13.1.3)
I have a Base DTO class: BaseEntity
and I have some DTOs with name eg. Grape, Melon ... (come later in ABC) which extend BaseEntity.
Typescript generation works well until I add a DTO with Name starting with A (before B in ABC)
So after I add these block to my extensions ts:
class Apple extends generated.Apple {
// some customizations ...
}
I get the following: error TS2449: Class 'BaseEntity' used before its declaration.
How can I solve it?
I run into the same issue, can you give us some update about that?
I'm also seeing this behaviour, I've tried versions 13.5.0
and 13.4.2
. The base class is put at the bottom of the file. I followed the guide from here:
https://github.com/RicoSuter/NSwag/wiki/TypeScriptClientGenerator#inject-an-authorization-header
Is this still an issue with the latest version? I think we improved the ordering...
I have run into this problem today - trying to write a base class for all clients, options:
"clientBaseClass": "ClientBase",
"extensionCode": "clientbase.ts",
where clientbase.ts
looks like:
export class ClientBase {
protected transformOptions = (options: AxiosRequestConfig): Promise<AxiosRequestConfig> => {
options.headers = {
...options.headers,
'SOME-TOKEN': 'SomeToken',
};
return Promise.resolve(options);
};
}
resulting in:
using: NSwag toolchain v13.10.1.0 (NJsonSchema v10.3.3.0 (Newtonsoft.Json v12.0.0.0)) (http://NSwag.org)
It still happens for us with version 13.17.0 :(