Hey all, encountering a TypeScript error I’m not f...
# general
b
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
Remove that quotes on “foo”
b
^, it's a JS object declaration
b
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
b
oh it wants the tags property maybe? so:
Copy code
defaultTags: {
   tags: {
       foo: "bar"
   },
}
👏 1
b
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