Skip to content

Bug: parserOptions.projectService does not respect extraFileExtensions #8899

Closed
@alfredringstad

Description

@alfredringstad

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.

Issue Description

When linting a project containing e.g. svelte files, you need to provide extraFileExtensions: ['.svelte'] to make the parser use the correct tsconfig for the specific file. This works well with project: true, since that path ends up in createWatchProgram where we provide the extraFileExtensions option to ts.

However, if we switch EXPERIMENTAL_useProjectService on, we end up in a code path where the extraFileExtensions are not passed to ts. In my reproduction case this is surfaced by the fact that ts will then use the default compiler options, which transpiles the code back to ES5, instead of using the correct tsconfig.

While this reproduction example is using Svelte, the same issue should apply to other cases where extraFileExtensions would be used (such as when using Vite).

Reproduction Repository Link

https://github.com/alfredringstad/typescript-eslint-svelte-use-project-service-bug-reproduction

Repro Steps

  1. clone the repo
  2. npm i
  3. npm run lint

Switch EXPERIMENTAL_useProjectService to false in eslint.config.js and run npm run lint to see how it works well without the project service.

Versions

package version
@typescript-eslint/parser 7.6.0
@typescript-eslint/typescript-estree 7.6.0
TypeScript 5.4.5
ESLint 8.57.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workinglocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: typescript-estreeIssues related to @typescript-eslint/typescript-estree

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions