This is really a refinement of my earlier question...
# typescript
a
This is really a refinement of my earlier question. The refined form is: How can I use a pulumi.Input<> as a key in a dictionary? In the code-snippet, the indexer access in line 3 doesn't compile because it says that, understandably, the possible type variants of
nvp.Name
(
OutputInstance<string>
,
Promise<string>,
undefined
) "cannot be used as an index type".
I have found a way to work around this by wrapping my data into a different structure from which I then create
NameValuePairArgs
and the dictionary type where needed. But for curiosity, I'd still like to know whether the above is possible at all and if so, then how.
l
No, not possible. Even if you found out how to include the type as an index type, there's no way to discriminate between two outputs. Until they're applied, all outputs are the same (they are that error message that says you need to use apply.. I forget how it's phrased.).
You could create a new asynchronous map type of some kind, that waits on all keys before being available. But generally, you're better off waiting for the keys before adding them to the collection.