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(type-utils): union types always being marked as readonly #4419

Merged
merged 8 commits into from Jan 17, 2022

Conversation

RebeccaStevens
Copy link
Contributor

@RebeccaStevens RebeccaStevens commented Jan 9, 2022

PR Checklist

Overview

isTypeReadonly now checks unions properly.

Note: This PR builds off #4416

@nx-cloud
Copy link

nx-cloud bot commented Jan 9, 2022

☁️ Nx Cloud Report

CI ran the following commands for commit 727d999. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 48 targets

Sent with 💌 from NxCloud.

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @RebeccaStevens!

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. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day.

@netlify
Copy link

netlify bot commented Jan 9, 2022

❌ Deploy Preview for typescript-eslint failed.

🔨 Explore the source changes: 727d999

🔍 Inspect the deploy log: https://app.netlify.com/sites/typescript-eslint/deploys/61e5365ed96c3500085cab49

@RebeccaStevens RebeccaStevens force-pushed the issue-4418 branch 3 times, most recently from e6fa110 to 50f6c13 Compare January 9, 2022 08:55
@codecov
Copy link

codecov bot commented Jan 9, 2022

Codecov Report

Merging #4419 (727d999) into main (ef3147c) will decrease coverage by 1.52%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main    #4419      +/-   ##
==========================================
- Coverage   94.23%   92.70%   -1.53%     
==========================================
  Files         169      161       -8     
  Lines        9448     8144    -1304     
  Branches     2948     2612     -336     
==========================================
- Hits         8903     7550    -1353     
- Misses        321      395      +74     
+ Partials      224      199      -25     
Flag Coverage Δ
unittest 92.70% <ø> (-1.53%) ⬇️

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

Impacted Files Coverage Δ
packages/type-utils/src/isTypeReadonly.ts 78.57% <ø> (ø)
...ript-estree/src/create-program/createSourceFile.ts
...ckages/typescript-estree/src/jsx/xhtml-entities.ts
...lugin-internal/src/rules/plugin-test-formatting.ts
...-internal/src/rules/no-typescript-estree-import.ts
packages/typescript-estree/src/convert.ts
...ges/typescript-estree/src/create-program/shared.ts
packages/typescript-estree/src/node-utils.ts
...estree/src/create-program/createIsolatedProgram.ts
...pt-estree/src/create-program/createWatchProgram.ts
... and 27 more

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.

LGTM! I'm up for merging this in as-is, but feel mildly positive about suggested changes. What about you?

If nobody is opinionated after a few days + the next time I take a look, I can just merge :)

type: ts.Type;
checker: ts.TypeChecker;
} {
const { ast, services } = parseForESLint(code, {
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, this is essentially the same as the code at the beginning of isUnsafeAssignment.

const { ast, services } = parseForESLint(code, {

Since we're starting to establish a precedent of unit testing these type utilities directly, I think we'll want to make a standard way to generate the AST & node maps for them. What do you think about making a standard util like this?:

const { body, checker, esTreeNodeToTSNodeMap } = parseForUtilTest(code);

packages/type-utils/tests/isTypeReadonly.test.ts Outdated Show resolved Hide resolved
@RebeccaStevens RebeccaStevens force-pushed the issue-4418 branch 2 times, most recently from 1e1bfdd to c61f18d Compare January 10, 2022 07:37
@bradzacher bradzacher added the bug Something isn't working label Jan 11, 2022
@bradzacher bradzacher added the awaiting response Issues waiting for a reply from the OP or another party label Jan 17, 2022
@bradzacher
Copy link
Member

I merged your test PR first - just needs the conflict resolved and we can merge this!

@bradzacher bradzacher removed the awaiting response Issues waiting for a reply from the OP or another party label Jan 17, 2022
bradzacher
bradzacher previously approved these changes Jan 17, 2022
Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

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

thanks for fixing this!

bradzacher
bradzacher previously approved these changes Jan 17, 2022
@bradzacher bradzacher merged commit 99ab193 into typescript-eslint:main Jan 17, 2022
@RebeccaStevens RebeccaStevens deleted the issue-4418 branch January 17, 2022 10:39
lonyele pushed a commit to lonyele/typescript-eslint that referenced this pull request Feb 12, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 17, 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.

[isTypeReadonly] Unions are always marked as readonly
3 participants