{"id":13494707,"url":"https://github.com/green-labs/ppx_ts","last_synced_at":"2025-09-15T03:07:11.538Z","repository":{"id":43320466,"uuid":"459234581","full_name":"green-labs/ppx_ts","owner":"green-labs","description":"ReScript PPX helps the binding to typescript modules","archived":false,"fork":false,"pushed_at":"2024-06-18T09:22:01.000Z","size":214,"stargazers_count":35,"open_issues_count":5,"forks_count":2,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-04-06T08:03:47.333Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"OCaml","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/green-labs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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":"2022-02-14T16:19:26.000Z","updated_at":"2024-11-04T23:39:02.000Z","dependencies_parsed_at":"2024-10-31T09:41:33.262Z","dependency_job_id":null,"html_url":"https://github.com/green-labs/ppx_ts","commit_stats":{"total_commits":50,"total_committers":3,"mean_commits":"16.666666666666668","dds":0.06000000000000005,"last_synced_commit":"78fa3b42188d399bebed76aa5ac3203e983fe00d"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-labs%2Fppx_ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-labs%2Fppx_ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-labs%2Fppx_ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-labs%2Fppx_ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/green-labs","download_url":"https://codeload.github.com/green-labs/ppx_ts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251812313,"owners_count":21647885,"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":[],"created_at":"2024-07-31T19:01:27.416Z","updated_at":"2025-05-01T02:31:00.742Z","avatar_url":"https://github.com/green-labs.png","language":"OCaml","funding_links":[],"categories":["OCaml"],"sub_categories":[],"readme":"# PPX_ts\n\n`ppx_ts` is a ReScript preprocessor, which helps generating helper types to bind to typescript modules.\n\n## Install\n\n```rescript\nyarn add -D @greenlabs/ppx-ts\n```\n\n```rescript\n// bsconfig.json\n\"ppx-flags\": [\n  ...,\n  \"@greenlabs/ppx-ts/ppx\"\n],\n```\n\n## Features\n\n### Attributes `@`\n\n#### `keyOf`\n\n```rescript\n@ppx_ts.keyOf\ntype t = {\n  name: string,\n  age: int\n}\n\n// automatically generated\ntype t_keyOf = Name | Age\n\n// automatically generated\nlet t_keyToString = key =\u003e\n  switch key {\n  | Name =\u003e \"name\"\n  | Age =\u003e \"age\"\n  }\n```\n\n#### `setType(t)`\n\n```rescript\nmodule Error = {\n  type t\n}\n@ppx_ts.setType(Error.t)\ntype t = {\n  name: string,\n  age: int\n}\n\n// automatically generated\ntype t_setType = {\n  name: Error.t\n  age: Error.t\n}\n```\n\n#### `toGeneric`\n\n```rescript\n@ppx_ts.toGeneric\ntype t = {\n  name: string,\n  age: int\n}\n\n// automatically generated\ntype t_toGeneric\u003c'a\u003e = {\n  name: 'a\n  age: 'a\n}\n```\n\n#### `partial`\n\n```rescript\n@ppx_ts.partial\ntype t = {\n  name: string,\n  age: int\n}\n\n// automatically generated\ntype t_partial = {\n  name: option\u003cstring\u003e,\n  age: option\u003cint\u003e\n}\n```\n\n#### `pick`\n\n```rescript\n@ppx_ts.pick([\"name\"])\ntype t = {\n  name: string,\n  age: int\n}\n\n// automatically generated\ntype t_pick_name = {\n  name: string,\n}\n```\n\n#### `omit`\n\n```rescript\n@ppx_ts.omit([\"name\"])\ntype t = {\n  name: string,\n  age: int\n}\n\n// automatically generated\ntype t_omit_name = {\n  age: int,\n}\n```\n\n#### `toArray`\n\n```rescript\n@ppx_ts.toArray\ntype t = Name | Age\n\n// automatically generated\nlet t_toArray = [\"Name\", \"Age\"]\n```\n\n### Extension `%`\n\n#### `keyOf`\n\n```rescript\nmodule Error = {\n  type t = {\n    name: string,\n    age: int\n  }\n}\n\n@spice // attributes are available\ntype t1 = %ppx_ts.keyOf(Error.t) // type t1 = Name | Age\n\n// automatically generated\nlet t1_keyToString = key =\u003e\n  switch key {\n  | Name =\u003e \"name\"\n  | Age =\u003e \"age\"\n  }\n```\n\n#### `setType`\n\n```rescript\ntype t = {\n  name: string,\n  age: int\n}\n\n@spice // attributes are available\ntype t1 = %ppx_ts.setType((t, string))\n// changed\ntype t1 = {\n  name: string\n  age: string\n}\n```\n\n#### `setTypeExceptBool`\n\n```rescript\ntype t = {\n  name: string,\n  age: int,\n  isKorean: bool\n}\n\n@spice // attributes are available\ntype t1 = %ppx_ts.setTypeExceptBool((t, string))\n// changed\ntype t1 = {\n  name: string,\n  age: string,\n  isKorean: bool\n}\n```\n\n#### `toGeneric`\n\n```rescript\ntype t = {\n  name: string,\n  age: int\n}\n\n@spice // attributes are available\ntype t1 = %ppx_ts.toGeneric(t)\n// generated\ntype t1\u003c'a\u003e = {\n  name: 'a\n  age: 'a\n}\n```\n\n#### `partial`\n\n```rescript\ntype t = {\n  name: string,\n  age: int,\n  isKorean: bool\n}\n\n@spice // attributes are available\ntype t1 = %ppx_ts.partial(t)\n// generated\ntype t1 = {\n  name: option\u003cstring\u003e,\n  age: option\u003cint\u003e,\n  isKorean: option\u003cbool\u003e\n}\n```\n\n## Contribution\n\n1. Create a sandbox with opam\n\n```\nopam switch create ppx_ts 4.12.1\n```\n\n2. Install dependencies\n\n```\nopam install . --deps-only --with-test\n```\n\n3. Build\n\n```\nopam exec -- dune build\n```\n\n4. Test\n\n```\ncd rescript\n\n(install dependencies)\nyarn\n\n(build --watch)\nyarn res:clean \u0026\u0026 yarn res:watch\n\n(run test --watch)\nyarn test:watch\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreen-labs%2Fppx_ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgreen-labs%2Fppx_ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreen-labs%2Fppx_ts/lists"}