{"id":14981892,"url":"https://github.com/andywer/gear","last_synced_at":"2025-10-24T03:28:12.822Z","repository":{"id":57097629,"uuid":"85236895","full_name":"andywer/gear","owner":"andywer","description":"🛠 Experimental tool to bootstrap typed JavaScript code.","archived":false,"fork":false,"pushed_at":"2017-11-22T16:13:54.000Z","size":40,"stargazers_count":33,"open_issues_count":2,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-09-29T06:22:07.009Z","etag":null,"topics":["babeljs","flowtype","javascript","static-typing","types"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andywer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-16T20:04:16.000Z","updated_at":"2022-09-29T13:55:38.000Z","dependencies_parsed_at":"2022-08-20T16:50:29.076Z","dependency_job_id":null,"html_url":"https://github.com/andywer/gear","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andywer%2Fgear","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andywer%2Fgear/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andywer%2Fgear/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andywer%2Fgear/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andywer","download_url":"https://codeload.github.com/andywer/gear/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219857951,"owners_count":16556049,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["babeljs","flowtype","javascript","static-typing","types"],"created_at":"2024-09-24T14:04:26.937Z","updated_at":"2025-10-24T03:28:07.804Z","avatar_url":"https://github.com/andywer.png","language":"JavaScript","readme":"# Gear\n\nBootstrap typed JavaScript projects in less than a minute or easily add types to untyped code. Built around [Babel 7](https://babeljs.io/), [Flow](https://flowtype.org/), [babel-preset-env](https://babeljs.io/) and [functional type syntax](https://github.com/andywer/proposal-double-colon-types).\n\nThe tool is written using itself, so have a look at its own code if you are interested. [type-check.js](./src/commands/type-check.js) is quite a good example, for instance.\n\nI wanted to play a little with Hindley-Milner types in JavaScript, see how it feels and by the way reduce the boilerplate necessary to get starting with typed JavaScript.\n\n⚠️ *Caution: This is highly experimental.*\n\n\n## Installation\n\n```sh\nyarn add --dev @andywer/gear\n```\n\nor using npm\n\n```sh\nnpm install --save-dev @andywer/gear\n```\n\n\n## Usage\n\n```json\n{\n  \"scripts\": {\n    \"build\": \"gear compile src/ -d lib/\",\n    \"test\": \"gear type-check src/\"\n  }\n}\n```\n\n### Compile sources\n\n```sh\n# Run Babel\ngear compile src/ -d lib/\n```\n\n### Type checking\n\n```sh\n# Run Babel \u0026 Flow\ngear type-check src/\n```\n\nWill create a `.flowcheck` directory, babel the sources, but not completely, just translating the custom type syntax Flow does not understand. Creates a `.flowconfig` and runs Flow.\n\n\n## Write some code\n\nYou can write JS code with Flow's regular type syntax, with Hindley-Milner types or without types (Flow will infer types as good as possible).\n\nGimmick: When writing Hindley-Milner types (functional style) you don't need to add `// @flow` to the file. It will automatically be added on first encounter of a type.\n\n```js\nexists :: string =\u003e Promise\u003cbool\u003e\n\n/** Checks if a file or directory exists */\nasync function exists (path) {\n  try {\n    await fs.access(path)\n    return true\n  } catch (error) {\n    return false\n  }\n}\n```\n\n\n## Why not just use TypeScript or Flow as it is?\n\nBecause TypeScript is kind of a closed ecosystem on its own and Flow is written in OCAML. Gear tries to stick to the tech stack you already have as much as possible.\n\n*And thus the stack becomes easily hackable.*\n\nWrite a Babel plugin, even change the type syntax and it will work. And it even requires little effort to use it with real-world code since it is built around the tools you use anyway.\n\n\n## License\n\nReleased under the terms of the MIT license.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandywer%2Fgear","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandywer%2Fgear","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandywer%2Fgear/lists"}