Lint and autocomplete fail in specific setup
hermann-p opened this issue · comments
Checklist
- I have searched both open and closed issues and cannot find a duplicate.
- I can reproduce the problem with the latest version of the relevant packages.
- The problem still occurs after I issued
M-x tide-restart-server
in the buffer where I had the problem. - I verified that the version and the configuration file path reported by
M-x tide-verify-setup
are correct. - If tide is reporting an error or warning I think should not be reported, I can run
tsc
(andtslint
, if applicable) without the error or warning I'm seeing in tide. - If tide is not reporting an error or warning I think should be reported,
tsc
(ortslint
, if applicable) reports the error or warning I was expecting to see. - I am positive the problem does not belong to
typescript-mode
ortsserver
.
Relevant Version Numbers
- Tide: built today from github, affects older versions, too
- TypeScript: 4.0.3 (also affects 3.x, 4.x)
- Emacs: 27.?
I use tide in my day job for some years, and although it's really great I have one specific setup where it fails completely, and I wonder if it can be solved.
We have a project, which is setup like this:
├── tsconfig.json
├── src
| ├── lots of source code files and dirs
| └── index.ts
├── tests
| └── lots of test files
└── dist
├── build artefacts from the src directory
└── index.js
To build that, we have the tsconfig contain
"include": ["./src"]
"compilerOptions": {
"outDir": "./dist"
}
Which results in all source files from the src
directory compiled into the dist
directory as shown above.
As the tests
dir is not in the include
-array of tsconfig, tide is not able to provide auto completion, type checking or anything whatsoever when writing tests.
If we add "./tests"
to the include
, tide works there, too, but suddenly the artefacts get compiled into a different folder structure:
└── dist
├── src
| ├── some stuff
| └── index.js
└── tests
which breaks the complete package setup, expected paths and so on.
I could accept that as given, but my colleagues who use VSCode can simply work with full TS support for tests and "normal" sources, and I'm not yet ready to let them think they bested emacs ;)
Message buffer
Error from syntax checker typescript-tide: Error processing request. No Project.
Error: No Project.
at Object.ThrowNoProject (/home/myname/workspace/customer/project/node_modules/typescript/lib/tsserver.js:146360:23)
at ScriptInfo.getDefaultProject (/home/myname/workspace/customer/project/node_modules/typescript/lib/tsserver.js:147153:46)
at ProjectService.doEnsureDefaultProjectForFile (/home/myname/workspace/customer/project/node_modules/typescript/lib/tsserver.js:150033:48)
at ProjectService.ensureDefaultProjectForFile (/home/myname/workspace/customer/project/node_modules/typescript/lib/tsserver.js:150028:75)
at IOSession.Session.getFileAndProjectWorker (/home/myname/workspace/customer/project/node_modules/typescript/lib/tsserver.js:154165:87)
at IOSession.Session.getFileAndProject (/home/myname/workspace/customer/project/node_modules/typescript/lib/tsserver.js:154148:29)
at IOSession.Session.getDiagnosticsWorker (/home/myname/workspace/customer/project/node_modules/typescript/lib/tsserver.js:153829:31)
at IOSession.Session.getSyntacticDiagnosticsSync (/home/myname/workspace/customer/project/node_modules/typescript/lib/tsserver.js:153962:29)
at Session.handlers.ts.Map.ts.getEntries._a.<computed> (/home/myname/workspace/customer/project/node_modules/typescript/lib/tsserver.js:153255:61)
at /home/myname/workspace/customer/project/node_modules/typescript/lib/tsserver.js:154962:88
at IOSession.Session.executeWithRequestId (/home/myname/workspace/customer/project/node_modules/typescript/lib/tsserver.js:154953:28)
at IOSession.Session.executeCommand (/home/myname/workspace/customer/project/node_modules/typescript/lib/tsserver.js:154962:33)
at IOSession.Session.onMessage (/home/myname/workspace/customer/project/node_modules/typescript/lib/tsserver.js:154986:35)
at Interface.<anonymous> (/home/myname/workspace/customer/project/node_modules/typescript/lib/tsserver.js:157202:27)
at Interface.emit (events.js:314:20)
at Interface._onLine (readline.js:329:10)
at Interface._normalWrite (readline.js:474:12)
at Socket.ondata (readline.js:186:10)
at Socket.emit (events.js:314:20)
at addChunk (_stream_readable.js:297:12)
at readableAddChunk (_stream_readable.js:272:9)
at Socket.Readable.push (_stream_readable.js:213:10)
at Pipe.onStreamRead (internal/stream_base_commons.js:188:23)
Error from syntax checker typescript-tide: Error processing request. No Project.
Error: No Project.
Could this stem from Emacs (or tide) somehow determining the wrong root folder for the project, and passing off wrong info to tsserver?
What does evaling (tide-project-root)
show in the src
folder and in the tests
-folder?
I think the project-root detection should be ok, it's just that, when you send a file to tsserver and if it's not in the src file list (specified by include
or files
), then tsserver might throw error.
For fixing the issue, perhaps you could try to add tsconfig.json
file in the test
folder with {"extends": "../tsconfig.json", "include": ["../src", "*.ts"]}
?. At the end of the day, the tsconfig should include the typescript file for tide to work
I am not sure how vscode is handling this case though.
In both cases it's the same: ~/workspace/customer/project/backend
I found I could fix the behaviour by creating a tsconfig file with
{
"extends": "../tsconfig.json",
"compilerOptions": {
"noEmit": true,
},
"include": [ "./" ]
}
in the tests folder. Still, this requires me to check in additional files just to make my IDE work as well as others.
Oh, I see that ananthakumaran was faster than me
Still, this requires me to check in additional files just to make my IDE work as well as others.
Completely off topic, but still: If we can now denounce Emacs as a (typescript) IDE, I think we can conclude we've been successful 😃
OT: Well... TIDE self-proclaims as "the Typescript IDE for Emacs"... ;)
closing this as there are reasonable workarounds and references feature might help as well.