language-tools icon indicating copy to clipboard operation
language-tools copied to clipboard

language-server test suite fails on Node.js >=23 due to angle-bracket syntax

Open polyzen opened this issue 5 months ago • 10 comments

Describe the bug

Tests fail on Node.js >=23 with "The angle-bracket syntax for type assertions, <T>expr, is not supported in type strip mode. Instead, use the 'as' syntax: expr as T."

Reproduction

https://gitlab.archlinux.org/archlinux/packaging/packages/svelte-language-server/-/blob/0.17.16-1/PKGBUILD?ref_type=tags#L23-38

The package has to use nodejs-lts in the meantime.

Expected behaviour

Tests pass

System Info

  • OS: Arch Linux
  • IDE: Neovim

Which package is the issue about?

svelte-language-server

Additional Information, eg. Screenshots

Started working on this, but it's quite tedious. Maybe there's a way to automate it?

polyzen avatar Jul 13 '25 14:07 polyzen

What's the reason for wanting to use the uncompiled version of the language server? It's provided as JS on npm

dummdidumm avatar Jul 13 '25 16:07 dummdidumm

Uncompiled? It should come out to be the same as the one on npm, though I tend to avoid bundling if possible. It's policy to build from source, as opposed to packaging precompiled software.

polyzen avatar Jul 13 '25 19:07 polyzen

I still don't fully understand your motivation. Are you saying your company does not allow you to use the npm version? If so, why not run the build script that transpiles the TS files to JS and use that output?

dummdidumm avatar Jul 13 '25 19:07 dummdidumm

I still don't fully understand your motivation. Are you saying your company does not allow you to use the npm version?

Not a company, a Linux distribution: https://archlinux.org/

If so, why not run the build script that transpiles the TS files to JS and use that output?

Where can I find that?

polyzen avatar Jul 13 '25 19:07 polyzen

https://github.com/sveltejs/language-tools/blob/master/README.md#setup

dummdidumm avatar Jul 13 '25 20:07 dummdidumm

This is about the test suite for the language server failing when run on Node.js >=23.

polyzen avatar Jul 13 '25 21:07 polyzen

Why do you care about the test suite when you just want to have a local build? And how are you running it that these errors occur? If you use the test setup it shouldn't happen AFAICT

dummdidumm avatar Jul 13 '25 21:07 dummdidumm

Why do you care about the test suite when you just want to have a local build?

It's also policy to make sure available tests pass when building our packages. It's not just for personal use, but for our users at large to be able to use.

And how are you running it that these errors occur?

Run the language server's test script with a Node.js >=23 runtime.

If you use the test setup it shouldn't happen AFAICT

Where can that be found?

polyzen avatar Jul 13 '25 22:07 polyzen

Hmm, it's another weird case of the node.js API used by mocha/ts-node to load a TypeScript file. Kind of similar to https://github.com/sveltejs/language-tools/pull/2706. Where the runtime skips the ts-node transpile step and directly loads the ts file. Adding the --no-experimental-strip-types flag seems to have stopped Node.js from directly running the ts file. Maybe we should add that to the test script. But for now, you can also add that yourself by running pnpm run test --no-experimental-strip-types instead of pnpm test

jasonlyu123 avatar Jul 14 '25 01:07 jasonlyu123

@jasonlyu123, thank you!

polyzen avatar Jul 14 '25 15:07 polyzen