-
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
Convert warning package to TypeScript #61522
Convert warning package to TypeScript #61522
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. |
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @jpstevens! 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. |
Thanks for your help typing all these packages. I thought this package was already fully typed. Is renaming to ts files necessary? @sirreal Can you help me navigate this a bit :P |
Changing the file extension doesn't change much here. This package is typechecked, types are generated for the package, and no complex types are necessary that can't be easily expressed in JSDoc. The type of the public API of the current version this package can be found here: That would be exactly the same. The explicit return type annotations added to the two functions might be a nice change, they're both inferred to be the same thing, but some would argue that adding those annotations is a good thing. |
@@ -24,7 +24,7 @@ function isDev() { | |||
* } | |||
* ``` | |||
*/ | |||
export default function warning( message ) { | |||
export default function warning( message: string ): void { |
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'm guessing that we need to remove the types from the JSDocs to be consistent with how we document ts files.
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.
Yes. If we change the files to TypeScript we should definitely remove the types from JSDoc 💯
@@ -4,4 +4,4 @@ | |||
* | |||
* @type {Set<string>} |
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.
Should probably remove this as well right?
I've been thinking about this PR. While I see some value in it, I'm not sure that we should move forward with it. It has no real impact on the generated types or whether the package is fully typed. It's really a code style change. And the thing is that while for this package it's fine, it may create a snowball effect for other packages and we'll find our selves spending time rewriting JS to TS for a lot of code and reviewing a lot of code for a small benefit. |
My main argument in favor of TS conversions like this is that the JSDoc type annotations are a rather obscure feature and most people are not familiar with them. I guess that many would be surprised to learn that such a thing even exists. Who is really fluent in knowing that |
I don't feel that strongly, so I can be convinced, happy to hear other opinions. |
👋 @jpstevens If you'll update this PR on the latest |
What?
This PR converts the
warning
package to TypeScript.Why?
Ensures package is fully type checked.
How?
.ts
index
andutils
filesTesting Instructions
npm run test:unit -- packages/warning
tests passnpm run build:package-types
returns a zero exit code