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

Handle when default project for file is solution with file actually referenced by one of the project references #37239

Merged
merged 11 commits into from Mar 13, 2020

Conversation

@sheetalkamat
Copy link
Member

sheetalkamat commented Mar 6, 2020

Fixes #36708, #27372

Now when we find that the project is a solution project, we try to open referenced projects to see if we can find project that contains the opened file.

@amcasey
Copy link
Member

amcasey commented Mar 6, 2020

A solution project is a composite project with references to other projects, but no files of its own?

@uniqueiniquity
Copy link
Member

uniqueiniquity commented Mar 6, 2020

@amcasey That appears to be the case, but I would appreciate confirmation as well. Also, how common is that as a pattern?

@sheetalkamat
Copy link
Member Author

sheetalkamat commented Mar 10, 2020

A solution project is project with project referenes but no files on its own.. (Eg https://github.com/microsoft/TypeScript/blob/master/src/tsconfig.json)

@sheetalkamat
Copy link
Member Author

sheetalkamat commented Mar 10, 2020

Note that we already handle solutions for scenarios like our own repo.. Wherein the tsconfig for compiler is in its own folder and named tsconfig.json so found for the file open in src\compiler ... This tries to solve cases if say that tsconfig was named tsconfig.compiler.json or was in src\compiler or src itself instead. Good repro scenario to look at would be the issues this PR is fixing.. #27372 has a link to https://github.com/OliverJAsh/jest-ts-project-references which demos the issue.

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Mar 10, 2020

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 10, 2020

Heya @DanielRosenwasser, I've started to run the tarball bundle task on this PR at 914f358. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 10, 2020

Hey @DanielRosenwasser, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/67599/artifacts?artifactName=tgz&fileId=ED6224134493FAA69B7797634F6182922F217A4923B3181D8B91B238C9CBB63002&fileName=/typescript-3.9.0-insiders.20200310.tgz"
    }
}

and then running npm install.


There is also a playground for this build.

src/server/editorServices.ts Outdated Show resolved Hide resolved
Copy link
Member

amcasey left a comment

How did you identify the code paths that needed to be updated (i.e. how do you know you didn't miss one)?

src/server/editorServices.ts Show resolved Hide resolved
src/server/editorServices.ts Show resolved Hide resolved
src/server/editorServices.ts Show resolved Hide resolved
src/server/editorServices.ts Show resolved Hide resolved
@sheetalkamat
Copy link
Member Author

sheetalkamat commented Mar 12, 2020

How did you identify the code paths that needed to be updated (i.e. how do you know you didn't miss one)?

Well i looked at all the calls to getConfigFileNameForFile which is where after finding solution project, we are changing the behavior

@amcasey
Copy link
Member

amcasey commented Mar 13, 2020

How did you identify the code paths that needed to be updated (i.e. how do you know you didn't miss one)?

Well i looked at all the calls to getConfigFileNameForFile which is where after finding solution project, we are changing the behavior

It sounds like anyone who calls getConfigFileNameForFile in the future will need to think about this as well. Is there some way we could organize the code to guard against a new caller failing to do so? Perhaps it could become a private helper of findConfiguredProjectByProjectName, for example?

@amcasey
Copy link
Member

amcasey commented Mar 13, 2020

Confirmed that #36708 and #27372 no longer repro. The tests work better if I launch the version of VS Code running against this change. 😝

Copy link
Member

amcasey left a comment

I'm mildly concerned about missing a case now or in the future, but this looks correct to the extent of my ability to verify it.

@sheetalkamat sheetalkamat merged commit ba39113 into master Mar 13, 2020
8 checks passed
8 checks passed
build (8.x)
Details
build (10.x)
Details
build (12.x)
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
license/cla All CLA requirements met.
Details
node10 Build #67813 succeeded
Details
node12 Build #67811 succeeded
Details
node8 Build #67812 succeeded
Details
@sheetalkamat sheetalkamat deleted the projectRefOpen branch Mar 13, 2020
@kripod
Copy link

kripod commented Apr 5, 2020

Can a solution tsconfig.json file contain solution-wide compilerOptions? Is the configuration below valid?

// tsconfig.json
{
  "files": [],
  "references": [
    { "path": "./packages/client/tsconfig.json" },
    { "path": "./packages/server/tsconfig.json" },
  ],
  "compilerOptions": {
    "noEmit": true,
    "allowJs": true,
    "checkJs": true,
    "strict": true,
    "target": "ES2019",
    "module": "ESNext",
    "moduleResolution": "Node",
    "esModuleInterop": true,
    "isolatedModules": true,
    "jsx": "react"
  }
}
@amcasey
Copy link
Member

amcasey commented Apr 6, 2020

@kripod I think you're asking whether your client and server projects will automatically pick up those compiler options - no, they won't. If you want to inherit the configuration, you need to use extends in the derived/child projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

6 participants
You can’t perform that action at this time.