Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(typescript-estree): handle 3.9's non-null assertion changes #2036

Merged
merged 3 commits into from May 21, 2020

Commits on May 18, 2020

  1. 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.
    bradzacher committed May 18, 2020
    Copy the full SHA
    81741e6 View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    c2ea63f View commit details
    Browse the repository at this point in the history
  3. Copy the full SHA
    85e58c9 View commit details
    Browse the repository at this point in the history