Skip to content

Bug: EXPERIMENTAL_useProjectService: true throws unclear error if file is not included in a program #7435

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

Closed
4 tasks done
mrazauskas opened this issue Aug 7, 2023 · 6 comments
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. package: parser Issues related to @typescript-eslint/parser
Milestone

Comments

@mrazauskas
Copy link
Contributor

mrazauskas commented Aug 7, 2023

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Relevant Package

parser

Playground Link

No response

Repro

To the root of a project that is using EXPERIMENTAL_useProjectService: true recently I added rollup.config.js. That file was not added to tsconfig's include list. ESLint throws:

Error while loading rule '@typescript-eslint/consistent-type-exports': You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project" property for @typescript-eslint/parser.

By the way, it was so exciting to see the EXPERIMENTAL_useProjectService option added. The project I talk about is rather experimental so it was perfect playground to tryout the ProjectService.

ESLint Config

module.exports = {
  parser: "@typescript-eslint/parser",
  parserOptions: {
    "EXPERIMENTAL_useProjectService": true
  }
};

tsconfig

{
  "include": ["./src"]
}

Expected Result

Perhaps the error could be more useful. If this should be an error at all. Not sure what is going on.

Actual Result

Looking at the error, I thought that maybe the option was removed or stoped working.

Additional Info

No response

Versions

package version
@typescript-eslint/parser 6.2.1
@mrazauskas mrazauskas added bug Something isn't working triage Waiting for team members to take a look labels Aug 7, 2023
@JoshuaKGoldberg
Copy link
Member

Ahh so exciting that you're trying out the new option @mrazauskas! 🙌

Would you be able to provide us with a minimum reproduction of what you're seeing locally? Failing that, would we be able to see the original code? We're happy to sign whatever NDAs are needed if this is private.

@JoshuaKGoldberg JoshuaKGoldberg added unable to repro issues that a maintainer was not able to reproduce package: parser Issues related to @typescript-eslint/parser and removed triage Waiting for team members to take a look labels Aug 7, 2023
@mrazauskas
Copy link
Contributor Author

Reproduction is here: https://github.com/mrazauskas/x-use-project-service

  1. Install with yarn
  2. Run yarn lint and you will see the error
  3. Delete rollup.config.js file in the root
  4. Run yarn lint and the error is gone
  5. Bring rollup.config.js file back
  6. Open tsconfig.json and uncomment one line in the include list
  7. Run yarn lint, there will be no error as well

@quantizor
Copy link

quantizor commented Sep 6, 2023

I ran into this too today.

Error: Error while loading rule '@typescript-eslint/dot-notation': You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project" property for @typescript-eslint/parser.
Occurred while linting /Users/esj/code/frontend-v2/packages/cad-pro/src/integration/autodesigner/autodesigner-defaults.docker-integration.tsx
    at getParserServices (/Users/esj/code/frontend-v2/node_modules/@typescript-eslint/utils/dist/eslint-utils/getParserServices.js:24:15)
    at create (/Users/esj/code/frontend-v2/node_modules/@typescript-eslint/eslint-plugin/dist/rules/dot-notation.js:84:55)
    at Object.create (/Users/esj/code/frontend-v2/node_modules/@typescript-eslint/utils/dist/eslint-utils/RuleCreator.js:38:20)
    at createRuleListeners (/Users/esj/code/frontend-v2/node_modules/eslint/lib/linter/linter.js:870:21)
    at /Users/esj/code/frontend-v2/node_modules/eslint/lib/linter/linter.js:1040:110
    at Array.forEach (<anonymous>)
    at runRules (/Users/esj/code/frontend-v2/node_modules/eslint/lib/linter/linter.js:977:34)
    at Linter._verifyWithoutProcessors (/Users/esj/code/frontend-v2/node_modules/eslint/lib/linter/linter.js:1330:31)
    at Linter._verifyWithConfigArray (/Users/esj/code/frontend-v2/node_modules/eslint/lib/linter/linter.js:1706:21)
    at Linter.verify (/Users/esj/code/frontend-v2/node_modules/eslint/lib/linter/linter.js:1412:65)
v%    

My config (override object):

files: ['*.{ts,tsx}'],
settings: {
  'import/parsers': {
    '@typescript-eslint/parser': ['.ts', '.tsx', '.d.ts'],
  },
  'import/resolver': {
    node: {
      extensions: ['.js', '.jsx', '.json', '.d.ts', '.tsx', '.ts', '.mjs'],
    },
  },
},
parser: '@typescript-eslint/parser',
parserOptions: {
  project: ['./tsconfig.json', './tsconfig.integration.json'],
  EXPERIMENTAL_useProjectService: true,
},
extends: [
  'plugin:@typescript-eslint/eslint-recommended',
  'plugin:@typescript-eslint/recommended',
],
plugins: [
  '@typescript-eslint',
],

The file being linted is included by ./tsconfig.integration.json but it seems like that project settings field might be ignored now?

The only debug information from the plugin is:

  typescript-eslint:typescript-estree:createSourceFile Getting AST without type information in TSX mode for: /Users/esj/code/frontend-v2/packages/cad-pro/src/integration/autodesigner/autodesigner-defaults.docker-integration.tsx +0ms

Then it crashes. FWIW other files seem to be working just fine and the performance is significantly better!

@JoshuaKGoldberg JoshuaKGoldberg added accepting prs Go ahead, send a pull request that resolves this issue and removed unable to repro issues that a maintainer was not able to reproduce labels Sep 6, 2023
@JoshuaKGoldberg
Copy link
Member

Thanks for the reminder - I was actually able to repro this myself. I did a brief dive and it doesn't look easy to solve.

I'm hoping to close out some work on DefinitelyTyped this month (DefinitelyTyped/DefinitelyTyped#65993), then pick up this issue in earnest after that.

@mrazauskas
Copy link
Contributor Author

@JoshuaKGoldberg It feels like this issue is resolved after #8815. Or?

@JoshuaKGoldberg
Copy link
Member

JoshuaKGoldberg commented Apr 15, 2024

Yes, good call - thanks! #8815 also resolved this.

We'll push out more comprehensive docs soon (#7350).

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 23, 2024
@bradzacher bradzacher added the locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. label Apr 14, 2025
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 locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. package: parser Issues related to @typescript-eslint/parser
Projects
None yet
Development

No branches or pull requests

4 participants