Skip to content

Commit

Permalink
feat(tsconfig): split tsconfig to mutliple files for different scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
foray1010 committed Mar 20, 2023
1 parent ef8b2e7 commit fcaf3ae
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 30 deletions.
2 changes: 1 addition & 1 deletion packages/babel-preset/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@foray1010/tsconfig",
"extends": "@foray1010/tsconfig/tsconfig.base.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true
Expand Down
2 changes: 1 addition & 1 deletion packages/common-presets-utils/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@foray1010/tsconfig",
"extends": "@foray1010/tsconfig/tsconfig.base.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@foray1010/tsconfig",
"extends": "@foray1010/tsconfig/tsconfig.base.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-preset/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@foray1010/tsconfig",
"extends": "@foray1010/tsconfig/tsconfig.base.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true
Expand Down
2 changes: 1 addition & 1 deletion packages/prettier-config/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@foray1010/tsconfig",
"extends": "@foray1010/tsconfig/tsconfig.base.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true
Expand Down
2 changes: 1 addition & 1 deletion packages/stylelint-config/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@foray1010/tsconfig",
"extends": "@foray1010/tsconfig/tsconfig.base.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true
Expand Down
64 changes: 43 additions & 21 deletions packages/tsconfig/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,47 @@ If you need to compile TypeScript, use [@foray1010/babel-preset](../babel-preset

2. Create an `tsconfig.json` in the project root

for app (type checking only):

```json
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@foray1010/tsconfig"
}
```

for library (type checking and generate typings):

```json
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@foray1010/tsconfig",
"compilerOptions": {
"emitDeclarationOnly": true,
"noEmit": false,
"outDir": "build/dts"
- For Node.js app (type checking only):

```json
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@foray1010/tsconfig/tsconfig.base.json"
}
```

- For general frontend application (type checking only):

```json
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": [
"@foray1010/tsconfig/tsconfig.base.json",
"@foray1010/tsconfig/tsconfig.frontend.json"
]
}
```

- For react.js application (type checking only):

```json
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": [
"@foray1010/tsconfig/tsconfig.base.json",
"@foray1010/tsconfig/tsconfig.react.json"
]
}
```

- For library (type checking and generate typings):

```json
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": [
"@foray1010/tsconfig/tsconfig.base.json",
"@foray1010/tsconfig/tsconfig.library.json"
]
}
}
```
```
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"declaration": true,
"esModuleInterop": true,
"exactOptionalPropertyTypes": true,
"incremental": true,
"isolatedModules": true,
"jsx": "react-jsx",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"lib": ["ES2020"],
"module": "Node16",
"moduleDetection": "force",
"moduleResolution": "Node",
Expand Down
6 changes: 6 additions & 0 deletions packages/tsconfig/tsconfig.frontend.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"lib": ["ES2020", "DOM", "DOM.Iterable"]
}
}
9 changes: 9 additions & 0 deletions packages/tsconfig/tsconfig.library.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"declaration": true,
"emitDeclarationOnly": true,
"noEmit": false,
"outDir": "dist"
}
}
7 changes: 7 additions & 0 deletions packages/tsconfig/tsconfig.react.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "./tsconfig.frontend.json",
"compilerOptions": {
"jsx": "react-jsx"
}
}

0 comments on commit fcaf3ae

Please sign in to comment.