-
Notifications
You must be signed in to change notification settings - Fork 4.4k
TypeScript: migrate deprecated package to TS #70362
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
TypeScript: migrate deprecated package to TS #70362
Conversation
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @USERSATOSHI! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
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. |
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.
Thank you for your contribution.
This looks good, I just have a minor suggestion about the type improvements.
packages/deprecated/src/index.ts
Outdated
* @type {Record<string, true | undefined>} | ||
*/ | ||
export const logged = Object.create( null ); | ||
export const logged: Record< string, true | undefined > = Object.create( null ); |
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 the undefined
type here as the value is always true
down there. So let us fix it
So, it should be
* @type {Record<string, true>}
and
Record< string, true >
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.
In fact, let us remove that @type
annonotation from the comment as the TS type is sufficient.
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.
In fact, let us remove that
@type
annonotation from the comment as the TS type is sufficient.
Got it, I will remove the @type
annonotations.
Do I also remove types from JSDoc and convert them to follow TSDoc or leave it like that?
like:
* @param {string} feature Name of the deprecated feature.
* @param {Object} [options] Personalisation options
* @param {string} [options.since] Version in which the feature was deprecated.
* @param {string} [options.version] Version in which the feature will be removed.
* @param {string} [options.alternative] Feature to use instead
* @param {string} [options.plugin] Plugin name if it's a plugin feature
* @param {string} [options.link] Link to documentation
* @param {string} [options.hint] Additional message to help transition away from the deprecated feature.
to
* @param feature Name of the deprecated feature.
* @param [options] Personalisation options
* @param [options.since] Version in which the feature was deprecated.
* @param [options.version] Version in which the feature will be removed.
* @param [options.alternative] Feature to use instead
* @param [options.plugin] Plugin name if it's a plugin feature
* @param [options.link] Link to documentation
* @param [options.hint] Additional message to help transition away from the deprecated feature.
cc: @manzoorwanijk
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.
Let us move those docs to the type instead. So, it will be
type DeprecatedOptions = {
/**
* Version in which the feature was deprecated.
*/
since?: string;
// Other properties
};
and then change the options param like this
/**
* @param {DeprecatedOptions} [options] Personalisation options
*/
Likewise for doAction
docs
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.
Got it, updating to this.
Updated the params and README.md to reflect the same. |
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 perfect now. Congratulations for your first contribution 🎉
Thank you very much :) |
* refactor: migrate deprecated package from js to ts for type safety * docs: move inline param docs to type definition * docs: add the missing message param inline comment * docs: fix param documentation for deprecated action
What?
Part of #67691
Migrating the deprecated package to Typescript.
Why?
To enhance DX and add type safety
How?
By porting the code to TypeScript
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast