Skip to content
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

Bug: typescript-estree 6.16.0+ requires TypeScript v5.3+ #8172

Closed
4 tasks done
adidahiya opened this issue Jan 2, 2024 · 2 comments · Fixed by #8193
Closed
4 tasks done

Bug: typescript-estree 6.16.0+ requires TypeScript v5.3+ #8172

adidahiya opened this issue Jan 2, 2024 · 2 comments · Fixed by #8193
Assignees
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working package: typescript-estree Issues related to @typescript-eslint/typescript-estree

Comments

@adidahiya
Copy link

adidahiya commented Jan 2, 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

typescript-estree

Playground Link

No response

Repro Code

(sorry this isn't minimal)

I'm compiling my eslint plugin with custom rules which use the @typescript-eslint/utils package.

While trying to upgrade to typescript-eslint 6.16, I encountered a type incompatibility with typescript 5.2.

See failing CI job for the dependabot upgrade

ESLint Config

No response

tsconfig

No response

Expected Result

No errors, my ESLint plugin is able to compile with TypeScript 5.2. I did not expect to be required to upgrade to TypeScript 5.3 at this time.

Actual Result

../../node_modules/@typescript-eslint/typescript-estree/dist/create-program/createProjectService.d.ts:8:121 - error TS2694: Namespace 'ts' has no exported member 'JSDocParsingMode'.

8 export declare function createProjectService(options: boolean | ProjectServiceOptions | undefined, jsDocParsingMode: ts.JSDocParsingMode | undefined): ProjectServiceSettings;
                                                                                                                          ~~~~~~~~~~~~~~~~


Found 1 error in ../../node_modules/@typescript-eslint/typescript-estree/dist/create-program/createProjectService.d.ts:8

Additional Info

I noticed your note about a type incompatibility caveat in the 6.13.0 release notes, but I believe my issue is distinct.

It appears that ts.JSDocParsingMode is not available in tsserverlibrary.d.ts in typescript@5.2.2, so that reference fails when I try to compile @blueprintjs/eslint-plugin with @typescript-eslint/utils types.

Versions

package version
@typescript-eslint/rule-tester 6.16.0
@typescript-eslint/typescript-estree 6.16.0
@typescript-eslint/utils 6.16.0
TypeScript 5.2.2
ESLint 8.56.0
node 18.18.1
@adidahiya adidahiya added bug Something isn't working triage Waiting for maintainers to take a look labels Jan 2, 2024
@drewbrend

This comment has been minimized.

@JoshuaKGoldberg
Copy link
Member

👋 Hey again @adidahiya, good to see you as always! + thanks for filing.

This was meant to be fixed in #7997 / #7999 with:

// Workaround to support new TS version features for consumers on old TS versions
declare module 'typescript' {
// Added in TypeScript 5.3
enum JSDocParsingMode {}
}

...but confirmed that removing skipLibCheck from https://github.com/palantir/blueprint/blob/b80ca1df59a3b6da1e7b33dd6d2e6ce1e80e9ba3/packages/eslint-plugin/src/tsconfig.json, setting TypeScript to 5.2.2 in all the repo's package.jsons, and running yarn compile from its packages/eslint-plugin directory gives the same issue on my machine:

../../node_modules/@typescript-eslint/typescript-estree/dist/create-program/createProjectService.d.ts:8:121 - error TS2694: Namespace 'ts' has no exported member 'JSDocParsingMode'.

8 export declare function createProjectService(options: boolean | ProjectServiceOptions | undefined, jsDocParsingMode: ts.JSDocParsingMode | undefined): ProjectServiceSettings;
                                                                                                                          ~~~~~~~~~~~~~~~~


Found 1 error in ../../node_modules/@typescript-eslint/typescript-estree/dist/create-program/createProjectService.d.ts:8

I think the root cause is that the declare module 'typescript' doesn't impact import type * as ts from 'typescript/lib/tsserverlibrary'; imports. The createProjectService.d.ts contents are:

import type * as ts from 'typescript/lib/tsserverlibrary';
import type { ProjectServiceOptions } from '../parser-options';
export type TypeScriptProjectService = ts.server.ProjectService;
export interface ProjectServiceSettings {
    allowDefaultProjectForFiles: string[] | undefined;
    service: TypeScriptProjectService;
}
export declare function createProjectService(options: boolean | ProjectServiceOptions | undefined, jsDocParsingMode: ts.JSDocParsingMode | undefined): ProjectServiceSettings;
//# sourceMappingURL=createProjectService.d.ts.map

If I add in a declare module 'typescript/lib/tsserverlibrary' that also merges in an empty JSDocParsingMode the error goes away. I'll send a PR.

#1752 -> #5573 would have caught this error. I hope we'll have to get to those soon.

@JoshuaKGoldberg JoshuaKGoldberg self-assigned this Jan 5, 2024
@JoshuaKGoldberg JoshuaKGoldberg added package: typescript-estree Issues related to @typescript-eslint/typescript-estree accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for maintainers to take a look labels Jan 5, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 20, 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 package: typescript-estree Issues related to @typescript-eslint/typescript-estree
Projects
None yet
3 participants