language-server test suite fails on Node.js >=23 due to angle-bracket syntax
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?
What's the reason for wanting to use the uncompiled version of the language server? It's provided as JS on npm
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.
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?
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?
https://github.com/sveltejs/language-tools/blob/master/README.md#setup
This is about the test suite for the language server failing when run on Node.js >=23.
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
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?
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, thank you!