@joshdb/ts-config 1.1.0-pr-148.dc48f31.0 → 2.0.0-next.e492223.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -24,30 +24,90 @@ npm install @joshdb/ts-config
24
24
 
25
25
  ## Usage
26
26
 
27
- Add the ESLint config to your `package.json`:
28
-
29
- ```json
30
- {
31
- "name": "my-project",
32
- "eslintConfig": {
33
- "extends": "@joshdb/ts-config"
34
- }
35
- }
36
- ```
27
+ This package ships a couple of different sets of tsconfig, they should be used in an array of
28
+ `extends` in your `tsconfig.json` file. The supported configs are:
37
29
 
38
- Or to your `.eslintrc.js` / `.eslintrc.json`:
30
+ - `@joshdb/ts-config/base` -> This is identical to `@joshdb/ts-config`
31
+ - `@joshdb/ts-config/extra-strict`
32
+ - `@joshdb/ts-config/decorators`
33
+ - `@joshdb/ts-config/verbatim`
39
34
 
40
- ```json
41
- {
42
- "extends": "@joshdb/ts-config"
43
- }
44
- ```
35
+ You should always start with the base config, regardless of what other configs you choose.
36
+ Next you can opt-in to the other configs.
45
37
 
46
- Create `tsconfig.eslint.json` next to the eslint config file, for example with content:
38
+ Finally you should configure your package.json properly based on what kind of package you are writing
47
39
 
