-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Tools: Update TypeScript to the 4.4.x version #34373
Conversation
I would appreciate some help with addressing all the reported errors. |
It looks like there is more strict handling in https://devblogs.microsoft.com/typescript/announcing-typescript-4-4/#use-unknown-catch-variables |
debug( | ||
`first-time-contributor-account-link: Error retrieving from profile API:\n\n${ error.toString() }` | ||
); | ||
if ( error instanceof 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.
The question is whether request
throws an Error
instance.
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.
It may be better to change the original promise so that it creates a new error when rejecting:
reject(new Error('fail'))
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.
error.toString()
would print fail
in that case.
I came up with a simpler solution. I added a check if error
is an object which should be general enough and ensure there is toString
method present 😄
Took a look at the
I presume we still want to use it if the browser supports it (cc @ellatrix ). Is there a way to tell TypeScript not to report some error? |
Thanks for the notes @oandregal!
I pushed a fix for this in b4636c1. Basically it restores the type that was removed. I've pushed commits for type issues as they manifested. There were a number of issues with Reakit types so I ended up disabling type checks for external libs (
|
There's an open PR to fix that on Reakit (ariakit/ariakit#903). I'll take a look at that and I hope it gets merged this week. |
For better visibility, CI issues are unrelated to these changes. More details in #34377. |
092cb5b
to
7b193fb
Compare
I rebased this branch with the latest changes applied to Thank you all for your help and kudos to @sirreal for all fixes applied. I'm going to land this when CI turns green. |
@@ -28,8 +28,9 @@ export function sprintf( format, ...args ) { | |||
try { | |||
return sprintfjs.sprintf( format, ...args ); | |||
} catch ( error ) { | |||
logErrorOnce( 'sprintf error: \n\n' + error.toString() ); | |||
|
|||
if ( error instanceof 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.
This one is good, sprintfjs
throws only Error
instances:
Size Change: +77 B (0%) Total Size: 1.04 MB
ℹ️ View Unchanged
|
Yes we need to keep it. See https://developer.mozilla.org/en-US/docs/Web/API/Document/caretRangeFromPoint. |
* | ||
* @return {boolean} Whether error is a duplicate validation request error. | ||
*/ | ||
const isDuplicateValidationError = ( requestError ) => { | ||
// The included version of RequestError provides no way to access the | ||
// full 'errors' array that the github REST API returns. Hopefully they | ||
// resolve this soon! | ||
return requestError.message.includes( 'already_exists' ); | ||
const errorMessage = /** @type {undefined | null | {message?: string}} */ ( requestError ) |
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.
It looks like it errors in the GitHub action:
https://github.com/WordPress/gutenberg/runs/3482847233
I will try to find a quick fix.
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.
6730182 should fix it.
…-automation` Follow-up for #34373.
Description
See: https://devblogs.microsoft.com/typescript/announcing-typescript-4-4/
There is
118 errors to fix reported after runningnpm run clean:package-types
andnpm run build:package-types
:How has this been tested?
npm run clean:package-types
npm run build:package-types
Types of changes