Description
Before You File a Documentation Request Please Confirm You Have Done The Following...
- I have looked for existing open or closed documentation requests that match my proposal.
- I have read the FAQ and my problem is not listed.
Suggested Changes
Add a short note to the docs for no-duplicate-type-constituents to explain that the prohibition of | undefined
only applies to parameters and therefore does not conflict with TypeScript's exactOptionalPropertyTypes
setting which applies to properties.
As someone who uses exactOptionalPropertyTypes: true
, I'm very used to seeing foo?: T | undefined
all over my codebase and out of habit apparently added it to some parameters as well. After upgrading to typescript-eslint@8.5.0
, I got a bunch of errors from no-duplicate-type-constituents
. I immediately assumed that the new rule conflicts with exactOptionalPropertyTypes
but the docs page didn't mention anything about it. So I started searching for issues containing "no-duplicate-type-constituents" "exactOptionalPropertyTypes"
on the typescript-eslint
repo which yielded the original PR where at least two people also got confused by missing that subtle distinction between parameters and properties.
Once you understand the distinction, it makes perfect sense. If the docs clarified it from the start, it would save the next person who runs into this a bunch of time searching.
Affected URL(s)
https://typescript-eslint.io/rules/no-duplicate-type-constituents/
Additional Info
I have a PR ready if helpful: https://github.com/typescript-eslint/typescript-eslint/compare/main...justmoon:docs-optional-undef?expand=1