Add check for ./node_modules/typescript when tsc is run #5157#5465
Add check for ./node_modules/typescript when tsc is run #5157#5465carlosdubus wants to merge 2 commits into
Conversation
|
@carlosdubus, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR. |
|
Hi @carlosdubus, you added resolve as a devDependency, I think it should be a normal dependency in this case as it required runtime and not only for development |
|
Have a look at angular/clang-format@2f9ceb9 |
There was a problem hiding this comment.
@mprobst in clang-format you use the last arg as a hint where the node_modules directory can be located, then fallback to process.cwd(). I suppose this allows you to run from anywhere, do you think users do that?
There may be a different problem here - the -p flag. If the user is in their home directory, I think they could run tsc -p path/to/my/project - so maybe we should use the value of -p as a hint?
There was a problem hiding this comment.
Yes, I think that commonly happens when you e.g. have an editor integration, and the editor effectively runs /usr/bin/clang-format some/path/to/my/file.ts. I'm not sure how much that applies to TypeScript.
I think -p is a very good signal, but of course at some point you end up having to parse all of tsc's args, which gets nasty. Some sort of a simple heuristic like -p or --project followed by a file name could work, though. If you want to be correct, you could use TypeScript's ts.parseCommandLine API, which should give a precise result.
|
//cc: @billti Playing with this a bit, I am not sure we would want to take this change. with node v5 now flattening modules is the default, so if you are in a folder, and transitively, one of your imports has a dependency on TypeScript, it will be in |
|
What about using the content of package.json (either parsing it or getting Note the value here is if someone on the team updates TypeScript, then some On Fri, Oct 30, 2015 at 4:00 PM Mohamed Hegazy notifications@github.com
|
|
@alexeagle I definitely see the value of it, but is that a common thing that other node projects do as well? |
|
gulp warns if you have a different version installed locally than global On Sun, Nov 1, 2015 at 12:53 AM Daniel Rosenwasser notifications@github.com
|
|
Another challenge is that on Windows running Would an option be to use an NPM script ( https://docs.npmjs.com/cli/run-script )? This always looks in the For example, if your Then running You can also pass args to it (e.g. run |
|
I'm actually a big fan of warning the user that they are using a different version than is installed locally. I'll open an issue for that. |

@alexeagle Hello, I would like to work on this issue. I'm new to Typescript codebase and I'm not sure where to add a test for this. I changed the bin/tsc file directly so it doesn't load ../lib/tsc if is not needed. Would you rather have src/compiler/tsc.ts modified?
Let me know what do you think,
Thanks