able-artist-91005
12/06/2023, 4:15 AMOutput<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>.
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?
Thanksgreen-stone-37839
12/06/2023, 4:23 AMgetOutput("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);
able-artist-91005
12/06/2023, 4:24 AMgreen-stone-37839
12/06/2023, 4:25 AMable-artist-91005
12/06/2023, 4:25 AMsalmon-account-74572
12/06/2023, 4:58 PM