This message was deleted.
# general
s
This message was deleted.
o
If you're quite confident, you can usually cast the type via
as Output<string>
, or if that doesn't work,
as any as Output<string>
. A helper library like this one contains type guards like "is.string". You'd need to use that inside an Apply and decide how to handle the else case - throwing an error in the Apply would work. https://www.npmjs.com/package/@sindresorhus/is
I think you'd end up with:
Copy code
requireOutput(...).apply(x => {
  if is.string(x) {
    return x;
  } else { 
    throw new Error("expected a string!")
});
k
Thanks @orange-policeman-59119, very helpful! For anyone that stumbles upon this, I also found you can do an await for stack references that aren't secrets. Makes it much easier to handle them since they end as default string types instead of pulumi output strings:
Copy code
export = async () => {
  const pulumiStackReference = new pulumi.StackReference(`otherStack`);
  const myOutput = await pulumiStackReference.requireOutputValue('myOutput')
}