48
- ```json
49
- {
50
- "extends": "./tsconfig.base.json",
51
- "include": ["src", "tests"]
52
- }
53
- ```
40
+ - For CJS packages you should add `"type": "commonjs"` to your `package.json`
41
+ - For ESM packages you should add `"type": "module"` to your `package.json`
42
+ - For a package that is going to be used by both CJS and ESM then you should not add any `"type"` to your `package.json`
43
+ - Note that if you intend to compile for both your best option is to compile
44
+ for CJS from TypeScript, then use [`gen-esm-wrapper`](https://github.com/addaleax/gen-esm-wrapper) to transform your
45
+ input file to ESM compatible exports. This is also what we do for our Josh packages.
46
+ - Note also that in this case you should not enable `@joshdb/ts-config/verbatim`, because it will not work without
47
+ a `"type"` specified in `package.json`
48
+
49
+ Next we will go over the different configs and what they do.
50
+
51
+ ### Base
52
+
53
+ The base config (`@joshdb/ts-config`, or `@joshdb/ts-config/base`) is the default config with options set up in
54
+ such a way that it will suite nearly all projects.
55
+
56
+ You can view the content of this tsconfig [here](https://github.com/josh-development/utilities/blob/main/packages/ts-config/src/tsconfig.json)
57
+
58
+ ### Extra Strict
59
+
60
+ You should include this config if you want to extra strict checking. This configures the following compiler options:
61
+
62
+ - [`allowUnreachableCode` to `false`](https://www.typescriptlang.org/tsconfig#allowUnreachableCode)
63
+ - [`allowUnusedLabels` to `false`](https://www.typescriptlang.org/tsconfig#allowUnusedLabels)
64
+ - [`exactOptionalPropertyTypes` to `false`](https://www.typescriptlang.org/tsconfig#exactOptionalPropertyTypes)
65
+ - [`noImplicitOverride` to `true`](https://www.typescriptlang.org/tsconfig#noImplicitOverride)
66
+
67
+ You can view the content of this tsconfig [here](https://github.com/josh-development/utilities/blob/main/packages/ts-config/src/extra-strict.json)
68
+
69
+ ### Decorators
70
+
71
+ You should include this config if you want to use decorators in the project using decorators from before the TC39
72
+ TC39 standardization process. Note that at time of writing (2023-08-24) TC39 decorators aren't fully properly
73
+ implemented by either NodeJS or TypeScript yet, so at least at time of writing we recommend enabling this config if
74
+ you are using decorators. Packages such as `@joshdb/decorators` rely on this config being enabled.
75
+
76
+ This enables the following compiler options:
77
+
78
+ - [experimentalDecorators](https://www.typescriptlang.org/tsconfig#experimentalDecorators)
79
+ - [emitDecoratorMetadata](https://www.typescriptlang.org/tsconfig#emitDecoratorMetadata)
80
+
81
+ You can view the content of this tsconfig [here](https://github.com/josh-development/utilities/blob/main/packages/ts-config/src/decorators.json)
82
+
83
+ ### Verbatim
84
+
85
+ You should include this config if you want to enable the
86
+ [verbatimModuleSyntax](https://www.typescriptlang.org/tsconfig#verbatimModuleSyntax) option. This option has some
87
+ drawbacks when writing CJS code but also ensures even more type strictness.
88
+ See the TypeScript documentation for more information.
89
+
90
+ This enables the following compiler options:
91
+
92
+ - [verbatimModuleSyntax](https://www.typescriptlang.org/tsconfig#verbatimModuleSyntax)
93
+
94
+ You can view the content of this tsconfig [here](https://github.com/josh-development/utilities/blob/main/packages/ts-config/src/verbatim.json)
95
+
96
+ ### Bundler
97
+
98
+ You may include this config if bundle your code with a bundler such as [tsup], [esbuild], [swc] or something else. This
99
+ config sets [`moduleResolution` to `Bundler`][moduleResolution] and [`module` to `ES2022`][module]. This will likely also allow you to enable
100
+ [Verbatim](#verbatim).
101
+
102
+ This configures the following compiler options:
103
+
104
+ - [`moduleResolution` to `Bundler`][moduleResolution]
105
+ - [`module` to `ES2022`][module]
106
+
107
+ You can view the content of this tsconfig [here](https://github.com/josh-development/utilities/blob/main/packages/ts-config/src/bundler.json)
108
+
109
+ [module]: https://www.typescriptlang.org/tsconfig#module
110
+ [moduleResolution]: https://www.typescriptlang.org/tsconfig#moduleResolution
111
+ [tsup]: https://tsup.egoist.dev
112
+ [esbuild]: https://esbuild.github.io
113
+ [swc]: https://swc.rs
package/package.json CHANGED
@@ -1,15 +1,43 @@
1
1
  {
2
2
  "name": "@joshdb/ts-config",
3
- "version": "1.1.0-pr-148.dc48f31.0",
3
+ "version": "2.0.0-next.e492223.0",
4
4
  "description": "Standard TypeScript config for the Josh Project",
5
5
  "author": "Évelyne Lachance <eslachance@gmail.com> (https://evie.codes/)",
6
6
  "contributors": [
7
7
  "Hezekiah Hendry <hezekiah.hendry@gmail.com>"
8
8
  ],
9
- "main": "tsconfig.json",
9
+ "main": "src/tsconfig.json",
10
10
  "exports": {
11
- "import": "./tsconfig.json",
12
- "require": "./tsconfig.json"
11
+ ".": {
12
+ "types": "./src/tsconfig.json",
13
+ "import": "./src/tsconfig.json",
14
+ "require": "./src/tsconfig.json"
15
+ },
16
+ "./base": {
17
+ "types": "./src/tsconfig.json",
18
+ "import": "./src/tsconfig.json",
19
+ "require": "./src/tsconfig.json"
20
+ },
21
+ "./decorators": {
22
+ "types": "./src/decorators.json",
23
+ "import": "./src/decorators.json",
24
+ "require": "./src/decorators.json"
25
+ },
26
+ "./extra-strict": {
27
+ "types": "./src/extra-strict.json",
28
+ "import": "./src/extra-strict.json",
29
+ "require": "./src/extra-strict.json"
30
+ },
31
+ "./verbatim": {
32
+ "types": "./src/verbatim.json",
33
+ "import": "./src/verbatim.json",
34
+ "require": "./src/verbatim.json"
35
+ },
36
+ "./bundler": {
37
+ "types": "./src/bundler.json",
38
+ "import": "./src/bundler.json",
39
+ "require": "./src/bundler.json"
40
+ }
13
41
  },
14
42
  "sideEffects": false,
15
43
  "scripts": {
@@ -17,23 +45,24 @@
17
45
  "check-update": "cliff-jumper --dry-run"
18
46
  },
19
47
  "dependencies": {
20
- "@sapphire/ts-config": "^3.3.4"
48
+ "@sapphire/ts-config": "^5.0.1",
49
+ "tslib": "^2.6.2",
50
+ "typescript": "^5.4.4"
21
51
  },
22
52
  "devDependencies": {
23
- "@favware/cliff-jumper": "^1.9.0",
24
- "gen-esm-wrapper": "^1.1.3",
25
- "typedoc": "^0.23.23",
26
- "typedoc-json-parser": "^7.0.2"
53
+ "@favware/cliff-jumper": "^3.0.1",
54
+ "typedoc": "^0.25.12",
55
+ "typedoc-json-parser": "^9.0.1"
27
56
  },
28
57
  "repository": {
29
58
  "type": "git",
30
59
  "url": "git+https://github.com/josh-development/utilities.git"
31
60
  },
32
61
  "files": [
33
- "tsconfig.json"
62
+ "src"
34
63
  ],
35
64
  "engines": {
36
- "node": ">=16.6.0",
65
+ "node": ">=20",
37
66
  "npm": ">=7"
38
67
  },
39
68
  "keywords": [
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/tsconfig.json",
3
+ "compilerOptions": {
4
+ "module": "ES2022",
5
+ "moduleResolution": "Bundler"
6
+ }
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/tsconfig.json",
3
+ "compilerOptions": {
4
+ "emitDecoratorMetadata": true,
5
+ "experimentalDecorators": true
6
+ }
7
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/tsconfig.json",
3
+ "compilerOptions": {
4
+ "allowUnreachableCode": false,
5
+ "allowUnusedLabels": false,
6
+ "exactOptionalPropertyTypes": false,
7
+ "noImplicitOverride": true
8
+ }
9
+ }
@@ -1,10 +1,9 @@
1
1
  {
2
- "extends": "@sapphire/ts-config/extra-strict",
2
+ "extends": "@sapphire/ts-config",
3
3
  "compilerOptions": {
4
4
  "importHelpers": true,
5
5
  "noEmitHelpers": true,
6
6
  "lib": ["ESNext"],
7
- "target": "ES2021",
8
- "module": "ESNext"
7
+ "target": "ES2022"
9
8
  }
10
9
  }
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/tsconfig.json",
3
+ "compilerOptions": {
4
+ "verbatimModuleSyntax": true
5
+ }
6
+ }