Partial C# classes result in multiple conflicting TS classes
See original GitHub issueThis is fairly simple to replicate:
Dummy.a.cs
public partial class Dummy { public string A {get; set;} ... }
Dummy.b.cs
public partial class Dummy { public int B {get; set;} ... }
dummy.tst
$Classes(Dummy)[
export class $Name {$Properties[
public $name: $Type;]
}]
Output:
Dummy.a.ts
export class Dummy {
public a: string;
public b: number;
}
Dummy.b.ts
export class Dummy {
public a: string;
public b: number;
}
This doesn’t compile in TypeScript due to the duplicates. It should either output a single Dummy.ts file or include something in the template for later files to extend (rather than re-define) the class.
The $Classes
method should iterate each class, not each file that holds part of a class.
Issue Analytics
- State:
- Created 7 years ago
- Comments:14 (4 by maintainers)
Top Results From Across the Web
C# Partial Classes
In short, you can't use partial classes across projects. All the source must be compiled at the same time, and that's done per...
Read more >How to extend an existing TypeScript class without a ...
It makes extending an existing class very simple: just declare the class as partial and extend it freely. It is especially useful when...
Read more >TypeScript: Documentation - Modules
Classes and function declarations can be authored directly as default exports. Default export class and function declaration names are optional.
Read more >Practical Ways to Write Better JavaScript
When TS is setup correctly, it will be difficult to write code without first defining your interfaces and classes. This provides a way...
Read more >Content Configuration
Configuring source paths. Tailwind CSS works by scanning all of your HTML, JavaScript components, and any other template files for class names, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi guys, I’ve just released a new version with improved support for partial types (1.10.0). The solution is very similar to @KeithHenry’s suggestion using different modes that can be configured in the template constructor.
PartialRenderingMode.Partial
: Partial types are rendered as defined in the c# source containing only the parts defined in each file. This is the default rendering mode.PartialRenderingMode.Combined
: Partial type definitions are combined to a single type acting as if the full type was defined only once in the c# source (using the filename of the first file containing a part of the type).PartialRenderingMode.Legacy
: A combined type definition are rendered for each file containing a partial definition.Please try it out and let me know if it solves your issues 😃
Hello all,
I absolutely love the typewriter concept, however, some of my files (one for example) have
public partial class ApplicationUser {}
twice in the same file reporting a duplicate class declaration. I cannnot seem to figure out what I am doing wrong. The template I am using is below.The output reports as