TypeScript: Give better error messages for bare imports with badly configured projects
When targeting es2015 or later, moduleResolution isn’t set to node by default.
Perhaps when
moduleResolutionis calculated to beclassicandpathsaren’t specified
we should hint to the user
Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 15
- Comments: 16 (11 by maintainers)
@saramorsi , I just added this line under
compilerOptionsin my tsconfig.json file and it solved my problem."moduleResolution": "node"You need to edit the error on
src\testRunner\unittests\tsserver\symLinks.tsLet’s steer away from the word “throw” because that’s just not the way TypeScript reports errors.
You need to report the diagnostic/error that I mentioned in my last comment instead of the current error when the project is misconfigured.
The local folder only changes when the baselines have changed - so if your diffs don’t match the reference folder.
Adding the throw in the user’s project (e.g. creating the error diagnostic) should be the thing which will break a reference test of two hopefully.
Sure - you might want to create one new diagnostic in
diagnosticMessages.jsonRun
npx gulp generate-diagnosticsRun the tests
see what breaks. Diff the folders
tests/baselines/localandtests/baselines/referencewith a tool like WinMerge or Beyond Compare to see if the new errors are good.If nothing fails, you need to add a test case in a file named
tests/cases/compiler/errorForBareSpecifierWithImplicitModuleResolution1.ts:Then run the tests to get baselines from that. Accept the baselines: