Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

TS versions for parsing source and linting rules differ #281

Closed
Maxim-Mazurok opened this issue Mar 24, 2020 · 4 comments · Fixed by #295
Closed

TS versions for parsing source and linting rules differ #281

Maxim-Mazurok opened this issue Mar 24, 2020 · 4 comments · Fixed by #295

Comments

@Maxim-Mazurok
Copy link

It all started here, when our CI for linting type definitions for Google APIs started failing after dtslint update: Maxim-Mazurok/google-api-typings-generator#101

First, I thought that something is wrong with TS itself, so I opened issue there with my investigation details: microsoft/TypeScript#37551

But then I found out that dtslint uses different TS versions for parsing source and for applying linting rules (see microsoft/TypeScript#37551 (comment)).

When parsing source, dtslint uses Linter.createProgram(tsconfigPath) which resolves to project's TS. But then in rules, it requires internal (bundled) TS: import * as ts from "typescript";. Which results in unpredicted behavior, because version might not match at all.
In my case, SyntaxKind.VoidKeyword and other SyntaxKind.*s values were changed because of microsoft/TypeScript#35998 PR to TS.

I think we should either use projects TS, or use bundled TS version for both tasks. I'll be happy to investigate more and open PR with this change. Let me know what you think, thanks!

@IvanGoncharov
Copy link
Contributor

We experience the same issue on graphql-js and I left a detailed comment here: #292 (comment)

@sandersn
Copy link
Member

tslint has typescript as a peer dependency, so it should pick up whatever is installed. So it actually looks like the fault of dtslint's dependencies dts-critic and @definitelytyped/definitions-parser, which both depend on older versions of Typescript. They should both have typescript as a peer dependency too.

@IvanGoncharov
Copy link
Contributor

@sandersn Thanks for trying to address this issue 👍
In graphql-js we still experience the same issue even after we updated to 3.6.9:
image

We also use eslint-typescript so we a forced to have typescript as a direct dependency and tslint use it instead of dtslint version.
Not sure if it's possible but ideally typescript should either peerDependency or devDependency of dtslint.

@Maxim-Mazurok
Copy link
Author

@IvanGoncharov try this PR locally: #295 it worked for me like a charm :)
It does exactly what you suggested.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants