Skip to content

projectService / EXPERIMENTAL_useProjectService gives TS error if not boolean on v8 alpha / v7 #9313

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
hkatzdev opened this issue Jun 9, 2024 · 1 comment
Closed
4 tasks done
Assignees
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 package: typescript-eslint Issues related to the typescript-eslint package
Milestone

Comments

@hkatzdev
Copy link

hkatzdev commented Jun 9, 2024

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

types

ESLint Config

import tseslint from 'typescript-eslint';

// v8 alpha
export default tseslint.config(
  {
    languageOptions: {
      parserOptions: {
        projectService: {
          allowDefaultProject: ['./*.js'],
          defaultProject: './tsconfig.json',
        },
      },
    },
  },
);

// v7
export default tseslint.config(
  {
    languageOptions: {
      parserOptions: {
        EXPERIMENTAL_useProjectService: {
          allowDefaultProject: ['./*.js'],
          defaultProject: './tsconfig.json',
        },
      },
    },
  },
);

tsconfig

{
  "compilerOptions": {
    "allowJs": true,
    "checkJs": true,
  }
}

Expected Result

Config should not have a type error.

Actual Result

On line 7, there is an error.
On v8 alpha:

Type '{ allowDefaultProject: string[]; defaultProject: string; }' is not assignable to type 'boolean'.ts(2322)
parser-options.d.ts(30, 5): The expected type comes from property 'projectService' which is declared here on type 'ParserOptions'

On v7:

Type '{ allowDefaultProject: string[]; defaultProject: string; }' is not assignable to type 'boolean'.ts(2322)
parser-options.d.ts(25, 5): The expected type comes from property 'EXPERIMENTAL_useProjectService' which is declared here on type 'ParserOptions'

Additional Info

Config is adapted from https://typescript-eslint.io/blog/announcing-typescript-eslint-v8-beta/#project-service.
At a glance, it seems like there is a type mismatch between

projectService?: boolean | ProjectServiceOptions;
and . It looks like a similar issue exists in the stable version (
EXPERIMENTAL_useProjectService?: boolean | ProjectServiceOptions;
and
EXPERIMENTAL_useProjectService?: boolean; // purposely undocumented for now
)

Versions

v8 alpha

package version
@typescript-eslint/types 8.0.0-alpha.29
@typescript-eslint/parser 8.0.0-alpha.29
typescript-eslint 8.0.0-alpha.29

v7

package version
@typescript-eslint/types 7.12.0
@typescript-eslint/parser 7.12.0
typescript-eslint 7.12.0
@hkatzdev hkatzdev added bug Something isn't working triage Waiting for team members to take a look labels Jun 9, 2024
@bradzacher bradzacher added package: parser Issues related to @typescript-eslint/parser accepting prs Go ahead, send a pull request that resolves this issue package: typescript-eslint Issues related to the typescript-eslint package and removed triage Waiting for team members to take a look labels Jun 10, 2024
@bradzacher
Copy link
Member

Cc @JoshuaKGoldberg

@bradzacher bradzacher added this to the 8.0.0 milestone Jun 10, 2024
@JoshuaKGoldberg JoshuaKGoldberg self-assigned this Jun 10, 2024
@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 Jun 19, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 19, 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: parser Issues related to @typescript-eslint/parser package: typescript-eslint Issues related to the typescript-eslint package
Projects
None yet
Development

No branches or pull requests

3 participants