'Typescript - Programmatic generation of union types from exports
So, I have a file structure like this:
|---- foo.ts
|---- bar.ts
|- index.ts
Both foo.ts and bar.ts export a Data interface. What I'd want is to basically create a union type out of the 2 Data interfaces exported from foo and bar. Ideally, this should also be future proof. I.e. if I add a third file at the same level of foo and bar, that file will also export a Data interface and that should be included in the union type too.
I was wondering if there was a way of doing this without performing type generation from a JSON schema or something at "compile" time and the programmatic creation of the union type itself from this.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
