Bit of a basic question I think. How do I access r...
# typescript
m
Bit of a basic question I think. How do I access registered outputs of a component after constructing it? I have registerOutputs called at the end of my custom component constructor. There does not seem to be a
getOutput
or any getter for that matter, on the component type?
Would a PR be reasonable to allow for a generic version of
ComponentResource<pulumi.Outputs>
which provides type safety for registerOutputs and types the class properties?
There’s a problem with having to add class property types because typescript will complain that the property is “definitely not set in the constructor”.
Unless you have to also set the property yourself (I was expecting registerOutputs to do this)
m
In a pulumi component you do all the work in the constructor, so there is not usually an issue with setting the properties there?
yes - you set the properties of the class yourself - in the same way you would for other typescript classes - there is no magic going on with register outputs...
m
If there's no magic what does it do? My expectation was that it (registerOutputs) would be required so that pulumi could correctly understand the dependency graph. But then if it's doing that, why not set the properties too so I am not having to jump to three places to set an output which is highly error prone (property type, set the property in constructor, call registerOutputs)? Eg. with psuedo:
Integration { target = myFunctionComponent.lambdaArn }
should allow pulumi to say "Integration depends on myFunctionComponent" and not "integration depends on a lambda resource" which is supposed to be hidden and encapsulated in the component.