Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ESLint "Parsing error: ',' expected." when using TypeScript satisfies operator

I'm trying to use TypeScript's new satisfies operator to keep the most specific type for a variable in my code, but ESLint is throwing a Parsing error: ',' expected. error on the closing curly bracket of the object when I add satisfies Prisma.gameInclude; to the end of it.

Here's how the object in question looks:

const includeFields = {
  participants: true,
  queue: {
    include: {
      gamemode: {
        include: {
          character_pool: {
            include: {
              characters: true,
            },
          },
        },
      },
    },
  },
} satisfies Prisma.gameInclude;
^ Parsing error: ',' expected.

And here's my .eslintrc.js

module.exports = {
  env: {
    browser: true,
    es2021: true,
    node: true,
  },
  extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
  overrides: [],
  parser: "@typescript-eslint/parser",
  parserOptions: {
    ecmaVersion: "latest",
    sourceType: "module",
  },
  plugins: ["@typescript-eslint", "unused-imports"],
  rules: {
    "unused-imports/no-unused-imports": "error",
  },
};

I've tried adding the parserOptions.project property to it pointing to my tsconfig, but no luck.

Reading through some PRs and issues for typescript-eslint I found our that it does already support the satisfies operator. I'm currently on its latest version, 5.56.0.

How can I fix this?

like image 683
Pedro Fracassi Avatar asked Mar 28 '26 10:03

Pedro Fracassi


1 Answers

Well, that's embarassing. I found the cause of the error a few minutes after posting this question.

Upon checking the package.json for this project I found out that typescript was on version 4.3.5. The satisfies operator was added on TypeScript 4.9.

Updating TS to its newest version, 5.0.2, fixed the issue.

like image 99
Pedro Fracassi Avatar answered Mar 29 '26 22:03

Pedro Fracassi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!