ok, I see the issue, the tsconfig I was inheriting from (node12) sets strict: true, which does not pass in this case
specifically, it seems that this fails because strict implies strictNullChecks, and given that this type is nullable it won't pass (if I cast it as { [name: string] : string } it's ok)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
the sample snippet doesn't build for me:
fixed it as follows:
(note, this won't actually enforce runtime type checks, but it will make it compile)
Interesting... it works well for me, code runs as expected and
ts-checks
return no warnings or errorsPlus
{ msg }
definitely exists in type[name: string] : string
😜ok, I see the issue, the tsconfig I was inheriting from (node12) sets strict: true, which does not pass in this case
specifically, it seems that this fails because strict implies strictNullChecks, and given that this type is nullable it won't pass (if I cast it as
{ [name: string] : string }
it's ok)