Skip to content

Dynamic Parameters using a single field named name avoids type safety #4742

Answered by Andarist
turgid-tributary asked this question in Q&A
Discussion options

You must be logged in to vote

My question is simply why this might be happening? I

It's because TS is a structural type system and functions... have .name property that is a string. So to hit this problem you specifically have to have name: string in your params (where a name's type usually would be a string).

I had a PR fixing this (here) but we decided to close it since this is not a super common problem and it would require us to do "weird things" to overcome this. Maybe we should revisit that decision though

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@turgid-tributary
Comment options

Answer selected by turgid-tributary
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants