Skip to content

Commit

Permalink
update config settings and readme
Browse files Browse the repository at this point in the history
bump version to 2.0.0
  • Loading branch information
fox1t committed Sep 16, 2023
1 parent 510bcee commit 6b76fa1
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 18 deletions.
52 changes: 44 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,61 @@ $ npm install --save-dev fastify-tsconfig

## Usage

Extend your own `tsconfig.json` file from `fastify-tsconfig` and override/add 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.
Create 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.

Depending on the type of the project, you should add the following settings.

### Application
`tsconfig.json`
```json
{
"extends": "fastify-tsconfig",
"compilerOptions": {
"outDir": "dist",
"sourceMap": true
},
"include": [
"src/**/*.ts"
]
}
```
### Package
`tsconfig.json`

```json
{
"extends": "fastify-tsconfig",
"compilerOptions": {
"outDir": "build",
"target": "es2018",
"lib": ["es2018"]
}
"extends": "fastify-tsconfig",
"compilerOptions": {
"outDir": "dist",
"declaration": true
},
"include": [
"src/**/*.ts"
]
}
```
### Monorepo Package
`tsconfig.json`

```json
{
"extends": "fastify-tsconfig",
"compilerOptions": {
"outDir": "dist",
"declarationMap": true,
"composite": true
},
"include": [
"src/**/*.ts"
]
}
```

Check the other settings [here](./tsconfig.json)

## Configuration target

The configuration targets es2018, that is supported in Node.js 10 and later. There is only one feature that is is missing from Node.js v10: [Proxy "ownKeys"](https://node.green/#ES2018) . However using es2018 as target makes some widely used features ("object rest properties", "object spread properties", and "Asynchronous Iterators") not being transpiled. To target some other version, just override `target` property.
The configuration targets ES2022, which is supported in Node.js 16 and later. Only one feature still needs to be implemented: [RegExp Match Indices shows up in flags](https://node.green/#ES2022). However, using ES2022 as a target makes widely used features not being compiled. To target an older version, override the `target` property.

## License

Expand All @@ -38,3 +73,4 @@ Licensed under [MIT](./LICENSE).
---

Inspired by: [sindresorhus/tsconfig](https://github.com/sindresorhus/tsconfig)

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fastify-tsconfig",
"version": "1.0.1",
"version": "2.0.0",
"description": "Shared TypeScript configuration",
"license": "MIT",
"repository": {
Expand All @@ -14,7 +14,7 @@
},
"main": "tsconfig.json",
"engines": {
"node": ">=10.4.0"
"node": ">=16.13.2"
},
"files": [
"tsconfig.json"
Expand Down
15 changes: 7 additions & 8 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"target": "es2018",
"module": "commonjs",
"moduleResolution": "node",
"declaration": true,
"pretty": true,
"noEmitOnError": true,
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"strict": true,
"resolveJsonModule": true,
"removeComments": true,
"newLine": "lf",
"noUnusedLocals": true,
"noFallthroughCasesInSwitch": true,
"useDefineForClassFields": true,
"isolatedModules": true,
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true,
"lib": [
"esnext"
"ESNext"
]
}
}

0 comments on commit 6b76fa1

Please sign in to comment.