Hey, thought I should come here before making an issue because I'm probably missing something..
I've been writing a node project for some time now, and I decided to switch to Typescript. I've been using ALE for a while so I'm pretty certain it's not broken but I think I might be missing some crucial configuration.
The problem is that ALE constantly tells me Cannot find module X
, whether it's fs, rxjs, or a local file in the projects source tree. If I use tsc
, this error does not show up and the files compile fine. I'm really quite confused as to why one linter tells me one thing, and the other.. something else.
From what I can tell, ALE is using tsserver, but I don't know how to check because :ALEInfo just gives me a list and :ALEDetail doesn't indicate which linter it got the error from. I suspect whatever linter is being used isn't respecting my tsconfig.json
file.. but I'm really just thinking out loud here, I've got no evidence to suggest it's not, other than the above which may be indicative of a completely different issue.
If anyone here has any ideas, I'd really appreciate it. I'm starting to pull my hair out over here.
tsc
, so I doubt that's the linter throwing the error as when I run tsc
manually it has no problems.
let g:ale_linters = {'typescript': []}
, this stopped the error (but obviously also stopped any linting). Setting let g:ale_linters = {'typescript': ['tsserver']}
saw the incorrect 'Unable to load module' errors come back, so it's absolutely using tsserver (and accoring to :ALEInfo it is the one contained locally in node_modules
)... I.. ugh
node_modules
and tsconfig.json
in the same directory, and your code in subdirectories beneath that directory. You might need to use settings like "baseUrl": "."
or similar for imports to work everywhere.
yarn
. npm install
probably also works, but I am used to yarn
now.
Thanks @w0rp, never knew the ch_logfile
function was a thing, very helpful.
I was thinking the same regarding the location of the tsconfig.json
file relative to the node_modules
directory; however having them in the same directory didn't work.
My directory structure was
tsconfig.json
node_modules
src
bootstrap.ts
/classes
...
Even when opening the file bootstrap.ts from the root of the project (ie: vim src/bootstrap.ts
) the linting still failed. However moving the tsconfig.json
file in to the src
directory magically fixed the problem.
Which to me, makes very little sense as every where I've read says that tsserver
looks up the directory tree until it finds one.
My guess is it stops looking at the same directory as the last source file, so because no source files are in the root dir (probably doesn't help that I specify an include in my tsconfig.json that tells it to look in src), it doesn't look there for the config.
IDK, probably talking out my ass.
Either way, it works now. Thanks for your input. I'll look in to the baseUrl
property too, might be a better way to specify the source than include: []
tsserver
on my Mac and Windows machine.Info 0 [18:7:15.843] Starting TS Server
Info 1 [18:7:15.845] Version: 3.5.2
Info 2 [18:7:15.845] Arguments: C:\Program Files\nodejs\node.exe C:\cygwin64\home\HarryF\ImportProcessor\node_modules\typescript\bin\tsserver
Info 3 [18:7:15.846] Platform: win32 NodeVersion: 12 CaseSensitive: false
Info 4 [18:7:15.849] Binding...
Info 5 [18:7:15.854] event:
{"seq":0,"type":"event","event":"typingsInstallerPid","body":{"pid":12684}}
Info 6 [18:7:15.855] request:
{"seq":null,"arguments":{"file":"/home/HarryF/ImportProcessor/src/classes/Application.ts"},"type":"request","command":"open"}
Info 7 [18:7:15.856] Search path: /home/HarryF/ImportProcessor/src/classes
Info 8 [18:7:15.856] ConfigFilePresence:: Current Watches: :: File: /home/HarryF/ImportProcessor/src/classes/tsconfig.json Currently impacted open files: RootsOfInferredProjects: OtherOpenFiles: /home/HarryF/ImportProcessor/src/classes/Application.ts Status: File added to open files impacted by this config file
...
Info 20 [18:7:15.858] For info: /home/HarryF/ImportProcessor/src/classes/Application.ts :: No config files found.
Info 12 [18:7:15.857] ConfigFilePresence:: Current Watches: :: File: /home/HarryF/ImportProcessor/tsconfig.json Currently impacted open files: RootsOfInferredProjects: OtherOpenFiles: /home/HarryF/ImportProcessor/src/classes/Application.ts Status: File added to open files impacted by this config file
No config files found
, it actually comes back with the correct path and all is well
stack exec hlint [file]
works from the CLI, but setting let b:ale_haskell_hlint_executable = "'stack exec -- hlint'"
errors with: (executable check - failure) 'stack exec hlint'
. Any ideas about how to do this?
:ALEInfo
.
hlint_executable = 'stack'
and hlint_options = ''
actually ran (executable check - success) stack (finished - exit code 1) ['/bin/bash', '-c', '''stack'' exec ''hlint'' -- --color=never --json - < ''/tmp/nvimNImjwE/1/APISpec.hs''']
, so it works, but I don't know why...Anyway, maybe you'll find that curious.
/Users/bashar/work/projects/adl/adl-backend/node_modules/eslint/bin/eslint.js /Users/bashar/work/projects/adl/adl-backend/src/app.ts
if PWD is /Users/bashar/
. Is there a way we can set the PWD explicitly when running eslin6?
CWD
in the job options in ALE to the buffer or linter directory.
:help completeopt
. If you don't have preview
in your setting there, ALE won't show the preview window.
ftplugin
file either