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

chore(gatsby): Convert jobs-manager to typescript #22189

Merged
merged 9 commits into from
Aug 11, 2020

Conversation

martijnjanssen
Copy link
Contributor

Description

This converts the gatsby/util/jobs-manager and the corresponding tests to typescript, one more step towards a fully typed core codebase! I do think that I have gotten the lion's share of the types correct and don't think I have forgotten anything, but if I did, please say so 🙏

Related Issues

Related to #21995

@martijnjanssen martijnjanssen requested a review from a team as a code owner March 11, 2020 21:30
@martijnjanssen martijnjanssen force-pushed the jobs-manager-typescript-convert branch from 9b4bfd3 to 1d9d07e Compare March 11, 2020 21:37
@martijnjanssen martijnjanssen force-pushed the jobs-manager-typescript-convert branch from 1d9d07e to aebcb60 Compare March 11, 2020 21:53
@martijnjanssen martijnjanssen force-pushed the jobs-manager-typescript-convert branch from aebcb60 to 811fd6f Compare April 4, 2020 10:45
@martijnjanssen
Copy link
Contributor Author

I completely forgot to push my changes. I have reverted the changes to the tests, since I cannot figure out how to handle module isolation in typescript.

@pvdz pvdz marked this pull request as draft April 9, 2020 08:13
@pvdz pvdz removed the status: WIP label Apr 9, 2020
@pvdz
Copy link
Contributor

pvdz commented Apr 9, 2020

