Skip to content

Docs: Clarify that no-duplicate-type-constituents does not conflict with exactOptionalPropertyTypes #10041

Closed
@justmoon

Description

@justmoon

Before You File a Documentation Request Please Confirm You Have Done The Following...

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuedocumentationDocumentation ("docs") that needs adding/updatinglocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions