{"id":13791568,"url":"https://github.com/privatenumber/get-tsconfig","last_synced_at":"2026-04-15T01:02:07.463Z","repository":{"id":37084895,"uuid":"447268358","full_name":"privatenumber/get-tsconfig","owner":"privatenumber","description":"Lightweight tsconfig.json parser \u0026 paths resolver","archived":false,"fork":false,"pushed_at":"2026-04-08T20:37:29.000Z","size":2832,"stargazers_count":243,"open_issues_count":14,"forks_count":19,"subscribers_count":3,"default_branch":"master","last_synced_at":"2026-04-08T22:24:51.046Z","etag":null,"topics":["find","get","node","parse","paths","tsconfig","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/privatenumber.png","metadata":{"files":{"readme":"README.md","changelog":null,"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},"funding":{"github":"privatenumber"}},"created_at":"2022-01-12T15:23:21.000Z","updated_at":"2026-04-05T11:11:30.000Z","dependencies_parsed_at":"2023-12-20T13:24:36.090Z","dependency_job_id":"d58197c9-b3a2-4eb1-99d0-ce8cd851dd08","html_url":"https://github.com/privatenumber/get-tsconfig","commit_stats":{"total_commits":145,"total_committers":11,"mean_commits":"13.181818181818182","dds":0.08275862068965523,"last_synced_commit":"7e58ea3067aa8aea7f06c708706d13af60cda8dd"},"previous_names":[],"tags_count":47,"template":false,"template_full_name":null,"purl":"pkg:github/privatenumber/get-tsconfig","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fget-tsconfig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fget-tsconfig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fget-tsconfig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fget-tsconfig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/privatenumber","download_url":"https://codeload.github.com/privatenumber/get-tsconfig/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fget-tsconfig/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31752220,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T09:16:15.125Z","status":"ssl_error","status_checked_at":"2026-04-13T09:16:05.023Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["find","get","node","parse","paths","tsconfig","typescript"],"created_at":"2024-08-03T22:01:01.892Z","updated_at":"2026-04-15T01:02:07.400Z","avatar_url":"https://github.com/privatenumber.png","language":"TypeScript","funding_links":["https://github.com/sponsors/privatenumber","https://github.com/sponsors/privatenumber/sponsorships?tier_id=398771","https://github.com/sponsors/privatenumber/sponsorships?tier_id=397608"],"categories":["TypeScript"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\t\u003cimg width=\"160\" src=\".github/logo.webp\"\u003e\n\u003c/p\u003e\n\u003ch1 align=\"center\"\u003e\n\t\u003csup\u003eget-tsconfig\u003c/sup\u003e\n\t\u003cbr\u003e\n\t\u003ca href=\"https://npm.im/get-tsconfig\"\u003e\u003cimg src=\"https://badgen.net/npm/v/get-tsconfig\"\u003e\u003c/a\u003e \u003ca href=\"https://npm.im/get-tsconfig\"\u003e\u003cimg src=\"https://badgen.net/npm/dm/get-tsconfig\"\u003e\u003c/a\u003e\n\u003c/h1\u003e\n\nFind and parse `tsconfig.json` files.\n\n### Features\n- Zero dependency (not even TypeScript)\n- Tested against TypeScript for correctness\n- Supports comments \u0026 dangling commas in `tsconfig.json`\n- Resolves [`extends`](https://www.typescriptlang.org/tsconfig/#extends)\n- Fully typed `tsconfig.json`\n- Validates and throws parsing errors\n- Tiny! `7 kB` Minified + Gzipped\n\n\u003cbr\u003e\n\n\u003cp align=\"center\"\u003e\n\t\u003ca href=\"https://github.com/sponsors/privatenumber/sponsorships?tier_id=398771\"\u003e\u003cimg width=\"412\" src=\"https://raw.githubusercontent.com/privatenumber/sponsors/master/banners/assets/donate.webp\"\u003e\u003c/a\u003e\n\t\u003ca href=\"https://github.com/sponsors/privatenumber/sponsorships?tier_id=397608\"\u003e\u003cimg width=\"412\" src=\"https://raw.githubusercontent.com/privatenumber/sponsors/master/banners/assets/sponsor.webp\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\u003csup\u003e\u003ci\u003eAlready a sponsor?\u003c/i\u003e Join the discussion in the \u003ca href=\"https://github.com/pvtnbr/get-tsconfig\"\u003eDevelopment repo\u003c/a\u003e!\u003c/sup\u003e\u003c/p\u003e\n\n## Install\n\n```bash\nnpm install get-tsconfig\n```\n\n## Why?\nFor TypeScript related tooling to correctly parse `tsconfig.json` file without depending on TypeScript.\n\n## API\n\n### getTsconfig(searchPath?, configName?, cache?)\n\nSearches for a tsconfig file (defaults to `tsconfig.json`) in the `searchPath` and parses it. (If you already know the tsconfig path, use [`parseTsconfig`](#parsetsconfigtsconfigpath-cache) instead). Returns `null` if a config file cannot be found, or an object containing the path and parsed TSConfig object if found.\n\nReturns:\n\n```ts\ntype TsconfigResult = {\n\n    /**\n     * The path to the tsconfig.json file\n     */\n    path: string\n\n    /**\n     * The resolved tsconfig.json file\n     */\n    config: TsConfigJsonResolved\n}\n```\n\n#### searchPath\nType: `string`\n\nDefault: `process.cwd()`\n\nAccepts a path to a file or directory to search up for a `tsconfig.json` file.\n\n#### configName\nType: `string`\n\nDefault: `tsconfig.json`\n\nThe file name of the TypeScript config file.\n\n#### cache\nType: `Map\u003cstring, any\u003e`\n\nDefault: `new Map()`\n\nOptional cache for fs operations.\n\n#### Example\n\n```ts\nimport { getTsconfig } from 'get-tsconfig'\n\n// Searches for tsconfig.json starting in the current directory\nconsole.log(getTsconfig())\n\n// Find tsconfig.json from a TypeScript file path\nconsole.log(getTsconfig('./path/to/index.ts'))\n\n// Find tsconfig.json from a directory file path\nconsole.log(getTsconfig('./path/to/directory'))\n\n// Explicitly pass in tsconfig.json path\nconsole.log(getTsconfig('./path/to/tsconfig.json'))\n\n// Search for jsconfig.json - https://code.visualstudio.com/docs/languages/jsconfig\nconsole.log(getTsconfig('.', 'jsconfig.json'))\n```\n\n---\n\n### parseTsconfig(tsconfigPath, cache?)\n\nParse the tsconfig file provided. Used internally by `getTsconfig`. Returns the parsed tsconfig as `TsConfigJsonResolved`.\n\n#### tsconfigPath\nType: `string`\n\nRequired path to the tsconfig file.\n\n#### cache\nType: `Map\u003cstring, any\u003e`\n\nDefault: `new Map()`\n\nOptional cache for fs operations.\n\n#### Example\n\n```ts\nimport { parseTsconfig } from 'get-tsconfig'\n\n// Must pass in a path to an existing tsconfig.json file\nconsole.log(parseTsconfig('./path/to/tsconfig.custom.json'))\n```\n\n---\n\n### createFileMatcher(tsconfig: TsconfigResult, caseSensitivePaths?: boolean)\n\nGiven a `tsconfig.json` file, it returns a file-matcher function that determines whether it should apply to a file path.\n\n```ts\ntype FileMatcher = (filePath: string) =\u003e TsconfigResult['config'] | undefined\n```\n\n#### tsconfig\nType: `TsconfigResult`\n\nPass in the return value from `getTsconfig`, or a `TsconfigResult` object.\n\n#### caseSensitivePaths\nType: `boolean`\n\nBy default, it uses [`is-fs-case-sensitive`](https://github.com/privatenumber/is-fs-case-sensitive) to detect whether the file-system is case-sensitive.\n\nPass in `true` to make it case-sensitive.\n\n#### Example\n\nFor example, if it's called with a `tsconfig.json` file that has `include`/`exclude`/`files` defined, the file-matcher will return the config for files that match `include`/`files`, and return `undefined` for files that don't match or match `exclude`.\n\n```ts\nconst tsconfig = getTsconfig()\nconst fileMatcher = tsconfig \u0026\u0026 createFileMatcher(tsconfig)\n\n/*\n * Returns tsconfig.json if it matches the file,\n * undefined if not\n */\nconst configForFile = fileMatcher?.('/path/to/file.ts')\nconst distCode = compileTypescript({\n    code: sourceCode,\n    tsconfig: configForFile\n})\n```\n\n---\n\n### createPathsMatcher(tsconfig: TsconfigResult)\n\nGiven a tsconfig with [`compilerOptions.paths`](https://www.typescriptlang.org/tsconfig#paths) defined, it returns a matcher function.\n\nThe matcher function accepts an [import specifier (the path to resolve)](https://nodejs.org/api/esm.html#terminology), checks it against `compilerOptions.paths`, and returns an array of possible paths to check:\n```ts\nfunction pathsMatcher(specifier: string): string[]\n```\n\nThis function only returns possible paths and doesn't actually do any resolution. This helps increase compatibility wtih file/build systems which usually have their own resolvers.\n\n#### Example\n\n```ts\nimport { getTsconfig, createPathsMatcher } from 'get-tsconfig'\n\nconst tsconfig = getTsconfig()\nconst pathsMatcher = createPathsMatcher(tsconfig)\n\nconst exampleResolver = (request: string) =\u003e {\n    if (pathsMatcher) {\n        const tryPaths = pathsMatcher(request)\n\n        // Check if paths in `tryPaths` exist\n    }\n}\n```\n\n## FAQ\n\n### How can I use TypeScript to parse `tsconfig.json`?\nThis package is a re-implementation of TypeScript's `tsconfig.json` parser.\n\nHowever, if you already have TypeScript as a dependency, you can simply use it's API:\n\n```ts\nimport {\n    sys as tsSys,\n    findConfigFile,\n    readConfigFile,\n    parseJsonConfigFileContent\n} from 'typescript'\n\n// Find tsconfig.json file\nconst tsconfigPath = findConfigFile(process.cwd(), tsSys.fileExists, 'tsconfig.json')\n\n// Read tsconfig.json file\nconst tsconfigFile = readConfigFile(tsconfigPath, tsSys.readFile)\n\n// Resolve extends\nconst parsedTsconfig = parseJsonConfigFileContent(\n    tsconfigFile.config,\n    tsSys,\n    path.dirname(tsconfigPath)\n)\n```\n\n## Sponsors\n\u003cp align=\"center\"\u003e\n\t\u003ca href=\"https://github.com/sponsors/privatenumber\"\u003e\n\t\t\u003cimg src=\"https://cdn.jsdelivr.net/gh/privatenumber/sponsors/sponsorkit/sponsors.svg\"\u003e\n\t\u003c/a\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprivatenumber%2Fget-tsconfig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprivatenumber%2Fget-tsconfig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprivatenumber%2Fget-tsconfig/lists"}