I am using the reinforced.typings fluent configuration API (pleural methods) to map my C# DTOs to typescript interfaces, generating a single file.
currently i am getting the (correct) output such as
export interface ICourseDto
{
start: Date;
facultyMeetingRoom: IRoomDto;
courseParticipants: ICourseParticipantDto[];
...
}
export interface IRoomDto ...
ideally, I would like to:
import breeze from 'breeze-client'
to the beginning of the generated typescript file-
export interface ICourseDto
{
start: Date;
facultyMeetingRoom: IRoomDto & breeze.Entity;
courseParticipants: (ICourseParticipantDto & breeze.Entity)[];
...
is this possible with the reinforced.typings fluent configuration, and if so, what configuration code do I need to achieve it?
The simpliest way to achieve what you want is (where s is ConfigurationBuilder):
s.Global(a => a.UseModules());
s.AddImport("breeze", "breeze-client");
var mySpecialTypes = typeof(IBreezeEntity).Assembly.GetTypes()
.Where(d => typeof(IBreezeEntity).IsAssignableFrom(d));
foreach (var type in mySpecialTypes)
{
s.Substitute(type, new RtSimpleTypeName($"I{type.Name} & breeze.Entity"));
}
Reinforced.Typings also preserves inheritance. Consider deriving your entities from common type/interface and exporting it also.