Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Upgrade to TypeScript 4.3 #145

Merged
merged 2 commits into from
Jul 23, 2024
Merged

build: Upgrade to TypeScript 4.3 #145

merged 2 commits into from
Jul 23, 2024

Conversation

SimonAlling
Copy link
Owner

@SimonAlling SimonAlling commented Jul 22, 2024

I did this:

npm install --save-dev --save-exact [email protected]

Then I got this warning when running npm run lint:

WARNING: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estree.

You may find that it works just fine, or you may not.

SUPPORTED TYPESCRIPT VERSIONS: >=3.3.1 <4.3.0

YOUR TYPESCRIPT VERSION: 4.3.5

Please only submit bug reports when using the officially supported version.

So I did this:

npm install --save-dev @typescript-eslint/parser@^4

Reason

Upgrading TypeScript is always nice, just to get access to a better version of the language. There's also a specific reason: I want to upgrade Jest, and with Jest 26 (#144), npm run build fails with TypeScript versions older than 4.4 (which I will upgrade to in an upcoming PR):

node_modules/@types/babel__traverse/index.d.ts:314:10 - error TS1023: An index signature parameter type must be either 'string' or 'number'.

314         [k: `${string}|${string}`]: VisitNode<S, Node>;
             ~

Breaking?

It's generally tricky to determine whether upgrading to a new major version of TypeScript is breaking for our consumers. (TypeScript doesn't use SemVer; this PR should be thought of as upgrading from v42 to v43.) As soon as we have upgraded, we might accidentally – and without even realizing it – start writing code resulting in .d.ts files with new syntax that older versions can't even parse, etc.

So one could argue that to err on the side of caution, we should release a new major version every time we've upgraded our TypeScript version. But I think that might be taking it too far. And what do we even know about our consumers' TypeScript versions in the first place? It quickly spirals out of control. Maybe we should extend the CI setup to include checks with different TypeScript versions?

semver-ts is an attempt at describing the problem of TypeScript + SemVer and formalizing how it should be handled. I've just started reading about it and we're not even close to compliant.

This time, I'll go with considering this a backward compatible change, since I don't believe any consumer is broken by it. This belief is supported by the fact that the emitted code is exactly identical, modulo whitespace. (I figured that out by diffing the output of cat build/**/*.* lib/**/*.* after npm run build with and without this PR.)

@SimonAlling SimonAlling marked this pull request as ready for review July 23, 2024 15:54
@SimonAlling SimonAlling merged commit dbcfa77 into master Jul 23, 2024
12 checks passed
@SimonAlling SimonAlling deleted the typescript-4.3 branch July 23, 2024 16:11
SimonAlling added a commit that referenced this pull request Jul 23, 2024
This will enable upgrading to Jest 26 (#144; see #145).

## Breaking?

See #145 for details on why this should possibly be considered a breaking change.

I consider it backward compatible, because I don't think any consumer is broken by it. Notably, building with and without this PR in different Git working trees and using `git diff --no-index` to diff the emitted code (`build/` and `lib/`) reveals that the only difference is that some expressions in `.js` files are transformed from `foo` to `(0, foo)`.
SimonAlling added a commit that referenced this pull request Jul 24, 2024
This will enable upgrading to Jest 29, which [requires] TypeScript 4.5 if `jest-environment-jsdom` is used.

I did this:

    npm install --save-dev --save-exact [email protected]

Then I got this warning when running `npm run lint`:

    WARNING: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estree.

    You may find that it works just fine, or you may not.

    SUPPORTED TYPESCRIPT VERSIONS: >=3.3.1 <4.5.0

    YOUR TYPESCRIPT VERSION: 4.5.5

    Please only submit bug reports when using the officially supported version.

So I did this:

    npm install --save-dev @typescript-eslint/eslint-plugin@^4

It didn't help, so I did this:

    npm install --save-dev @typescript-eslint/eslint-plugin@^5 @typescript-eslint/parser@^5

## Breaking?

See #145 for details on why this should possibly be considered a breaking change.

I consider it backward compatible, because I don't think any consumer is broken by it. Notably, building with and without this PR in different Git working trees and using `git diff --no-index` to diff the emitted code (`build/` and `lib/`) reveals that it is exactly identical.

[requires]: https://jestjs.io/docs/upgrading-to-jest29#jsdom-upgrade
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant