-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Migrate plugins package to TS #70773
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
Migrate plugins package to TS #70773
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
interface PluginErrorBoundaryProps { | ||
/** | ||
* The name of the plugin that may encounter an errors. | ||
*/ | ||
name: string; | ||
/** | ||
* The child components to render. | ||
*/ | ||
children: ReactNode; | ||
/** | ||
* Callback function called when an error occurs. | ||
*/ | ||
onError?: ( name: string, error: Error ) => void; | ||
} | ||
|
||
interface PluginErrorBoundaryState { | ||
hasError: boolean; | ||
} |
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 we,
- Use
React.ReactNode
without importing from'react'
- Move these two interfaces to a
types.ts
file in the same directory, and then use
import type {
PluginErrorBoundaryProps as Props,
PluginErrorBoundaryState as State,
} from './types';
export class PluginErrorBoundary extends Component< Props, State > {
//
}
That way, we can preserve the git history of the file.
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 good now. Thank you for making the suggested changes.
Co-authored-by: dhruvikpatel18 <dhruvik18@git.wordpress.org> Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org>
What?
Part of: #67691
Migrating the plugins package to Typescript.
Why?
Type safety.
Testing Instructions
Type check