Dto with interfaces has no implements
See original GitHub issueSo, here’s an example:
public interface ICard
{
string Title { get; set; }
string Description { get; set;
}
Which has a final DTO of this form:
public class Card : ICard
{
string Title { get; set; }
string Description { get; set;
}
The final output using typegen is:
/**
* This is a TypeGen auto-generated file.
* Any changes made to this file can be lost when this file is regenerated.
*/
export class ICard {
title: string;
description: string;
}
/**
* This is a TypeGen auto-generated file.
* Any changes made to this file can be lost when this file is regenerated.
*/
export class Card {
title: string;
description: string;
}
I was expected to have this instead:
/**
* This is a TypeGen auto-generated file.
* Any changes made to this file can be lost when this file is regenerated.
*/
import { ICard} from "./i-card";
export class Card implements ICard {
title: string;
description: string;
}
Is there any way to achieve this right now?
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Should I create interfaces for data transfer objects?
The general answer is no, because you should never add code without having a specific, concrete reason for it, and there is no...
Read more >How to handle Dtos for objects which implement multiple ...
Using interfaces in the service is not recommended and is the cause of the problem, as when you try and substitute concrete classes...
Read more >Avoiding interfaces in DTOs
I am trying to get my head around the best DTO design for a particular use case. Our application supports custom properties which...
Read more >Immutable DTOs in C# with interfaces
Upside is that the project won't even build if the updated interface isn't implemented. On other hand, the alternative to reusing the same...
Read more >I've seen implemented contracts/interfaces for simple DTO ...
I do not believe that interfaces (C#/Java) are contracts. They mandate implementation of the interface but cannot guarantee the behaviour of the implementation....
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
Can confirm, only supporting extends: https://github.com/jburzynski/TypeGen/blob/master/src/TypeGen/TypeGen.Core/Templates/Class.tpl
I’m working on a PR, just need to figure out imports.
I’m running into this issue as well with inherited interfaces. I want to pass around the lowest level interface in typescript, but I can’t because it actually doesn’t have all the properties.
Example C# interfaces:
and the generated Typescript code: