Skip to content

Parser: remove EXPERIMENTAL_useSourceOfProjectReferenceRedirect in favor of project service #9088

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
JoshuaKGoldberg opened this issue May 13, 2024 · 2 comments
Labels
accepting prs Go ahead, send a pull request that resolves this issue breaking change This change will require a new major version to be released 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
Milestone

Comments

@JoshuaKGoldberg
Copy link
Member

JoshuaKGoldberg commented May 13, 2024

Overview

Following #2094: the parser flag EXPERIMENTAL_useSourceOfProjectReferenceRedirect was added in #2669 as experimental support for TypeScript project references. But it's never been stabilized, strongly recommended for end-users, or even documented on https://typescript-eslint.io/packages/parser.

Now that the project service is going to be our primary recommended way to enable type information and support project references ... what's going on with EXPERIMENTAL_useSourceOfProjectReferenceRedirect? Should we delete it in v8?

🔪

@JoshuaKGoldberg JoshuaKGoldberg added package: parser Issues related to @typescript-eslint/parser triage Waiting for team members to take a look breaking change This change will require a new major version to be released labels May 13, 2024
@bradzacher
Copy link
Member

Some people are getting some value out of it but I'd guess that the improvements released in v7.9.0 and soon to release in TS5.5 are going to fix some OOMs.

There are footguns with it as well so yeah I'm happy if we remove it.


The reason it never progressed is because essentially TS would only parse a subset of files from another tsconfig. So it meant that in many cases perf/memory was worse!

A .d.ts file is light - only contains the exported decls and their types - but a .ts file is heavy as it contains all the imementations AND pulls in more of the dep graph than necessary.

If project A references project B then when we got the program for A then TS would parse and typecheck a subset of B's .ts files. But unless that "subset" somehow was actually the entirety of B, then when we inevitably parsed an out-of-subset part of B, we would need to get the program for B - meaning we'd re-parse and re-typecheck that subset all over again.

OTOH with .d.ts files - because you're only parsing a file's exported signature - it's always lightweight and includes the minimum types to define that signature. So the file is light and the graph is light. There's not much type-check work to do because there aren't implementations to check.

Also imagine if there are some node modules used in implementations for B (but not A) - and those module's types aren't used in the exported signatures. With .ts files we'd need to typecheck the types for that node module twice (once for A then once for B) - but with .d.ts files we'd only need to do once (once for B).

Finally imagine a highly interdependent project. Eg imagine if you have C, D, and E which all also depend on B. Now you have 4 copies of the subgraph of B.

Essentially it was a dead-end. It kind-of let us share types between programs in specific usecases but in reality it was worse.
We really want to say "this program uses types from this program" to have two isolated but shared things - but TS doesn't support that.

@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 May 15, 2024
@JoshuaKGoldberg JoshuaKGoldberg added this to the 8.0.0 milestone May 15, 2024
@JoshuaKGoldberg JoshuaKGoldberg changed the title Parser: remove EXPERIMENTAL_useSourceOfProjectReferenceRedirect in favor of project service? Parser: remove EXPERIMENTAL_useSourceOfProjectReferenceRedirect in favor of project service May 26, 2024
@JoshuaKGoldberg
Copy link
Member Author

#9104 was merged into the v8 branch. ✅

@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 9, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 9, 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 breaking change This change will require a new major version to be released 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
Projects
None yet
Development

No branches or pull requests

2 participants