Typing a helper function parameter to be a table with required column(s)
I'm having a hard time typing some helper functions where I need some params to accept any table as long as it implements certain required columns (key and type). Here's what i'm aiming for:
Anyone have experience with this?
7 Replies
How about:
Hmmm, that could very well do! For some reason I was trying to use
AnyTable
's generic instead of just doing an intersectionI mean, you could, but why complicate it:
And say I want to be stricter regarding
locale
's type since I know it should be implemented on tables using a common definition:
I'm struggling to infer a table-agnostic column type for this.
(sorry for the deluge of things named locale
)The columns that you pass to a table definition get transformed by the table function
What you could do is use one of the tables where those columns are implemented and pull the types from them:
Alrighty, here's what I've got then:
Ah, yeah I could try that
Then you could do: