Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(typescript-estree): handle 3.9's non-null assertion changes
[TS 3.9 introduced a breaking change for how non-null assertions are handled in optional chains](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-9.html#parsing-differences-in-optional-chaining-and-non-null-assertions). Pre-3.9, `x?.y!.z` means `(x?.y).z` - i.e. it essentially scrubbed the optionality from the chain Post-3.9, `x?.y!.z` means `x?.y!.z` - i.e. it just asserts that the property `y` is non-null, not the result of `x?.y` This PR: **updates the AST so it matches this** Previously `x?.y!.z` produced `MemberExpression > TSNonNullAssertion > OptionalMemberExpression`. Now it produces `OptionalMemberExpression > TSNonNullAssertion > OptionalMemberExpression`. Note that `(x?.y)!.z` still produces `MemberExpression > TSNonNullAssertion > OptionalMemberExpression`. Same results apply for call expressions. **updates `no-non-null-asserted-optional-chain` to handle this** With the above AST change, the only change needed was a simple "is parent optional chain" check. Both of these changes are gated behind a version check, so they are completely backwards compatible.
- Loading branch information
1 parent
1bc105a
commit 81741e6
Showing
16 changed files
with
9,958 additions
and
3,626 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.