Open mike8161990 opened 7 months ago
+1 This would be very useful.
In the meantime, config can be used to map the type, and also inject its import to all generated files:
{
"customTypeMappings": {
"Some.Custom.Type": "SCT"
},
"fileHeading": "/** This is an auto-generated file */\r\n\r\nimport { SCT } from \"somewhere\";\r\n"
}
The downside is of course that it will be added to ALL generated files, even the ones that don't need it. But /* eslint-disable */
could also be injected to supress warnings.
In my team's project, we prefer to map all
DateTime
andDateTimeOffset
C# types to aMoment
TypeScript type. Using this type requires an additional import from themoment
package.I found that I am able to do this for individual fields using a
GenerationSpec
:Or using an annotation:
But I can't find a way to setup a universal type mapping rule which will affect all usage of a type. Does such a method exist?
Issue #175 seems to touch on this a bit noting that the
CustomTypeMappings
option could be changed from aIDictionary<string, string>
to some kind of object allowing additional configuration. Maybe this would be a good use case for that restructuring?