{"id":18488354,"url":"https://github.com/KnisterPeter/react-to-typescript-definitions","last_synced_at":"2025-04-08T20:33:04.665Z","repository":{"id":2706425,"uuid":"47227074","full_name":"KnisterPeter/react-to-typescript-definitions","owner":"KnisterPeter","description":"Create typescript definitions files (d.ts) from react components","archived":true,"fork":false,"pushed_at":"2023-11-27T13:00:45.000Z","size":3048,"stargazers_count":238,"open_issues_count":0,"forks_count":15,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-08T13:05:16.655Z","etag":null,"topics":["parser","proptypes","react","typescript","typescript-definitions"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/KnisterPeter.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-12-02T00:53:38.000Z","updated_at":"2023-11-27T13:05:22.000Z","dependencies_parsed_at":"2023-09-24T03:12:34.837Z","dependency_job_id":"dd6d36e0-93c2-4ad7-9ede-a176e32092b7","html_url":"https://github.com/KnisterPeter/react-to-typescript-definitions","commit_stats":{"total_commits":1578,"total_committers":20,"mean_commits":78.9,"dds":0.5196451204055768,"last_synced_commit":"f07dc0dc6e459bd2eff186c53e775694cc5b579f"},"previous_names":[],"tags_count":51,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KnisterPeter%2Freact-to-typescript-definitions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KnisterPeter%2Freact-to-typescript-definitions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KnisterPeter%2Freact-to-typescript-definitions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KnisterPeter%2Freact-to-typescript-definitions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KnisterPeter","download_url":"https://codeload.github.com/KnisterPeter/react-to-typescript-definitions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247923681,"owners_count":21019048,"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":["parser","proptypes","react","typescript","typescript-definitions"],"created_at":"2024-11-06T12:51:36.611Z","updated_at":"2025-04-08T20:33:04.656Z","avatar_url":"https://github.com/KnisterPeter.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# react-to-typescript-definitions\n\n[![GitHub license][license-image]][license-link]\n[![npm][npm-image]][npm-link]\n[![Travis][ci-image]][ci-link]\n[![codecov](https://codecov.io/gh/KnisterPeter/react-to-typescript-definitions/branch/master/graph/badge.svg)](https://codecov.io/gh/KnisterPeter/react-to-typescript-definitions)[![Commitizen friendly][commitizen-image]][commitizen-link]\n[![Standard Version][standard-version-image]][standard-version-link]\n[![renovate badge](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovateapp.com/)\n\nCreate typescript definitions files (d.ts) from react components.\n\n## Features\n\n- ES6 and ES7 class syntax\n- Most PropTypes\n  - any, array, bool, func, number, object, string, node, element, oneOfType, arrayOf, symbol, shape\n- Partial support for oneOf PropType\n- required PropTypes\n- instanceOf PropTypes (when using API and giving a resolve function)\n- jsdoc\n\n## Usage\n\n### Installation\n\nInstall as npm package:\n\n```sh\nnpm install react-to-typescript-definitions --save-dev\n```\n\nor\n\n```sh\nnpm install -g react-to-typescript-definitions\n```\n\n### CLI\n\n```sh\nUsage\n  $ react2dts [--module-name \u003cname\u003e | --top-level-module]\n\nreact2dts reads from stdin to process a file.\n\nOptions\n  --module-name, --name  name of the module to create\n  --top-level-module     if the created module should live in top-level\n\nExamples\n  $ cat \u003csome/react/component.jsx\u003e |react2dts --module-name module-name\n\n  $ cat \u003csome/react/component.jsx\u003e |react2dts --top-level-module\n```\n\n### API\n\nFunctions:\n\n```js\n/**\n * Returns the typescript definition for the given file.\n *\n * @param name The name of the generated module\n * @param path The path to the file to parse\n * @param options The options to use\n * @return The type definition as string\n */\nfunction generateFromFile(name, path, options)\n```\n\n```js\n/**\n * Returns the typescript definition for the given source.\n *\n * @param name The name of the generated module\n * @param code The code to parse\n * @param options The options to use\n * @return The type definition as string\n */\nfunction generateFromSource(name, code, options)\n```\n\n```js\n/**\n * Returns the typescript definition for the given babylon AST object.\n *\n * @param name The name of the generated module\n * @param ast The babylon ASt to parse\n * @param options The options to use\n * @return The type definition as string\n */\nfunction generateFromAst(name, ast, options)\n```\n\nOptions:\n\n- instanceOfResolver  \n  A function which gets a type name (as string) and should return the path\n  to the file defining the type or undefined if the type is not resolvable.\n  This function is required to generate instanceOf PropTypes.\n\n[license-image]: https://img.shields.io/github/license/KnisterPeter/react-to-typescript-definitions.svg\n[license-link]: https://github.com/KnisterPeter/react-to-typescript-definitions\n[npm-image]: https://img.shields.io/npm/v/react-to-typescript-definitions.svg\n[npm-link]: https://www.npmjs.com/package/react-to-typescript-definitions\n[ci-image]: https://img.shields.io/travis/KnisterPeter/react-to-typescript-definitions.svg\n[ci-link]: https://travis-ci.org/KnisterPeter/react-to-typescript-definitions\n[commitizen-image]: https://img.shields.io/badge/commitizen-friendly-brightgreen.svg\n[commitizen-link]: http://commitizen.github.io/cz-cli/\n[standard-version-image]: https://img.shields.io/badge/release-standard%20version-brightgreen.svg\n[standard-version-link]: https://github.com/conventional-changelog/standard-version\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKnisterPeter%2Freact-to-typescript-definitions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FKnisterPeter%2Freact-to-typescript-definitions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKnisterPeter%2Freact-to-typescript-definitions/lists"}