-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Description
Hello 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 chore(babel-plugin-remove-graphql-queries): Convert index.js #23954)
- /murmur.js (@zachtylr21 in chore(babel-plugin-remove-graphql-queries): Convert murmur.js #22458)
- src
- packages/babel-preset-gatsby
- src
- /utils/path-serializer.js (@MichaelDeBoey in chore(babel-preset-gatsby): Convert path-serializer to TS #22035)
- /dependencies.js + test (@MichaelDeBoey in chore(babel-preset-gatsby): Convert dependencies to TS #22038)
- /index.js + test
- src
- packages/gatsby
- /cache-dir DON'T DO
- src/bootstrap
- load-plugins (@Eyas in chore(gatsby): Update load-plugins to Typescript. #22504)
- /index.js
- /load.js
- /validate.js
- load-themes/index.js
- get-config-file.js (@mottox2 in chore(gatsby): Convert get-config-file to typescript #22472)
- graphql-runner.js (@rayriffy in refactor: migrate graphql-runner into TypeScript #22860)
- index.js (@ascorbic in refactor(gatsby): change bootstrap to use services #24816)
- log-line-function.js (@gabrieluizramos in Convert prefer-default and log-line-function to TS #23677 )
- page-hot-reloader.js (@jeffreymeng in chore(gatsby): Migrate page-hot-reloader to typescript #27330)
- prefer-default.js (@gabrieluizramos in Convert prefer-default and log-line-function to TS #23677)
- redirects-writer.js (@mottox2 in chore(gatsby): Convert redirects-writer to typescript #22530)
- remove-stale-jobs.js (@gabrieluizramos in Convert remove-stale-job to TS #23538)
- requires-writer.js (@alexpyzhianov in chore(gatsby) Rewrite requires-writer.js to TypeScript #24289)
- resolve-module-exports.js (@Eyas in chore(gatsby): Update resolve-module-exports to TS #24519)
- schema-hot-reloader.js (@mottox2 in chore(gatsby): Convert schema-hot-reloader to typescript #22497)
- load-plugins (@Eyas in chore(gatsby): Update load-plugins to Typescript. #22504)
- src/commands
- /build.js (@devrchancay in chore(gatsby): convert build to typescript #23695)
- /build-html.js (@blainekasten in chore(gatsby): convert build-html to typescript #20535)
- /build-javascript.js (@mottox2 in chore(gatsby): Port build-javascript to TypeScript #22028)
- /build-utils.js (@mottox2 in chore(gatsby): Convert build-utils to typescript #22262)
- /clean.js (@mottox2 in chore(gatsby): Convert clean to typescript #22036)
- /develop (@blainekasten in chore(gatsby): Use Typescript internally! #19923)
- /develop-static.js (@blainekasten in chore(gatsby): Convert develop-static to TypeScript #22106)
- /repl.js (@mottox2 in chore(gatsby): Convert repl to typescript #22037)
- /serve.js (@mottox2 in chore(gatsby): Convert serve to typescript #22209)
- src/db
- common/query.js
-
loki/*
DON'T DO - index.js (@arthurjdam in chore(gatsby) Migrate db methods to Typescript #22725)
- nodes.js (@pvdz in chore(gatsby): Convert db/nodes to TS #25199)
- sanitize-node.js (@arthurjdam in chore(gatsby) Migrate db methods to Typescript #22725)
- src/internal-plugins DON'T DO
- src/joi-schemas/joi.js (@arthurjdam in chore(gatsby) Migrate joi schema to Typescript #22738)
- src/query
- /better-queue-custom-store.js + test (@chooban in chore: Migrate custom store and queue to TypeScript #25389)
- /error-parser.js + test (@LekoArts in Port parts of Structured Errors to TS + Add two more errors #20597)
- /file-parser.js + test (@martingreilinger )
- /graphql-errors.js (@jeffreymeng)
- /graphql-runner.js (@ascorbic in chore(gatsby): Port gql runner to TypeScript #21956)
- /index.js + test - data-tracking.js
- /query-compiler.js + test (@mohinderps)
- /query-runner.js (@mottox2 in chore(gatsby): Convert query-runner to typescript #22427)
- /query-watcher.js (@ArcaneDiver in chore(gatsby): Migrate query-watcher to ts #27324)
- /queue.js (@chooban in chore: Migrate custom store and queue to TypeScript #25389)
- /redirects-writer.js (@PerfectPan in chore(gatsby): Migrate query/redirects-writer to Typescript #23332), (@taejs in chore(gatsby): migrate query/redirectWriter to TypeScript #23785 - this was closed as duplicate)
- /utils.js + test (@kawamataryo chore(gatsby): Convert query/utils to typescript #22171
- src/redux
- /actions
- add-page-dependency.js (@MichaelDeBoey in chore(gatsby): Convert redux/actions/add-page-dependency to TS #22062)
- index.js (@MichaelDeBoey in chore(gatsby): Convert redux/actions/index to TS #22063)
- internal.js (@blainekasten in chore(gatsby): Begin typing the redux code #20457)
- public.js DON'T DO
- restricted.js (@1natsu172 in chore(gatsby): Migrate redux/actions/types and redux/actions/restricted to TypeScript #22297)
- types.js (@1natsu172 in chore(gatsby): Migrate redux/actions/types and redux/actions/restricted to TypeScript #22297)
- machines/page-component.js (@Kornil in chore(gatsby): convert page-component to typescript #23277)
- /reducers
- babelrc.js (@Kornil in chore(gatsby): convert babelrc to typescript #24115)
- component-data-dependencies.js (@Kornil in chore(gatsby): convert component-data-dependencies to typescript #24028)
- components.js (@Kornil in chore(gatsby): convert components to typescript #24045)
- config.js (@pieh in fix(gatsby): log config validation errors #23620)
- flattened-plugins.js (@alisson-suzigan chore(gatsby): Convert flattened-plugins and resolved-nodes to TS #24062)
- index.js (@alisson-suzigan in chore(gatsby): Migrate reducers/index to TypeScript #23877)
- inference-metadata.js (@Kornil in chore(gatsby): convert inference-metadata to typescript #24381)
- jobs.js (@Kornil in chore(gatsby): convert jobs to typescript #24209)
- jobsv2.js (@gabrieluizramos in chore(gatsby): Convert jobsV2 reducer to TS #23708)
- last-actions.js (@alisson-suzigan in chore(gatsby): Migrate nodes reducer and last-action reducer to TypeScript #23771)
- nodes-by-type.js (@alisson-suzigan chore(gatsby): Migrate reducers/nodes-by-type to TypeScript #24419)
- nodes-touched.js (@carrotderek in chore(gatsby): Migrate reducers/nodes-touched to TypeScript #24247)
- nodes.js (@alisson-suzigan in chore(gatsby): Migrate nodes reducer and last-action reducer to TypeScript #23771)
- page-data-stats.js (@carrotderek in chore(gatsby): Convert page-data-stats reducer to TypeScript #24082)
- page-data.js(@taejs in chore(gatsby): migrate pageData reducer to TypeScript #23738)
- pages.js (@hiwelo in chore(gatsby): migrate pages reducer to TypeScript #23701)
- program.js (@tgallacher in refactor(gatsby): convert program reducer to typescript #24941)
- redirects.js (@akshitkrnagpal in chore(gatsby): Convert redux/reducers/redirects to typescript #22810)
- resolved-nodes.js (@alisson-suzigan in chore(gatsby): Convert flattened-plugins and resolved-nodes to TS #24062)
- schema-customization.js (@Kornil in chore(gatsby): convert schema-customization to typescript #24259)
- schema.js (@hiwelo in chore(gatsby): migrate schema reducer to TypeScript #23591)
- static-query-components.js (@hiwelo in chore(gatsby): migrate static-query-components reducer to TypeScript #23475)
- status.js (@hiwelo in chore(gatsby): migrate status reducer to TypeScript #23474)
- themes.js (@taejs in chore(gatsby): migrate themes reducer to TypeScript #23716)
- webpack-compilation-hash.js (@chrisq21 in Converted webpack-compilation-hash javascript file to typescript #23439)
- webpack.js (@hiwelo in chore(gatsby): migrate webpack reducer to TS #23566)
- index.js (@blainekasten in chore(gatsby): Begin typing the redux code #20457)
- nodes.js (@blainekasten in chore(gatsby): Translate redux/nodes to TypeScript #21010)
- persist.js (@blainekasten in chore(gatsby): Begin typing the redux code #20457)
- plugin-runner.js (@kawamataryo in chore(gatsby): Migrate src/redux/plugin-runner to TypeScript #22476)
- run-fast-filters.js (@pvdz in chore(gatsby): migrate run-sift to TS #25055)
- /actions
- src/schema
- extensions/index.js
- infer/
- add-inferred-fields.js
- build-example-data.js (@chooban in chore(gatsby): Migrate build-example-data to TS #23389)
- index.js
- inference-metadata.js (@chooban in refactor(gatsby): Convert inference metadata to TypeScript #23264)
- is-32-bit-integer.js (@Pittan in chore(gatsby): Convert is-32-bit-integer to TypeScript #22138)
- is-file.js (@chooban in refactor(is-file): Convert to TypeScript #23093)
- type-conflict-reporter.js (@chooban in refactor(gatsby): Convert inference metadata to TypeScript #23264)
- types/
- built-in-types.js (@mottox2 in chore(gatsby): Convert built-in-types to typescript #22391)
- date.js (@sasurau4 in chore(gatsby): migrate date to TypeScript #22430)
- derived-types.js (@sasurau4 in chore(gatsby): migrate derived-types to TypeScript #22442)
- filter.js (@sasurau4 in chore(gatsby): migrate type of filter to TypeScript #22493)
- node-interface.js (@alisson-suzigan in chore(gatsby): Migrate types/node-interface.js to TypeScript #26733)
- pagination.js (@alisson-suzigan in chore(gatsby): Convert pagination to TypeScript #23717)
- sort.js
- type-builders.js (@PerfectPan in chore(gatsby): Migrate type-builders to TypeScript #23892)
- type-defs.js
- context.js
- index.js
- node-model.js
- print.js (@LinnJS)
- resolvers.js
- schema-composer.js
- schema.js (@alisson-suzigan in chore(gatsby): Convert pagination to TypeScript #23717)
- src/utils
- tracer/
- index.js (@kawamataryo chore(gatsby): Convert utils/tracer/index to typescript #22296 )
- jaeger-local.js (@chooban in chore(gatsby): jaeger-local to TypeScript #23656)
- zipkin-local.js (@kawamataryo)
- worker/
- child.js ( @kawamataryo chore(gatsby): Migrate utils/worker/child to TypeScript #22583 )
- page-data.js (@kawamataryo chore(gatsby): Convert utils/worker/page-data to typescript #22155)
- pool.js (@kawamataryo chore(gatsby): Convert utils/worker/pool to typescript #22150)
- render-html.js( @kawamataryo chore(gatsby): Convert util/worker/render-html to typescript #22263 )
- /api-browser-docs.js (@gabrieluizramos in Convert api-browser and api-node docs to TS #23688)
- /api-node-docs.js (@gabrieluizramos in Convert api-browser and api-node docs to TS #23688)
- /api-runner-error-parser.js (@LekoArts in Port parts of Structured Errors to TS + Add two more errors #20597)
- /api-runner-node.js
- /app-data.js (@kawamataryo in chore(gatsby): Convert src/utils/utils/app-data.js to typescript #22076 )
- /babel-loader-helpers.js (#kornil in chore(gatsby): convert babel-loader-helpers to typescript #25100)
- /babel-loader.js
- /babel-parse-to-ast.js (@john015 in chore(gatsby): Convert babel-parse-to-ast to TypeScript #22480)
- /browserlist.js (@kawamataryo in chore(gatsby): Convert utils/browserslist to typescript #22089 )
- /cache.ts (@MattKane in chore(gatsby): Convert cache.js to TypeScript #20626)
- /create-node-id.js (@Pittan in chore(gatsby): Convert utils/create-node-id to TypeScript #22096)
- /create-schema-customization.js (@mottox2 in chore(gatsby): Convert create-schema-customization to typescript #22392)
- /detect-port-in-use-and-prompt.js (@mottox2 in chore(gatsby): Convert detect-port-in-use-and-prompt to typescript #22061)
- /eslint-config.js (@dvrylc in chore(gatsby): Migrate eslint-config to TypeScript #22294)
- /gatsby-dependents.js (@dvrylc in chore(gatsby): Migrate gatsby-dependents to TypeScript #22422)
- /gatsby-webpack-eslint-graphql-schema-reload-plugin.js (@sasurau4 chore(gatsby): migrate gatsby-webpack-eslint-graphql-schema-reload-plugin to TS #22408)
- /gatsby-webpack-stats-extractor.js (@sasurau4 chore(gatsby): migrate gatsby-webpack-stats-extractor to TypeScript #22404)
- /get-cache.js (@cola119 in chore(gatsby): Migrate utils/get-cache.js to ts #22094)
- /get-latest-apis.js (@cola119 in chore(gatsby): Migrate utils/get-latest-apis.js to ts #22097)
- /get-public-path.js (@cola119 in chore(gatsby): Migrate utils/get-public-path.js to ts #22093)
- /get-ssl-cert.js (@mottox2 in chore(gatsby): Convert get-ssl-cert to typescript #22447)
- /get-static-dir.js (@mottox2 in chore(gatsby): Convert get-static-dir to typescript #22083)
- /get-value-at.js (@martijnjanssen in chore(gatsby) Convert get-value-at to typescript #22182)
- /is-32-bit-integer.js (@Pittan in chore(gatsby): Convert is-32-bit-integer to TypeScript #22138)
- /jobs-manager.js (@martijnjanssen in chore(gatsby): Convert jobs-manager to typescript #22189)
- /js-chunk-names.js (@mottox2 in chore(gatsby): Convert js-chunk-names to typescript #22289)
- /local-eslint-config-finder.js (@mottox2 in chore(gatsby): Convert local-eslint-config-finder to typescript #22403)
- /merge-gatsby-config.js(@taejs in chore(gatsby): migrate merge-gatsby-config to TypeScript #23789)
- /normalize-page-path.js (@martijnjanssen in chore(gatsby): Convert normalize-page-path to typescript #22188)
- /page-data.js (@hiwelo in
chore(gatsby): Migrate utils/page-data to TypeScript #23436chore(gatsby): Migrate utils/page-data to TypeScript #23991) - /page-html.js (@kawamataryo in chore(gatsby): Convert utils/page-html to typescript #22118)
- /path.js (@kawamataryo in chore(gatsby): Convert utils/path to typescript #22130)
- /prepare-regex.js (@mottox2 in chore(gatsby): Convert utils/prepare-regex to typescript #22133)
- /profile.js
- /reach-router-add-basecontext-export-loader.js
- /source-nodes.js
- /stack-trace-utils.js (@sasurau4 in chore(gatsby): Convert stack-trace-utils to TypeScript #22251)
- /test-require-error.js (@sasurau4 in chore(gatsby): migrate test-require-error to typescript #22265)
- /webpack-error-utils.js (@sasurau4 in chore(gatsby): migrate webpack-error-utils to TypeScript #22278)
- /webpack-helpers.js (@sasurau4 in chore(gatsby): delete webpack-helpers #22279)
- /webpack-hmr-hooks-patch.js (@sasurau4 in chore(gatsby): migrate webpack-hmr-hooks-patch to TypeScript #22280)
- /webpack-plugins.js (@sasurau4 in chore(gatsby): migrate webpack-plugins to TypeScript #22378)
- /webpack-utils.js (@sasurau4 in [WIP]: chore(gatsby): migrate webpack utils to TypeScript #22381)
- /webpack.config.js
- /websocket-manager.js (@Eyas in chore(gatsby): Update websocket-manager to TS #22510)
- tracer/
- packages/gatsby-cli
- src/reporter
- loggers
- ink (@arthurjdam in chore(gatsby-cli) Migrate remaining files in reporters/logger/ink to Typscript #22782)
- components (@arthurjdam in chore(gatsby-cli) Migrate remaining files in reporters/logger/ink to Typscript #22782)
- develop.js (@arthurjdam in chore(gatsby-cli) Migrate remaining files in reporters/logger/ink to Typscript #22782)
- error.js (@Naturalclar in chore(cli): migrate error component to typescript #22098)
- messages.js (@cola119 in chore(cli): migrate messages to typescript #22084)
- progress-bar.js (@Naturalclar in chore(cli): migrate progress-bar to typescript #22081)
- spinner.js (@Naturalclar in chore(cli): migrate spinner to typescript #22080)
- cli.js (@arthurjdam in chore(gatsby-cli) Migrate remaining files in reporters/logger/ink to Typscript #22782)
- context.js (@arthurjdam in chore(gatsby-cli) Migrate remaining files in reporters/logger/ink to Typscript #22782)
- index.js (@arthurjdam in chore(gatsby-cli) Migrate remaining files in reporters/logger/ink to Typscript #22782)
- components (@arthurjdam in chore(gatsby-cli) Migrate remaining files in reporters/logger/ink to Typscript #22782)
- ipc/index.js (@anoriqq in chore(gatsby-cli): migrate loggers/ipc to typescript #23960)
- json/index.js (@wiput1999 in Update json logger in gatsby-cli to TS #24140)
- yurnalist/index.js (@blainekasten in Ts migration/convert yurnalist logger #24224)
- ink (@arthurjdam in chore(gatsby-cli) Migrate remaining files in reporters/logger/ink to Typscript #22782)
- redux (@Kornil in chore(gatsby-cli): migrate redux folder to typescript #22292)
- actions.js
- index.js
- reducer.js
- constants.js (@cola119 in chore(cli): migrate messages to typescript #22084)
- errors.js (@blainekasten in chore(gatsby-cli): Convert errors and prepare-stack-trace to TypeScript #24226)
- index.js (@blainekasten in chore(gatsby-cli): Migrate reporter to TypeScript #22869)
- prepare-stack-trace.js (@blainekasten in chore(gatsby-cli): Convert errors and prepare-stack-trace to TypeScript #24226)
- types.js (@blainekasten in chore(gatsby-cli): Migrate reporter to TypeScript #22869)
- loggers
- src/structured-errors (@LekoArts in Port parts of Structured Errors to TS + Add two more errors #20597)
- construct-error.js
- error-map.js
- error-schema.js
- src/util
- calc-elapsed-time.js (@Naturalclar in chore(cli): migrate progress-bar to typescript #22081)
- configstore.js (@mottox2 in chore(gatsby-cli): Convert util/configstore to typescript #22180 renamed to package-manager)
- ensure-windows-drive-letter-is-uppercase.js (@mottox2 in chore(gatsby-cli): Convert ensure-windows-drive-letter-is-uppercase to typescript #22140)
- is-tty.js (@mottox2 in chore(gatsby-cli): Convert is-tty to typescript #22129)
- version.js (@mottox2 in chore(gatsby-cli): Convert util/version to typescript #22176)
- src/create-cli.js (@alexpyzhianov in Convert create-cli.js (gatsby-cli) to TypeScript #23650)
- src/did-you-mean.js (@mottox2 in chore(gatsby-cli): Convert did-you-mean to typescript #22068)
- src/index.js (@blainekasten in chore(gatsby): Use Typescript internally! #19923)
- src/init-starter.js (@mottox2 in chore(gatsby-cli): Convert init-starter to typescript #22086)
- src/reporter
- packages/gatsby-core-utils
- src/
- /ci.js (@danielkov in chore(gatsby-core-utils): ci to TS #22047)
- /cpu-core-count.js (@danielkov in chore(gatsby-core-utils): cpu-core-count to TS #22048)
- /create-content-digest.js (@danielkov in chore(gatsby-core-utils): create-content-digest to TS #22049)
- /create-require-from-path.js (@danielkov in chore(gatsby-core-utils): create-require-from-path to TS #22050)
- /get-config-file.js (@danielkov in chore(gatsby-core-utils): get-config-store to TS #22051)
- /get-gatsby-version.js (@danielkov in chore(gatsby-core-utils): get-gatsby-version to TS #22052)
- /index.js (@danielkov in chore(gatsby-core-utils): index to TS #22053)
- /path.js (@danielkov in chore(gatsby-core-utils): path to ts #22054)
- /physical-cpu-count.js (@blainekasten in Ts/gatsby core utils #22122)
- /url.js (@danielkov in chore(gatsby-core-utils): url to TS #22056)
- src/
- packages/gatsby-link (@herecydev in Rewrite gatsby-link in typescript #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 chore(gatsby-telemetry): Migrate package to TS #22532)
- src/
- error-helpers.js + test
- /event-storage.js
- /flush.js (@blainekasten in chore(gatsby-telemetry): Migrate flush to TypeScript #25886)
- /index.js
- /is-truthy.js + test (@blainekasten in chore(gatsby-telemetry): Migrate is-truthy to TypeScript #25884)
- /postinstall.js
- /repository-id.js + test (@mottox2 in chore(gatsby-telemetry): Convert repository-id to typescript #22474)
- /send.js
- /showAnalyticsNotification.js
- /store.js
- /telemetry.js + test
- src/
- packages/gatsby-react-router-scroll (@blainekasten in fix: Several Fixes for Scroll Handling and Restoration #24306)
- src/
- /index.js
- /ScrollBehaviorContext.js
- /ScrollContainer.js
- /StateStorage.js
- src/