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

[isTypeReadonly] Conditional types are always marked as readonly #4420

Closed
3 tasks done
RebeccaStevens opened this issue Jan 9, 2022 · 0 comments · Fixed by #4421
Closed
3 tasks done

[isTypeReadonly] Conditional types are always marked as readonly #4420

RebeccaStevens opened this issue Jan 9, 2022 · 0 comments · Fixed by #4421
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working package: type-utils Issues related to the @typescript-eslint/type-utils package

Comments

@RebeccaStevens
Copy link
Contributor

RebeccaStevens commented Jan 9, 2022

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

type TestType<T> = T extends number[] ? string[] : number[];
isTypeReadonly(checker, type, {})

Expected Result

isTypeReadonly should return false

Actual Result

isTypeReadonly returns true for any conditional type.

Additional Info

Conditional types aren't being tested for and are thus being treated as primitives.

// all non-object, non-intersection types are readonly.
// this should only be primitive types
if (!isObjectType(type) && !isUnionOrIntersectionType(type)) {
return Readonlyness.Readonly;
}

Versions

package version
@typescript-eslint/type-utils 5.9.0
@typescript-eslint/type-utils 5.9.0
TypeScript 4.5.4
node 17.1.0

Also note the error in the template in Versions: @typescript-eslint/type-utils's version is requested twice. I assume there is supposed to be only one or one is supposed to be @typescript-eslint/experimental-utils

@RebeccaStevens RebeccaStevens added the triage Waiting for maintainers to take a look label Jan 9, 2022
RebeccaStevens added a commit to RebeccaStevens/typescript-eslint that referenced this issue Jan 9, 2022
@JoshuaKGoldberg JoshuaKGoldberg changed the title [isTypeReadonly] Conational types are always marked as readonly [isTypeReadonly] Conditional types are always marked as readonly Jan 9, 2022
RebeccaStevens added a commit to RebeccaStevens/typescript-eslint that referenced this issue Jan 10, 2022
RebeccaStevens added a commit to RebeccaStevens/typescript-eslint that referenced this issue Jan 10, 2022
@bradzacher bradzacher added bug Something isn't working package: type-utils Issues related to the @typescript-eslint/type-utils package accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for maintainers to take a look labels Jan 11, 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
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working package: type-utils Issues related to the @typescript-eslint/type-utils package
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants