ValidPath without const assertion? #178
-
🤔 QuestionI'm new to this library, and am still trying to get my head around it. It's very impressive! :) In this sample https://pirix-gh.github.io/ts-toolbelt/modules/_object_pathvalid_.html there's the following code:
Why is const needed? And is there a way to make it work without the const assertion? Hope you can help. |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 2 replies
-
Hi there, Without a const assertion, the type of |
Beta Was this translation helpful? Give feedback.
-
I somehow missed your answer, sorry! What I meant was that, I'd like the type safety to be enforced by the function signature, so the caller does not have to add |
Beta Was this translation helpful? Give feedback.
-
It's a TypeScript limitation, I know how inconvenient this is. To work around that, the only solution is to take rest parameters instead. Or you could have this Maybe this can help you: |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot for your swift reply :) I'll look into those links right away! |
Beta Was this translation helpful? Give feedback.
-
I posted a solution to this problem here in microsoft/TypeScript#30680. It will land soon in ts-toolbelt. |
Beta Was this translation helpful? Give feedback.
-
This is amazing, thank you for doing this! I look forward to it landing is ts-toolbelt too. |
Beta Was this translation helpful? Give feedback.
-
This has been shipped in the latest release https://millsp.github.io/ts-toolbelt/modules/function_narrow.html |
Beta Was this translation helpful? Give feedback.
This has been shipped in the latest release https://millsp.github.io/ts-toolbelt/modules/function_narrow.html