{"_id":"@unts/get-tsconfig","_rev":"5-b05b6b8acb46f3641807df1ffd16daf0","name":"@unts/get-tsconfig","dist-tags":{"latest":"4.1.1"},"versions":{"4.1.1":{"name":"@unts/get-tsconfig","version":"4.1.1","keywords":["get-tsconfig","get","typescript","tsconfig","tsconfig.json"],"author":{"name":"Hiroki Osame","email":"hiroki.osame@gmail.com"},"license":"MIT","_id":"@unts/get-tsconfig@4.1.1","maintainers":[{"name":"jounqin","email":"admin@1stg.me"}],"homepage":"https://github.com/privatenumber/get-tsconfig#readme","bugs":{"url":"https://github.com/privatenumber/get-tsconfig/issues"},"dist":{"shasum":"f2d308a0c9e56a73b815b0525d4bf37a28914cdd","tarball":"https://registry.npmjs.org/@unts/get-tsconfig/-/get-tsconfig-4.1.1.tgz","fileCount":6,"integrity":"sha512-8mPf1bBzF2S+fyuyYOQWjDcaJTTgJ14UAnXW9I3KwrqioRWG1byRXHwciYdqXpbdOiu7Fg4WJbymBIakGk+aMA==","signatures":[{"sig":"MEQCIBWuAEvUGgIU2lyy0P6YQdWKVFo1NFvpbCz8WDAwhl1SAiA+vVbo/zlGwHSjc4icx00htmD5Gk7Jmc3Lqeyh0gH41g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":54148,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJixHmAACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmotTw/+L38cXedtz7fEH+Haobdg6yksfZ2HQTYT/9LM3dfHGJ1ZrGR7\r\neHPo7aGsfcawpjLX0yLUsF1BA2KUYCI+LYf0I5LsU+kBMDP3FrHp4OkYTEEI\r\n2npsnZO4enj7f+4BjkZm0dq/5L4EJDi36WOO2VSwxWXWWeeiIsVBXhYqW50a\r\n5LaHGmInTm9QMIBGFbcVtgyAjNyKLNF9mAl9BcQTMBlD9CT+QdnlCobVUIqJ\r\nKZW3oeSfrD71eV6pCagU8TVab96bG3NaZdsnm3S99sOOC1LOPDgyV5CDEAle\r\nNj1MIHN1+smoUbiBjXHQkKr0R9jOL9Xw6vC2A83Xa6Hyjr5/5fNFIF0ZXR/v\r\nvWu+0vkXrYhpdAgo/FWGQbaccamHPjtCAuKoFrqWB5dw1VrJNJsOHobzvhvb\r\nb68uD3e9v4669woKMt1Otcyn3/KkF2x+tX7pSpy7FAlSrmKjwc6tNpbGXrjk\r\nBDXCeUHNsQlTRNMpVX2tKL2/zvVcphUOFR35kE7sBYWRba6z61JY1J2dcAEp\r\nGUJJ8VpMmK0G+MmJ7s76B5v1VdWFvVBW/d0gDpwM4oV3qqZgtaU3zp6xTtd0\r\nFd5ErSqKVNYt6WQwdDgLbxaPMHuc6sw7hlv5L54j39unukflYeFQrxWHV8Op\r\nubmlyAn0MOUDCExIkOFcwBsGcBMuTM2vM9U=\r\n=uWZR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./dist/index.js","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"},"funding":"https://github.com/privatenumber/get-tsconfig?sponsor=1","gitHead":"f7bd073abe0363ad75d880657ded3dac822be69d","scripts":{"dev":"tsx watch --conditions=development tests","lint":"eslint .","test":"tsx tests","build":"pkgroll --minify --target node12.20","pretest":"npm run build"},"_npmUser":{"name":"jounqin","email":"admin@1stg.me"},"repository":{"url":"git+https://github.com/privatenumber/get-tsconfig.git","type":"git"},"_npmVersion":"8.5.0","description":"Find and parse the tsconfig.json file from a directory path","directories":{},"_nodeVersion":"16.14.2","eslintConfig":{"extends":"@pvtnbr/eslint-config","overrides":[{"files":"tests/**/*.ts","rules":{"@typescript-eslint/no-shadow":["error",{"allow":["test","describe"]}]}}],"ignorePatterns":["tests/fixtures"]},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"packageManager":"yarn@3.2.1","devDependencies":{"tsx":"^3.6.0","execa":"^6.1.0","slash":"^4.0.0","eslint":"^8.18.0","manten":"^0.2.1","pkgroll":"^1.3.1","type-fest":"^2.13.1","typescript":"^4.7.3","@types/node":"^17.0.41","jsonc-parser":"^3.0.0","@pvtnbr/eslint-config":"^0.26.1"},"_npmOperationalInternal":{"tmp":"tmp/get-tsconfig_4.1.1_1657043327927_0.16260358402162178","host":"s3://npm-registry-packages"},"deprecated":"Use original `get-tsconfig` instead"}},"time":{"created":"2022-07-05T17:48:47.863Z","modified":"2025-04-03T04:45:05.299Z","4.1.1":"2022-07-05T17:48:48.146Z"},"bugs":{"url":"https://github.com/privatenumber/get-tsconfig/issues"},"author":{"name":"Hiroki Osame","email":"hiroki.osame@gmail.com"},"license":"MIT","homepage":"https://github.com/privatenumber/get-tsconfig#readme","keywords":["get-tsconfig","get","typescript","tsconfig","tsconfig.json"],"repository":{"url":"git+https://github.com/privatenumber/get-tsconfig.git","type":"git"},"description":"Find and parse the tsconfig.json file from a directory path","maintainers":[{"name":"jounqin","email":"admin@1stg.me"}],"readme":"# get-tsconfig [![Latest version](https://badgen.net/npm/v/get-tsconfig)](https://npm.im/get-tsconfig)\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 & 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! `3.6 kB` Minified + Gzipped\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?)\nSearches for a `tsconfig.json` file and parses it. 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     * 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#### 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\n---\n\n### parseTsconfig(tsconfigPath)\nThe `tsconfig.json` parser used internally by `getTsconfig`. Returns the parsed tsconfig as `TsConfigJsonResolved`.\n\n#### tsconfigPath\nType: `string`\n\nRequired path to the tsconfig file.\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### 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\nfunction exampleResolver(request: string) {\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","readmeFilename":"README.md"}