Closed eladb closed 2 years ago
As far as Typescript is concerned, isn't it better to just generate a type union?
engine: "9.5" | "11";
Another deficiency of enums (at least in Typescript) is the super long names that are auto-geneareted. For example
import {
VerticalPodAutoscaler,
VerticalPodAutoscalerSpecResourcePolicyContainerPoliciesControlledResources as res,
} from '../imports/autoscaling.k8s.io';
I have to rename the long type name to res
so I can use res.CPU
or res.MEMORY
.
What do you think about changing the emitted code to use string litterals?
Now that I think of it, we can have it both. For the example of autoscaling:
/**
* @schema VerticalPodAutoscalerSpecResourcePolicyContainerPoliciesControlledResources
*/
export enum VerticalPodAutoscalerSpecResourcePolicyContainerPoliciesControlledResources {
/** cpu */
CPU = "cpu",
/** memory */
MEMORY = "memory",
}
export interface VerticalPodAutoscalerSpecResourcePolicyContainerPolicies {
/**
* @schema VerticalPodAutoscalerSpecResourcePolicyContainerPolicies#controlledResources
*/
readonly controlledResources?: (VerticalPodAutoscalerSpecResourcePolicyContainerPoliciesControlledResources | "cpu" | "memory")[];
}
@jvassev We try and avoid using type unions because they don't translate well to other languages. Since the type script generation is the base for other languages bindings, it would be tricky to special case it.
See https://aws.github.io/jsii/specification/2-type-system/#type-unions
Perhaps this can shift to a jsii feature request. But I can see this getting rather complex.
This issue is now marked as stale because it hasn't seen activity for a while. Add a comment or it will be closed soon.
Closing this issue as it hasn't seen activity for a while. Please add a comment @mentioning a maintainer to reopen.
Closing this issue as it hasn't seen activity for a while. Please add a comment @mentioning a maintainer to reopen.
This issue is now marked as stale because it hasn't seen activity for a while. Add a comment or it will be closed soon.
Closing this issue as it hasn't seen activity for a while. Please add a comment @mentioning a maintainer to reopen.
Description of the bug:
For example, this is from
postgressqlinstance.database.crossplane.io
:Oouch....
This is :bug: Bug Report