Reputation: 11032
Such this question is asked before here and here but it can't help. my case is different.
I have one typescript file containing 40 DTO class converted from C# file, like:
//model.ts
export class A extends B
{
//...
}
export class B
{
//...
}
export class C
{
//...
}
export class D extends C
{
//...
}
//more classes
}
When I try to compile the file using tsc I get an error:
model.ts:3:24 - error TS2449: Class 'B' used before its declaration.
3 export class A extends B
~
model.ts:8:14
8 export class B
~
'B' is declared here.
If I Generated the c# class as interface, compilation success without error. tsc say that class B is declared here, but can't use it.
Sure, editing the file and moving the B class before A class, I get no error.
I want to avoid the manual editing of the converted file.
My Question: Is there an option in tsc configuration or other way to avoid this error and the manual editing of the generated file?
Upvotes: 1
Views: 779
Reputation: 11032
I find a good tool that reorder the classes based on the dependency, so parent (base class) is written before the child.
It's csharp2ts by @Rafael Salguero Iturrios, and it's an extension to VScode.
I converted the c# file and the error disappear
Upvotes: 1