ihni what type of object it expects but if you rem...
# general
b
ihni what type of object it expects but if you remove the vpc.getOutput() to a variable it might help
b
ok thanks, so it does appear to be type related… i’ll give that a shot
b
public readonly subnetMappings: pulumi.Output<{ allocationId?: string, subnetId: string }[]>;
i guess vpc.getOutput().apply(x => ({ subnetId: x }))
b
yea was wondering about that
setting to a var first didnt work
b
oh it wont actually fix it i just mean it would remove the erroneous no-error-for-type-mismatch caused by the <any>
b
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
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
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
ok cool well i think it should work
are you using an IDE? vscode gives good type help for stuff like this
b
yes vscode
b
fair enough
b
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
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
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
cool no probs