我使用reinforced.typings fluent配置api(胸膜方法)将我的c dto映射到typescript接口,生成一个文件。
目前我得到了(正确的)输出,比如
export interface ICourseDto { start: Date; facultyMeetingRoom: IRoomDto; courseParticipants: ICourseParticipantDto[]; ... } export interface IRoomDto ...
理想情况下,我希望:
import breeze from 'breeze-client'
-
export interface ICourseDto { start: Date; facultyMeetingRoom: IRoomDto & breeze.Entity; courseParticipants: (ICourseParticipantDto & breeze.Entity)[]; ...
对于reinforced.typings fluent配置,这可能吗?如果可能,我需要什么配置代码来实现它?
实现您想要的最简单的方法是(其中s是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")); }
加强。打字也能保留遗产。考虑从公共类型/接口派生实体并导出它。