{"id":14969157,"url":"https://github.com/fastify/tsconfig","last_synced_at":"2025-04-07T13:05:20.670Z","repository":{"id":56374354,"uuid":"297929860","full_name":"fastify/tsconfig","owner":"fastify","description":"Shared TypeScript configuration for fastify projects","archived":false,"fork":false,"pushed_at":"2025-02-03T09:53:22.000Z","size":14,"stargazers_count":23,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-31T12:08:29.024Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/fastify-tsconfig","language":null,"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/fastify.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},"funding":{"github":"fastify","open_collective":"fastify"}},"created_at":"2020-09-23T10:09:33.000Z","updated_at":"2025-03-31T06:40:23.000Z","dependencies_parsed_at":"2024-01-23T20:11:31.196Z","dependency_job_id":"2b7efbc6-c00d-4e64-b231-8976fd7c81ea","html_url":"https://github.com/fastify/tsconfig","commit_stats":{"total_commits":6,"total_committers":2,"mean_commits":3.0,"dds":"0.16666666666666663","last_synced_commit":"510bcee88096fc5f6cd89b77a203f361c59f9232"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Ftsconfig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Ftsconfig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Ftsconfig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Ftsconfig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fastify","download_url":"https://codeload.github.com/fastify/tsconfig/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247657276,"owners_count":20974344,"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-09-24T13:41:14.684Z","updated_at":"2025-04-07T13:05:20.641Z","avatar_url":"https://github.com/fastify.png","language":null,"readme":"# tsconfig\n\n\u003e Shared [TypeScript configuration](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) for fastify projects\n\n## Install\n\n```\n$ npm i -D fastify-tsconfig\n```\n\n## Usage\n\nCreate your own `tsconfig.json` in the projects' root folder and extend it from `fastify-tsconfig`, overriding or adding the desired settings. By default, no `outDir` is set (because of [this issue](https://github.com/Microsoft/TypeScript/issues/29172)), so be sure to add one.\n\n### Configuration module and moduleResolution\n\nThis configuration sets `\"module\"` and `\"moduleResolution\"` to [`NodeNext`](https://www.typescriptlang.org/docs/handbook/esm-node.html). This means that TypeScript will read the nearest `package.json` file in the scope and search for the `\"type\"` field or the absence of it.\n\nIf `type` is not set or is `\"type\": \"commonjs\"` the emitted code will be CommonJS, with `.js` extension. Moreover, `tsc` will complain if ESM-only properties/features are used in source files. If you want to emit `.mjs` files, use the `.mts` extension.\nOn the other hand, if `\"type\": \"module\"` is set, the sources will be compiled to the ESM with the `.js` extension. In this case, if you want to emit `.cjs` files, use the `.cts` extension for the source file.\n\nThe \"following the Node.js rules\" goes also for the `package.json` `exports` field. If `type` is set, regardless of the value, TypeScript will check the `exports` field to know where the compiled code and the types are located. If the `type` field is not set, it will check for the `main` and `types` fields.\n\n#### CommonJS example\n`package.json`\n```jsonc\n{\n  \"name\": \"my-package\",\n  \"type\": \"commonjs\",\n  \"main\": \"dist/index.js\", // this is for older Node.js versions\n  \"types\": \"dist/index.d.ts\", // this is optional and can be omitted\n  \"exports\": {\n    \"import\": \"./dist/index.js\",\n    \"require\": \"./dist/index.js\",\n    \"types\": \"./dist/index.d.ts\" // this is optional and can be omitted\n }\n}\n```\n`tsconfig.json`\n```jsonc\n{\n \"extends\": \"fastify-tsconfig\",\n \"compilerOptions\": {\n    \"outDir\": \"dist\",\n    \"sourceMap\": true\n  },\n  \"include\": [\n    \"src/**/*.ts\"\n  ]\n}\n```\n#### ESM example\n`package.json`\n```jsonc\n{\n  \"name\": \"my-package\",\n  \"type\": \"module\",\n  \"main\": \"dist/index.js\", // this is for older Node.js versions\n  \"types\": \"dist/index.d.ts\", // this is optional and can be omitted\n  \"exports\": {\n    \"import\": \"./dist/index.js\",\n    \"require\": \"./dist/index.js\",\n    \"types\": \"./dist/index.d.ts\" // this is optional and can be omitted\n }\n}\n```\n`tsconfig.json`\n```jsonc\n{\n \"extends\": \"fastify-tsconfig\",\n \"compilerOptions\": {\n    \"outDir\": \"dist\",\n    \"sourceMap\": true\n  },\n  \"include\": [\n    \"src/**/*.ts\"\n  ]\n}\n```\n### Extending this configuration\n\nDepending on the type of the project, you should add the following settings.\n\n#### Application\n`tsconfig.json`\n```json\n{\n \"extends\": \"fastify-tsconfig\",\n \"compilerOptions\": {\n    \"outDir\": \"dist\",\n    \"sourceMap\": true\n },\n \"include\": [\n    \"src/**/*.ts\"\n ]\n}\n```\n#### NPM Package\n`tsconfig.json`\n\n```json\n{\n \"extends\": \"fastify-tsconfig\",\n \"compilerOptions\": {\n    \"outDir\": \"dist\",\n    \"declaration\": true\n },\n \"include\": [\n    \"src/**/*.ts\"\n ]\n}\n```\n#### Monorepo Package\n`tsconfig.json`\n\n```json\n{\n \"extends\": \"fastify-tsconfig\",\n \"compilerOptions\": {\n    \"outDir\": \"dist\",\n    \"declarationMap\": true,\n    \"composite\": true\n },\n \"include\": [\n    \"src/**/*.ts\"\n ]\n}\n```\n\nCheck the other settings [here](./tsconfig.json)\n\n## Configuration target\n\nThe configuration targets ES2023, which is supported in Node.js 20 and later. However, using ES2023 as a target makes widely used features not being compiled. To target an older version, override the `target` property.\n\n## License\n\nLicensed under [MIT](./LICENSE).\n\n---\n\nInspired by: [sindresorhus/tsconfig](https://github.com/sindresorhus/tsconfig)\n\n","funding_links":["https://github.com/sponsors/fastify","https://opencollective.com/fastify"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastify%2Ftsconfig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffastify%2Ftsconfig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastify%2Ftsconfig/lists"}