Allow dynamic files script info to be created when not opened by client#20910
Conversation
sheetalkamat
left a comment
There was a problem hiding this comment.
This just is changing assert... That doesnt seem correct, wouldnt you need to handle the cases like https://github.com/Microsoft/TypeScript/pull/20910/files#diff-efa731ca7c6279501f903db87403d2beL1791 as well to handle the dynamic files? Can you add the test case that fails to get idea about whats really not working right now?
|
I can add a test case. Could you point me to some test cases that test similar code paths? I wasn't able to find any. Regarding changing behavior in response to the new assert, it seems that the code already reflects the possibility of this new assert. For example, line 1789, which would be hit given this change, already handles dynamic files. The line you pointed out, 1791, is unaffected by this change, since this assert is already true if |
|
Disregard my request for finding tests; I'll add a test to |
| }); | ||
|
|
||
| it("external project for dynamic file", () => { | ||
| const file1 = { |
There was a problem hiding this comment.
give the file a dynamic filename
There was a problem hiding this comment.
The idea with file1 was not for it to be the dynamic file, but to be the real version of the file. This may not be entirely necessary, I guess. Regardless, we don't actually open this file, we just make the host aware of it.
There was a problem hiding this comment.
You dont need this at all.. better to remove.
What i meant is that if in your test case if you change projectFileName to say |
|
Understood. I will try to match the test case closer to what VS is actually calling and see what I might need to update. |
|
After discussing separately with @sheetalkamat, I added another assertion explaining that dynamic script infos will always share the same name and project file name, and therefore will always have the tsserver location as the current directory. |
Currently, if a dynamic file is opened in VS, either the language service will fail to start or the file will be incorrectly added to an inferred project rather than the intended external project.
This change allows the script info for the dynamic file to be created as part of a call to
openExternalProjects, thereby resolving the issue.