Excalibur: Tsserver throws error when class member names ends with $
Not really an Excalibur bug so I hope it’s alright that I post this here.
The problem occurs when trying to extend the Actor class. The Actor extends the Entity class which have a couple of observables with names suffixed with the $ sign. When trying to add new members in my extended class, tsserver is throwing an error. Pics below.
I tracked down the problem to the version of TypeScript (4.6.3) that Excalibur uses. After I downloaded this project and updated TypeScript to the latest version, 4.7.3, the problem went away. Unfortunately I couldn’t find a related ticket in TypeScript’s Github repo and I’ve only seen this occur in Neovim. The problem also goes away if I remove all dollar signs in the Entity class.
Steps to Reproduce
Open the Actor class in this project or extend the Actor class with (Neo)Vim and a configured tsserver plugin, eg. coc-tsserver.
Expected Result
With TypeScript 4.7.3

Actual Result
With TypeScript 4.6.3

Environment
- operating system: osx
- Excalibur versions: 0.26.0
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 20 (8 by maintainers)
Sure @ewal let me know if you run into new information and we’ll look into it again 👍
Sorry for the delay, @eonarheim!
I decided to do some more testing. I still haven’t figured out the source of the problem but at least I now know how to bypass it 😃 I have my suspects though, see further down.
TLDR; The problem goes away if the consuming project is using TypeScript version <= 4.5.5
Using Excalibur in a new minimal project
npm run clean && npm run buildError message: [coc.nvim] Error: Error processing request. Debug Failure. Did not expect GetAccessor t o have an Identifier in its trivia … More
IDE: Neovim 0.7.0 coc-tsserver
(Tested two different computers with nvim and coc, Linux and Mac)
Minimal test project: TypeScript:
Excalibur:
Node:
Yarn:
Excalibur source project: TypeScript:
Node:
Npm:
Test class
I have no idea what the underlying problem is but I suspect that it is related to js-doc comments. Example issue https://github.com/microsoft/TypeScript/issues/48238 My idea is that TypeScript misinterpret some comment content where code examples are used… 🤷
I upgraded all dependencies in Excalibur and fiddled with the configurations for eslint, typescript, js-doc etc. which resultet in js-doc started to throw a lot of errors. Not of them saved but they all related to how the comments where formatted.
That’s what I have so far 😃
I found the cause to the problem, … 13+ days later 😬 I’ll write a short summary soon. Was nearly going crazy there for a while.
@ewal Thanks for digging into this issue so deep, this is truly mysterious!
True true! This code will in theory go away soon 😃 I have some performance optimizations that hopefully makes the old transform implementation obsolete (in addition to being a lot simpler) https://github.com/excaliburjs/Excalibur/blob/perf/transform-matrix-refactor/src/engine/Math/transform.ts
I’m wondering if it’s an odd interaction with that specific version of typescript’s tsserver and the tsserver extension? At least in vscode pointing to that same version of typescript it seems to work okay.
There might not be anything we can directly do here other than upgrade typescript on main.
Hi @ewal thanks for the issue!
Oh wow, this is very interesting! It’s wild that
$is messing with the tsserver/typescript, that should be a totally okay character to use in a variable name.I have a colleague with a similar environment to yours that will be digging into the issue.
I found the related coc-tsserver issue you posted on (including here for posterity) https://github.com/neoclide/coc-tsserver/issues/365