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(eslint-plugin): isTypeReadonly error with <TS3.7 #3731

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions .all-contributorsrc
Expand Up @@ -400,6 +400,13 @@
"avatar_url": "https://avatars.githubusercontent.com/u/16860535?v=4",
"profile": "https://github.com/soobing",
"contributions": []
},
{
"login": "RebeccaStevens",
"name": "Rebecca Stevens",
"avatar_url": "https://avatars.githubusercontent.com/u/7224206?v=4",
"profile": "https://github.com/RebeccaStevens",
"contributions": []
}
],
"contributorsPerLine": 5
Expand Down
7 changes: 6 additions & 1 deletion packages/eslint-plugin/src/util/isTypeReadonly.ts
Expand Up @@ -23,7 +23,12 @@ function isTypeReadonlyArrayOrTuple(
seenTypes: Set<ts.Type>,
): Readonlyness {
function checkTypeArguments(arrayType: ts.TypeReference): Readonlyness {
const typeArguments = checker.getTypeArguments(arrayType);
const typeArguments =
// getTypeArguments was only added in TS3.7
checker.getTypeArguments
? checker.getTypeArguments(arrayType)
: arrayType.typeArguments ?? [];

// this shouldn't happen in reality as:
// - tuples require at least 1 type argument
// - ReadonlyArray requires at least 1 type argument
Expand Down