We're moving to TypeScript! 🎉 #3654
Closed
dimitropoulos
announced in
Announcement
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This umbrella issue will outline the transition of the entire insomnia codebase from Flow (or plain JS) to 1st-class idiomatic TypeScript.
Phases
This work will be conducted in a few phases.
🎣 Phase 0: reconnaissance and spike
Reconnaissance
Many projects before us have undergone this same transition. Here are some examples:
Spike
@develohpanda conducted the initial spike using 22935ec...122785f
🔰 Phase 1 - initial packages
Similar to almost all of the conversions listed above, we will be taking this conversion in a "bottom up" approach where we will be converting many of the things without dependencies first. This conversion will aim to be fairly final in nature. Some ambient declarations will be necessary here and there for packages we can't upgrade (which, is a common thing to happen in a conversion like this so that we can have access to types), but in general the hope is do a fairly thorough job such that we won't have a step later to come back and fix a lot of things up.
Phase 1 Checklist
insomnia-xpathinsomnia-urlinsomnia-prettifyinsomnia-importersinsomnia-cookiesinsomina-testinginsomnia-inso🦺 Phase 2 -
app's rough conversionWe will then be converting the bulk of the codebase (
insomnia-app) to TypeScript using a script that uses https://github.com/Khan/flow-to-ts. The goal of this phase is to do the conversion with as much automation as physically possible, taking every opportunity to use@ts-expect-errorand other workarounds.The bulk of the manual work for this phase will come in the form of updates to the build pipeline (e.g. webpack).
We know that this is going to be a noisy time for all open/existing PRs, so we have planned it in this way to lessen the burden. We know from the spike of this phase that we may need to first submit a PR that simply upgrades the codebase to prettier v2 (which is required by flow-to-ts, but is also required by us anyway if we're going to be using prettier because prettier v1 doesn't support the version of TypeScript that we're on).
One benefit of doing things this way is that we'll be able to go and update most PRs (as part of this phase) by simply running the script mentioned above. We will temporarily check the script into the source code while phase 2 is ongoing.
That said, things will probably feel fairly shaky at this step because the codebase will have lots of
@ts-expect-errors and other opting-out of the type system.Phase 2 Checklist
insomnia-appinsomnia-componentsinsomnia-smoke-testopenapi-2-kong🥅 Phase 3 - Moar and better TypeScript
Since by this phase Flow will be completely gone, we'll be able to scavenge the codebase for any of the
@ts-expect-errors and other opting-out of the typesystems that we did and fix them all. By the completion of this phase we will have quite a large portion of the codebase into idiomatic TypeScript.Another component of this is to enable type-checking (such that a typescript error alone will fail a test suite) in tests by setting
isolatedModules: falsein our jest configs.Phase 3 Checklist
insomnia-appinsomnia-componentsinsomnia-smoke-testopenapi-2-kongisolatedModules: false🧹 Phase 4 - plugins and cleanup
That leaves the plugins. Many of the plugins are quite small and from our current estimates it should be quite reasonable to do them all in one step (or, PR).
Once that's complete, the entire codebase with almost no single exception should be in TypeScript. There are a few cleanup tasks I've assembled from the spike work an Phase 1 (this list will be updated as we go along):
flow-typeddirectories were removed// @flowflowe.g.// make flow happytypecheckstep from the CItypecheckscripts are gone from all package.jsonsutility-types/** @type { import('webpack').Configuration } */before webpack configs and/** @type {import('@jest/types').Config.InitialOptions} */before jest configspackage.jsons for"jest": {to make sure all jest configs are separate (TypeScript checked).jsfiles and not package.json addonsmodule.exportsand make sure they only exist in config files that (due to their place in the build chain) cannot be transpiledcleanandpostcleannpm script that removes the typescript built filesbuildandlintlerna bootstrapbut now will. make sure they all have it. (perhaps a test for this is a clean clone followed byyarnandyarn bootstrap)npx typesyncin every packageindex.tsfiles are simple exporters without other source codetsconfig.build.jsonfiles exclude tests (including mocks and fixtures)tsconfig.build.jsonfiles extend the base and that thetsconfig.jsonfiles extend the build (and not the other way around).TODO(TSCONVERSION)temp-disabledfrom package.jsons (used during testing to individually disable errant scripts).Phase 4 checklist
insomnia-plugin-base64insomnia-plugin-cookie-jarinsomnia-plugin-core-themesinsomnia-plugin-default-headersinsomnia-plugin-fileinsomnia-plugin-hashinsomnia-plugin-jsonpathinsomnia-plugin-kong-bundleinsomnia-plugin-kong-declarative-configinsomnia-plugin-kong-kubernetes-configinsomnia-plugin-kong-portalinsomnia-plugin-nowinsomnia-plugin-osinsomnia-plugin-promptinsomnia-plugin-requestinsomnia-plugin-responseinsomnia-plugin-uuidBeta Was this translation helpful? Give feedback.
All reactions