typescript-language-server / typescript-language-server

TypeScript & JavaScript Language Server

Home Page:https://www.npmjs.com/package/typescript-language-server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tsserver doesn't discover all files on OpenBSD

nbonfils opened this issue · comments

So I've been trying to setup a typescript dev environment on my OpenBSD box with Emacs+Eglot and latest typescript-language-server. (It may also be worth noting I use node v18.17.1)
So the server start and Emacs is able to communicate with it, without any issues, it even manages to send some diagnostics and display them.

Problem

Now the problem is that it gives me diagnostics when it shouldn't, I increased the log verbosity and it seems that the issues might be related to tsserver, it's in those logs that I observed a difference between a fully functional setup on Linux and a broken one on OpenBSD.

Case study: Create React App

So to test a similar setup on both OSes, I setup a barebone CRA project with typescript template, I just added the files in a git repo (so that emacs sees the whole project), otherwise there is no modification, just running npx create-react-app ts-test --template typescript should get you the exact same setup.

On Linux

I get no diagnostics and I get the following tsserver.log:
tsserver_linux.log

All is fine there.

On OpenBSD

As an example, I get diagnostics like the following in the index.tsx file of the CRA project:

    1  18 error    e-f-b    typescript [2306]: File '/home/nature/dev/ts-test/node_modules/@types/react/ts5.0/index.d.ts' is not a module.
    2  21 error    e-f-b    typescript [2306]: File '/home/nature/dev/ts-test/node_modules/@types/react-dom/client.d.ts' is not a module.
    4  16 error    e-f-b    typescript [2306]: File '/home/nature/dev/ts-test/src/App.tsx' is not a module.
    5  28 error    e-f-b    typescript [2306]: File '/home/nature/dev/ts-test/src/reportWebVitals.ts' is not a module.
    8   2 error    e-f-b    typescript [2584]: Cannot find name 'document'. Do you need to change your target library? Try changing the 'lib' compiler option to include 'dom'.
    8  37 error    e-f-b    typescript [2304]: Cannot find name 'HTMLElement'.
   11   2 error    e-f-b    typescript [2306]: File '/home/nature/dev/ts-test/node_modules/@types/react/ts5.0/jsx-runtime.d.ts' is not a module.

And the tsserver.log is the following:
tsserver_openbsd.log

What's mostly different is all those sysLog:: /home/nature/dev/ts-test/node_modules/react:: Changing to watchFile which seems to indicate that those files are not being considered.

When scrolling down we also see that Linux sees something like 200+ files and OpenBSD only 60.

Notes

An interesting thing to note is that when I run tsc --watch on the project (on OpenBSD) it's able to compile successfully without errors and notice the changes made to any files within the project (even those that don't seem to be picked up by tsserver).

I wasn't sure if I should've posted the issue here or on the typescript repo, but I've been struggling with this setup for 2 days straight now... So any help will be highly appreciated, even redirecting to the right place to figure this out.

This looks like a very good initial investigation of the issue but it feels like a tsserver/typescript specific issue to me.

I would even risk a statement that it would also reproduce in VSCode but quick googling suggests that VSCode is not available for openbsd so that might be hard to prove.

I would still suggest reporting it in the typescript repo. I'm not willing to spend hours debugging this :)

Based on the report in the typescript repo it appears like the issue is reproducible without typescript-language-server so I'll close it here and hopefully it will get addressed in typescript itself.