I'm quite often writing utility functions which ne...
# azure
b
I'm quite often writing utility functions which need to be able to take e.g. an azure.network.Subnet, or an azure.network.GetSubnetResult - 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:
Copy code
export type CommonProperties<A, B> = { [K in keyof A & keyof B]: A[K] extends B[K] ? K : never };

export type AzureSubnetResult = CommonProperties<azure.network.GetSubnetResult, azure.network.Subnet>;
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?