This message was deleted.
# typescript
s
This message was deleted.
g
Wrapping both in an output should give you the same effect for both, to get the projectId you would do
project.apply(p => p.projectId)
One will unwrap the promise to an output of the object with primitives and the other will traverse the object to have all the outputs as primitives during the apply
l
But in Typescript, what is the common “type” here I can set in my component constructor? I hope not
any
.
constructor(project: <which type here?>)
g
I'm not sure if what those types resolve actually intersect but going for the safe route you could do
Input<Project|GetProjectResult>
and then do
project = output(project)
before using it on your component
👏🏼 1
l
Your
|
character made me think about having
or
-types to indicate one or the other:
constructor(project: gcp.organizations.Project | Promise<gcp.organizations.GetProjectResult>)
My editor is not complaining… will see how far I can get with this.
g
I would still prefer using
Input
wrapping them on the argument list to allow the values to be passed both directly, as promise or as output
l
Why do you prefer it that way? Because it is clearer referring to an
Input
or is there also another technical thing I’m missing here?
g
Input<Project|GetProjectResult>
is the same as
Project | GetProjectResult | Promise<Project | GetProjectResult> | Output<Project | GetProjectResult>
So it will accept resources created inside an
apply
, in a promise chain or directly
💯 1
Copy code
getSomeConfigsExternally().then(config => new Project(projectId: config.projectId))