-
-
Notifications
You must be signed in to change notification settings - Fork 320
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
Bump Typescript to v4 #1924
Bump Typescript to v4 #1924
Conversation
Code Climate has analyzed commit b573aba and detected 1 issue on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
A lot of unit tests are failing, anyone has a clue what might have changed to cause so many failures? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only breaking changes that could cause tests to fail are:
- https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#getterssetters-are-no-longer-enumerable
- https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#parsing-differences-in-optional-chaining-and-non-null-assertions
You should probably debug one tests and detect line thats causing trouble
Seems the stubs are no longer working Eg: Seems related to the getters no longer being enumerable? |
Typical response from Ryan... I think it worked before because typescript didn't generated esm compliant code (aka module imports were mutable). If my memory serves me correctly, babel was already doing that so we switched from babel-register to ts-node/register. Few ideas:
|
We could use an import mocking library such as https://www.npmjs.com/package/rewiremock I've used it with success and offers full type support. Example: const { default: getPortsToOpen } = await rewiremock.around(
() => import("../../../src/watchers/natRenewal/getPortsToOpen"),
mock => {
mock(() => import("../../../src/modules/docker/listContainers"))
.with({ listContainers })
.toBeUsed();
}
); |
Im pretty sure that only works because you are using typescript <3.9. All those libs were just modifying exports. Feel free to try it though |
RIght, I have not tried it with Typescript >= 3.9 |
Fix type issue in benchmark-utils Bump @types/eventsource to support Typescrip v4 Remove un-used toHex() function Cast pubkey to Uint8Array in lodestar-validator Cast querystring.parse to fastify querystringParser networkInterfaces maybe undefined Declare Promise resolve type void Remove unused import ArrayLike Revert deleting toHex()
rewiremock works fine with Typescript v4.
All our code does dependency injection everywhere, where we pass entire instances of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good for now to move forward.
I think ideally, we can build out better testing infrastructure that can help us test on valid-ish states so we can avoid relying on mocking and just have better e2e tests.
Fixes type breaking changes to be compatible with Typecript v4, so we can benefit from the performance improvements and new features.
See https://devblogs.microsoft.com/typescript/announcing-typescript-4-0/
Fixes #1784