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

fix(ast-spec): correct some incorrect ast types #6257

Merged
merged 2 commits into from
Dec 21, 2022

Conversation

bradzacher
Copy link
Member

PR Checklist

Overview

These changes will be disruptive to downstream consumers but they are correct and will help expose potentially bad code.
Particularly the sparse array type fix because it's meant to include null, not just some other node type. They're a rarer case in code (because sparse arrays are one of the dumbest features in JS), but if encountered it will crash code that doesn't expect it.

@bradzacher bradzacher added the bug Something isn't working label Dec 21, 2022
@typescript-eslint
Copy link
Contributor

Thanks for the PR, @bradzacher!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint.

@nx-cloud
Copy link

nx-cloud bot commented Dec 21, 2022

☁️ Nx Cloud Report

CI is running/has finished running commands for commit a87c2ce. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 47 targets

Sent with 💌 from NxCloud.

@netlify
Copy link

netlify bot commented Dec 21, 2022

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit a87c2ce
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/63a273dfad47780009c62e94
😎 Deploy Preview https://deploy-preview-6257--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@codecov
Copy link

codecov bot commented Dec 21, 2022

Codecov Report

Merging #6257 (a87c2ce) into main (ccd45d4) will decrease coverage by 0.01%.
The diff coverage is 0.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6257      +/-   ##
==========================================
- Coverage   91.28%   91.27%   -0.02%     
==========================================
  Files         366      366              
  Lines       12445    12445              
  Branches     3645     3645              
==========================================
- Hits        11361    11359       -2     
+ Misses        773      772       -1     
- Partials      311      314       +3     
Flag Coverage Δ
unittest 91.27% <0.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...lugin-internal/src/rules/plugin-test-formatting.ts 79.76% <0.00%> (-1.16%) ⬇️
...slint-plugin/src/rules/no-unnecessary-condition.ts 98.33% <ø> (ø)
...plugin/src/rules/prefer-string-starts-ends-with.ts 97.83% <ø> (ø)
...int-plugin/src/rules/require-array-sort-compare.ts 88.23% <ø> (ø)

import type { Property } from '../element/Property/spec';
import type { SpreadElement } from '../element/SpreadElement/spec';

export type ObjectLiteralElement = MethodDefinition | Property | SpreadElement;
export type ObjectLiteralElement = Property | SpreadElement;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, I guess they're not the same in objects. Cool.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah objects use Property with method: true

There's definitely scope to work on the Property type to better discriminate the union based on the flags.
I might raise a PR to do that soon as it's a pretty nice property to have hyper-specific types for this sort of case.

I actually did it when I wrote the flow-estree types
https://github.com/facebook/hermes/blob/main/tools/hermes-parser/js/hermes-estree/src/types.js#L448-L536
(looks like I didn't do method types, but that's a natural next step)

Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're confident changing the types here isn't a breaking change, then I am! LGTM :) thanks for doing these.

@bradzacher
Copy link
Member Author

For posterity - in theory these are breaking changes as they will cause errors in consumer's code.

In practice however we consider this a bug fix because the types did not match reality - the existing runtime values did not match the old types - meaning any new type errors in consuming are flagging code that may be broken and may crash for some cases.

@bradzacher bradzacher merged commit 0f3f645 into main Dec 21, 2022
@bradzacher bradzacher deleted the fix-ast-types-20221221 branch December 21, 2022 21:06
@Josh-Cena
Copy link
Member

@bradzacher Sorry for the late message, but as a heads-up, virtually all expressions' type defs are too narrow after removal of the ParenthesizedExpression node. For example, typeof (1, 2) produces UnaryExpression.argument: SequenceExpression, but the type says that argument is LeftHandSideExpression | Literal | UnaryExpression.

omril1 pushed a commit to omril1/typescript-eslint that referenced this pull request Dec 22, 2022
* fix(ast-spec): correct some ast types

* type error
crapStone pushed a commit to Calciumdibromid/CaBr2 that referenced this pull request Dec 27, 2022
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint) | devDependencies | patch | [`5.47.0` -> `5.47.1`](https://renovatebot.com/diffs/npm/@typescript-eslint%2feslint-plugin/5.47.0/5.47.1) |
| [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint) | devDependencies | patch | [`5.47.0` -> `5.47.1`](https://renovatebot.com/diffs/npm/@typescript-eslint%2fparser/5.47.0/5.47.1) |

---

### Release Notes

<details>
<summary>typescript-eslint/typescript-eslint (@&#8203;typescript-eslint/eslint-plugin)</summary>

### [`v5.47.1`](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#&#8203;5471-httpsgithubcomtypescript-eslinttypescript-eslintcomparev5470v5471-2022-12-26)

[Compare Source](typescript-eslint/typescript-eslint@v5.47.0...v5.47.1)

##### Bug Fixes

-   **ast-spec:** correct some incorrect ast types ([#&#8203;6257](typescript-eslint/typescript-eslint#6257)) ([0f3f645](typescript-eslint/typescript-eslint@0f3f645))
-   **eslint-plugin:** \[member-ordering] correctly invert optionalityOrder ([#&#8203;6256](typescript-eslint/typescript-eslint#6256)) ([ccd45d4](typescript-eslint/typescript-eslint@ccd45d4))

</details>

<details>
<summary>typescript-eslint/typescript-eslint (@&#8203;typescript-eslint/parser)</summary>

### [`v5.47.1`](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/parser/CHANGELOG.md#&#8203;5471-httpsgithubcomtypescript-eslinttypescript-eslintcomparev5470v5471-2022-12-26)

[Compare Source](typescript-eslint/typescript-eslint@v5.47.0...v5.47.1)

**Note:** Version bump only for package [@&#8203;typescript-eslint/parser](https://github.com/typescript-eslint/parser)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC43My4xIiwidXBkYXRlZEluVmVyIjoiMzQuNzMuMSJ9-->

Co-authored-by: cabr2-bot <cabr2.help@gmail.com>
Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1693
Reviewed-by: Epsilon_02 <epsilon_02@noreply.codeberg.org>
Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: MemberExpression.object should be Expression, not LeftHandSideExpression
3 participants