-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
chore: update to [email protected] #10859
Conversation
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.
The type cast looks ok to me, just curious why have to do it explicitly. Does tsc complain without explicit casting ?
packages/jest-config/src/utils.ts
Outdated
@@ -101,7 +101,9 @@ export const _replaceRootDirTags = <T extends ReplaceRootDirConfigValues>( | |||
case 'object': | |||
if (Array.isArray(config)) { | |||
/// can be string[] or {}[] | |||
return config.map(item => _replaceRootDirTags(rootDir, item)) as T; | |||
return (config as Array<string>).map(item => |
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 looks a bit wrong comparing to the comment above it
@@ -26,6 +26,7 @@ export default class PCancelable<T> extends Promise<T> { | |||
reject: (reason?: unknown) => void, | |||
) => void, | |||
) { | |||
// @ts-expect-error |
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.
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.
What are the actual errors?
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.
hah, should have pushed without the ignore 🙈
packages/jest-jasmine2/src/PCancelable.ts:29:22 - error TS2554: Expected 1 arguments, but got 0.
29 super(resolve => resolve());
~~~~~~~~~
node_modules/typescript/lib/lib.es2015.promise.d.ts:33:34
33 new <T>(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
~~~~~~~~~~~~~~~~~~~~~~~~~
An argument for 'value' was not provided.
packages/jest-jasmine2/src/PCancelable.ts:40:19 - error TS2345: Argument of type 'T | PromiseLike<T> | undefined' is not assignable to parameter of type 'T | PromiseLike<T>'.
Type 'undefined' is not assignable to type 'T | PromiseLike<T>'.
40 resolve(val);
~~~
[8:25:19 PM] Found 2 errors. Watching for file changes.
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.
probably related to the new Promise<void>
changes I've had to make other places, but I wasn't able to make this one happy
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.
I think the answer for that last one is that we need to change resolve
in the same way TS did in 4.1:
resolve‘s Parameters Are No Longer Optional in Promises
So resolve: (value?: T | PromiseLike<T>) => void,
needs to lose its ?
.
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.
Maybe replace extends Promise<T>
with implements PromiseLike<T>
- that doesn't give errors for me in this file but I've not checked if the rest of the project is typesafe.
We might have to chuck the setPrototypeOf
back for instanceof
and such to work?
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.
If it's easier we can just use some function instead of new PCancelable
which extends Promise
?
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.
we don't need instanceof
, this is just internal to have a cancel
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.
That'd also probably work 🤷
This is only used in jest-jasmine2
internally, so shouldn't be too much work to refactor nor too breaking.
I'd see if it compiles & passes the tests with doing implements PromiseLike<T>
first as that to me feels like the right change, and I think that should be fine as the only place this is actually used is in queneRunner
.
That function returns an object with cancel: () => void;
- while it binds the cancel
to the PCancelable
instance, there's no spec saying it's this
is a Promise nor does it return a Promise for chaining.
So I think it should all be fine.
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.
implements PromiseLike<T>
seems to work, yeah 🚀
This reverts commit 5ed6467.
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
I'm unsure about the second commit - seems to be some array changes in TS 4.1 that are causing errors for us. @jeysal thoughts?Updating to 4.1.5 fixed those errors
Test plan
Green CI