type-fest 2.11.1 → 2.12.1
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/package.json +1 -1
- package/readme.md +21 -1
- package/source/package-json.d.ts +18 -2
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -185,7 +185,7 @@ Click the type names for complete docs.
|
|
|
185
185
|
|
|
186
186
|
### Miscellaneous
|
|
187
187
|
|
|
188
|
-
- [`PackageJson`](source/package-json.d.ts) - Type for [npm's `package.json` file](https://docs.npmjs.com/creating-a-package-json-file).
|
|
188
|
+
- [`PackageJson`](source/package-json.d.ts) - Type for [npm's `package.json` file](https://docs.npmjs.com/creating-a-package-json-file). It also includes support for [TypeScript Declaration Files](https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html) and [Yarn Workspaces](https://classic.yarnpkg.com/lang/en/docs/workspaces/).
|
|
189
189
|
- [`TsConfigJson`](source/tsconfig-json.d.ts) - Type for [TypeScript's `tsconfig.json` file](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) (TypeScript 4.4).
|
|
190
190
|
|
|
191
191
|
## Declined types
|
|
@@ -199,6 +199,7 @@ Click the type names for complete docs.
|
|
|
199
199
|
- [`Nullish`](https://github.com/sindresorhus/type-fest/pull/318) - The type only saves a couple of characters, not everyone knows what "nullish" means, and I'm also trying to [get away from `null`](https://github.com/sindresorhus/meta/discussions/7).
|
|
200
200
|
- [`TitleCase`](https://github.com/sindresorhus/type-fest/pull/303) - It's not solving a common need and is a better fit for a separate package.
|
|
201
201
|
- [`ExtendOr` and `ExtendAnd`](https://github.com/sindresorhus/type-fest/pull/247) - The benefits don't outweigh having to learn what they mean.
|
|
202
|
+
- [`PackageJsonExtras`](https://github.com/sindresorhus/type-fest/issues/371) - There are too many possible configurations that can be put into `package.json`. If you would like to extend `PackageJson` to support an additional configuration in your project, please see the *Extending existing types* section below.
|
|
202
203
|
|
|
203
204
|
## Alternative type names
|
|
204
205
|
|
|
@@ -209,9 +210,28 @@ Click the type names for complete docs.
|
|
|
209
210
|
|
|
210
211
|
## Tips
|
|
211
212
|
|
|
213
|
+
### Extending existing types
|
|
214
|
+
|
|
215
|
+
- [`PackageJson`](source/package-json.d.ts) - There are a lot of tools that place extra configurations inside the `package.json` file. You can extend `PackageJson` to support these additional configurations.
|
|
216
|
+
<details>
|
|
217
|
+
<summary>
|
|
218
|
+
Example
|
|
219
|
+
</summary>
|
|
220
|
+
|
|
221
|
+
[Playground](https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBDAnmApnA3gBQIYGMDW2A5igFIDOEAdnNuXAEJ0o4HFmVUC+cAZlBBBwA5ElQBaXinIxhAbgCwAKFCRYCZGnQAZYFRgooPfoJHSANntmKlysWlaESFanAC8jZo-YuaAMgwLKwBhal5gIgB+AC44XX1DADpQqnCiLhsgA)
|
|
222
|
+
|
|
223
|
+
```ts
|
|
224
|
+
import type {PackageJson as BasePackageJson} from 'type-fest';
|
|
225
|
+
import type {Linter} from 'eslint';
|
|
226
|
+
|
|
227
|
+
type PackageJson = BasePackageJson & {eslintConfig?: Linter.Config};
|
|
228
|
+
```
|
|
229
|
+
</details>
|
|
230
|
+
|
|
212
231
|
### Related
|
|
213
232
|
|
|
214
233
|
- [typed-query-selector](https://github.com/g-plane/typed-query-selector) - Enhances `document.querySelector` and `document.querySelectorAll` with a template literal type that matches element types returned from an HTML element query selector.
|
|
234
|
+
- [`Linter.Config`](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/eslint/index.d.ts) - Definitions for the [ESLint configuration schema](https://eslint.org/docs/user-guide/configuring/language-options).
|
|
215
235
|
|
|
216
236
|
### Built-in types
|
|
217
237
|
|
package/source/package-json.d.ts
CHANGED
|
@@ -214,6 +214,7 @@ declare namespace PackageJson {
|
|
|
214
214
|
| 'import'
|
|
215
215
|
| 'require'
|
|
216
216
|
| 'node'
|
|
217
|
+
| 'node-addons'
|
|
217
218
|
| 'deno'
|
|
218
219
|
| 'browser'
|
|
219
220
|
| 'electron'
|
|
@@ -226,11 +227,19 @@ declare namespace PackageJson {
|
|
|
226
227
|
Entry points of a module, optionally with conditions and subpath exports.
|
|
227
228
|
*/
|
|
228
229
|
export type Exports =
|
|
230
|
+
| null
|
|
229
231
|
| string
|
|
230
232
|
| string[]
|
|
231
233
|
| {[key in ExportCondition]: Exports}
|
|
232
234
|
| {[key: string]: Exports}; // eslint-disable-line @typescript-eslint/consistent-indexed-object-style
|
|
233
235
|
|
|
236
|
+
/**
|
|
237
|
+
Import map entries of a module, optionally with conditions.
|
|
238
|
+
*/
|
|
239
|
+
export type Imports = { // eslint-disable-line @typescript-eslint/consistent-indexed-object-style
|
|
240
|
+
[key: string]: string | {[key in ExportCondition]: Exports};
|
|
241
|
+
};
|
|
242
|
+
|
|
234
243
|
export interface NonStandardEntryPoints {
|
|
235
244
|
/**
|
|
236
245
|
An ECMAScript module ID that is the primary entry point to the program.
|
|
@@ -415,12 +424,19 @@ declare namespace PackageJson {
|
|
|
415
424
|
main?: string;
|
|
416
425
|
|
|
417
426
|
/**
|
|
418
|
-
|
|
427
|
+
Subpath exports to define entry points of the package.
|
|
419
428
|
|
|
420
|
-
[Read more.](https://nodejs.org/api/
|
|
429
|
+
[Read more.](https://nodejs.org/api/packages.html#subpath-exports)
|
|
421
430
|
*/
|
|
422
431
|
exports?: Exports;
|
|
423
432
|
|
|
433
|
+
/**
|
|
434
|
+
Subpath imports to define internal package import maps that only apply to import specifiers from within the package itself.
|
|
435
|
+
|
|
436
|
+
[Read more.](https://nodejs.org/api/packages.html#subpath-imports)
|
|
437
|
+
*/
|
|
438
|
+
imports?: Imports;
|
|
439
|
+
|
|
424
440
|
/**
|
|
425
441
|
The executable files that should be installed into the `PATH`.
|
|
426
442
|
*/
|