Skip to content

Bug(typescript-estree): Project services default project not working with extended tsconfigs #9205

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
higherorderfunctor opened this issue Jun 1, 2024 · 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: typescript-estree Issues related to @typescript-eslint/typescript-estree
Milestone

Comments

@higherorderfunctor
Copy link
Contributor

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

I have identified two issues with project services.

  1. If the default project's tsconfig.json has an extends, to say a tsconfig.base.json with a common set of compiler options, those compiler options are not used. The example repo is a monorepo with liberal use of project references. An example published package that uses a similar setup is https://github.com/Effect-TS/effect.
  2. Fixing or working around the first issue (both are demonstrated in the example), reveals that parserOptions.extraFileExtensions is not working as expected to setup tsserver for type checking using project references with non-standard file extensions. The example demonstrates how .vue files are not type checking correctly.

I have created a basic patch that solves both issues (minus rigorous testing).

The first issue is triggered by tsserver.readConfigFile at

Replacing with tsserver.getParsedCommandLineOfConfigFile solves the extends issue. This was pretty much lifted from

const parsed = ts.getParsedCommandLineOfConfigFile(

Fixing this issue will reveal the second issue with file extensions. The patch corrects this by forwarding extraFileExtensions to tsserver using service.setHostConfiguration.

Reproduction Repository Link

https://github.com/higherorderfunctor/example-typescript-eslint-bug

Repro Steps

Directions are located in the example repo's README.

The repo has a patch to fix the bugs (enabled by default) and needs to disabled to demonstrate the bugs.

Versions

node --version
v20.12.2

pnpm --version
8.15.5

pnpm list -r
Legend: production dependency, optional only, dev only

example-typescript-eslint-bug@1.0.0 <REDACTED>/example-typescript-eslint-bug (PRIVATE)

devDependencies:
eslint 8.57.0
eslint-plugin-vue 9.26.0
typescript 5.4.5
typescript-eslint 7.11.0
vue-eslint-parser 9.4.3
vue-tsc 2.0.19

package-a@1.0.0 <REDACTED>/example-typescript-eslint-bug/packages/package-a (PRIVATE)

dependencies:
@types/jsdom 21.1.7
@types/node 20.13.0
vite 5.2.12
vue 3.4.27

cat /etc/os-release
ANSI_COLOR="1;34"
BUG_REPORT_URL="https://github.com/NixOS/nixpkgs/issues"
BUILD_ID="24.11.20240529.ad57eef"
DOCUMENTATION_URL="https://nixos.org/learn.html"
HOME_URL="https://nixos.org/"
ID=nixos
IMAGE_ID=""
IMAGE_VERSION=""
LOGO="nix-snowflake"
NAME=NixOS
PRETTY_NAME="NixOS 24.11 (Vicuña)"
SUPPORT_URL="https://nixos.org/community.html"
VERSION="24.11 (Vicuña)"
VERSION_CODENAME="vicuña"
VERSION_ID="24.11"
@higherorderfunctor higherorderfunctor added bug Something isn't working triage Waiting for team members to take a look labels Jun 1, 2024
@higherorderfunctor
Copy link
Contributor Author

Retested with v8. (1) is still present but (2) appears fixed as of alpha.24.

https://github.com/higherorderfunctor/example-typescript-eslint-bug/tree/rc-v8

pnpm list -r
Legend: production dependency, optional only, dev only

example-typescript-eslint-bug@1.0.0 /home/caubut/Documents/work/example-typescript-eslint-bug (PRIVATE)

devDependencies:
eslint 8.57.0
eslint-plugin-vue 9.26.0
typescript 5.4.5
typescript-eslint 8.0.0-alpha.24
vue-eslint-parser 9.4.3
vue-tsc 2.0.19

package-a@1.0.0 /home/caubut/Documents/work/example-typescript-eslint-bug/packages/package-a (PRIVATE)

dependencies:
@types/jsdom 21.1.7
@types/node 20.13.0
vite 5.2.12
vue 3.4.27

@higherorderfunctor higherorderfunctor changed the title Bug: Project services not working with (tsconfig) extends, project references, and extraFileExtensions Bug(typescript-estree): Project services not working with (tsconfig) extends, project references, and extraFileExtensions Jun 2, 2024
@JoshuaKGoldberg
Copy link
Member

JoshuaKGoldberg commented Jun 2, 2024

Wow! Great investigation + report, thanks a million @higherorderfunctor! Are you up for sending a PR? 😁

Confirmed that (1) is a bug we should have fixed. I like the ts.getParsedCommandLineOfConfigFile approach, that makes a lot of sense. cc @jakebailey as FYI.

Confirmed that (2) is fixed now as of #8899 -> #9051.

@JoshuaKGoldberg JoshuaKGoldberg added accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for team members to take a look labels Jun 2, 2024
@JoshuaKGoldberg JoshuaKGoldberg removed their assignment Jun 2, 2024
@JoshuaKGoldberg JoshuaKGoldberg added this to the 8.0.0 milestone Jun 2, 2024
@higherorderfunctor
Copy link
Contributor Author

@JoshuaKGoldberg might take a few days, but if nobody else gets to it by the end of the week I can work the PR.

Thanks for confirming!

@fire332
Copy link

fire332 commented Jun 3, 2024

Does your patch solve your first issue for #8835 ?

EDIT: Nevermind. Just tested and it doesn't.

@Josh-Cena Josh-Cena added the package: typescript-estree Issues related to @typescript-eslint/typescript-estree label Jun 4, 2024
@higherorderfunctor higherorderfunctor changed the title Bug(typescript-estree): Project services not working with (tsconfig) extends, project references, and extraFileExtensions Bug(typescript-estree): Project services default project not working with extended tsconfigs Jun 8, 2024
@higherorderfunctor
Copy link
Contributor Author

Reducing scope to what the PR will solve. The extraFileExtensions issue was already fixed and project references ended up not playing into the issue.

Copy link

Closed by #9306.

@github-actions github-actions bot 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 Aug 5, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 5, 2024
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: typescript-estree Issues related to @typescript-eslint/typescript-estree
Projects
None yet
Development

No branches or pull requests

4 participants