Road to Typescript
See original GitHub issueThis is an issue is to discuss our plan to convert this library to TypeScript. Note: We will still continue to provide full Flow typings in the same package.
This effort is in line with the ongoing conversion of GraphQL IDE packages (GraphiQL, GraphQL LSP, etc.): https://github.com/graphql/graphiql/tree/convert-to-ts
Note this decision is not related to the technical aspect of Flow vs TS. GraphQL.js has complete Flow coverage and it is excellent for ongoing maintenance. But our goal is to increase the number of active contributors and by switching codebase to TypeScript we hope to make the codebase feel more familiar and easy to contribute to.
Big thanks to @JacksonKearl from Apollo team for making PoC for such conversion and exploring different conversion strategies.
Before we start discussing the action plan here is a few important points:
14.x.xis stable release so we shouldn’t do any potentially breaking things in this release.- We need to do
15.0.0anyway since it becomes hard to maintain support for Node6 since ESLint and other projects stop supporting it. Plus it allows us simply remove all deprecated stuff that was scheduled for removal in this release. - Even after we release
15.0.0we will still need to support14.x.xas a branch and backport all critical or security-related bugfixes until16.0.0.
Giving these constraints here is a plan I want to propose:
- 1. Freeze all non-critical merges for the duration of this conversion
- 2. I copied all
*.d.tsfrom@types/graphqlinto tstypes folder and working on removing it from DefinetlyTyped. I included this typings in14.5.0release as the baseline for our future work. - 3. Synchronize
*.d.tsfiles with Flow types (some stuff is missing and a lot of types are based on14.0.0release) and identify all changes that were done in@types/graphqlbut weren’t reflected in Flow. We will release these changes as14.5.1release. - 4. After we are sure that
*.d.tsfiles are complete and don’t break existing TS libraries we can branch of14.x.xand switch master to15.0.0-alpha.1. Remove all stuff marked as deprecated and was scheduled for removal in v15. - 5. We will start manually converting files one by one to TS and extract Flow typings into separate files. I propose first to convert all test files (should be pretty fast since they don’t use a lot of typings) and latter switch to converting the rest of the project. We can schedule frequent
15.0.0-alpha.xreleases just to get the early feedback. - 6. After we converted all files we can switch to
15.0.0-beta.xand ask the different project to test both our TS and Flow typings. After we fix all the issues we would release15.0.0and finish this conversion effort.
Also, I think it makes sense use this opportunity and fully convert our codebase to ES6 and idiomatic TypeScript. It means we can finally get rid of pre-ES6 classes constructs and also some weird constructs caused by Flow technical limitations and other similar artifacts.
CC: @kassens @Neitsch @jbaxleyiii @JacksonKearl @martijnwalraven @mjmahone @acao @19majkel94 @tgriesser @nodkz @benjie
Issue Analytics
- State:
- Created 4 years ago
- Reactions:96
- Comments:40 (21 by maintainers)

Top Related StackOverflow Question
Closing since we successfully migrated
mainto TS. Big thanks to everyone who helped in that 🙌@mike-marcacci I have been working on this the last week and have a shim over the plain
graphqlthat strongly types pretty much everything I can think of. It’s about 150 lines of (almost exclusively TypeScript) code + comments .Ideally I would like to get this functionality into the plain graphql repo too, so I am happy to share thoughts and techniques on this if anyone finds it useful.