typescript & joi for pulumi spec
# πŸ’»ο½œcontributing
a
is there any known trick to avoid this kind of repetition to make the type system happy? https://github.com/garden-io/garden/pull/4497/files#diff-def0851e81190cb5605afe8d5779115f595aaa677399e2d72cdfb791fb766fe6R118-R128
in the similar terraform plugin https://github.com/garden-io/garden/blob/8e8bc8093ec0f1760bbc55c07bb06dca4586d9d2/plugins/terraform/index.ts#L194-L207 we don't use
omit
and that seems to keep the type system happy
if i remove the manual handling in the pulumi spec, i get type errors like these for each of those fields
Copy code
e2e β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„  ../plugins/pulumi/index.ts(118,15): error TS2322: Type '{ dependencies?: string[] | undefined; allowDestroy?: boolean | undefined; autoApply?: boolean |         β”„β”„
                             undefined; createStack?: boolean | undefined; pulumiVariables?: DeepPrimitiveMap | undefined; ... 6 more ...; stack?: string | undefined; }' is not assignable   β”„β”„
                             to type 'PulumiDeploySpec'.                                                                                                                                      β”„β”„
e2e β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„    Types of property 'allowDestroy' are incompatible.                                                                                                             β”„β”„
e2e β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„      Type 'boolean | undefined' is not assignable to type 'boolean'.                                                                                              β”„β”„
e2e β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„        Type 'undefined' is not assignable to type 'boolean'.                                                                                                      β”„β”„
e2e β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„  3:48:32 PM - Found 1 error. Watching for file changes.
i don't necessarily mind the manual handling or repetition per se, but i am slightly worried about possible mismatch in case we ever need to change the defaults (joi schema vs this file)
cc @curved-intern-91221 re: code review comments on
we did not find a quick fix for this so leaving it as something to optionally refactor later. merging and moving forward
2 Views