How does one assign a stack output to an `Output&l...
# general
a
How does one assign a stack output to an
Output<string>
variable? The docs show this example:
const ip: Output<string> = infra.getOutput("privateIp");
But I get a compilation error when I try something similar, since we can't assign Output<any> to Output<string>.
Copy code
TSError: ⨯ Unable to compile TypeScript:
    index.ts(28,9): error TS2322: Type 'Output<any>' is not assignable to type 'Output<string>'.
      Type 'OutputInstance<any>' is not assignable to type 'Output<string>'.
        Property 'length' is missing in type 'OutputInstance<any>' but required in type 'LiftedObject<String, NonFunctionPropertyNames<String>>'.
What's the correct solution here? Thanks
g
getOutput("someKey")
return type is
pulumi.Output<any>
not
pulumi.Output<string>
. You could leave the variable untyped
const ip = ...
or also use an apply statement to provide the string type.
getOutput("someKey").apply(s => <string>s);
a
So this is indeed a documentation bug?
g
By the looks of it, yeah.
a
thx for confirming
s
I’ve filed https://github.com/pulumi/docs/issues/10342 to fix the documentation issue noted here.