Skip to content

Document why there's no parserOptions.typescriptLocation #4102

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
loynoir opened this issue Nov 8, 2021 · 4 comments · Fixed by #4373
Closed

Document why there's no parserOptions.typescriptLocation #4102

loynoir opened this issue Nov 8, 2021 · 4 comments · Fixed by #4373
Assignees
Labels
accepting prs Go ahead, send a pull request that resolves this issue documentation Documentation ("docs") that needs adding/updating package: parser Issues related to @typescript-eslint/parser

Comments

@loynoir
Copy link

loynoir commented Nov 8, 2021

Scenario

Using typescript > 4.5.0, but not yet officially supported by eslint.

Is there a way to specific typescript location for typescript-eslint, so no need to modify package.json?

Additional Infomation

=============                                                                                                                                                 
                                                                                                                                                              
WARNING: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estree.                         
                                                                                                                                                              
You may find that it works just fine, or you may not.                                                                                                         
                                                                                                                                                              
SUPPORTED TYPESCRIPT VERSIONS: >=3.3.1 <4.5.0                                                                                                                 
                                                                                                                                                              
YOUR TYPESCRIPT VERSION: 4.5.0-beta                                                                                                                           
                                                                                                                                                              
Please only submit bug reports when using the officially supported version.                                                                                   
                                                                                                                                                              
=============   
@loynoir loynoir added package: parser Issues related to @typescript-eslint/parser triage Waiting for team members to take a look labels Nov 8, 2021
@JoshuaKGoldberg JoshuaKGoldberg added question Questions! (i.e. not a bug / enhancment / documentation) documentation Documentation ("docs") that needs adding/updating and removed triage Waiting for team members to take a look labels Nov 8, 2021
@JoshuaKGoldberg
Copy link
Member

I don't know of one. @bradzacher might.

However, my gut instinct is that you don't want to do this. TypeScript versions often have slight differences in edge cases that can cause contradictory information between typescript-eslint rules and editor information. For example:

  • @typescript-eslint/strict-boolean-expressions might be operating with TypeScript version X and think a variable is string[] | undefined
  • TypeScript itself might be on version X+1-beta and think the variable is string[]

Either way, we should definitely document this recommendation somewhere. 😄

@bradzacher
Copy link
Member

bradzacher commented Nov 8, 2021

We don't want to do this because it makes life really complicated.

TypeScript must be imported in three places:

  • parser
  • plugins
  • utils

If we allow users to specify a path for typescript then we need to ensure every single TS import in this project respects that, and we need to make sure every 3rd party plugin that we don't control also respects that.
I.e. it's an impossible problem to solve. Also as the world migrates to ES modules, it becomes even more intractable because you can't rely on requireing dynamically synchronously.

The system works by simply using nodes standard module resolution to import the TS version it you installed. This is why we only have a peer dependency on TS - so that you can control the exact version of TS you are using.

@JoshuaKGoldberg JoshuaKGoldberg removed the question Questions! (i.e. not a bug / enhancment / documentation) label Nov 8, 2021
@loynoir loynoir closed this as completed Nov 8, 2021
@JoshuaKGoldberg
Copy link
Member

Oh @loynoir would it be inoffensive to you if we kept this open as a documentation ticket? We should add this to our docs somewhere.

Fun fact, we just pushed a very early version of the new http://typescript-eslint.io in #4105 🚀 and are about to start a docs overhaul!

@JoshuaKGoldberg JoshuaKGoldberg added the accepting prs Go ahead, send a pull request that resolves this issue label Nov 8, 2021
@JoshuaKGoldberg JoshuaKGoldberg changed the title Is there a parserOptions.typescriptLocation? Document why there's no parserOptions.typescriptLocation Nov 8, 2021
@loynoir
Copy link
Author

loynoir commented Nov 8, 2021

I'm OK with it. :)

@JoshuaKGoldberg JoshuaKGoldberg moved this to Todo in Documentation Nov 9, 2021
@JoshuaKGoldberg JoshuaKGoldberg self-assigned this Dec 30, 2021
@JoshuaKGoldberg JoshuaKGoldberg moved this from Todo to In Progress in Documentation Dec 30, 2021
@JoshuaKGoldberg JoshuaKGoldberg moved this from In Progress to In Review in Documentation Dec 30, 2021
Repository owner moved this from In Review to Done in Documentation Dec 31, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 31, 2022
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 documentation Documentation ("docs") that needs adding/updating package: parser Issues related to @typescript-eslint/parser
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants