https://pulumi.com logo
#general
Title
# general
f

full-dress-10026

03/14/2019, 6:37 PM
When using a
StackReference
, how do you get the output as an array? I tried this:
Copy code
let subnetIds = myStack.getOutput("subnetIds") as pulumi.Output<string[]>;
but Typescript fails with:
TS2740: Type 'Output<any>' is missing the following properties from type 'Input<string>[]': length, pop, push, concat, and 26 more..
. I'm fairly certain the type of
getOutput
is correct.
i

important-leather-28796

03/14/2019, 6:38 PM
Guessing that is
pulumi.Output<pulumi.Output<string>[]>
helps to
import {Output} from '@pulumi/pulumi'
to shorten it up
oh yes, stack.getOutput returns
Output<any>
, I was thinking Input types
f

full-dress-10026

03/14/2019, 6:40 PM
That results in a similar message:
Copy code
TS2740: Type 'Output<Output<string>[]>' is missing the following properties from type 'Input<string>[]': length, pop, push, concat, and 26 more.
i

important-leather-28796

03/14/2019, 6:40 PM
that’s another one for @lemon-spoon-91807
f

full-dress-10026

03/14/2019, 6:43 PM
Fairly certain the type is Output<string[]> from
getOutput
. If I do
Copy code
myStack.getOutput("subnetIds").apply(x => { console.log(x); return x;})
x
is printed as an array.
i

important-leather-28796

03/14/2019, 6:45 PM
I think the
getOutput
return type is overly vague since it could be one of many. It could possibly be parameterized to allow a return type, like
getOutput<string[]>
to provide a better dev experience. As-is it is a cast either way to what you want to use.
👍 1
f

full-dress-10026

03/14/2019, 6:50 PM
FWIW, I'm trying to create a vpc from the output:
Copy code
let subnetIds = myStack.getOutput("subnetIds") as pulumi.Output<string[]>;
const vpc = awsx.ec2.Vpc.fromExistingIds("infra-vpc", {
    vpcId: vpcId,
    publicSubnetIds: subnetIds,
});
and the error is on the
publicSubnetIds
line.
I can convert it to a
Output<Output<string>[]>
but
publicSubnetIds
doesn't like that either.
l

lemon-spoon-91807

03/15/2019, 3:52 AM
I would love to help you. And i will! But i'm oof for a few days.
However, let me say this: you should never have Outputs in other Outputs
because Outputs 'unwrap' their data
You can have
Input<Input<string>[]>
you could also have
Output<string[]>
do go from the former to the latter, you just call
pulumi.output(the_inputs)