TypeScript tests passed locally but failed on Exercism (possible version mismatch)

Hi,

I think there might be a version mismatch between TypeScript versions used locally vs on Exercism, on the TypeScript track.

Context

On the TypeScript track, on the “word-count” exercise, the tests passed locally for me, but when submitted to Exercism, threw an error:

error TS1384: A ‘new’ expression with type arguments must always be followed by a parenthesized argument list.

The issue was the following line in my solution:

const result = new Map<string, number>;

Changing it to the below fixed it:

const result = new Map<string, number>();

Root cause investigation

On the main branch of TypeScript’s source code repo, the error code TS1384 no longer exists in the diagnostic messages file, which suggests it’s been removed at some point.

I’m wondering whether it’s present in the TypeScript version being used by the test runner, but not in the version required when running the tests locally?

I see in the package.json for the TypeScript exercises, the development dependency version for TypeScript is listed ^4.5.4, i.e. v4.5.4 and above, whilst TypeScript’s latest version is v4.9.4 (which I’m running locally).

This is probably caused by the version difference.

Most of the languages on exercism doesnt run on the cutting edge version. That is among other things for stabillity. But also every new version has to be tested on the test runner, thereby some tracks make the decesion to do bigger jumps in version when they do that push.

But in general if you want to ensure that the tests will passed so would I recomend to use the same version as the test runner.

Thanks, that makes sense.

To be clear, I’ve not changed the TypeScript version provided when attempting the solution. Since the TypeScript package.json uses ^4.5.4, it’s automatically using the latest version of TypeScript (4.9.4) on my machine. On the other hand, the test runner seems to be using ^4.5.5, so maybe this means it hasn’t installed a later TypeScript version yet. (My understanding is that v4.5.4 is equivalent to <v5.0.0.)

Out of interest, if the versions across languages aren’t actively updated, would it be easier to maintain by using a fixed version, rather than the caret notation?

(P.S. please feel free to close this, if it’s easier to reduce noise, it’s non-urgent.)

(cc @sleeplessbyte)

Was answered on GitHub :slight_smile:

2 Likes