-
Notifications
You must be signed in to change notification settings - Fork 202
Multiple Project Support #910
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
Comments
Here is a method I found that works for me
|
I think about this subject from time to time. My thoughts generally lead to a supposition that if atom-typescript's worker were based on the identification of a set of tsconfig files as its "drivers" (instead of having the editor window be the driver), that the process of identifying which project(s) include a given .ts (or now also .js) file would be more straightforward. And, given that tsconfig files no longer need to be named tsconfig.json, it seems pretty obvious that somebody's now got to maintain or infer a list of them. I know there's a lot more going on, because I've seen some of it and actually learned a bit of it, but I believe the process now is something like "I seem to be handling a ts file, let me findup for a tsconfig that includes this file", it would be, 'I seem to be handling a ts file, let me check my tsconfigs to see which projects (note the plural) include this file'. Regarding the circumstance where more than one project includes the file, it seems to me that the only correct response is to process it under both regimes in parallel. In psuedo code, I'm talking about:
and if I happen to have extra errors because my file is wrong in more than one project context, then I see the concatted errors, even if they all happen to be for the same reason... What scares me in saying this is that I think it would be a lot of work to go in this direction... |
This issue has been marked as stale because it did not have any activity for the last 90 days or more. Remove the stale label or comment or this will be closed in 14 days |
How tsconfig.json detection works now.
We have a file/class called
Project
which basically consolidates all our access to the TypeScript language service (the code).When you open a
.tsx?
file in the editor we lookup sometsconfig.json
up the directory tree. If we find one we(here is the code)
Issues with this
If you have several tsconfig.json files in your project, e.g.:
The tsconfig files also reference some shared files in:
If you open a file from
server
first then all the files referenced (includingshared
) will point to thatserver/tsconfig.json
. Then even if you updateclient/tsconfig.json
it will have seemingly no effect on any file that the editor opens (as they all already point toserver/tsconfig.json
).Potential fixes
Project selector
This is the approach I am taking with http://alm.tools/ . It features a
project
search/selector : https://github.com/alm-tools/alm/tree/master/docs/features#project-search + ability to provide a project on the command line (-p
flag).It is less magical then what atom-typescript does, but then again atom-typescript was designed to be as quick to start / unobtrusive as possible i.e. you open a ts file and it just works.
alm.tools is designed to be for typescript alone. You need a project file.
Multiple simultaneous projects
This is the approach taken by VSCode / TSServer (that comes with
typescript
out of the box).However there are issues with this design too e.g.:
All of these complex scenarios are being fixed in TSServer by the Microsoft team (:rose:) and if this is the approach that needs to happen I recommend that current code be pulled out and migrate to TSServer. This will result in feature decrease (e.g. dependency view) but might be better in the long term 🌹
Personal opinions
What I did with atom typescript isn't ideal for sure and it would be better if it takes one of the mentioned approaches. Please note that I did this before tsserver was a thing so
¯\_(ツ)_/¯
, and because of (again) ambitious plans of https://alm.tools it does something custom (doesn't use tsserver again as I find my work on async support easier personally, also haven't had the time to take a hard look at TSServer) 🌹 ❤️The text was updated successfully, but these errors were encountered: