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

better-rainbow-14549

05/07/2019, 3:33 PM
ihni what type of object it expects but if you remove the vpc.getOutput() to a variable it might help
b

brave-angle-33257

05/07/2019, 3:34 PM
ok thanks, so it does appear to be type related… i’ll give that a shot
b

better-rainbow-14549

05/07/2019, 3:35 PM
public readonly subnetMappings: pulumi.Output<{ allocationId?: string, subnetId: string }[]>;
i guess vpc.getOutput().apply(x => ({ subnetId: x }))
b

brave-angle-33257

05/07/2019, 3:36 PM
yea was wondering about that
setting to a var first didnt work
b

better-rainbow-14549

05/07/2019, 3:37 PM
oh it wont actually fix it i just mean it would remove the erroneous no-error-for-type-mismatch caused by the <any>
b

brave-angle-33257

05/07/2019, 3:44 PM
all this type stuff is definitely not my strength.. started in on TS when I found out python wasn’t quite there yet (few months ago)
i feel like this shouldn’t be so tough.. trying to do
apply()
but nothing seems to be valid syntax
b

better-rainbow-14549

05/07/2019, 3:47 PM
ok well i've not used stack references myself but if you do e.g.
Copy code
var subnets = <pulumi.Output<string[]>>vpc.getOutput(`blah`);
it will at least let typescript / your IDE know its type so it can start giving you sensible error messages
and then i'd expect
Copy code
subnetMappings: subnets.apply(x => ({ subNetId: x })),
to work
b

brave-angle-33257

05/07/2019, 3:50 PM
ok great, thanks.. yea that’s more advanced on the typing side than anything I’ve done yet.. appreciate the example
i got it to take this (hard coded):
Copy code
subnetMappings: [
        {subnetId: "subnet-00c7ed0ec22cb3ce4"},
        {subnetId: "subnet-04327ab075a2ae3b3"}
    ],
as a test
b

better-rainbow-14549

05/07/2019, 3:50 PM
ok cool well i think it should work
are you using an IDE? vscode gives good type help for stuff like this
b

brave-angle-33257

05/07/2019, 3:51 PM
yes vscode
b

better-rainbow-14549

05/07/2019, 3:51 PM
fair enough
b

brave-angle-33257

05/07/2019, 3:51 PM
i think its more of i just havent wrapped my head around it all yet
(as far as the type stuff) coming from python
b

better-rainbow-14549

05/07/2019, 3:51 PM
oh no i'm ignoring the array part of it i think my example's wrong
Copy code
subnetMappings: subnets.apply(x => x.map(y => ({ subnetId: y }))),
x is string[], y is string
b

brave-angle-33257

05/07/2019, 3:55 PM
ok let me try it
yea that works heh, i’ll have to look into the apply/map bit some more to make sure I fully understand it
awesome, thank you so much
b

better-rainbow-14549

05/07/2019, 3:57 PM
cool no probs