Before You File a Proposal Please Confirm You Have Done The Following...
My proposal is suitable for this project
Link to the rule's documentation
https://typescript-eslint.io/rules/no-duplicate-type-constituents/
Description
I propose that no-duplicate-type-constituents supports a checkOptionalProperties option.
Similar to #9203 - when a property is marked as optional with ?, it implicitly includes undefined in the type definition, so there is no need to explicitly add an | undefined. I'd like to detect these cases and also autofix away the | undefined.
Note that this is explicitly incompatible with the exactOptionalPropertyTypes compiler option, that the rule otherwise is intended to not conflict with (see e.g. #5344). The documentation should clearly state that this option is intended for projects where exactOptionalPropertyTypes is NOT enabled.
Fail
type T = {
a?: string | undefined
}
Pass
Additional Info
I would be more than happy to create a PR that implements this :)
Before You File a Proposal Please Confirm You Have Done The Following...
My proposal is suitable for this project
Link to the rule's documentation
https://typescript-eslint.io/rules/no-duplicate-type-constituents/
Description
I propose that no-duplicate-type-constituents supports a checkOptionalProperties option.
Similar to #9203 - when a property is marked as optional with ?, it implicitly includes undefined in the type definition, so there is no need to explicitly add an | undefined. I'd like to detect these cases and also autofix away the | undefined.
Note that this is explicitly incompatible with the
exactOptionalPropertyTypescompiler option, that the rule otherwise is intended to not conflict with (see e.g. #5344). The documentation should clearly state that this option is intended for projects whereexactOptionalPropertyTypesis NOT enabled.Fail
Pass
Additional Info
I would be more than happy to create a PR that implements this :)