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): intersection types involving readonly arrays are now handled in most cases #4429

Merged
merged 23 commits into from Jan 17, 2022

Conversation

RebeccaStevens
Copy link
Contributor

@RebeccaStevens RebeccaStevens commented Jan 10, 2022

PR Checklist

Overview

isTypeReadonly now handles intersection involving readonly arrays and tuples properly in most cases.

The cases that aren't handled are those of that intersect a readonly array with an object that shares mutable properties with the array. For example:

type Test = ReadonlyArray<string> & { length: string; };

Handling this in the general case may not be possible as we can't treat readonly arrays in nested intersections properly (at least not without a lot of work).
As a workaround, users can just wrap their intersection in Readonly if they come across this case.

Note: This PR builds off #4416

@nx-cloud
Copy link

nx-cloud bot commented Jan 10, 2022

☁️ Nx Cloud Report

CI ran the following commands for commit bd475fb. 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 10, 2022

✔️ Deploy Preview for typescript-eslint ready!

🔨 Explore the source changes: bd475fb

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

😎 Browse the preview: https://deploy-preview-4429--typescript-eslint.netlify.app

@bradzacher bradzacher added the bug Something isn't working label Jan 11, 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 so much for handling this!
I merged your test PR first - just needs the conflict resolved and we can merge this!

@bradzacher bradzacher added the awaiting response Issues waiting for a reply from the OP or another party label Jan 17, 2022
@bradzacher bradzacher removed the awaiting response Issues waiting for a reply from the OP or another party label Jan 17, 2022
@codecov
Copy link

codecov bot commented Jan 17, 2022

Codecov Report

Merging #4429 (bd475fb) into main (f4016c2) will decrease coverage by 1.81%.
The diff coverage is 93.33%.

@@            Coverage Diff             @@
##             main    #4429      +/-   ##
==========================================
- Coverage   94.54%   92.73%   -1.82%     
==========================================
  Files         147      161      +14     
  Lines        7851     8160     +309     
  Branches     2516     2621     +105     
==========================================
+ Hits         7423     7567     +144     
- Misses        234      392     +158     
- Partials      194      201       +7     
Flag Coverage Δ
unittest 92.73% <93.33%> (-1.82%) ⬇️

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

Impacted Files Coverage Δ
packages/type-utils/src/isTypeReadonly.ts 84.69% <93.33%> (ø)
packages/type-utils/src/typeFlagUtils.ts 83.33% <0.00%> (ø)
packages/type-utils/src/propertyTypes.ts 87.50% <0.00%> (ø)
packages/type-utils/src/containsAllTypesByName.ts 0.00% <0.00%> (ø)
packages/type-utils/src/getContextualType.ts 0.00% <0.00%> (ø)
packages/type-utils/src/getTokenAtPosition.ts 0.00% <0.00%> (ø)
...ges/type-utils/src/getConstrainedTypeAtLocation.ts 0.00% <0.00%> (ø)
packages/type-utils/src/isUnsafeAssignment.ts 84.00% <0.00%> (ø)
packages/type-utils/src/getSourceFileOfNode.ts 0.00% <0.00%> (ø)
packages/type-utils/src/getTypeArguments.ts 25.00% <0.00%> (ø)
... and 5 more

@bradzacher
Copy link
Member

ugh. git is the worst.

@bradzacher bradzacher enabled auto-merge (squash) January 17, 2022 11:26
@bradzacher bradzacher merged commit 5046882 into typescript-eslint:main Jan 17, 2022
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
@RebeccaStevens RebeccaStevens deleted the issue-4428 branch March 10, 2023 23:27
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] Intersections involving a readonly array fail
2 participants