Open gkielyellation opened 3 years ago
Hi @gkielyellation.
You will have the same behavior if you will move the question mark after :
like this:
type ObjectType = {
key: ?string
}
const test: ObjectType = {};
But in the next version (Hegel 2) we will use TypeScript syntax :)
@JSMonk isn't it significant whether the key is present or not?
I think that, If the developer defined the property as undefinedable
, it means that it thinks that the property can be inside the object, so, in the case there is no difference, because in both case, at the static time, the result will be undefined
.
The only difference will be when we use in
operator.
Object.keys
and Object.entries
also give different results when prop is not there vs when prop is undefined
It's true. And also we infer the keys result from the object type.
It would be great for users coming from typescript to be able to write the following:
Thanks.