Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate one class/interface/enum per file #5

Open
dsibinski opened this issue May 25, 2020 · 3 comments
Open

Generate one class/interface/enum per file #5

dsibinski opened this issue May 25, 2020 · 3 comments

Comments

@dsibinski
Copy link

dsibinski commented May 25, 2020

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 😉

@AdrianWilczynski
Copy link
Owner

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 😅

@dsibinski
Copy link
Author

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 😉

@antal-huck
Copy link

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")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants