{"id":13494733,"url":"https://github.com/rescript-association/genType","last_synced_at":"2025-03-28T14:31:50.197Z","repository":{"id":39565090,"uuid":"141404208","full_name":"rescript-association/genType","owner":"rescript-association","description":"Auto generation of idiomatic bindings between Reason and JavaScript: either vanilla or typed with TypeScript/FlowType.","archived":true,"fork":false,"pushed_at":"2023-11-13T11:53:17.000Z","size":44693,"stargazers_count":760,"open_issues_count":0,"forks_count":44,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-04-13T17:13:21.008Z","etag":null,"topics":["bucklescript","flowtype","javascript","reasonml","type-safety","types","typescript"],"latest_commit_sha":null,"homepage":"https://rescript-lang.org/docs/gentype/latest/introduction","language":"OCaml","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/rescript-association.png","metadata":{"files":{"readme":"README.md","changelog":"Changes.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-18T08:22:32.000Z","updated_at":"2024-05-10T22:44:33.021Z","dependencies_parsed_at":"2024-05-10T22:44:15.468Z","dependency_job_id":"a517b709-ce35-4764-84f7-1deb88d17709","html_url":"https://github.com/rescript-association/genType","commit_stats":null,"previous_names":["cristianoc/gentype"],"tags_count":169,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rescript-association%2FgenType","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rescript-association%2FgenType/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rescript-association%2FgenType/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rescript-association%2FgenType/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rescript-association","download_url":"https://codeload.github.com/rescript-association/genType/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246046075,"owners_count":20714899,"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":["bucklescript","flowtype","javascript","reasonml","type-safety","types","typescript"],"created_at":"2024-07-31T19:01:27.621Z","updated_at":"2025-03-28T14:31:46.352Z","avatar_url":"https://github.com/rescript-association.png","language":"OCaml","readme":"\u003e ⚠️ This project has moved into the [rescript-compiler](https://github.com/rescript-lang/rescript-compiler/tree/master/jscomp/gentype) and is part of `rescript@10.1` and above.\n\u003e\n\u003e Please report any issues regarding ReScript -\u003e TypeScript compilation in the [compiler issue tracker](https://github.com/rescript-lang/rescript-compiler/issues).\n\n# ReScript genType\n\n\u003e The latest genType docs have been migrated to the [ReScript website](https://rescript-lang.org/docs/gentype/latest/introduction).\n\n`genType` lets you export [ReScript](https://rescript-lang.org/) values and types to use in JavaScript, and import JavaScript values and types into ReScript, idiomatically. Converter functions between the two representations are generated based on the type of the value. The converters can be generated in vanilla JavaScript, or in [TypeScript](https://www.typescriptlang.org/) / [Flow](https://flow.org/en/) for a type-safe idiomatic interface.\nIn particular, conversion of [ReasonReact](https://reasonml.github.io/reason-react/) components both ways is supported, with automatic generation of the wrappers.\n\n# Project status.\n\nSee [Changes.md](Changes.md) for a complete list of features, fixes, and changes for each release.\n\n# Requirements\n\n`rescript` 9.1.0 or higher: use `genType` 3.45.0 or higher.\n\n`bs-platform` 9.0.1 or higher: use `genType` 3.44.0 or higher.\n\n`bs-platform` 9.0.0 or higher: use `genType` 3.43.0 or higher.\n\n`bs-platform` 8.3.0 or higher: use `genType` 3.36.0 or higher.\n\n`bs-platform` 8.2.0 or higher: use `genType` 3.31.0 or higher.\n\n`bs-platform` 8.1.1 or higher: use `genType` 3.27.0 or higher.\n\n`bs-platform` 8.0.0 or higher: use `genType` 3.26.0 or higher.\n\n`bs-platform` 7.3.0 or higher: use `genType` 3.18.0 or higher.\n\n`bs-platform` 7.2.0 or higher: use `genType` 3.13.0 or higher.\n\n`bs-platform` 7.0.2 or higher: use `genType` 3.8.0 or higher.\n\n`bs-platform` 7.0.0 or higher: use `genType` 3.2.0 or higher.\n\n`bs-platform` 6.2.0 or higher: use `genType` 3.0.0 or higher.\n\n`bs-platform` 5.2.0 or higher: use `genType` 2.40.0 or higher.\n\n`bs-platform` 5.0.x and 5.1.x: use `genType` 2.17.0 or higher.\n\nFor earlier versions, see the older [README](https://github.com/cristianoc/genType/blob/v2.16.0/README.md).\n\n# Installation\n\nInstall the binaries via `npm`:\n\n```\nnpm install --save-dev gentype\n\n# Test running gentype\nnpx gentype --help\n```\n\nAdd a `gentypeconfig` section to your `bsconfig.json` (See [Configuration](#configuration) for details):\n\n```\n\"gentypeconfig\": {\n    \"language\": \"untyped\",\n    \"shims\": {},\n    \"debug\": {\n      \"all\": false,\n      \"basic\": false\n    }\n}\n```\n\nFor running `gentype` with ReScript via `npm` workflow, add following script in your `package.json`:\n\n```\nscripts: {\n  \"build\": \"rescript\",\n  \"clean\": \"rescript clean\"\n}\n```\n\n\u003e **Note:** With genType \u003c 2.17.0 or ReScript \u003c 5.0.0, one has to set environment variable `BS_CMT_POST_PROCESS_CMD`. See the older [README](https://github.com/cristianoc/genType/blob/v2.16.0/README.md).\n\nWith this configuration, ReScript will call `gentype` for each newly built file. You might want to clean your build artifacts before usage: `npx bsb -clean-world` (otherwise there might be cached values and no `.gen.js` files are generated).\n\nCheck out the [Examples](#examples) for detailed setups (TypeScript, Flow and Plain JavaScript).\n\n## Adding shims (TypeScript \u0026 Flow)\n\nConfigure your shim files in your `\"gentypeconfig\"` in [`bsconfig.json`](examples/typescript-react-example/bsconfig.json), and add relevant `.shims.js` files in a directory which is visible by ReScript e.g. [`src/shims/`](examples/typescript-react-example/src/shims). An example shim to export ReactEvent can be found [here](examples/typescript-react-example/src/shims/ReactEvent.shim.ts).\n\n## Testing the whole setup\n\nOpen any relevant `*.res` file and add `@genType` annotations to any bindings / values / functions to be used from JavaScript. If an annotated value uses a type, the type must be annotated too. See e.g. [Hooks.res](examples/typescript-react-example/src/Hooks.res).\n\nSave the file and rebuild the project with ReScript. You should now see a `*.gen.tsx` (for TypeScript, or `*.gen.js` for Flow) file with the same name (e.g. `MyComponent.res` -\u003e `MyComponent.gen.tsx`).\n\nAny values exported from `MyComponent.res` can then be imported from JS. For example:\n\n```js\nimport MyComponent from \"./components/MyComponent.gen\";\n```\n\n# Examples\n\nWe prepared some examples to give you an idea on how to integrate `genType` in your own project. Check out the READMEs of the listed projects.\n\n**Please make sure to build genType before trying to build the examples.**\n\n- [flow-react-example](examples/flow-react-example/README.md)\n- [typescript-react-example](examples/typescript-react-example/README.md)\n- [untyped-react-example](examples/untyped-react-example/README.md)\n\n# Documentation\n\nFull documentation can be found [here](https://rescript-lang.org/docs/gentype/latest/introduction).\n\n(In case you are looking for the previous version of the docs, here is an [older version](https://github.com/rescript-association/genType/blob/be699a467800b84221a7cb448e140d8f232d7025/README.md) of this README)\n\n# Development/Contributing\n\nPlease check out our [development instructions](DEVELOPMENT.md).\n","funding_links":[],"categories":["OCaml","[🧑‍💻 dev](https://github.com/stars/ketsapiwiq/lists/dev)"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frescript-association%2FgenType","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frescript-association%2FgenType","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frescript-association%2FgenType/lists"}