Generics are not generated properly
- Same as #398 Issue was closed, but I tried and failed... Am I doing something wrong...?
Generated:
Record({ abc: <{ data: string; } extends any, > ({ data: string; }: Runtype<{ data: string; }>,) => Record({ data: String, }).And(Record({ count: Number, })),});
I don't think the bottom part is necessary and gills in my opinion. Is it necessary for some generative process...?
<{ data: string; } extends any, > ({ data: string; }: Runtype<{ data: string; }>,) =>
Hey @AsPulse. I just tried your example in #398, but I get a different result to what you're saying here. https://stackblitz.com/edit/node-atzfxo?file=src/index.runtypes.ts Can you provide me with a full example?
Sorry, I checked and it seems that the problem only occurs when importing a Type containing Generics from another file (external.ts in the example below).
https://stackblitz.com/edit/node-ahtzsa?file=src/external.ts
So, finally got around to having a look at this. The problem boils down to a bug when importing types from other files. It's a toughy, and I'll get around to it soon. In the mean time, if at all possible, the work around is to specify the source file of the type you're trying to build.
Instead of:
- targetFile: ./src/index.runtypes.ts
sourceTypes:
- file: ./src/index.ts
type: [Foo]
Use:
- targetFile: ./src/index.runtypes.ts
sourceTypes:
- file: ./src/external.ts
type: [Bar]