-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
external modules resolve by node_modules and package.json-main #3147
Conversation
break; | ||
} | ||
searchPath = parentPath; | ||
let resolvedName: string = host.resolveExternalModule(moduleName, searchPath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Omit the type annotation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
I've added a commit which gets the tests passing to demonstrate the issue : a781916 |
If it is because the language service didn't get such a resolved file as a part of its original file set : then this can be solved by lazily expanding the file set : https://github.com/TypeStrong/atom-typescript/blob/8df1482222fb88363b504d9c27f98692e938e44f/lib/main/lang/core/languageServiceHost2.ts#L353-L358 I've tried the code in this PR with atom-typescript and it works like a charm 🌹 |
I guess main points of inconvenience on our end are:
|
@vladima Taking your points into consideration I guess you are recommending:
So:
|
do you mean this guy ? The idea behind it (and shims in general) is that they act as a send\receive proxies whose purpose is to extract incoming parameters from JSON, call corresponding method on the language service instance, wrap its return value to JSON and send it back.
In general yes, you got the idea. I need to think more about details of interaction with VS that should be handled. |
Yup. Thanks. I'll see if it comes up in this refactoring (I am sure it will) :)
I'll give it a go 🌹 |
Pushed basarat@a17c6aa The current changeset is ready for an early review if anyone is interested. I'm moving on to adding tests for this. |
Tests pushed. The PR is ready for review 👍 🌹 |
TSC may not be able to output a d.ts to a separate location, but a post-compile build step easily could. It seems to be fairly common for typings to sit in a typings directory. That being said, I believe there is value in setting a standard for how people should distribute their TS/JS packages (no typings folder) and expand it later if necessary. |
Thanks ❤️ Also at the moment the typings from the |
👍 on this functionality! |
I've pulled with PR into the moduleResolution branch in this repo - this will cover node related part of #2338 and the rest of the work on this proposal will be continued in that branch. Thanks! |
Thanks @vladima! |
This should be in the 1.6 release |
Code for #2338. This is just for the node_modules resolution. Does everything for
node_modules
except for thetypings
stuff as I don't see the rational for that considering there is no way to have tsc send.js
to one location and.d.ts
to another location.[](No longer relevant :
using
ts.sys.fileExists
doesn't work under the test harness because it doesn't give actual file system paths. So tests are broken by this commit. What is the best way to overcome this. I have reviewed [previous work]%28master...Nemo157:node_modules) that usesprogram.getSourceFile
%28which resolves to [this code]%28https://github.com/Microsoft/TypeScript/blob/e76439b2ff39e1e8afd926450e7cebba2149fe28/src/harness/projectsRunner.ts#L212-L222%29%29 to do exists checks and readpackage.json
and that feels very ugly. How would you guys recommend authoring theresolveExternalModule
function.)