Skip to content

Commit

Permalink
fix(eslint-plugin): isTypeReadonly error with <TS3.7 (#3731)
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaStevens committed Aug 30, 2021
1 parent 921cbca commit 5696407
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
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

0 comments on commit 5696407

Please sign in to comment.