{"id":13432887,"url":"https://github.com/markogresak/js-to-tsx","last_synced_at":"2025-07-10T09:34:27.258Z","repository":{"id":87212990,"uuid":"42077158","full_name":"markogresak/js-to-tsx","owner":"markogresak","description":null,"archived":false,"fork":false,"pushed_at":"2020-10-01T06:45:42.000Z","size":9,"stargazers_count":37,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-13T11:53:50.809Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","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/markogresak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-09-07T22:21:37.000Z","updated_at":"2024-06-15T09:13:52.000Z","dependencies_parsed_at":"2023-07-26T04:30:53.087Z","dependency_job_id":null,"html_url":"https://github.com/markogresak/js-to-tsx","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/markogresak/js-to-tsx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markogresak%2Fjs-to-tsx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markogresak%2Fjs-to-tsx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markogresak%2Fjs-to-tsx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markogresak%2Fjs-to-tsx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markogresak","download_url":"https://codeload.github.com/markogresak/js-to-tsx/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markogresak%2Fjs-to-tsx/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264559340,"owners_count":23628037,"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-31T02:01:18.076Z","updated_at":"2025-07-10T09:34:27.233Z","avatar_url":"https://github.com/markogresak.png","language":"Shell","funding_links":[],"categories":["Shell"],"sub_categories":[],"readme":"# Rename .js to .tsx\n\n**I suggest using [react-javascript-to-typescript-transform](https://github.com/lyft/react-javascript-to-typescript-transform). It's a smart tool for migrating from React with JavaScript to React with TypeScript which also maps `propTypes` to TypeScript `type`.**\n\n---\n\nThis is a short script, which will rename all `.js` files to `.tsx` (TypeScript with JSX support).\n\n```\nUsage: rename-to-tsx [option]\n -h (help): Print this help message.\n -a (all): Rename files ending in .js and .jsx to .tsx.\n -r (respectively): Rename files ending in .js to .ts and .jsx to .tsx.\n```\n\n\u003e  *Never execute scripts unless you know what will they do!*\n\nSince this code is changing your file names and might not work correctly, **make sure to use source control or back up your work before running the script**.\n\nExplanation of the script:\n\n`find .`: find all files in current working directory (`.`) and recursive in all subfolders. Arguments:\n\n - `-type f`: Match only file types (ignores directories etc.).\n - `\\( -iname '*.js' -or -iname '*.jsx' \\)`: Use case insensitive name matching, match files ending in `.js` or `.jsx`. Note that surrounding brackets have to be escaped to be interpreted correctly.\n - `-not -wholename '*node_modules*'`: Match `node_modules` in whole path, negate matches, which means any path including `node_modules` will be ignored.\n - `-exec sh -c '[rename script]' _ {} \\;`: will call given *rename script* as shell script, passing the full file path (`{}`) as the first argument (`$1`).\n\nRenaming script when using `-a`:\n\n - `'mv \"$1\" \"${1%.js*}.tsx\"'`: Execute a `sh` command and pass it `{}`, which is current file path, as first argument (`$1`). The script uses `mv` (move files) command to move `$1` (found file [relative] path) to the same path, just with replaced `.js*` (`.js` or `.jsx`) extension with `.tsx` (TypeScript React). If the terminology *move* confuses you, don't worry, it's not really moving the files anywhere, just renaming them.\n\nRenaming script when using `-r`:\n\n  - ``'mv \"$1\" `sed -re \"s/\\.js(x)?$/\\.ts\\1/g\" \u003c\u003c\u003c \"$1\"\\`'``: Command `sed` (stream editor) is used to replace matching regex `\\.js(x)?$` (`.js` or `.jsx` at end of string) with `.ts(x)`, where the `x` is only added if it existed in old extension.\n\n## As terminal commands\n\nInstead of downloading and running the script, you can copy one of the scripts below directly into the terminal.\n\nSame as `rename -a` (rename both `.js` and `.jsx` to `.tsx`):\n\n``` sh\nfind . -type f \\( -iname '*.js' -or -iname '*.jsx' \\) -not -wholename '*node_modules*' -exec sh -c 'mv \"$1\" \"${1%.js*}.tsx\"' _ {} \\;\n```\n\nSame as `rename -r` (rename `.js` and `.jsx` to `.ts` and `.tsx`, respectively):\n\n``` sh\nfind . -type f \\( -iname '*.js' -or -iname '*.jsx' \\) -not -wholename '*node_modules*' -exec sh -c 'mv \"$1\" `sed -Ee \"s/\\.js(x)?$/\\.ts\\1/g\" \u003c\u003c\u003c \"$1\"`' _ {} \\;\n```\n\n# Contributing\n\nIf you find a problem with using this script or have an idea which you believe will improve this script, share it as an issue on this repo.\n\nIf you're feeling extra helpful, pull requests are welcome!\n\n## [License (MIT)](LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkogresak%2Fjs-to-tsx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkogresak%2Fjs-to-tsx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkogresak%2Fjs-to-tsx/lists"}