-
-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable --exactOptionalPropertyTypes
#14
Comments
Almost 3 months into 2023, is it time yet? |
I think this will make conditional properties annoying to set: const a: A = {
name: 'Fregante',
email: user.hasEmail ? user.email : undefined
} Would need to be: const a: A = {
name: 'Fregante',
...(user.hasEmail ? {email: user.email} : undefined)
} Or worse yet split with an JavaScript badly needs a new nullish value 🤭 const a: A = {
name: 'Fregante',
email: user.hasEmail ? user.email : reallyundefined
} |
TS ESlint has issues with |
@fregante It only makes it annoying to set if the type hasn't been explicitly set to accept type A = {
email?: string
}
const foo: A = {
email: '[email protected]'
}
if ('email' in foo && foo.email.length > 1) {
console.log('This only works with exactOptionalPropertyTypes');
} When it comes to module development its good to have I personally have |
I don't want to do it yet as it will cause some friction. We can try to enable it in 2023.
https://devblogs.microsoft.com/typescript/announcing-typescript-4-4/#exact-optional-property-types
The text was updated successfully, but these errors were encountered: