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

bitter-island-28909

05/12/2021, 3:46 PM
Hey all, encountering a TypeScript error I’m not familiar with. I’m not experienced enough with TS to tell if this is a user error or a bug, but I’m pretty perplexed. I’m trying to set the
defaultTags
property on an
aws.Provider
, like so:
Copy code
new aws.Provider(`my-provider`, {
    ...
    defaultTags: {
        "foo": "bar"
    }
});
I’m getting a type error on
defaultTags
, stating that
Object literal may only specify known properties, and '"foo"' does not exist in type 'Input<ProviderDefaultTags>'.
A type option for
Input<T>
is
T
, and the signature of
ProviderDefaultTags
is
{[key: string]: string}
So using an arbitrary string such as “foo”:“bar” should work. What am I missing?
r

rich-farmer-40546

05/12/2021, 3:46 PM
Remove that quotes on “foo”
b

bored-oyster-3147

05/12/2021, 3:47 PM
^, it's a JS object declaration
b

bitter-island-28909

05/12/2021, 3:49 PM
Copy code
new aws.Provider(`my-provider`, {
    ...
    defaultTags: {
        foo: "bar"
    }
});
No, that’s not it: this returns a similar error:
Object literal may only specify known properties, and 'foo' does not exist in type 'Input<ProviderDefaultTags>'.
r

rich-farmer-40546

05/12/2021, 3:54 PM
b

bored-oyster-3147

05/12/2021, 3:55 PM
oh it wants the tags property maybe? so:
Copy code
defaultTags: {
   tags: {
       foo: "bar"
   },
}
👏 1
b

bitter-island-28909

05/12/2021, 4:01 PM
That was it. Thank you! This makes sense when reading the source code for the Provider DefaultTags type… it wasn’t clear that there was an additional layer of structure from the error message or the in-browser type hints.
👍 2
4 Views