06/17/2020, 11:29 AM
I'm quite often writing utility functions which need to be able to take e.g. an, or an - so that the library can handle use cases of whether a resource is created within that stack or just queried and created elsewhere. I've solved this by defining a whole new type for each resource using a common generic function:
export type CommonProperties<A, B> = { [K in keyof A & keyof B]: A[K] extends B[K] ? K : never };

export type AzureSubnetResult = CommonProperties<,>;
but it does mean I have to specify it either long-form as a type in the function, or create a new type from it for each resource. Is this something that could be added to the generated TF code somehow? Any reasons why it's bad practice or not?