(I've converted this PR into a Draft PR)

@martijnjanssen
Copy link
Contributor Author

This is not a draft, the PR is finished in my opinion, just waiting for a final review. I should've removed that label 🙂

@martijnjanssen martijnjanssen marked this pull request as ready for review April 9, 2020 08:42
pvdz
pvdz previously requested changes Jul 17, 2020
Copy link
Contributor

@pvdz pvdz left a comment

Choose a reason for hiding this comment

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

Hey the PR looks good to me. One change I'd like to request is to move the types to the top directly after the imports. Other comments are minor or can be ignored for this PR. Thank you!

packages/gatsby/src/utils/jobs-manager.ts Outdated Show resolved Hide resolved
packages/gatsby/src/utils/jobs-manager.ts Show resolved Hide resolved
packages/gatsby/src/utils/jobs-manager.ts Show resolved Hide resolved
packages/gatsby/src/utils/jobs-manager.ts Outdated Show resolved Hide resolved
@martijnjanssen martijnjanssen force-pushed the jobs-manager-typescript-convert branch from 811fd6f to 66bf919 Compare July 17, 2020 14:12
@gatsby-cloud-staging
Copy link

gatsby-cloud-staging bot commented Jul 17, 2020

Gatsby Cloud Build Report

🚩 Your build failed. See the build logs here

Errors

Error in "/usr/src/app/www/examples/gatsbygram/node_modules/gatsby-plugin-page-creator/gatsby-node.js": Cannot find module 'gatsby-cli/lib/reporter'
Require stack:
- /usr/src/app/www/examples/gatsbygram/node_modules/gatsby-plugin-page-creator/is-valid-collection-path-implementation.js
- /usr/src/app/www/examples/gatsbygram/node_modules/gatsby-plugin-page-creator/create-pages-from-collection-builder.js
- /usr/src/app/www/examples/gatsbygram/node_modules/gatsby-plugin-page-creator/create-page-wrapper.js
- /usr/src/app/www/examples/gatsbygram/node_modules/gatsby-plugin-page-creator/gatsby-node.js
- /usr/src/app/www/examples/gatsbygram/node_modules/gatsby/dist/bootstrap/resolve-module-exports.js
- /usr/src/app/www/examples/gatsbygram/node_modules/gatsby/dist/bootstrap/load-plugins/validate.js
- /usr/src/app/www/examples/gatsbygram/node_modules/gatsby/dist/bootstrap/load-plugins/load.js
- /usr/src/app/www/examples/gatsbygram/node_modules/gatsby/dist/bootstrap/load-plugins/index.js
- /usr/src/app/www/examples/gatsbygram/node_modules/gatsby/dist/services/initialize.js
- /usr/src/app/www/examples/gatsbygram/node_modules/gatsby/dist/services/index.js
- /usr/src/app/www/examples/gatsbygram/node_modules/gatsby/dist/bootstrap/index.js
- /usr/src/app/www/examples/gatsbygram/node_modules/gatsby/dist/commands/build.js
- /usr/src/app/www/examples/gatsbygram/node_modules/gatsby/node_modules/gatsby-cli/lib/create-cli.js
- /usr/src/app/www/examples/gatsbygram/node_modules/gatsby/node_modules/gatsby-cli/lib/index.js
- /usr/src/app/www/examples/gatsbygram/node_modules/gatsby/dist/bin/gatsby.js
- /usr/src/app/www/examples/gatsbygram/node_modules/gatsby/cli.js

@pvdz
Copy link
Contributor

pvdz commented Jul 17, 2020

Ah looks like WorkerError has to go above the types (because classes aren't hoisted). Sorry about that.

@martijnjanssen
Copy link
Contributor Author

Looks like my editor removed all trailing ,'s... I'm adding them back now.

@martijnjanssen
Copy link
Contributor Author

Okay there are some pre-commit tasks which keep formatting the file and removing trailing ,'s from the file, would you know anything about that @pvdz?

@pvdz
Copy link
Contributor

pvdz commented Jul 17, 2020

I believe it's caused by formatting? What happens when you do yarn format? (or npm run format)
image

I'll proc the formatting from a bot (this will cause remote changes for you. When necessary, either pull before pushing or force push)

@pvdz
Copy link
Contributor

pvdz commented Jul 17, 2020

I'm actually about to go on vacation so if we can't resolve that before then, somebody else will take over. But I think this is about ready to merge.

@pvdz
Copy link
Contributor

pvdz commented Jul 17, 2020

This seems like an actual problem:

../gatsby/src/redux/types.ts(6,10): error TS2305: Module '"../utils/jobs-manager"' has no exported member 'InternalJobInterface'.

Looks like you can repro this locally by running yarn bootstrap, which pretty much compiles all the packages. And probably for one package specifically although the output is not clear on that. Good bet that it's just the gatsby package itself :)

@pvdz
Copy link
Contributor

pvdz commented Jul 29, 2020

@martijnjanssen friendly ping :)

@pvdz
Copy link
Contributor

pvdz commented Aug 11, 2020

I've went ahead and fixed the two remaining typing problems.

@pvdz pvdz removed the request for review from blainekasten August 11, 2020 11:07
@pvdz pvdz changed the title Convert jobs-manager to typescript chore(gatsby): Convert jobs-manager to typescript Aug 11, 2020
@gatsbyjs gatsbyjs deleted a comment from gatsby-cloud bot Aug 11, 2020
Copy link
Contributor

@blainekasten blainekasten left a comment

Choose a reason for hiding this comment

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

This looks great to me, let's merge it!

Thank you so much for contributing to our TypeScript refactor! We have more work to do and we would love to have you stay involved in our transition. Please submit more PRs! 💜

@blainekasten blainekasten added the bot: merge on green Gatsbot will merge these PRs automatically when all tests passes label Aug 11, 2020
@blainekasten blainekasten dismissed pvdz’s stale review August 11, 2020 19:21

you fixed it!

@blainekasten blainekasten merged commit f59fb37 into master Aug 11, 2020
@blainekasten blainekasten deleted the jobs-manager-typescript-convert branch August 11, 2020 19:22
pragmaticpat pushed a commit to pragmaticpat/gatsby that referenced this pull request Apr 28, 2022
* chore(gatsby) convert jobs-manager to typescript

* chore(gatsby) revert jobs-manager tests to js

* chore(gatsby) fix formatting for jobs-manager

* chore(gatsby) move imports for jobs-manager after imports

* Chore(gatsby) check contentDigest of job when checking internalJob

* Chore(gatsby) declare WorkerError before usage

* chore: format

* Fix types

Co-authored-by: gatsbybot <mathews.kyle+gatsbybot@gmail.com>
Co-authored-by: Peter van der Zee <github-public@qfox.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: merge on green Gatsbot will merge these PRs automatically when all tests passes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants