Bug: [no-unnecessary-type-assertion] false negative with exactOptionalPropertyTypes
compiler option
#5344
Closed
4 tasks done
Labels
accepting prs
Go ahead, send a pull request that resolves this issue
bug
Something isn't working
locked due to age
Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.
package: eslint-plugin
Issues related to @typescript-eslint/eslint-plugin
Before You File a Bug Report Please Confirm You Have Done The Following...
Playground Link
https://typescript-eslint.io/play/#ts=4.7.2&sourceType=module&code=CYUwxgNghgTiAEYD2A7AzgF3gMyUgXPAN4CwAUPPFAPyGYwCWKA5uQL7nLpYBGs8AXhx4AdFCpp49JswA+AVxShsTEMHJA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1tiacTJTIAhtEK0ipWkOTJE0fJQ5N0UOdA7RI4MAF8QOoA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3QAacDUjoAHgENmuAsXmoACpliIseAJ4AVPTuFhR6KQF8QloA
Repro Code
ESLint Config
tsconfig
Expected Result
no-unnecessary-type-assertion
errorActual Result
no error
Additional Info
even thought
exactOptionalPropertyTypes
changes the meaning ofa?: string
to be different toa?: string | undefined
, that difference is not relevant when checking the type offoo.a
, as it will bestring | undefined
in both casesVersions
@typescript-eslint/eslint-plugin
5.30.6
@typescript-eslint/parser
5.30.6
TypeScript
4,7,2
ESLint
8.15.0
The text was updated successfully, but these errors were encountered: