Skip to content
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

Add TypeScript support #23522

Merged
merged 27 commits into from
Apr 14, 2022
Merged

Add TypeScript support #23522

merged 27 commits into from
Apr 14, 2022

Conversation

manzoorwanijk
Copy link
Member

@manzoorwanijk manzoorwanijk commented Mar 21, 2022

  • This PR adds TypeScript support for js-packages, plugins/jetpack and this can be extended to any part of the codebase.
  • You can now write all your components in TS.
  • Adds TS support for Unit tests - giving you more confidence writing tests.
  • You can now even use TypeScript for Storybook stories.

Also,

  • It updates the configuration files related to Unit tests, Storybook etc.
  • It adds some useful types (like @types/react etc.) as dependencies

Jetpack product discussion

p9dueE-4E8-p2

Does this pull request change what data or activity we track or use?

No

Testing instructions

  • Convert any component inside plugins/jetpack to TypeScript
  • Run jetpack build plugin/jetpack
  • Do the same for js-packages/components

See #23889 as an example/POC to use TypeScript.

@github-actions github-actions bot added [JS Package] Components [JS Package] Storybook [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ Admin Page React-powered dashboard under the Jetpack menu RNA labels Mar 21, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Mar 21, 2022

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ⚠️ All commits were linted before commit.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team review" label and ask someone from your team review the code.
Once you’ve done so, switch to the "[Status] Needs Review" label; someone from Jetpack Crew will then review this PR and merge it to be included in the next Jetpack release.


Jetpack plugin:

  • Next scheduled release: May 3, 2022.
  • Scheduled code freeze: April 25, 2022.

@github-actions github-actions bot added the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Mar 21, 2022
@manzoorwanijk manzoorwanijk self-assigned this Mar 21, 2022
@manzoorwanijk manzoorwanijk requested a review from a team March 21, 2022 15:37
@manzoorwanijk manzoorwanijk added the [Status] Needs Review To request a review from Crew. Label will be renamed soon. label Mar 21, 2022
@manzoorwanijk manzoorwanijk requested a review from a team March 21, 2022 15:37
@manzoorwanijk manzoorwanijk marked this pull request as ready for review March 21, 2022 15:38
Copy link
Contributor

@anomiex anomiex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR seems to be doing too many different things:

  • Fixing VSCode's locating of Jetpack components.
  • Fixing VSCode's locating of monorepo JS packages, if that's even broken?
  • Adding typescript support all over the place.
  • Moving code around to create a new component.

I'd like to see a version that does the minimum possible to handle just the first and second bullets (if the second is actually a problem). Then do the others as followups.

As it is, I can't tell which things are here to fix vscode, which are here to try to support typescript, and which are extra stuff that got added in trying to figure out vscode and didn't get backed out if they didn't work.

projects/js-packages/components/package.json Outdated Show resolved Hide resolved
tools/js-tools/eslintrc/base.js Outdated Show resolved Hide resolved
@jeherve jeherve requested a review from a team March 21, 2022 16:48
Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does play nice in VS code. It doesn't quite fix the svelte issue with Prettier that we discussed in #20996, but it does make it really easier to navigate between components, nice work!

There are a few failing tests you'll need to address, as you can see below, related to version bumps and changelogs.

projects/js-packages/components/tsconfig.json Outdated Show resolved Hide resolved
@jeherve jeherve removed the [Status] Needs Review To request a review from Crew. Label will be renamed soon. label Mar 21, 2022
@jeherve
Copy link
Member

jeherve commented Mar 21, 2022

I've added @Automattic/jetpack-agora as reviewers for this PR. If we are adding TypeScript support to the Components package and to the Jetpack, it may be good to discuss (here or maybe preferably on +jetpackcrew) whether we should start encouraging / mandating the use of TypeScript in the monorepo from now on, setting the right expectations for everyone contributing, to avoid having a mix in the components from now on, all depending on who writes the first version of the component, and thus making it a bit more difficult for new contributors to jump in and contribute to a specific part of Jetpack.

@manzoorwanijk
Copy link
Member Author

This PR seems to be doing too many different things:

Actually all of those things are basically the same problem - i.e. VS Code is not able to locate the imported components.

If we try to fix those separately, we may have many test failures thus it will mean we will need to merge PRs that break many things.

@manzoorwanijk
Copy link
Member Author

It doesn't quite fix the svelte issue with Prettier that we discussed in #20996

You can see that I mentioned the issues that this PR fixes. ESLint/Prettier issue is another big one that can be handled separately in another PR.

@manzoorwanijk manzoorwanijk added [Status] Needs Review To request a review from Crew. Label will be renamed soon. and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Mar 22, 2022
@anomiex
Copy link
Contributor

anomiex commented Mar 22, 2022

Actually all of those things are basically the same problem - i.e. VS Code is not able to locate the imported components.

How exactly are adding typescript support for all sorts of things and moving and rewriting RecordMeterBar required to fix vscode locating things?

I could see that you might need a minimal typescript config file to teach vscode how to find things if that's where it insists on getting its configs from, but it seems to me this PR goes beyond that.

@retrofox
Copy link
Contributor

...it may be good to discuss whether we should start encouraging / mandating the use of TypeScript in the monorepo from now on,

jetpack-components IMO

... setting the right expectations for everyone contributing, to avoid having a mix in the components from now on, all depending on who writes the first version of the component, and thus making it a bit more difficult for new contributors to jump in and contribute to a specific part of Jetpack.

Even sounds like a nice plan :-D We agree that TypeScript is something that we should start to encourage to use sooner than later. Being said that and just in case, I'm not the right person to lead this refactoring process but 100more than happy to get 100% involved on it.

First action to take is to document the process, some rules, whatever that can make the developers tasks painless as much as possible.

Copy link
Contributor

@renatoagds renatoagds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good for me! .. Did some tests and it looks fine, it will be a good movement for RNA Components 🤘🏽

@manzoorwanijk manzoorwanijk enabled auto-merge (squash) April 12, 2022 23:50
@matticbot
Copy link
Contributor

Caution: This PR has changes that must be merged to WordPress.com
Hello manzoorwanijk! These changes need to be synced to WordPress.com - If you 're an a11n, please commandeer and confirm D78670-code works as expected before merging this PR. Once this PR is merged, please commit the changes to WP.com. Thank you!
This revision will be updated with each commit to this PR

Copy link
Contributor

@anomiex anomiex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok to me now as far as structure goes. I'll leave it to someone from Agora to do a review of whether the actual typescript stuff is right.

@manzoorwanijk manzoorwanijk requested review from a team and renatoagds April 13, 2022 15:06
Copy link
Contributor

@renatoagds renatoagds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did some tests at jetpack-components and everything went well. Let's move forward and we could start to improve the configuration as soon we have more use cases.

@manzoorwanijk manzoorwanijk enabled auto-merge (squash) April 13, 2022 22:39
@manzoorwanijk
Copy link
Member Author

It looks like it can't be merged until @jeherve approves it because he had requested changes earlier which I had made. Since he is AFK, can someone with permissions merge this anyway?
CC @Automattic/jetpack-crew @kraftbj

@brbrr brbrr dismissed jeherve’s stale review April 14, 2022 01:50

Feedback addressed

@manzoorwanijk manzoorwanijk merged commit acf3c69 into master Apr 14, 2022
@manzoorwanijk manzoorwanijk deleted the fix/vs-code-ts-fixes branch April 14, 2022 01:50
@brbrr
Copy link
Contributor

brbrr commented Apr 14, 2022

@manzoorwanijk fwiw there is a way to dismiss the "requested changes" thing.

@github-actions github-actions bot removed the [Status] Needs Review To request a review from Crew. Label will be renamed soon. label Apr 14, 2022
@github-actions github-actions bot added this to the jetpack/10.9 milestone Apr 14, 2022
@github-actions
Copy link
Contributor

Great news! One last step: head over to your WordPress.com diff, D78670-code, and deploy it.
Once you've done so, come back to this PR and add a comment with your changeset ID.

Thank you!

@manzoorwanijk
Copy link
Member Author

manzoorwanijk commented Apr 14, 2022

@manzoorwanijk fwiw there is a way to dismiss the "requested changes" thing.

I think that also requires higher permissions

Thank you for doing that for me @brbrr

@vitozev
Copy link
Contributor

vitozev commented Apr 14, 2022

r243684-wpcom

@manzoorwanijk
Copy link
Member Author

...it may be good to discuss whether we should start encouraging / mandating the use of TypeScript in the monorepo from now on,

jetpack-components IMO

... setting the right expectations for everyone contributing, to avoid having a mix in the components from now on, all depending on who writes the first version of the component, and thus making it a bit more difficult for new contributors to jump in and contribute to a specific part of Jetpack.

Even sounds like a nice plan :-D We agree that TypeScript is something that we should start to encourage to use sooner than later. Being said that and just in case, I'm not the right person to lead this refactoring process but 100more than happy to get 100% involved on it.

First action to take is to document the process, some rules, whatever that can make the developers tasks painless as much as possible.

Will it be worth to take this discussion to a p2 post? @retrofox @jeherve @renatoagds @oskosk

There is already this p2 post I found p9dueE-3Hs-p2 (by @allilevine)

Whenever you plan to work on migrating components to TypeScript, count me in for any help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Admin Page React-powered dashboard under the Jetpack menu [JS Package] Components [JS Package] Storybook [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ RNA [Tools] Monorepo Setup Touches WP.com Files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants