Should ScalarTag be generic? #527
Unanswered
MindfulMinun
asked this question in
Q&A
Replies: 1 comment
-
It could be, but would that really be beneficial? At the moment, the typing is kinda forcing you to either:
Both approaches are valid, but if the ScalarTag did let you narrow down the type, then you'd probably never consider the first choice. In the built-in tags (under |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I'm encountering some TypeScript problems when using this library. I have a document with a custom tag
!day
, and this is the ScalarTag I've come up with.Unfortunately, I get an error on the last line. According to TypeScript, I can't call
toISOString
on that value because it'sunknown
. I've also tried to change the function like so:but I get another error stating that unknown is unassignable to Date. Currently I'm using this code as a workaround:
but this leads me to think that ScalarTag should be generic and take an optional type parameter like so:
Beta Was this translation helpful? Give feedback.
All reactions