{"id":28174358,"url":"https://github.com/2bad/tsfix","last_synced_at":"2026-03-02T08:02:19.925Z","repository":{"id":208396020,"uuid":"713589831","full_name":"2BAD/tsfix","owner":"2BAD","description":"One tool to fix all issues that TypeScript's compiler leaves behind","archived":false,"fork":false,"pushed_at":"2026-02-25T01:51:41.000Z","size":1564,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-02-25T07:12:07.262Z","etag":null,"topics":["alias","cli","esm","fix","import","import-path","paths","tsc","tsconfig-paths","typescript"],"latest_commit_sha":null,"homepage":"","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/2BAD.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-11-02T20:41:49.000Z","updated_at":"2025-10-28T01:39:41.000Z","dependencies_parsed_at":"2024-01-06T19:25:20.928Z","dependency_job_id":"5ee34492-9aff-4d8e-acd1-f125351a2bba","html_url":"https://github.com/2BAD/tsfix","commit_stats":null,"previous_names":["2bad/fix-esm-specifier","2bad/tsfix"],"tags_count":5,"template":false,"template_full_name":"2BAD/ts-lib-starter","purl":"pkg:github/2BAD/tsfix","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2BAD%2Ftsfix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2BAD%2Ftsfix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2BAD%2Ftsfix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2BAD%2Ftsfix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/2BAD","download_url":"https://codeload.github.com/2BAD/tsfix/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2BAD%2Ftsfix/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29995910,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-02T01:47:34.672Z","status":"online","status_checked_at":"2026-03-02T02:00:07.342Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["alias","cli","esm","fix","import","import-path","paths","tsc","tsconfig-paths","typescript"],"created_at":"2025-05-15T22:16:04.817Z","updated_at":"2026-03-02T08:02:14.914Z","avatar_url":"https://github.com/2BAD.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TSFIX\n\n[![NPM version](https://img.shields.io/npm/v/@2bad/tsfix)](https://www.npmjs.com/package/@2bad/tsfix)\n[![License](https://img.shields.io/npm/l/@2bad/tsfix)](https://www.npmjs.com/package/@2bad/tsfix)\n[![GitHub Build Status](https://img.shields.io/github/actions/workflow/status/2BAD/tsfix/build.yml)](https://github.com/2BAD/tsfix/actions/workflows/build.yml)\n[![Code coverage](https://img.shields.io/codecov/c/github/2BAD/tsfix)](https://codecov.io/gh/2BAD/tsfix)\n[![Written in TypeScript](https://img.shields.io/github/languages/top/2BAD/tsfix)](https://github.com/2BAD/tsfix/search?l=typescript)\n\nA post-compilation tool that fixes TypeScript's critical ESM compatibility failures. Properly adds .js extensions, resolves path aliases, and handles index.js imports where tsc consistently falls short, even in the latest versions.\n\n## Complete Solution for All TypeScript Issues\n\n- ✅ **Fixes Extension Problems**: Adds required `.js` extensions to imports\n- ✅ **Handles Directory Imports**: Properly resolves to `index.js` files\n- ✅ **Transforms Path Aliases**: Converts tsconfig aliases to valid relative paths\n- ✅ **Fixes Declaration Files**: Properly handles `.d.ts` files (unlike TypeScript itself)\n- ✅ **Zero Configuration**: Works out-of-the-box with any TypeScript setup\n- ✅ **Universal Compatibility**: Works with all TypeScript versions and config setups\n- ✅ **High Performance**: Offers both fast regex mode and accurate AST mode\n\n## Zero Hassle Setup\n\n```shell\nnpm install --save-dev @2bad/tsfix\n```\n\nThen add `postbuild` script to your package.json:\n\n```json\n{\n  \"scripts\": {\n    \"build\": \"tsc\",\n    \"postbuild\": \"tsfix\"\n  }\n}\n```\n\nThat's it. TSFIX finds your TypeScript output and fixes all import issues automatically.\n\n## Real World Examples\n\n### Converting Regular Imports\n\n```typescript\n// Before TypeScript Compilation\nimport { helper } from './utils/helper.ts'\n\n// After TypeScript Compilation (BROKEN)\nimport { helper } from './utils/helper.ts'\n\n// After TSFIX (FIXED)\nimport { helper } from './utils/helper.js' // Works in ESM!\n```\n\n### Fixing Path Alias Imports\n\n```typescript\n// tsconfig.json\n{\n  \"compilerOptions\": {\n    \"baseUrl\": \".\",\n    \"paths\": {\n      \"@/*\": [\"src/*\"]\n    }\n  }\n}\n\n// Before TypeScript Compilation\nimport { Button } from '@/components/Button'\n\n// After TypeScript Compilation (BROKEN)\nimport { Button } from '@/components/Button'\n\n// After TSFIX (FIXED)\nimport { Button } from './src/components/Button.js' // Correctly resolved!\n```\n\n### Resolving Directory Imports\n\n```typescript\n// Before TypeScript Compilation\nimport { config } from './config'\n\n// After TypeScript Compilation (BROKEN)\nimport { config } from './config'\n\n// After TSFIX (FIXED)\nimport { config } from './config/index.js' // Properly resolved!\n```\n\n## Advanced Usage\n\n```sh\n# Use AST-based extraction (more accurate but slower)\nnpx @2bad/tsfix --mode ast\n\n# Custom file matching pattern\nnpx @2bad/tsfix --pattern \"**/*.js\"\n```\n\n## Debugging\n\n```sh\n# Enable all debug logging\nDEBUG=* tsfix\n\n# Only enable specific components\nDEBUG=tsfix:main,tsfix:extractor tsfix\n\n# Show only fixer operations\nDEBUG=tsfix:fixer tsfix\n```\n\n## Why TSFIX exists\n\n### Major TypeScript Issues (Still Unresolved)\n- [#16577](https://github.com/microsoft/TypeScript/issues/16577): Provide a way to add the '.js' file extension to the end of module specifiers (2017)\n- [#28288](https://github.com/microsoft/TypeScript/issues/28288): Feature: disable extensionless imports (2018)\n- [#40878](https://github.com/microsoft/TypeScript/issues/40878): Compiled JavaScript import is missing file extension (2020)\n- [#42151](https://github.com/microsoft/TypeScript/issues/42151): TypeScript cannot emit valid ES modules due to file extension issue (2020)\n- [#50501](https://github.com/microsoft/TypeScript/issues/50501): TypeScript is not an ECMAScript superset post-ES2015 (2022)\n- [#61037](https://github.com/microsoft/TypeScript/issues/61037): `rewriteRelativeImportExtensions` doesn't rewrite extensions in emitted declaration files (2025)\n- [#61213](https://github.com/microsoft/TypeScript/issues/61213): Allow allowImportingTsExtensions: without either '--noEmit' or '--emitDeclarationOnly' (2025)\n\n### Previously Addressed (Partially)\n\n- [#49083](https://github.com/microsoft/TypeScript/issues/49083): \"module\": \"node16\" should support extension rewriting (Partially addressed via [#59767](https://github.com/microsoft/TypeScript/pull/59767))\n\n\n## Performance Options\n\nTSFIX offers two extraction engines:\n\n- **Regex mode** (default): Fast pattern-based extraction (5x faster than AST mode)\n- **AST mode**: Precise syntax tree-based extraction for complex codebases\n\n## Contributing\n\nContributions welcome! Open issues for bugs/features or submit PRs with improvements.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F2bad%2Ftsfix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F2bad%2Ftsfix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F2bad%2Ftsfix/lists"}