[Umbrella] TypeScript Migration (Help wanted!)
See original GitHub issueHello Community!
Gatsby is rewriting our core codebase in TypeScript! Checkout the RFC: #21798
We would love love love your help! This work is incredibly important in Gatsby being a stable product and you could be a part of it! We are looking for community members who would be willing to jump into the codebase in transition files from .js to .ts and add the proper typings. We have a few guidelines we are wanting to stick to when doing this:
Gatsby TS Guidelines
- Only use named exports, no export default.
- When importing a package, always try to find community maintained types instead of typing ourselves. Look at the DefinitelyTyped github repository.
- Opt for using Interfaces for objects and functions.
- Type aliases should be used for primitives, unions and tuples
- Interface declaration merging is an anti-pattern and should not be used internally.
- Use
Array<type>
rather thantype[]
syntax, as it’s clearer and matches built-in types such asMap
. - Use TypeScript’s helper types, such as
Record
, rather than defining your own. - Every function should type its input and output (even if it’s inferrable)
- Enums are great, but beware they map to index numbers if not redefined. This can cause weird problems for public APIs that interop to normal JS.
- The
any
type can be used for stubbing module types that would be out of scope to migrate. But it should not be used for any functional input/outputs. The end goal of this migration is to have ZEROany
types in the codebase. See ifunknown
makes more sense in that context. Don’t use@ts-ignore
comments. - Lastly and most imporantly, we want to have simple types whenever possible. Primarily we should try to avoid Generics. Generic code can be highly reusable, but that can also come with the greater chance of breaking things. If you do need to use generics, please either give them default values or ensure the generic value can be inferred. Code should be simple when possible. DRY is not always best.
If you’re interested in getting involved, check out the list below. If you’re interested in doing something, please respond as a comment, i’ll put your name by a file so others know it’s “claimed”, when the PR is merged i’ll check the box.
Tips to get involved: first read the contribution docs, and see how to set up your local environment. After you’ve claimed the file to work on, convert it locally and ensure there are no typing or lint errors displayed in your IDE. Run yarn typecheck
and yarn lint:code
in the root before opening the PR, which will show any errors. Once you’re ready, open the PR and one of us will review it. Thanks, and good luck!
File list
- packages/babel-plugin-remove-graphql-queries
- src
- /index.js (@zachtylr21 in #23954)
- /murmur.js (@zachtylr21 in #22458)
- src
- packages/babel-preset-gatsby
- src
- /utils/path-serializer.js (@MichaelDeBoey in #22035)
- /dependencies.js + test (@MichaelDeBoey in #22038)
- /index.js + test
- src
- packages/gatsby
- /cache-dir DON’T DO
- src/bootstrap
- load-plugins (@Eyas in #22504)
- /index.js
- /load.js
- /validate.js
- load-themes/index.js
- get-config-file.js (@mottox2 in #22472)
- graphql-runner.js (@rayriffy in #22860)
- index.js (@ascorbic in #24816)
- log-line-function.js (@gabrieluizramos in #23677 )
- page-hot-reloader.js (@jeffreymeng in #27330)
- prefer-default.js (@gabrieluizramos in #23677)
- redirects-writer.js (@mottox2 in #22530)
- remove-stale-jobs.js (@gabrieluizramos in #23538)
- requires-writer.js (@alexpyzhianov in #24289)
- resolve-module-exports.js (@Eyas in #24519)
- schema-hot-reloader.js (@mottox2 in #22497)
- load-plugins (@Eyas in #22504)
- src/commands
- /build.js (@devrchancay in #23695)
- /build-html.js (@blainekasten in #20535)
- /build-javascript.js (@mottox2 in #22028)
- /build-utils.js (@mottox2 in #22262)
- /clean.js (@mottox2 in #22036)
- /develop (@blainekasten in #19923)
- /develop-static.js (@blainekasten in #22106)
- /repl.js (@mottox2 in #22037)
- /serve.js (@mottox2 in #22209)
- src/db
- common/query.js
-
loki/*
DON’T DO - index.js (@arthurjdam in #22725)
- nodes.js (@pvdz in #25199)
- sanitize-node.js (@arthurjdam in #22725)
- src/internal-plugins DON’T DO
- src/joi-schemas/joi.js (@arthurjdam in #22738)
- src/query
- /better-queue-custom-store.js + test (@chooban in #25389)
- /error-parser.js + test (@LekoArts in #20597)
- /file-parser.js + test (@martingreilinger )
- /graphql-errors.js (@jeffreymeng)
- /graphql-runner.js (@ascorbic in #21956)
- /index.js + test - data-tracking.js
- /query-compiler.js + test (@mohinderps)
- /query-runner.js (@mottox2 in #22427)
- /query-watcher.js (@ArcaneDiver in #27324)
- /queue.js (@chooban in #25389)
- /redirects-writer.js (@PerfectPan in #23332), (@taejs in #23785 - this was closed as duplicate)
- /utils.js + test (@kawamataryo #22171
- src/redux
- /actions
- add-page-dependency.js (@MichaelDeBoey in #22062)
- index.js (@MichaelDeBoey in #22063)
- internal.js (@blainekasten in #20457)
- public.js DON’T DO
- restricted.js (@1natsu172 in #22297)
- types.js (@1natsu172 in #22297)
- machines/page-component.js (@kornil in #23277)
- /reducers
- babelrc.js (@kornil in #24115)
- component-data-dependencies.js (@kornil in #24028)
- components.js (@Kornil in #24045)
- config.js (@pieh in #23620)
- flattened-plugins.js (@alisson-suzigan #24062)
- index.js (@alisson-suzigan in #23877)
- inference-metadata.js (@kornil in #24381)
- jobs.js (@kornil in #24209)
- jobsv2.js (@gabrieluizramos in #23708)
- last-actions.js (@alisson-suzigan in #23771)
- nodes-by-type.js (@alisson-suzigan #24419)
- nodes-touched.js (@carrotderek in #24247)
- nodes.js (@alisson-suzigan in #23771)
- page-data-stats.js (@carrotderek in #24082)
- page-data.js(@taejs in #23738)
- pages.js (@hiwelo in #23701)
- program.js (@tgallacher in #24941)
- redirects.js (@akshitkrnagpal in #22810)
- resolved-nodes.js (@alisson-suzigan in #24062)
- schema-customization.js (@kornil in #24259)
- schema.js (@hiwelo in #23591)
- static-query-components.js (@hiwelo in #23475)
- status.js (@hiwelo in #23474)
- themes.js (@taejs in #23716)
- webpack-compilation-hash.js (@chrisq21 in #23439)
- webpack.js (@hiwelo in #23566)
- index.js (@blainekasten in #20457)
- nodes.js (@blainekasten in #21010)
- persist.js (@blainekasten in #20457)
- plugin-runner.js (@kawamataryo in #22476)
- run-fast-filters.js (@pvdz in #25055)
- /actions
- src/schema
- extensions/index.js
- infer/
- types/
- built-in-types.js (@mottox2 in #22391)
- date.js (@sasurau4 in #22430)
- derived-types.js (@sasurau4 in #22442)
- filter.js (@sasurau4 in #22493)
- node-interface.js (@alisson-suzigan in #26733)
- pagination.js (@alisson-suzigan in #23717)
- sort.js
- type-builders.js (@PerfectPan in #23892)
- type-defs.js
- context.js
- index.js
- node-model.js
- print.js (@LinnJS)
- resolvers.js
- schema-composer.js
- schema.js (@alisson-suzigan in #23717)
- src/utils
- tracer/
- index.js (@kawamataryo #22296 )
- jaeger-local.js (@chooban in #23656)
- zipkin-local.js (@kawamataryo)
- worker/
- child.js ( @kawamataryo #22583 )
- page-data.js (@kawamataryo #22155)
- pool.js (@kawamataryo #22150)
- render-html.js( @kawamataryo #22263 )
- /api-browser-docs.js (@gabrieluizramos in #23688)
- /api-node-docs.js (@gabrieluizramos in #23688)
- /api-runner-error-parser.js (@LekoArts in #20597)
- /api-runner-node.js
- /app-data.js (@kawamataryo in #22076 )
- /babel-loader-helpers.js (#kornil in #25100)
- /babel-loader.js
- /babel-parse-to-ast.js (@john015 in #22480)
- /browserlist.js (@kawamataryo in #22089 )
- /cache.ts (@mattkane in #20626)
- /create-node-id.js (@Pittan in #22096)
- /create-schema-customization.js (@mottox2 in #22392)
- /detect-port-in-use-and-prompt.js (@mottox2 in #22061)
- /eslint-config.js (@dvrylc in #22294)
- /gatsby-dependents.js (@dvrylc in #22422)
- /gatsby-webpack-eslint-graphql-schema-reload-plugin.js (@sasurau4 #22408)
- /gatsby-webpack-stats-extractor.js (@sasurau4 #22404)
- /get-cache.js (@cola119 in #22094)
- /get-latest-apis.js (@cola119 in #22097)
- /get-public-path.js (@cola119 in #22093)
- /get-ssl-cert.js (@mottox2 in #22447)
- /get-static-dir.js (@mottox2 in #22083)
- /get-value-at.js (@martijnjanssen in #22182)
- /is-32-bit-integer.js (@Pittan in #22138)
- /jobs-manager.js (@martijnjanssen in #22189)
- /js-chunk-names.js (@mottox2 in #22289)
- /local-eslint-config-finder.js (@mottox2 in #22403)
- /merge-gatsby-config.js(@taejs in #23789)
- /normalize-page-path.js (@martijnjanssen in #22188)
- /page-data.js (@hiwelo in ~#23436~ #23991)
- /page-html.js (@kawamataryo in #22118)
- /path.js (@kawamataryo in #22130)
- /prepare-regex.js (@mottox2 in #22133)
- /profile.js
- /reach-router-add-basecontext-export-loader.js
- /source-nodes.js
- /stack-trace-utils.js (@sasurau4 in #22251)
- /test-require-error.js (@sasurau4 in #22265)
- /webpack-error-utils.js (@sasurau4 in #22278)
- /webpack-helpers.js (@sasurau4 in #22279)
- /webpack-hmr-hooks-patch.js (@sasurau4 in #22280)
- /webpack-plugins.js (@sasurau4 in #22378)
- /webpack-utils.js (@sasurau4 in #22381)
- /webpack.config.js
- /websocket-manager.js (@Eyas in #22510)
- tracer/
- packages/gatsby-cli
- src/reporter
- loggers
- ink (@arthurjdam in #22782)
- components (@arthurjdam in #22782)
- develop.js (@arthurjdam in #22782)
- error.js (@Naturalclar in #22098)
- messages.js (@cola119 in #22084)
- progress-bar.js (@Naturalclar in #22081)
- spinner.js (@Naturalclar in #22080)
- cli.js (@arthurjdam in #22782)
- context.js (@arthurjdam in #22782)
- index.js (@arthurjdam in #22782)
- components (@arthurjdam in #22782)
- ipc/index.js (@anoriqq in #23960)
- json/index.js (@wiput1999 in #24140)
- yurnalist/index.js (@blainekasten in #24224)
- ink (@arthurjdam in #22782)
- redux (@Kornil in #22292)
- actions.js
- index.js
- reducer.js
- constants.js (@cola119 in #22084)
- errors.js (@blainekasten in #24226)
- index.js (@blainekasten in #22869)
- prepare-stack-trace.js (@blainekasten in #24226)
- types.js (@blainekasten in #22869)
- loggers
- src/structured-errors (@LekoArts in #20597)
- construct-error.js
- error-map.js
- error-schema.js
- src/util
- src/create-cli.js (@alexpyzhianov in #23650)
- src/did-you-mean.js (@mottox2 in #22068)
- src/index.js (@blainekasten in #19923)
- src/init-starter.js (@mottox2 in #22086)
- src/reporter
- packages/gatsby-core-utils
- src/
- /ci.js (@danielkov in #22047)
- /cpu-core-count.js (@danielkov in #22048)
- /create-content-digest.js (@danielkov in #22049)
- /create-require-from-path.js (@danielkov in #22050)
- /get-config-file.js (@danielkov in #22051)
- /get-gatsby-version.js (@danielkov in #22052)
- /index.js (@danielkov in #22053)
- /path.js (@danielkov in #22054)
- /physical-cpu-count.js (@blainekasten in #22122)
- /url.js (@danielkov in #22056)
- src/
- packages/gatsby-link (@herecydev in #22027)
- src/
- /index.js + test
- /parse-path.js + test
- src/
- packages/gatsby-page-utils
- src/
- /create-path.js + test
- /ignore-path.js + test
- /index.js
- /validate-path.js + test
- /watch-directory.js
- src/
- packages/gatsby-telemetry (@Eyas in #22532)
- src/
- error-helpers.js + test
- /event-storage.js
- /flush.js (@blainekasten in #25886)
- /index.js
- /is-truthy.js + test (@blainekasten in #25884)
- /postinstall.js
- /repository-id.js + test (@mottox2 in #22474)
- /send.js
- /showAnalyticsNotification.js
- /store.js
- /telemetry.js + test
- src/
- packages/gatsby-react-router-scroll (@blainekasten in #24306)
- src/
- /index.js
- /ScrollBehaviorContext.js
- /ScrollContainer.js
- /StateStorage.js
- src/
Issue Analytics
- State:
- Created 4 years ago
- Reactions:53
- Comments:141 (100 by maintainers)
Huge milestone!
gatsby-cli
is 100% converted to TypeScript! Thank you everyone for your incredible work 💜💜💜Hello everyone!
Just wanted to drop in and say a HUUUUUUGE thank you! The response from the community has been amazing and (a little) overwhelming 😅. But keep it coming! Ya’ll are invaluable and speeding up this conversion 100x.
We’re making great progress. Let’s keep it up!