Conversation
| @@ -0,0 +1 @@ | |||
| export type IsEmpty<T> = [keyof T] extends [never] ? true : false; | |||
There was a problem hiding this comment.
Hah, I have seen that one somewhere else ;)
There was a problem hiding this comment.
Hey @danieldietrich,
I didn't though you'd see that.
In fact, I am just testing pre-releasing and Deno an NPM for a PR that I have going on.
I wouldn't just steal your utility without asking you first :)
About actually including IsEmpty<> I am divided.
On one and it's something that I need all the time, to make sure that I didn't forget to deconstruct any properties of an object, it is super handy.
I often do
const {foo, bar, baz, ...rest } = obj
assert<Equals<keyof typeof rest, never>>();I don't really need a utility but it does look cryptic to my colleagues, the following would make the assert statement much more transparent:
const {foo, bar, baz, ...rest } = obj
assert<IsEmpty<typeof rest>>();So I think it might be worth including.
I also think I should maybe rearrange the documentation and gather under a unique section all helper types that are meant to be used with assert<>()
Anyway, I'll close this for now but to be continued. :)
PS: I have opened an issue that I think if implemented properly could be game changing.
#18 I'd love to know what you think.
Best regards,
No description provided.