CSharpToTypeScript
CSharpToTypeScript copied to clipboard
Generate one class/interface/enum per file
Hi @AdrianWilczynski , the VS Code extension and CLI tools are great, very helpful and already saved me a lot of time 😉 Thanks for your great job!
However, I have some issue and want to ask you first, maybe you know something about that. I see that normally if I have few classes/interfaces/enums in a single C# file, cs2ts generates a single file with all these objects from C# file. However, in some cases from a single .cs file I have 2 .ts files generated - both with the same content (2 interfaces inside).
I'm also using import-generation = Simple. The issue is that sometimes few classes are defined in a single .cs file, but are needed in other .cs files (multiple), so the default naming convention for imports generation doesn't work properly.
What I'd like to achieve is that cs2ts generates a separate .ts file for each class/interface/enum it finds in the source .cs file. Do you know if this is somehow already supported? If not, where should I look in the source code to contribute and add such a feature?
Thanks a lot for answering 😉
Hi, thanks for the report. Sorry, it's taking so long for me to respond. I'm really busy right now. But I'm gonna get to it as some point 😅
Sure, no worries. Just answer when you find some time. For now, I decided to not use any automation for C#->TS generation, but it would be great if your tool supports generating separate .ts file for each C# object.
There are other solutions which supposedly support it (e.g. TypeGen), but it works on DLLs, not source (text) files like cs2ts, which is a great advantage over these tools 😉
I'm also using import-generation = Simple. The issue is that sometimes few classes are defined in a single .cs file, but are needed in other .cs files (multiple), so the default naming convention for imports generation doesn't work properly.
I think I have the same problem: Sometimes cs2ts generates two interfaces in one file and if those interfaces are referenced in another file, the imports may be wrong. E.g.
In file-A.ts
export interface A {...} export interface B {...}
In another file
import { B } from "file-B.ts" (instead of "file-A.ts")