@alexlit/lint-kit 182.2.0 → 182.3.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.
Files changed (409) hide show
  1. package/package.json +1 -1
  2. package/packages/config-eslint/package.json +3 -3
  3. package/packages/config-hooks/package.json +2 -2
  4. package/packages/config-stylelint/package.json +2 -2
  5. package/packages/config-stylelint/node_modules/ansi-regex/index.d.ts +0 -33
  6. package/packages/config-stylelint/node_modules/ansi-regex/index.js +0 -14
  7. package/packages/config-stylelint/node_modules/ansi-regex/license +0 -9
  8. package/packages/config-stylelint/node_modules/ansi-regex/package.json +0 -61
  9. package/packages/config-stylelint/node_modules/ansi-regex/readme.md +0 -66
  10. package/packages/config-stylelint/node_modules/file-entry-cache/LICENSE +0 -19
  11. package/packages/config-stylelint/node_modules/file-entry-cache/README.md +0 -630
  12. package/packages/config-stylelint/node_modules/file-entry-cache/dist/index.cjs +0 -559
  13. package/packages/config-stylelint/node_modules/file-entry-cache/dist/index.d.cts +0 -304
  14. package/packages/config-stylelint/node_modules/file-entry-cache/dist/index.d.ts +0 -304
  15. package/packages/config-stylelint/node_modules/file-entry-cache/dist/index.js +0 -525
  16. package/packages/config-stylelint/node_modules/file-entry-cache/package.json +0 -62
  17. package/packages/config-stylelint/node_modules/flat-cache/LICENSE +0 -19
  18. package/packages/config-stylelint/node_modules/flat-cache/README.md +0 -235
  19. package/packages/config-stylelint/node_modules/flat-cache/dist/index.cjs +0 -495
  20. package/packages/config-stylelint/node_modules/flat-cache/dist/index.d.cts +0 -255
  21. package/packages/config-stylelint/node_modules/flat-cache/dist/index.d.ts +0 -255
  22. package/packages/config-stylelint/node_modules/flat-cache/dist/index.js +0 -455
  23. package/packages/config-stylelint/node_modules/flat-cache/package.json +0 -87
  24. package/packages/config-stylelint/node_modules/globby/ignore.js +0 -337
  25. package/packages/config-stylelint/node_modules/globby/index.d.ts +0 -394
  26. package/packages/config-stylelint/node_modules/globby/index.js +0 -488
  27. package/packages/config-stylelint/node_modules/globby/license +0 -9
  28. package/packages/config-stylelint/node_modules/globby/package.json +0 -94
  29. package/packages/config-stylelint/node_modules/globby/readme.md +0 -388
  30. package/packages/config-stylelint/node_modules/globby/utilities.js +0 -382
  31. package/packages/config-stylelint/node_modules/meow/build/dependencies.js +0 -7347
  32. package/packages/config-stylelint/node_modules/meow/build/index.d.ts +0 -2684
  33. package/packages/config-stylelint/node_modules/meow/build/index.js +0 -185
  34. package/packages/config-stylelint/node_modules/meow/build/licenses.md +0 -1254
  35. package/packages/config-stylelint/node_modules/meow/build/options.js +0 -147
  36. package/packages/config-stylelint/node_modules/meow/build/parser.js +0 -113
  37. package/packages/config-stylelint/node_modules/meow/build/utils.js +0 -7
  38. package/packages/config-stylelint/node_modules/meow/build/validate.js +0 -145
  39. package/packages/config-stylelint/node_modules/meow/license +0 -9
  40. package/packages/config-stylelint/node_modules/meow/package.json +0 -103
  41. package/packages/config-stylelint/node_modules/meow/readme.md +0 -387
  42. package/packages/config-stylelint/node_modules/postcss-safe-parser/LICENSE +0 -20
  43. package/packages/config-stylelint/node_modules/postcss-safe-parser/README.md +0 -25
  44. package/packages/config-stylelint/node_modules/postcss-safe-parser/lib/safe-parse.js +0 -12
  45. package/packages/config-stylelint/node_modules/postcss-safe-parser/lib/safe-parser.js +0 -100
  46. package/packages/config-stylelint/node_modules/postcss-safe-parser/package.json +0 -36
  47. package/packages/config-stylelint/node_modules/slash/index.d.ts +0 -23
  48. package/packages/config-stylelint/node_modules/slash/index.js +0 -9
  49. package/packages/config-stylelint/node_modules/slash/license +0 -9
  50. package/packages/config-stylelint/node_modules/slash/package.json +0 -39
  51. package/packages/config-stylelint/node_modules/slash/readme.md +0 -36
  52. package/packages/config-stylelint/node_modules/string-width/index.d.ts +0 -39
  53. package/packages/config-stylelint/node_modules/string-width/index.js +0 -119
  54. package/packages/config-stylelint/node_modules/string-width/license +0 -9
  55. package/packages/config-stylelint/node_modules/string-width/package.json +0 -65
  56. package/packages/config-stylelint/node_modules/string-width/readme.md +0 -66
  57. package/packages/config-stylelint/node_modules/strip-ansi/index.d.ts +0 -15
  58. package/packages/config-stylelint/node_modules/strip-ansi/index.js +0 -19
  59. package/packages/config-stylelint/node_modules/strip-ansi/license +0 -9
  60. package/packages/config-stylelint/node_modules/strip-ansi/package.json +0 -59
  61. package/packages/config-stylelint/node_modules/strip-ansi/readme.md +0 -37
  62. package/packages/config-stylelint/node_modules/stylelint/LICENSE +0 -20
  63. package/packages/config-stylelint/node_modules/stylelint/README.md +0 -113
  64. package/packages/config-stylelint/node_modules/stylelint/bin/stylelint.mjs +0 -7
  65. package/packages/config-stylelint/node_modules/stylelint/lib/assignDisabledRanges.mjs +0 -483
  66. package/packages/config-stylelint/node_modules/stylelint/lib/augmentConfig.mjs +0 -586
  67. package/packages/config-stylelint/node_modules/stylelint/lib/cli.mjs +0 -746
  68. package/packages/config-stylelint/node_modules/stylelint/lib/constants.mjs +0 -25
  69. package/packages/config-stylelint/node_modules/stylelint/lib/createPartialStylelintResult.mjs +0 -114
  70. package/packages/config-stylelint/node_modules/stylelint/lib/createPlugin.mjs +0 -9
  71. package/packages/config-stylelint/node_modules/stylelint/lib/createStylelint.mjs +0 -37
  72. package/packages/config-stylelint/node_modules/stylelint/lib/descriptionlessDisables.mjs +0 -51
  73. package/packages/config-stylelint/node_modules/stylelint/lib/formatters/calcSeverityCounts.mjs +0 -21
  74. package/packages/config-stylelint/node_modules/stylelint/lib/formatters/compactFormatter.mjs +0 -23
  75. package/packages/config-stylelint/node_modules/stylelint/lib/formatters/index.mjs +0 -23
  76. package/packages/config-stylelint/node_modules/stylelint/lib/formatters/jsonFormatter.mjs +0 -10
  77. package/packages/config-stylelint/node_modules/stylelint/lib/formatters/preprocessWarnings.mjs +0 -74
  78. package/packages/config-stylelint/node_modules/stylelint/lib/formatters/stringFormatter.mjs +0 -308
  79. package/packages/config-stylelint/node_modules/stylelint/lib/formatters/tapFormatter.mjs +0 -85
  80. package/packages/config-stylelint/node_modules/stylelint/lib/formatters/terminalLink.mjs +0 -21
  81. package/packages/config-stylelint/node_modules/stylelint/lib/formatters/unixFormatter.mjs +0 -32
  82. package/packages/config-stylelint/node_modules/stylelint/lib/formatters/verboseFormatter.mjs +0 -175
  83. package/packages/config-stylelint/node_modules/stylelint/lib/getConfigForFile.mjs +0 -110
  84. package/packages/config-stylelint/node_modules/stylelint/lib/getPostcssResult.mjs +0 -130
  85. package/packages/config-stylelint/node_modules/stylelint/lib/index.mjs +0 -38
  86. package/packages/config-stylelint/node_modules/stylelint/lib/invalidScopeDisables.mjs +0 -41
  87. package/packages/config-stylelint/node_modules/stylelint/lib/isPathIgnored.mjs +0 -48
  88. package/packages/config-stylelint/node_modules/stylelint/lib/lintPostcssResult.mjs +0 -172
  89. package/packages/config-stylelint/node_modules/stylelint/lib/lintSource.mjs +0 -135
  90. package/packages/config-stylelint/node_modules/stylelint/lib/needlessDisables.mjs +0 -91
  91. package/packages/config-stylelint/node_modules/stylelint/lib/normalizeAllRuleSettings.mjs +0 -29
  92. package/packages/config-stylelint/node_modules/stylelint/lib/normalizeRuleSettings.mjs +0 -56
  93. package/packages/config-stylelint/node_modules/stylelint/lib/postcssPlugin.mjs +0 -50
  94. package/packages/config-stylelint/node_modules/stylelint/lib/prepareReturnValue.mjs +0 -63
  95. package/packages/config-stylelint/node_modules/stylelint/lib/printConfig.mjs +0 -44
  96. package/packages/config-stylelint/node_modules/stylelint/lib/reference/atKeywords.mjs +0 -83
  97. package/packages/config-stylelint/node_modules/stylelint/lib/reference/functions.mjs +0 -96
  98. package/packages/config-stylelint/node_modules/stylelint/lib/reference/keywords.mjs +0 -663
  99. package/packages/config-stylelint/node_modules/stylelint/lib/reference/mediaFeatures.mjs +0 -115
  100. package/packages/config-stylelint/node_modules/stylelint/lib/reference/mediaTypes.mjs +0 -14
  101. package/packages/config-stylelint/node_modules/stylelint/lib/reference/prefixes.mjs +0 -17
  102. package/packages/config-stylelint/node_modules/stylelint/lib/reference/properties.mjs +0 -1112
  103. package/packages/config-stylelint/node_modules/stylelint/lib/reference/selectors.mjs +0 -472
  104. package/packages/config-stylelint/node_modules/stylelint/lib/reference/units.mjs +0 -82
  105. package/packages/config-stylelint/node_modules/stylelint/lib/reportDisables.mjs +0 -48
  106. package/packages/config-stylelint/node_modules/stylelint/lib/reportUnknownRuleNames.mjs +0 -76
  107. package/packages/config-stylelint/node_modules/stylelint/lib/resolveConfig.mjs +0 -43
  108. package/packages/config-stylelint/node_modules/stylelint/lib/rules/alpha-value-notation/index.mjs +0 -207
  109. package/packages/config-stylelint/node_modules/stylelint/lib/rules/annotation-no-unknown/index.mjs +0 -88
  110. package/packages/config-stylelint/node_modules/stylelint/lib/rules/at-rule-allowed-list/index.mjs +0 -62
  111. package/packages/config-stylelint/node_modules/stylelint/lib/rules/at-rule-descriptor-no-unknown/index.mjs +0 -108
  112. package/packages/config-stylelint/node_modules/stylelint/lib/rules/at-rule-descriptor-value-no-unknown/index.mjs +0 -64
  113. package/packages/config-stylelint/node_modules/stylelint/lib/rules/at-rule-disallowed-list/index.mjs +0 -62
  114. package/packages/config-stylelint/node_modules/stylelint/lib/rules/at-rule-empty-line-before/index.mjs +0 -178
  115. package/packages/config-stylelint/node_modules/stylelint/lib/rules/at-rule-no-deprecated/index.mjs +0 -86
  116. package/packages/config-stylelint/node_modules/stylelint/lib/rules/at-rule-no-unknown/index.mjs +0 -80
  117. package/packages/config-stylelint/node_modules/stylelint/lib/rules/at-rule-no-vendor-prefix/index.mjs +0 -82
  118. package/packages/config-stylelint/node_modules/stylelint/lib/rules/at-rule-prelude-no-invalid/index.mjs +0 -76
  119. package/packages/config-stylelint/node_modules/stylelint/lib/rules/at-rule-property-required-list/index.mjs +0 -92
  120. package/packages/config-stylelint/node_modules/stylelint/lib/rules/block-no-empty/index.mjs +0 -116
  121. package/packages/config-stylelint/node_modules/stylelint/lib/rules/block-no-redundant-nested-style-rules/index.mjs +0 -52
  122. package/packages/config-stylelint/node_modules/stylelint/lib/rules/color-function-alias-notation/index.mjs +0 -87
  123. package/packages/config-stylelint/node_modules/stylelint/lib/rules/color-function-notation/index.mjs +0 -168
  124. package/packages/config-stylelint/node_modules/stylelint/lib/rules/color-hex-alpha/index.mjs +0 -75
  125. package/packages/config-stylelint/node_modules/stylelint/lib/rules/color-hex-length/index.mjs +0 -128
  126. package/packages/config-stylelint/node_modules/stylelint/lib/rules/color-named/colordUtils.mjs +0 -109
  127. package/packages/config-stylelint/node_modules/stylelint/lib/rules/color-named/index.mjs +0 -183
  128. package/packages/config-stylelint/node_modules/stylelint/lib/rules/color-no-hex/index.mjs +0 -69
  129. package/packages/config-stylelint/node_modules/stylelint/lib/rules/color-no-invalid-hex/index.mjs +0 -68
  130. package/packages/config-stylelint/node_modules/stylelint/lib/rules/comment-empty-line-before/index.mjs +0 -131
  131. package/packages/config-stylelint/node_modules/stylelint/lib/rules/comment-no-empty/index.mjs +0 -50
  132. package/packages/config-stylelint/node_modules/stylelint/lib/rules/comment-pattern/index.mjs +0 -51
  133. package/packages/config-stylelint/node_modules/stylelint/lib/rules/comment-whitespace-inside/index.mjs +0 -149
  134. package/packages/config-stylelint/node_modules/stylelint/lib/rules/comment-word-disallowed-list/index.mjs +0 -63
  135. package/packages/config-stylelint/node_modules/stylelint/lib/rules/container-name-pattern/index.mjs +0 -107
  136. package/packages/config-stylelint/node_modules/stylelint/lib/rules/custom-media-pattern/index.mjs +0 -61
  137. package/packages/config-stylelint/node_modules/stylelint/lib/rules/custom-property-empty-line-before/index.mjs +0 -156
  138. package/packages/config-stylelint/node_modules/stylelint/lib/rules/custom-property-no-missing-var-function/index.mjs +0 -148
  139. package/packages/config-stylelint/node_modules/stylelint/lib/rules/custom-property-pattern/index.mjs +0 -100
  140. package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-block-no-duplicate-custom-properties/index.mjs +0 -82
  141. package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-block-no-duplicate-properties/index.mjs +0 -301
  142. package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-block-no-redundant-longhand-properties/index.mjs +0 -411
  143. package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-block-no-shorthand-property-overrides/index.mjs +0 -74
  144. package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-block-single-line-max-declarations/index.mjs +0 -62
  145. package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-empty-line-before/index.mjs +0 -160
  146. package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-no-important/index.mjs +0 -51
  147. package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-property-max-values/index.mjs +0 -79
  148. package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-property-unit-allowed-list/index.mjs +0 -108
  149. package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-property-unit-disallowed-list/index.mjs +0 -94
  150. package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-property-value-allowed-list/index.mjs +0 -66
  151. package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-property-value-disallowed-list/index.mjs +0 -66
  152. package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-property-value-keyword-no-deprecated/index.mjs +0 -203
  153. package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-property-value-no-unknown/index.mjs +0 -424
  154. package/packages/config-stylelint/node_modules/stylelint/lib/rules/display-notation/index.mjs +0 -225
  155. package/packages/config-stylelint/node_modules/stylelint/lib/rules/font-family-name-quotes/index.mjs +0 -243
  156. package/packages/config-stylelint/node_modules/stylelint/lib/rules/font-family-no-duplicate-names/index.mjs +0 -122
  157. package/packages/config-stylelint/node_modules/stylelint/lib/rules/font-family-no-missing-generic-family-keyword/index.mjs +0 -122
  158. package/packages/config-stylelint/node_modules/stylelint/lib/rules/font-weight-notation/index.mjs +0 -221
  159. package/packages/config-stylelint/node_modules/stylelint/lib/rules/function-allowed-list/index.mjs +0 -114
  160. package/packages/config-stylelint/node_modules/stylelint/lib/rules/function-calc-no-unspaced-operator/index.mjs +0 -589
  161. package/packages/config-stylelint/node_modules/stylelint/lib/rules/function-disallowed-list/index.mjs +0 -73
  162. package/packages/config-stylelint/node_modules/stylelint/lib/rules/function-linear-gradient-no-nonstandard-direction/index.mjs +0 -145
  163. package/packages/config-stylelint/node_modules/stylelint/lib/rules/function-name-case/index.mjs +0 -120
  164. package/packages/config-stylelint/node_modules/stylelint/lib/rules/function-no-unknown/index.mjs +0 -83
  165. package/packages/config-stylelint/node_modules/stylelint/lib/rules/function-url-no-scheme-relative/index.mjs +0 -67
  166. package/packages/config-stylelint/node_modules/stylelint/lib/rules/function-url-quotes/index.mjs +0 -230
  167. package/packages/config-stylelint/node_modules/stylelint/lib/rules/function-url-scheme-allowed-list/index.mjs +0 -70
  168. package/packages/config-stylelint/node_modules/stylelint/lib/rules/function-url-scheme-disallowed-list/index.mjs +0 -70
  169. package/packages/config-stylelint/node_modules/stylelint/lib/rules/hue-degree-notation/index.mjs +0 -123
  170. package/packages/config-stylelint/node_modules/stylelint/lib/rules/import-notation/index.mjs +0 -104
  171. package/packages/config-stylelint/node_modules/stylelint/lib/rules/index.mjs +0 -180
  172. package/packages/config-stylelint/node_modules/stylelint/lib/rules/keyframe-block-no-duplicate-selectors/index.mjs +0 -68
  173. package/packages/config-stylelint/node_modules/stylelint/lib/rules/keyframe-declaration-no-important/index.mjs +0 -54
  174. package/packages/config-stylelint/node_modules/stylelint/lib/rules/keyframe-selector-notation/index.mjs +0 -202
  175. package/packages/config-stylelint/node_modules/stylelint/lib/rules/keyframes-name-pattern/index.mjs +0 -63
  176. package/packages/config-stylelint/node_modules/stylelint/lib/rules/layer-name-pattern/index.mjs +0 -91
  177. package/packages/config-stylelint/node_modules/stylelint/lib/rules/length-zero-no-unit/index.mjs +0 -221
  178. package/packages/config-stylelint/node_modules/stylelint/lib/rules/lightness-notation/index.mjs +0 -165
  179. package/packages/config-stylelint/node_modules/stylelint/lib/rules/max-nesting-depth/index.mjs +0 -195
  180. package/packages/config-stylelint/node_modules/stylelint/lib/rules/media-feature-name-allowed-list/index.mjs +0 -67
  181. package/packages/config-stylelint/node_modules/stylelint/lib/rules/media-feature-name-disallowed-list/index.mjs +0 -67
  182. package/packages/config-stylelint/node_modules/stylelint/lib/rules/media-feature-name-no-unknown/index.mjs +0 -79
  183. package/packages/config-stylelint/node_modules/stylelint/lib/rules/media-feature-name-no-vendor-prefix/index.mjs +0 -94
  184. package/packages/config-stylelint/node_modules/stylelint/lib/rules/media-feature-name-unit-allowed-list/index.mjs +0 -110
  185. package/packages/config-stylelint/node_modules/stylelint/lib/rules/media-feature-name-value-allowed-list/index.mjs +0 -100
  186. package/packages/config-stylelint/node_modules/stylelint/lib/rules/media-feature-name-value-no-unknown/index.mjs +0 -277
  187. package/packages/config-stylelint/node_modules/stylelint/lib/rules/media-feature-range-notation/index.mjs +0 -187
  188. package/packages/config-stylelint/node_modules/stylelint/lib/rules/media-query-no-invalid/index.mjs +0 -193
  189. package/packages/config-stylelint/node_modules/stylelint/lib/rules/media-type-no-deprecated/index.mjs +0 -82
  190. package/packages/config-stylelint/node_modules/stylelint/lib/rules/named-grid-areas-no-invalid/index.mjs +0 -117
  191. package/packages/config-stylelint/node_modules/stylelint/lib/rules/named-grid-areas-no-invalid/utils/findNotContiguousOrRectangular.mjs +0 -57
  192. package/packages/config-stylelint/node_modules/stylelint/lib/rules/nesting-selector-no-missing-scoping-root/index.mjs +0 -165
  193. package/packages/config-stylelint/node_modules/stylelint/lib/rules/no-descending-specificity/index.mjs +0 -200
  194. package/packages/config-stylelint/node_modules/stylelint/lib/rules/no-duplicate-at-import-rules/index.mjs +0 -156
  195. package/packages/config-stylelint/node_modules/stylelint/lib/rules/no-duplicate-selectors/index.mjs +0 -218
  196. package/packages/config-stylelint/node_modules/stylelint/lib/rules/no-empty-source/index.mjs +0 -61
  197. package/packages/config-stylelint/node_modules/stylelint/lib/rules/no-invalid-double-slash-comments/index.mjs +0 -77
  198. package/packages/config-stylelint/node_modules/stylelint/lib/rules/no-invalid-position-at-import-rule/index.mjs +0 -76
  199. package/packages/config-stylelint/node_modules/stylelint/lib/rules/no-invalid-position-declaration/index.mjs +0 -86
  200. package/packages/config-stylelint/node_modules/stylelint/lib/rules/no-irregular-whitespace/index.mjs +0 -236
  201. package/packages/config-stylelint/node_modules/stylelint/lib/rules/no-unknown-animations/index.mjs +0 -71
  202. package/packages/config-stylelint/node_modules/stylelint/lib/rules/no-unknown-custom-media/index.mjs +0 -77
  203. package/packages/config-stylelint/node_modules/stylelint/lib/rules/no-unknown-custom-properties/index.mjs +0 -72
  204. package/packages/config-stylelint/node_modules/stylelint/lib/rules/number-max-precision/index.mjs +0 -209
  205. package/packages/config-stylelint/node_modules/stylelint/lib/rules/property-allowed-list/index.mjs +0 -58
  206. package/packages/config-stylelint/node_modules/stylelint/lib/rules/property-disallowed-list/index.mjs +0 -58
  207. package/packages/config-stylelint/node_modules/stylelint/lib/rules/property-no-deprecated/index.mjs +0 -143
  208. package/packages/config-stylelint/node_modules/stylelint/lib/rules/property-no-unknown/index.mjs +0 -126
  209. package/packages/config-stylelint/node_modules/stylelint/lib/rules/property-no-vendor-prefix/index.mjs +0 -100
  210. package/packages/config-stylelint/node_modules/stylelint/lib/rules/rule-empty-line-before/index.mjs +0 -156
  211. package/packages/config-stylelint/node_modules/stylelint/lib/rules/rule-nesting-at-rule-required-list/index.mjs +0 -85
  212. package/packages/config-stylelint/node_modules/stylelint/lib/rules/rule-selector-property-disallowed-list/index.mjs +0 -119
  213. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-anb-no-unmatchable/index.mjs +0 -121
  214. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-attribute-name-disallowed-list/index.mjs +0 -69
  215. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-attribute-operator-allowed-list/index.mjs +0 -70
  216. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-attribute-operator-disallowed-list/index.mjs +0 -70
  217. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-attribute-quotes/index.mjs +0 -107
  218. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-class-pattern/index.mjs +0 -71
  219. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-combinator-allowed-list/index.mjs +0 -81
  220. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-combinator-disallowed-list/index.mjs +0 -81
  221. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-disallowed-list/index.mjs +0 -115
  222. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-id-pattern/index.mjs +0 -66
  223. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-max-attribute/index.mjs +0 -92
  224. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-max-class/index.mjs +0 -75
  225. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-max-combinators/index.mjs +0 -77
  226. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-max-compound-selectors/index.mjs +0 -123
  227. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-max-id/index.mjs +0 -107
  228. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-max-pseudo-class/index.mjs +0 -85
  229. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-max-specificity/index.mjs +0 -146
  230. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-max-type/index.mjs +0 -219
  231. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-max-universal/index.mjs +0 -95
  232. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-nested-pattern/index.mjs +0 -95
  233. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-no-qualifying-type/index.mjs +0 -323
  234. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-no-vendor-prefix/index.mjs +0 -92
  235. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-not-notation/index.mjs +0 -217
  236. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-pseudo-class-allowed-list/index.mjs +0 -84
  237. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-pseudo-class-disallowed-list/index.mjs +0 -84
  238. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-pseudo-class-no-unknown/index.mjs +0 -179
  239. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-pseudo-element-allowed-list/index.mjs +0 -75
  240. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-pseudo-element-colon-notation/index.mjs +0 -93
  241. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-pseudo-element-disallowed-list/index.mjs +0 -74
  242. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-pseudo-element-no-unknown/index.mjs +0 -91
  243. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-type-case/index.mjs +0 -118
  244. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-type-no-unknown/index.mjs +0 -148
  245. package/packages/config-stylelint/node_modules/stylelint/lib/rules/shorthand-property-no-redundant-values/index.mjs +0 -359
  246. package/packages/config-stylelint/node_modules/stylelint/lib/rules/string-no-newline/index.mjs +0 -120
  247. package/packages/config-stylelint/node_modules/stylelint/lib/rules/syntax-string-no-invalid/index.mjs +0 -80
  248. package/packages/config-stylelint/node_modules/stylelint/lib/rules/time-min-milliseconds/index.mjs +0 -167
  249. package/packages/config-stylelint/node_modules/stylelint/lib/rules/unit-allowed-list/index.mjs +0 -116
  250. package/packages/config-stylelint/node_modules/stylelint/lib/rules/unit-disallowed-list/index.mjs +0 -211
  251. package/packages/config-stylelint/node_modules/stylelint/lib/rules/unit-no-unknown/index.mjs +0 -207
  252. package/packages/config-stylelint/node_modules/stylelint/lib/rules/value-keyword-case/index.mjs +0 -253
  253. package/packages/config-stylelint/node_modules/stylelint/lib/rules/value-no-vendor-prefix/index.mjs +0 -92
  254. package/packages/config-stylelint/node_modules/stylelint/lib/standalone.mjs +0 -381
  255. package/packages/config-stylelint/node_modules/stylelint/lib/timing.mjs +0 -134
  256. package/packages/config-stylelint/node_modules/stylelint/lib/unscopedDisables.mjs +0 -66
  257. package/packages/config-stylelint/node_modules/stylelint/lib/utils/FileCache.mjs +0 -115
  258. package/packages/config-stylelint/node_modules/stylelint/lib/utils/addEmptyLineBefore.mjs +0 -21
  259. package/packages/config-stylelint/node_modules/stylelint/lib/utils/addSemicolonForEditInfo.mjs +0 -35
  260. package/packages/config-stylelint/node_modules/stylelint/lib/utils/appendRuleName.mjs +0 -13
  261. package/packages/config-stylelint/node_modules/stylelint/lib/utils/arrayEqual.mjs +0 -14
  262. package/packages/config-stylelint/node_modules/stylelint/lib/utils/beforeBlockString.mjs +0 -28
  263. package/packages/config-stylelint/node_modules/stylelint/lib/utils/blockString.mjs +0 -19
  264. package/packages/config-stylelint/node_modules/stylelint/lib/utils/blurInterpolation.mjs +0 -8
  265. package/packages/config-stylelint/node_modules/stylelint/lib/utils/cachedImport.mjs +0 -68
  266. package/packages/config-stylelint/node_modules/stylelint/lib/utils/checkAgainstRule.mjs +0 -71
  267. package/packages/config-stylelint/node_modules/stylelint/lib/utils/checkInvalidCLIOptions.mjs +0 -105
  268. package/packages/config-stylelint/node_modules/stylelint/lib/utils/configurationComment.mjs +0 -74
  269. package/packages/config-stylelint/node_modules/stylelint/lib/utils/containsString.mjs +0 -52
  270. package/packages/config-stylelint/node_modules/stylelint/lib/utils/createMapWithSet.mjs +0 -19
  271. package/packages/config-stylelint/node_modules/stylelint/lib/utils/dynamicImport.mjs +0 -13
  272. package/packages/config-stylelint/node_modules/stylelint/lib/utils/eachDeclarationBlock.mjs +0 -59
  273. package/packages/config-stylelint/node_modules/stylelint/lib/utils/eachNodeUpToRoot.mjs +0 -22
  274. package/packages/config-stylelint/node_modules/stylelint/lib/utils/emitWarning.mjs +0 -83
  275. package/packages/config-stylelint/node_modules/stylelint/lib/utils/errors.mjs +0 -55
  276. package/packages/config-stylelint/node_modules/stylelint/lib/utils/filterFilePaths.mjs +0 -17
  277. package/packages/config-stylelint/node_modules/stylelint/lib/utils/findAnimationName.mjs +0 -74
  278. package/packages/config-stylelint/node_modules/stylelint/lib/utils/findAtRuleContext.mjs +0 -27
  279. package/packages/config-stylelint/node_modules/stylelint/lib/utils/findFontFamily.mjs +0 -148
  280. package/packages/config-stylelint/node_modules/stylelint/lib/utils/findMediaFeatureNames.mjs +0 -151
  281. package/packages/config-stylelint/node_modules/stylelint/lib/utils/findNodeUpToRoot.mjs +0 -25
  282. package/packages/config-stylelint/node_modules/stylelint/lib/utils/fixEmptyLinesBefore.mjs +0 -26
  283. package/packages/config-stylelint/node_modules/stylelint/lib/utils/functionArgumentsSearch.mjs +0 -64
  284. package/packages/config-stylelint/node_modules/stylelint/lib/utils/getAtRuleParams.mjs +0 -7
  285. package/packages/config-stylelint/node_modules/stylelint/lib/utils/getDeclarationValue.mjs +0 -9
  286. package/packages/config-stylelint/node_modules/stylelint/lib/utils/getDimension.mjs +0 -62
  287. package/packages/config-stylelint/node_modules/stylelint/lib/utils/getFileIgnorer.mjs +0 -41
  288. package/packages/config-stylelint/node_modules/stylelint/lib/utils/getFormatter.mjs +0 -43
  289. package/packages/config-stylelint/node_modules/stylelint/lib/utils/getFormatterOptionsText.mjs +0 -12
  290. package/packages/config-stylelint/node_modules/stylelint/lib/utils/getImportantPosition.mjs +0 -15
  291. package/packages/config-stylelint/node_modules/stylelint/lib/utils/getLexer.mjs +0 -39
  292. package/packages/config-stylelint/node_modules/stylelint/lib/utils/getModulePath.mjs +0 -35
  293. package/packages/config-stylelint/node_modules/stylelint/lib/utils/getNextNonSharedLineCommentNode.mjs +0 -34
  294. package/packages/config-stylelint/node_modules/stylelint/lib/utils/getPreviousNonSharedLineCommentNode.mjs +0 -36
  295. package/packages/config-stylelint/node_modules/stylelint/lib/utils/getRelativePath.mjs +0 -12
  296. package/packages/config-stylelint/node_modules/stylelint/lib/utils/getRuleSelector.mjs +0 -9
  297. package/packages/config-stylelint/node_modules/stylelint/lib/utils/getSchemeFromUrl.mjs +0 -36
  298. package/packages/config-stylelint/node_modules/stylelint/lib/utils/getSelectorSourceIndex.mjs +0 -12
  299. package/packages/config-stylelint/node_modules/stylelint/lib/utils/getStrippedSelectorSource.mjs +0 -47
  300. package/packages/config-stylelint/node_modules/stylelint/lib/utils/getStylelintRule.mjs +0 -22
  301. package/packages/config-stylelint/node_modules/stylelint/lib/utils/hasBlock.mjs +0 -9
  302. package/packages/config-stylelint/node_modules/stylelint/lib/utils/hasEmptyLine.mjs +0 -13
  303. package/packages/config-stylelint/node_modules/stylelint/lib/utils/hasInterpolation.mjs +0 -24
  304. package/packages/config-stylelint/node_modules/stylelint/lib/utils/hasLessInterpolation.mjs +0 -11
  305. package/packages/config-stylelint/node_modules/stylelint/lib/utils/hasPsvInterpolation.mjs +0 -11
  306. package/packages/config-stylelint/node_modules/stylelint/lib/utils/hasScssInterpolation.mjs +0 -11
  307. package/packages/config-stylelint/node_modules/stylelint/lib/utils/hasTplInterpolation.mjs +0 -11
  308. package/packages/config-stylelint/node_modules/stylelint/lib/utils/hash.mjs +0 -10
  309. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isAfterBlock.mjs +0 -15
  310. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isAfterComment.mjs +0 -15
  311. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isAfterSingleLineComment.mjs +0 -19
  312. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isAfterStandardPropertyDeclaration.mjs +0 -19
  313. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isAutoprefixable.mjs +0 -364
  314. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isBlocklessAtRuleAfterBlocklessAtRule.mjs +0 -21
  315. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isBlocklessAtRuleAfterSameNameBlocklessAtRule.mjs +0 -21
  316. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isContextFunctionalPseudoClass.mjs +0 -24
  317. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isCounterIncrementCustomIdentValue.mjs +0 -19
  318. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isCounterResetCustomIdentValue.mjs +0 -19
  319. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isCustomElement.mjs +0 -34
  320. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isCustomFunction.mjs +0 -9
  321. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isCustomMediaQuery.mjs +0 -8
  322. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isCustomProperty.mjs +0 -8
  323. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isCustomSelector.mjs +0 -9
  324. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isDescriptorDeclaration.mjs +0 -22
  325. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isFirstNested.mjs +0 -83
  326. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isFirstNodeOfRoot.mjs +0 -17
  327. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isHexColor.mjs +0 -9
  328. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isInDocument.mjs +0 -32
  329. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isKeyframeRule.mjs +0 -17
  330. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isKeyframeSelector.mjs +0 -29
  331. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isMathFunction.mjs +0 -11
  332. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isNonNegativeInteger.mjs +0 -6
  333. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isNumbery.mjs +0 -9
  334. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isOnlyWhitespace.mjs +0 -17
  335. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isPathNotFoundError.mjs +0 -9
  336. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isScssVariable.mjs +0 -19
  337. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isSharedLineComment.mjs +0 -53
  338. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isSingleLineString.mjs +0 -10
  339. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxAtRule.mjs +0 -32
  340. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxColorFunction.mjs +0 -24
  341. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxCombinator.mjs +0 -32
  342. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxComment.mjs +0 -13
  343. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxDeclaration.mjs +0 -57
  344. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxFunction.mjs +0 -28
  345. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxHexColor.mjs +0 -14
  346. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxKeyframesName.mjs +0 -15
  347. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxProperty.mjs +0 -32
  348. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxRule.mjs +0 -24
  349. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxSelector.mjs +0 -56
  350. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxTypeSelector.mjs +0 -56
  351. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxUrl.mjs +0 -49
  352. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxValue.mjs +0 -51
  353. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isUnicodeRangeDescriptor.mjs +0 -24
  354. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isUnicodeSupported.mjs +0 -26
  355. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isUrlFunction.mjs +0 -9
  356. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isValidFontSize.mjs +0 -38
  357. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isValidHex.mjs +0 -11
  358. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isValidIdentifier.mjs +0 -39
  359. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isVarFunction.mjs +0 -9
  360. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isVariable.mjs +0 -9
  361. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isWhitespace.mjs +0 -9
  362. package/packages/config-stylelint/node_modules/stylelint/lib/utils/matchesStringOrRegExp.mjs +0 -97
  363. package/packages/config-stylelint/node_modules/stylelint/lib/utils/mergeSyntaxDefinitions.mjs +0 -137
  364. package/packages/config-stylelint/node_modules/stylelint/lib/utils/narrowFixRange.mjs +0 -68
  365. package/packages/config-stylelint/node_modules/stylelint/lib/utils/nodeContextLookup.mjs +0 -41
  366. package/packages/config-stylelint/node_modules/stylelint/lib/utils/nodeFieldIndices.mjs +0 -119
  367. package/packages/config-stylelint/node_modules/stylelint/lib/utils/normalizeFilePath.mjs +0 -26
  368. package/packages/config-stylelint/node_modules/stylelint/lib/utils/normalizeFixMode.mjs +0 -22
  369. package/packages/config-stylelint/node_modules/stylelint/lib/utils/normalizeSelector.mjs +0 -166
  370. package/packages/config-stylelint/node_modules/stylelint/lib/utils/optionsMatches.mjs +0 -20
  371. package/packages/config-stylelint/node_modules/stylelint/lib/utils/parseCustomMediaQuery.mjs +0 -15
  372. package/packages/config-stylelint/node_modules/stylelint/lib/utils/parseMediaQuery.mjs +0 -15
  373. package/packages/config-stylelint/node_modules/stylelint/lib/utils/parseSelector.mjs +0 -19
  374. package/packages/config-stylelint/node_modules/stylelint/lib/utils/pathExists.mjs +0 -16
  375. package/packages/config-stylelint/node_modules/stylelint/lib/utils/pluralize.mjs +0 -10
  376. package/packages/config-stylelint/node_modules/stylelint/lib/utils/putIfAbsent.mjs +0 -20
  377. package/packages/config-stylelint/node_modules/stylelint/lib/utils/rangesOverlap.mjs +0 -19
  378. package/packages/config-stylelint/node_modules/stylelint/lib/utils/rawNodeString.mjs +0 -29
  379. package/packages/config-stylelint/node_modules/stylelint/lib/utils/regexes.mjs +0 -135
  380. package/packages/config-stylelint/node_modules/stylelint/lib/utils/removeEmptyLinesBefore.mjs +0 -13
  381. package/packages/config-stylelint/node_modules/stylelint/lib/utils/report.mjs +0 -321
  382. package/packages/config-stylelint/node_modules/stylelint/lib/utils/reportCommentProblem.mjs +0 -39
  383. package/packages/config-stylelint/node_modules/stylelint/lib/utils/resolveFilePath.mjs +0 -38
  384. package/packages/config-stylelint/node_modules/stylelint/lib/utils/resolveNestedSelectorsForRule.mjs +0 -108
  385. package/packages/config-stylelint/node_modules/stylelint/lib/utils/resolveOptionValue.mjs +0 -30
  386. package/packages/config-stylelint/node_modules/stylelint/lib/utils/resolveSilent.mjs +0 -144
  387. package/packages/config-stylelint/node_modules/stylelint/lib/utils/ruleMessages.mjs +0 -18
  388. package/packages/config-stylelint/node_modules/stylelint/lib/utils/setAtRuleParams.mjs +0 -18
  389. package/packages/config-stylelint/node_modules/stylelint/lib/utils/setDeclarationValue.mjs +0 -18
  390. package/packages/config-stylelint/node_modules/stylelint/lib/utils/suppressionsService.mjs +0 -317
  391. package/packages/config-stylelint/node_modules/stylelint/lib/utils/toPath.mjs +0 -23
  392. package/packages/config-stylelint/node_modules/stylelint/lib/utils/typeGuards.mjs +0 -90
  393. package/packages/config-stylelint/node_modules/stylelint/lib/utils/uniteSets.mjs +0 -9
  394. package/packages/config-stylelint/node_modules/stylelint/lib/utils/validateObjectWithArrayProps.mjs +0 -29
  395. package/packages/config-stylelint/node_modules/stylelint/lib/utils/validateObjectWithProps.mjs +0 -28
  396. package/packages/config-stylelint/node_modules/stylelint/lib/utils/validateOptions.mjs +0 -176
  397. package/packages/config-stylelint/node_modules/stylelint/lib/utils/validateTypes.mjs +0 -148
  398. package/packages/config-stylelint/node_modules/stylelint/lib/utils/vendor.mjs +0 -43
  399. package/packages/config-stylelint/node_modules/stylelint/lib/validateDisableSettings.mjs +0 -67
  400. package/packages/config-stylelint/node_modules/stylelint/lib/writeOutputFile.mjs +0 -15
  401. package/packages/config-stylelint/node_modules/stylelint/package.json +0 -212
  402. package/packages/config-stylelint/node_modules/stylelint/types/stylelint/index.d.ts +0 -1590
  403. package/packages/config-stylelint/node_modules/unicorn-magic/default.d.ts +0 -13
  404. package/packages/config-stylelint/node_modules/unicorn-magic/default.js +0 -14
  405. package/packages/config-stylelint/node_modules/unicorn-magic/license +0 -9
  406. package/packages/config-stylelint/node_modules/unicorn-magic/node.d.ts +0 -125
  407. package/packages/config-stylelint/node_modules/unicorn-magic/node.js +0 -49
  408. package/packages/config-stylelint/node_modules/unicorn-magic/package.json +0 -68
  409. package/packages/config-stylelint/node_modules/unicorn-magic/readme.md +0 -31
@@ -1,2684 +0,0 @@
1
- /**
2
- Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
3
-
4
- @category Type
5
- */
6
- type Primitive =
7
- | null
8
- | undefined
9
- | string
10
- | number
11
- | boolean
12
- | symbol
13
- | bigint;
14
-
15
- /**
16
- Matches a JSON object.
17
-
18
- This type can be useful to enforce some input to be JSON-compatible or as a super-type to be extended from. Don't use this as a direct return type as the user would have to double-cast it: `jsonObject as unknown as CustomResponse`. Instead, you could extend your CustomResponse type from it to ensure your type only uses JSON-compatible types: `interface CustomResponse extends JsonObject { … }`.
19
-
20
- @category JSON
21
- */
22
- type JsonObject = {[Key in string]: JsonValue};
23
-
24
- /**
25
- Matches a JSON array.
26
-
27
- @category JSON
28
- */
29
- type JsonArray = JsonValue[] | readonly JsonValue[];
30
-
31
- /**
32
- Matches any valid JSON primitive value.
33
-
34
- @category JSON
35
- */
36
- type JsonPrimitive = string | number | boolean | null;
37
-
38
- /**
39
- Matches any valid JSON value.
40
-
41
- @see `Jsonify` if you need to transform a type to one that is assignable to `JsonValue`.
42
-
43
- @category JSON
44
- */
45
- type JsonValue = JsonPrimitive | JsonObject | JsonArray;
46
-
47
- /**
48
- Returns a boolean for whether the given type is `any`.
49
-
50
- @link https://stackoverflow.com/a/49928360/1490091
51
-
52
- Useful in type utilities, such as disallowing `any`s to be passed to a function.
53
-
54
- @example
55
- ```
56
- import type {IsAny} from 'type-fest';
57
-
58
- const typedObject = {a: 1, b: 2} as const;
59
- const anyObject: any = {a: 1, b: 2};
60
-
61
- function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(object: O, key: K) {
62
- return object[key];
63
- }
64
-
65
- const typedA = get(typedObject, 'a');
66
- //=> 1
67
-
68
- const anyA = get(anyObject, 'a');
69
- //=> any
70
- ```
71
-
72
- @category Type Guard
73
- @category Utilities
74
- */
75
- type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
76
-
77
- /**
78
- Returns a boolean for whether the given key is an optional key of type.
79
-
80
- This is useful when writing utility types or schema validators that need to differentiate `optional` keys.
81
-
82
- @example
83
- ```
84
- import type {IsOptionalKeyOf} from 'type-fest';
85
-
86
- type User = {
87
- name: string;
88
- surname: string;
89
-
90
- luckyNumber?: number;
91
- };
92
-
93
- type Admin = {
94
- name: string;
95
- surname?: string;
96
- };
97
-
98
- type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
99
- //=> true
100
-
101
- type T2 = IsOptionalKeyOf<User, 'name'>;
102
- //=> false
103
-
104
- type T3 = IsOptionalKeyOf<User, 'name' | 'luckyNumber'>;
105
- //=> boolean
106
-
107
- type T4 = IsOptionalKeyOf<User | Admin, 'name'>;
108
- //=> false
109
-
110
- type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
111
- //=> boolean
112
- ```
113
-
114
- @category Type Guard
115
- @category Utilities
116
- */
117
- type IsOptionalKeyOf<Type extends object, Key extends keyof Type> =
118
- IsAny<Type | Key> extends true ? never
119
- : Key extends keyof Type
120
- ? Type extends Record<Key, Type[Key]>
121
- ? false
122
- : true
123
- : false;
124
-
125
- /**
126
- Extract all optional keys from the given type.
127
-
128
- This is useful when you want to create a new type that contains different type values for the optional keys only.
129
-
130
- @example
131
- ```
132
- import type {OptionalKeysOf, Except} from 'type-fest';
133
-
134
- type User = {
135
- name: string;
136
- surname: string;
137
-
138
- luckyNumber?: number;
139
- };
140
-
141
- const REMOVE_FIELD = Symbol('remove field symbol');
142
- type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
143
- [Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
144
- };
145
-
146
- const update1: UpdateOperation<User> = {
147
- name: 'Alice',
148
- };
149
-
150
- const update2: UpdateOperation<User> = {
151
- name: 'Bob',
152
- luckyNumber: REMOVE_FIELD,
153
- };
154
- ```
155
-
156
- @category Utilities
157
- */
158
- type OptionalKeysOf<Type extends object> =
159
- Type extends unknown // For distributing `Type`
160
- ? (keyof {[Key in keyof Type as
161
- IsOptionalKeyOf<Type, Key> extends false
162
- ? never
163
- : Key
164
- ]: never
165
- }) & keyof Type // Intersect with `keyof Type` to ensure result of `OptionalKeysOf<Type>` is always assignable to `keyof Type`
166
- : never; // Should never happen
167
-
168
- /**
169
- Extract all required keys from the given type.
170
-
171
- This is useful when you want to create a new type that contains different type values for the required keys only or use the list of keys for validation purposes, etc...
172
-
173
- @example
174
- ```
175
- import type {RequiredKeysOf} from 'type-fest';
176
-
177
- declare function createValidation<
178
- Entity extends object,
179
- Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>,
180
- >(field: Key, validator: (value: Entity[Key]) => boolean): (entity: Entity) => boolean;
181
-
182
- type User = {
183
- name: string;
184
- surname: string;
185
- luckyNumber?: number;
186
- };
187
-
188
- const validator1 = createValidation<User>('name', value => value.length < 25);
189
- const validator2 = createValidation<User>('surname', value => value.length < 25);
190
-
191
- // @ts-expect-error
192
- const validator3 = createValidation<User>('luckyNumber', value => value > 0);
193
- // Error: Argument of type '"luckyNumber"' is not assignable to parameter of type '"name" | "surname"'.
194
- ```
195
-
196
- @category Utilities
197
- */
198
- type RequiredKeysOf<Type extends object> =
199
- Type extends unknown // For distributing `Type`
200
- ? Exclude<keyof Type, OptionalKeysOf<Type>>
201
- : never; // Should never happen
202
-
203
- /**
204
- Returns a boolean for whether the given type is `never`.
205
-
206
- @link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
207
- @link https://stackoverflow.com/a/53984913/10292952
208
- @link https://www.zhenghao.io/posts/ts-never
209
-
210
- Useful in type utilities, such as checking if something does not occur.
211
-
212
- @example
213
- ```
214
- import type {IsNever, And} from 'type-fest';
215
-
216
- type A = IsNever<never>;
217
- //=> true
218
-
219
- type B = IsNever<any>;
220
- //=> false
221
-
222
- type C = IsNever<unknown>;
223
- //=> false
224
-
225
- type D = IsNever<never[]>;
226
- //=> false
227
-
228
- type E = IsNever<object>;
229
- //=> false
230
-
231
- type F = IsNever<string>;
232
- //=> false
233
- ```
234
-
235
- @example
236
- ```
237
- import type {IsNever} from 'type-fest';
238
-
239
- type IsTrue<T> = T extends true ? true : false;
240
-
241
- // When a distributive conditional is instantiated with `never`, the entire conditional results in `never`.
242
- type A = IsTrue<never>;
243
- //=> never
244
-
245
- // If you don't want that behaviour, you can explicitly add an `IsNever` check before the distributive conditional.
246
- type IsTrueFixed<T> =
247
- IsNever<T> extends true ? false : T extends true ? true : false;
248
-
249
- type B = IsTrueFixed<never>;
250
- //=> false
251
- ```
252
-
253
- @category Type Guard
254
- @category Utilities
255
- */
256
- type IsNever<T> = [T] extends [never] ? true : false;
257
-
258
- /**
259
- An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
260
-
261
- Use-cases:
262
- - You can use this in combination with `Is*` types to create an if-else-like experience. For example, `If<IsAny<any>, 'is any', 'not any'>`.
263
-
264
- Note:
265
- - Returns a union of if branch and else branch if the given type is `boolean` or `any`. For example, `If<boolean, 'Y', 'N'>` will return `'Y' | 'N'`.
266
- - Returns the else branch if the given type is `never`. For example, `If<never, 'Y', 'N'>` will return `'N'`.
267
-
268
- @example
269
- ```
270
- import type {If} from 'type-fest';
271
-
272
- type A = If<true, 'yes', 'no'>;
273
- //=> 'yes'
274
-
275
- type B = If<false, 'yes', 'no'>;
276
- //=> 'no'
277
-
278
- type C = If<boolean, 'yes', 'no'>;
279
- //=> 'yes' | 'no'
280
-
281
- type D = If<any, 'yes', 'no'>;
282
- //=> 'yes' | 'no'
283
-
284
- type E = If<never, 'yes', 'no'>;
285
- //=> 'no'
286
- ```
287
-
288
- @example
289
- ```
290
- import type {If, IsAny, IsNever} from 'type-fest';
291
-
292
- type A = If<IsAny<unknown>, 'is any', 'not any'>;
293
- //=> 'not any'
294
-
295
- type B = If<IsNever<never>, 'is never', 'not never'>;
296
- //=> 'is never'
297
- ```
298
-
299
- @example
300
- ```
301
- import type {If, IsEqual} from 'type-fest';
302
-
303
- type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
304
-
305
- type A = IfEqual<string, string, 'equal', 'not equal'>;
306
- //=> 'equal'
307
-
308
- type B = IfEqual<string, number, 'equal', 'not equal'>;
309
- //=> 'not equal'
310
- ```
311
-
312
- Note: Sometimes using the `If` type can make an implementation non–tail-recursive, which can impact performance. In such cases, it’s better to use a conditional directly. Refer to the following example:
313
-
314
- @example
315
- ```
316
- import type {If, IsEqual, StringRepeat} from 'type-fest';
317
-
318
- type HundredZeroes = StringRepeat<'0', 100>;
319
-
320
- // The following implementation is not tail recursive
321
- type Includes<S extends string, Char extends string> =
322
- S extends `${infer First}${infer Rest}`
323
- ? If<IsEqual<First, Char>,
324
- 'found',
325
- Includes<Rest, Char>>
326
- : 'not found';
327
-
328
- // Hence, instantiations with long strings will fail
329
- // @ts-expect-error
330
- type Fails = Includes<HundredZeroes, '1'>;
331
- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
332
- // Error: Type instantiation is excessively deep and possibly infinite.
333
-
334
- // However, if we use a simple conditional instead of `If`, the implementation becomes tail-recursive
335
- type IncludesWithoutIf<S extends string, Char extends string> =
336
- S extends `${infer First}${infer Rest}`
337
- ? IsEqual<First, Char> extends true
338
- ? 'found'
339
- : IncludesWithoutIf<Rest, Char>
340
- : 'not found';
341
-
342
- // Now, instantiations with long strings will work
343
- type Works = IncludesWithoutIf<HundredZeroes, '1'>;
344
- //=> 'not found'
345
- ```
346
-
347
- @category Type Guard
348
- @category Utilities
349
- */
350
- type If<Type extends boolean, IfBranch, ElseBranch> =
351
- IsNever<Type> extends true
352
- ? ElseBranch
353
- : Type extends true
354
- ? IfBranch
355
- : ElseBranch;
356
-
357
- /**
358
- Represents an array with `unknown` value.
359
-
360
- Use case: You want a type that all arrays can be assigned to, but you don't care about the value.
361
-
362
- @example
363
- ```
364
- import type {UnknownArray} from 'type-fest';
365
-
366
- type IsArray<T> = T extends UnknownArray ? true : false;
367
-
368
- type A = IsArray<['foo']>;
369
- //=> true
370
-
371
- type B = IsArray<readonly number[]>;
372
- //=> true
373
-
374
- type C = IsArray<string>;
375
- //=> false
376
- ```
377
-
378
- @category Type
379
- @category Array
380
- */
381
- type UnknownArray = readonly unknown[];
382
-
383
- /**
384
- Returns a boolean for whether A is false.
385
-
386
- @example
387
- ```
388
- type A = Not<true>;
389
- //=> false
390
-
391
- type B = Not<false>;
392
- //=> true
393
- ```
394
- */
395
- type Not<A extends boolean> = A extends true
396
- ? false
397
- : A extends false
398
- ? true
399
- : never;
400
-
401
- /**
402
- An if-else-like type that resolves depending on whether the given type is `any` or `never`.
403
-
404
- @example
405
- ```
406
- // When `T` is a NOT `any` or `never` (like `string`) => Returns `IfNotAnyOrNever` branch
407
- type A = IfNotAnyOrNever<string, 'VALID', 'IS_ANY', 'IS_NEVER'>;
408
- //=> 'VALID'
409
-
410
- // When `T` is `any` => Returns `IfAny` branch
411
- type B = IfNotAnyOrNever<any, 'VALID', 'IS_ANY', 'IS_NEVER'>;
412
- //=> 'IS_ANY'
413
-
414
- // When `T` is `never` => Returns `IfNever` branch
415
- type C = IfNotAnyOrNever<never, 'VALID', 'IS_ANY', 'IS_NEVER'>;
416
- //=> 'IS_NEVER'
417
- ```
418
-
419
- Note: Wrapping a tail-recursive type with `IfNotAnyOrNever` makes the implementation non-tail-recursive. To fix this, move the recursion into a helper type. Refer to the following example:
420
-
421
- @example
422
- ```ts
423
- import type {StringRepeat} from 'type-fest';
424
-
425
- type NineHundredNinetyNineSpaces = StringRepeat<' ', 999>;
426
-
427
- // The following implementation is not tail recursive
428
- type TrimLeft<S extends string> = IfNotAnyOrNever<S, S extends ` ${infer R}` ? TrimLeft<R> : S>;
429
-
430
- // Hence, instantiations with long strings will fail
431
- // @ts-expect-error
432
- type T1 = TrimLeft<NineHundredNinetyNineSpaces>;
433
- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
434
- // Error: Type instantiation is excessively deep and possibly infinite.
435
-
436
- // To fix this, move the recursion into a helper type
437
- type TrimLeftOptimised<S extends string> = IfNotAnyOrNever<S, _TrimLeftOptimised<S>>;
438
-
439
- type _TrimLeftOptimised<S extends string> = S extends ` ${infer R}` ? _TrimLeftOptimised<R> : S;
440
-
441
- type T2 = TrimLeftOptimised<NineHundredNinetyNineSpaces>;
442
- //=> ''
443
- ```
444
- */
445
- type IfNotAnyOrNever<T, IfNotAnyOrNever, IfAny = any, IfNever = never> =
446
- If<IsAny<T>, IfAny, If<IsNever<T>, IfNever, IfNotAnyOrNever>>;
447
-
448
- /**
449
- Indicates the value of `exactOptionalPropertyTypes` compiler option.
450
- */
451
- type IsExactOptionalPropertyTypesEnabled = [(string | undefined)?] extends [string?]
452
- ? false
453
- : true;
454
-
455
- /**
456
- Transforms a tuple type by replacing it's rest element with a single element that has the same type as the rest element, while keeping all the non-rest elements intact.
457
-
458
- @example
459
- ```
460
- type A = CollapseRestElement<[string, string, ...number[]]>;
461
- //=> [string, string, number]
462
-
463
- type B = CollapseRestElement<[...string[], number, number]>;
464
- //=> [string, number, number]
465
-
466
- type C = CollapseRestElement<[string, string, ...Array<number | bigint>]>;
467
- //=> [string, string, number | bigint]
468
-
469
- type D = CollapseRestElement<[string, number]>;
470
- //=> [string, number]
471
- ```
472
-
473
- Note: Optional modifiers (`?`) are removed from elements unless the `exactOptionalPropertyTypes` compiler option is disabled. When disabled, there's an additional `| undefined` for optional elements.
474
-
475
- @example
476
- ```
477
- // `exactOptionalPropertyTypes` enabled
478
- type A = CollapseRestElement<[string?, string?, ...number[]]>;
479
- //=> [string, string, number]
480
-
481
- // `exactOptionalPropertyTypes` disabled
482
- type B = CollapseRestElement<[string?, string?, ...number[]]>;
483
- //=> [string | undefined, string | undefined, number]
484
- ```
485
- */
486
- type CollapseRestElement<TArray extends UnknownArray> = IfNotAnyOrNever<TArray, _CollapseRestElement<TArray>>;
487
-
488
- type _CollapseRestElement<
489
- TArray extends UnknownArray,
490
- ForwardAccumulator extends UnknownArray = [],
491
- BackwardAccumulator extends UnknownArray = [],
492
- > =
493
- TArray extends UnknownArray // For distributing `TArray`
494
- ? keyof TArray & `${number}` extends never
495
- // Enters this branch, if `TArray` is empty (e.g., []),
496
- // or `TArray` contains no non-rest elements preceding the rest element (e.g., `[...string[]]` or `[...string[], string]`).
497
- ? TArray extends readonly [...infer Rest, infer Last]
498
- ? _CollapseRestElement<Rest, ForwardAccumulator, [Last, ...BackwardAccumulator]> // Accumulate elements that are present after the rest element.
499
- : TArray extends readonly []
500
- ? [...ForwardAccumulator, ...BackwardAccumulator]
501
- : [...ForwardAccumulator, TArray[number], ...BackwardAccumulator] // Add the rest element between the accumulated elements.
502
- : TArray extends readonly [(infer First)?, ...infer Rest]
503
- ? _CollapseRestElement<
504
- Rest,
505
- [
506
- ...ForwardAccumulator,
507
- '0' extends OptionalKeysOf<TArray>
508
- ? If<IsExactOptionalPropertyTypesEnabled, First, First | undefined> // Add `| undefined` for optional elements, if `exactOptionalPropertyTypes` is disabled.
509
- : First,
510
- ],
511
- BackwardAccumulator
512
- >
513
- : never // Should never happen, since `[(infer First)?, ...infer Rest]` is a top-type for arrays.
514
- : never; // Should never happen
515
-
516
- type Whitespace =
517
- | '\u{9}' // '\t'
518
- | '\u{A}' // '\n'
519
- | '\u{B}' // '\v'
520
- | '\u{C}' // '\f'
521
- | '\u{D}' // '\r'
522
- | '\u{20}' // ' '
523
- | '\u{85}'
524
- | '\u{A0}'
525
- | '\u{1680}'
526
- | '\u{2000}'
527
- | '\u{2001}'
528
- | '\u{2002}'
529
- | '\u{2003}'
530
- | '\u{2004}'
531
- | '\u{2005}'
532
- | '\u{2006}'
533
- | '\u{2007}'
534
- | '\u{2008}'
535
- | '\u{2009}'
536
- | '\u{200A}'
537
- | '\u{2028}'
538
- | '\u{2029}'
539
- | '\u{202F}'
540
- | '\u{205F}'
541
- | '\u{3000}'
542
- | '\u{FEFF}';
543
-
544
- type WordSeparators = '-' | '_' | Whitespace;
545
-
546
- /**
547
- Remove spaces from the left side.
548
- */
549
- type TrimLeft<V extends string> = V extends `${Whitespace}${infer R}` ? TrimLeft<R> : V;
550
-
551
- /**
552
- Remove spaces from the right side.
553
- */
554
- type TrimRight<V extends string> = V extends `${infer R}${Whitespace}` ? TrimRight<R> : V;
555
-
556
- /**
557
- Remove leading and trailing spaces from a string.
558
-
559
- @example
560
- ```
561
- import type {Trim} from 'type-fest';
562
-
563
- type Example = Trim<' foo '>;
564
- //=> 'foo'
565
- ```
566
-
567
- @category String
568
- @category Template literal
569
- */
570
- type Trim<V extends string> = TrimLeft<TrimRight<V>>;
571
-
572
- /**
573
- Returns a boolean for whether the string is numeric.
574
-
575
- This type is a workaround for [Microsoft/TypeScript#46109](https://github.com/microsoft/TypeScript/issues/46109#issuecomment-930307987).
576
- */
577
- type IsNumeric<T extends string> = T extends `${number}`
578
- ? Trim<T> extends T
579
- ? true
580
- : false
581
- : false;
582
-
583
- /**
584
- Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
585
-
586
- @example
587
- ```
588
- import type {Simplify} from 'type-fest';
589
-
590
- type PositionProps = {
591
- top: number;
592
- left: number;
593
- };
594
-
595
- type SizeProps = {
596
- width: number;
597
- height: number;
598
- };
599
-
600
- // In your editor, hovering over `Props` will show a flattened object with all the properties.
601
- type Props = Simplify<PositionProps & SizeProps>;
602
- ```
603
-
604
- Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.
605
-
606
- If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.
607
-
608
- @example
609
- ```
610
- import type {Simplify} from 'type-fest';
611
-
612
- interface SomeInterface {
613
- foo: number;
614
- bar?: string;
615
- baz: number | undefined;
616
- }
617
-
618
- type SomeType = {
619
- foo: number;
620
- bar?: string;
621
- baz: number | undefined;
622
- };
623
-
624
- const literal = {foo: 123, bar: 'hello', baz: 456};
625
- const someType: SomeType = literal;
626
- const someInterface: SomeInterface = literal;
627
-
628
- declare function fn(object: Record<string, unknown>): void;
629
-
630
- fn(literal); // Good: literal object type is sealed
631
- fn(someType); // Good: type is sealed
632
- // @ts-expect-error
633
- fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
634
- fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
635
- ```
636
-
637
- @link https://github.com/microsoft/TypeScript/issues/15300
638
- @see {@link SimplifyDeep}
639
- @category Object
640
- */
641
- type Simplify<T> = {[KeyType in keyof T]: T[KeyType]} & {};
642
-
643
- /**
644
- Returns a boolean for whether the two given types are equal.
645
-
646
- @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
647
- @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
648
-
649
- Use-cases:
650
- - If you want to make a conditional branch based on the result of a comparison of two types.
651
-
652
- @example
653
- ```
654
- import type {IsEqual} from 'type-fest';
655
-
656
- // This type returns a boolean for whether the given array includes the given item.
657
- // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
658
- type Includes<Value extends readonly any[], Item> =
659
- Value extends readonly [Value[0], ...infer rest]
660
- ? IsEqual<Value[0], Item> extends true
661
- ? true
662
- : Includes<rest, Item>
663
- : false;
664
- ```
665
-
666
- @category Type Guard
667
- @category Utilities
668
- */
669
- type IsEqual<A, B> =
670
- [A] extends [B]
671
- ? [B] extends [A]
672
- ? _IsEqual<A, B>
673
- : false
674
- : false;
675
-
676
- // This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
677
- type _IsEqual<A, B> =
678
- (<G>() => G extends A & G | G ? 1 : 2) extends
679
- (<G>() => G extends B & G | G ? 1 : 2)
680
- ? true
681
- : false;
682
-
683
- /**
684
- Omit any index signatures from the given object type, leaving only explicitly defined properties.
685
-
686
- This is the counterpart of `PickIndexSignature`.
687
-
688
- Use-cases:
689
- - Remove overly permissive signatures from third-party types.
690
-
691
- This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
692
-
693
- It relies on the fact that an empty object (`{}`) is assignable to an object with just an index signature, like `Record<string, unknown>`, but not to an object with explicitly defined keys, like `Record<'foo' | 'bar', unknown>`.
694
-
695
- (The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
696
-
697
- ```
698
- const indexed: Record<string, unknown> = {}; // Allowed
699
-
700
- // @ts-expect-error
701
- const keyed: Record<'foo', unknown> = {}; // Error
702
- // TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
703
- ```
704
-
705
- Instead of causing a type error like the above, you can also use a [conditional type](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html) to test whether a type is assignable to another:
706
-
707
- ```
708
- type Indexed = {} extends Record<string, unknown>
709
- ? '✅ `{}` is assignable to `Record<string, unknown>`'
710
- : '❌ `{}` is NOT assignable to `Record<string, unknown>`';
711
-
712
- type IndexedResult = Indexed;
713
- //=> '✅ `{}` is assignable to `Record<string, unknown>`'
714
-
715
- type Keyed = {} extends Record<'foo' | 'bar', unknown>
716
- ? '✅ `{}` is assignable to `Record<\'foo\' | \'bar\', unknown>`'
717
- : '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`';
718
-
719
- type KeyedResult = Keyed;
720
- //=> '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`'
721
- ```
722
-
723
- Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#further-exploration), you can then check for each `KeyType` of `ObjectType`...
724
-
725
- ```
726
- type OmitIndexSignature<ObjectType> = {
727
- [KeyType in keyof ObjectType // Map each key of `ObjectType`...
728
- ]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
729
- };
730
- ```
731
-
732
- ...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
733
-
734
- ```
735
- type OmitIndexSignature<ObjectType> = {
736
- [KeyType in keyof ObjectType
737
- // Is `{}` assignable to `Record<KeyType, unknown>`?
738
- as {} extends Record<KeyType, unknown>
739
- ? never // ✅ `{}` is assignable to `Record<KeyType, unknown>`
740
- : KeyType // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
741
- ]: ObjectType[KeyType];
742
- };
743
- ```
744
-
745
- If `{}` is assignable, it means that `KeyType` is an index signature and we want to remove it. If it is not assignable, `KeyType` is a "real" key and we want to keep it.
746
-
747
- @example
748
- ```
749
- import type {OmitIndexSignature} from 'type-fest';
750
-
751
- type Example = {
752
- // These index signatures will be removed.
753
- [x: string]: any;
754
- [x: number]: any;
755
- [x: symbol]: any;
756
- [x: `head-${string}`]: string;
757
- [x: `${string}-tail`]: string;
758
- [x: `head-${string}-tail`]: string;
759
- [x: `${bigint}`]: string;
760
- [x: `embedded-${number}`]: string;
761
-
762
- // These explicitly defined keys will remain.
763
- foo: 'bar';
764
- qux?: 'baz';
765
- };
766
-
767
- type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
768
- //=> {foo: 'bar'; qux?: 'baz'}
769
- ```
770
-
771
- @see {@link PickIndexSignature}
772
- @category Object
773
- */
774
- type OmitIndexSignature<ObjectType> = {
775
- [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
776
- ? never
777
- : KeyType]: ObjectType[KeyType];
778
- };
779
-
780
- /**
781
- Pick only index signatures from the given object type, leaving out all explicitly defined properties.
782
-
783
- This is the counterpart of `OmitIndexSignature`.
784
-
785
- @example
786
- ```
787
- import type {PickIndexSignature} from 'type-fest';
788
-
789
- declare const symbolKey: unique symbol;
790
-
791
- type Example = {
792
- // These index signatures will remain.
793
- [x: string]: unknown;
794
- [x: number]: unknown;
795
- [x: symbol]: unknown;
796
- [x: `head-${string}`]: string;
797
- [x: `${string}-tail`]: string;
798
- [x: `head-${string}-tail`]: string;
799
- [x: `${bigint}`]: string;
800
- [x: `embedded-${number}`]: string;
801
-
802
- // These explicitly defined keys will be removed.
803
- ['kebab-case-key']: string;
804
- [symbolKey]: string;
805
- foo: 'bar';
806
- qux?: 'baz';
807
- };
808
-
809
- type ExampleIndexSignature = PickIndexSignature<Example>;
810
- // {
811
- // [x: string]: unknown;
812
- // [x: number]: unknown;
813
- // [x: symbol]: unknown;
814
- // [x: `head-${string}`]: string;
815
- // [x: `${string}-tail`]: string;
816
- // [x: `head-${string}-tail`]: string;
817
- // [x: `${bigint}`]: string;
818
- // [x: `embedded-${number}`]: string;
819
- // }
820
- ```
821
-
822
- @see {@link OmitIndexSignature}
823
- @category Object
824
- */
825
- type PickIndexSignature<ObjectType> = {
826
- [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
827
- ? KeyType
828
- : never]: ObjectType[KeyType];
829
- };
830
-
831
- // Merges two objects without worrying about index signatures.
832
- type SimpleMerge<Destination, Source> = Simplify<{
833
- [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key];
834
- } & Source>;
835
-
836
- /**
837
- Merge two types into a new type. Keys of the second type overrides keys of the first type.
838
-
839
- @example
840
- ```
841
- import type {Merge} from 'type-fest';
842
-
843
- type Foo = {
844
- [x: string]: unknown;
845
- [x: number]: unknown;
846
- foo: string;
847
- bar: symbol;
848
- };
849
-
850
- type Bar = {
851
- [x: number]: number;
852
- [x: symbol]: unknown;
853
- bar: Date;
854
- baz: boolean;
855
- };
856
-
857
- export type FooBar = Merge<Foo, Bar>;
858
- //=> {
859
- // [x: string]: unknown;
860
- // [x: number]: number;
861
- // [x: symbol]: unknown;
862
- // foo: string;
863
- // bar: Date;
864
- // baz: boolean;
865
- // }
866
- ```
867
-
868
- Note: If you want a merge type that more accurately reflects the runtime behavior of object spread or `Object.assign`, refer to the {@link ObjectMerge} type.
869
-
870
- @see {@link ObjectMerge}
871
- @category Object
872
- */
873
- type Merge<Destination, Source> =
874
- Destination extends unknown // For distributing `Destination`
875
- ? Source extends unknown // For distributing `Source`
876
- ? If<IsEqual<Destination, Source>, Destination, _Merge<Destination, Source>>
877
- : never // Should never happen
878
- : never; // Should never happen
879
-
880
- type _Merge<Destination, Source> =
881
- Simplify<
882
- SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>>
883
- & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>
884
- >;
885
-
886
- /**
887
- Merges user specified options with default options.
888
-
889
- @example
890
- ```
891
- type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
892
- type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
893
- type SpecifiedOptions = {leavesOnly: true};
894
-
895
- type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
896
- //=> {maxRecursionDepth: 10; leavesOnly: true}
897
- ```
898
-
899
- @example
900
- ```
901
- // Complains if default values are not provided for optional options
902
-
903
- type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
904
- type DefaultPathsOptions = {maxRecursionDepth: 10};
905
- type SpecifiedOptions = {};
906
-
907
- type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
908
- // ~~~~~~~~~~~~~~~~~~~
909
- // Property 'leavesOnly' is missing in type 'DefaultPathsOptions' but required in type '{ maxRecursionDepth: number; leavesOnly: boolean; }'.
910
- ```
911
-
912
- @example
913
- ```
914
- // Complains if an option's default type does not conform to the expected type
915
-
916
- type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
917
- type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: 'no'};
918
- type SpecifiedOptions = {};
919
-
920
- type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
921
- // ~~~~~~~~~~~~~~~~~~~
922
- // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
923
- ```
924
-
925
- @example
926
- ```
927
- // Complains if an option's specified type does not conform to the expected type
928
-
929
- type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
930
- type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
931
- type SpecifiedOptions = {leavesOnly: 'yes'};
932
-
933
- type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
934
- // ~~~~~~~~~~~~~~~~
935
- // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
936
- ```
937
- */
938
- type ApplyDefaultOptions<
939
- Options extends object,
940
- Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>,
941
- SpecifiedOptions extends Options,
942
- > =
943
- If<IsAny<SpecifiedOptions>, Defaults,
944
- If<IsNever<SpecifiedOptions>, Defaults,
945
- Simplify<Merge<Defaults, {
946
- [Key in keyof SpecifiedOptions
947
- as Key extends OptionalKeysOf<Options> ? undefined extends SpecifiedOptions[Key] ? never : Key : Key
948
- ]: SpecifiedOptions[Key]
949
- }> & Required<Options>>>>;
950
-
951
- /**
952
- Returns a boolean for whether either of two given types is true.
953
-
954
- Use-case: Constructing complex conditional types where at least one condition must be satisfied.
955
-
956
- @example
957
- ```
958
- import type {Or} from 'type-fest';
959
-
960
- type TT = Or<true, true>;
961
- //=> true
962
-
963
- type TF = Or<true, false>;
964
- //=> true
965
-
966
- type FT = Or<false, true>;
967
- //=> true
968
-
969
- type FF = Or<false, false>;
970
- //=> false
971
- ```
972
-
973
- Note: When `boolean` is passed as an argument, it is distributed into separate cases, and the final result is a union of those cases.
974
- For example, `Or<false, boolean>` expands to `Or<false, true> | Or<false, false>`, which simplifies to `true | false` (i.e., `boolean`).
975
-
976
- @example
977
- ```
978
- import type {Or} from 'type-fest';
979
-
980
- type A = Or<false, boolean>;
981
- //=> boolean
982
-
983
- type B = Or<boolean, false>;
984
- //=> boolean
985
-
986
- type C = Or<true, boolean>;
987
- //=> true
988
-
989
- type D = Or<boolean, true>;
990
- //=> true
991
-
992
- type E = Or<boolean, boolean>;
993
- //=> boolean
994
- ```
995
-
996
- Note: If `never` is passed as an argument, it is treated as `false` and the result is computed accordingly.
997
-
998
- @example
999
- ```
1000
- import type {Or} from 'type-fest';
1001
-
1002
- type A = Or<true, never>;
1003
- //=> true
1004
-
1005
- type B = Or<never, true>;
1006
- //=> true
1007
-
1008
- type C = Or<false, never>;
1009
- //=> false
1010
-
1011
- type D = Or<never, false>;
1012
- //=> false
1013
-
1014
- type E = Or<boolean, never>;
1015
- //=> boolean
1016
-
1017
- type F = Or<never, boolean>;
1018
- //=> boolean
1019
-
1020
- type G = Or<never, never>;
1021
- //=> false
1022
- ```
1023
-
1024
- @see {@link And}
1025
- @see {@link Xor}
1026
- */
1027
- type Or<A extends boolean, B extends boolean> =
1028
- _Or<If<IsNever<A>, false, A>, If<IsNever<B>, false, B>>; // `never` is treated as `false`
1029
-
1030
- type _Or<A extends boolean, B extends boolean> = A extends true
1031
- ? true
1032
- : B extends true
1033
- ? true
1034
- : false;
1035
-
1036
- /**
1037
- @see {@link AllExtend}
1038
- */
1039
- type AllExtendOptions = {
1040
- /**
1041
- Consider `never` elements to match the target type only if the target type itself is `never` (or `any`).
1042
-
1043
- - When set to `true` (default), `never` is _not_ treated as a bottom type, instead, it is treated as a type that matches only itself (or `any`).
1044
- - When set to `false`, `never` is treated as a bottom type, and behaves as it normally would.
1045
-
1046
- @default true
1047
-
1048
- @example
1049
- ```
1050
- import type {AllExtend} from 'type-fest';
1051
-
1052
- type A = AllExtend<[1, 2, never], number, {strictNever: true}>;
1053
- //=> false
1054
-
1055
- type B = AllExtend<[1, 2, never], number, {strictNever: false}>;
1056
- //=> true
1057
-
1058
- type C = AllExtend<[never, never], never, {strictNever: true}>;
1059
- //=> true
1060
-
1061
- type D = AllExtend<[never, never], never, {strictNever: false}>;
1062
- //=> true
1063
-
1064
- type E = AllExtend<['a', 'b', never], any, {strictNever: true}>;
1065
- //=> true
1066
-
1067
- type F = AllExtend<['a', 'b', never], any, {strictNever: false}>;
1068
- //=> true
1069
-
1070
- type G = AllExtend<[never, 1], never, {strictNever: true}>;
1071
- //=> false
1072
-
1073
- type H = AllExtend<[never, 1], never, {strictNever: false}>;
1074
- //=> false
1075
- ```
1076
- */
1077
- strictNever?: boolean;
1078
- };
1079
-
1080
- type DefaultAllExtendOptions = {
1081
- strictNever: true;
1082
- };
1083
-
1084
- /**
1085
- Returns a boolean for whether every element in an array type extends another type.
1086
-
1087
- @example
1088
- ```
1089
- import type {AllExtend} from 'type-fest';
1090
-
1091
- type A = AllExtend<[1, 2, 3], number>;
1092
- //=> true
1093
-
1094
- type B = AllExtend<[1, 2, '3'], number>;
1095
- //=> false
1096
-
1097
- type C = AllExtend<[number, number | string], number>;
1098
- //=> boolean
1099
-
1100
- type D = AllExtend<[true, boolean, true], true>;
1101
- //=> boolean
1102
- ```
1103
-
1104
- Note: Behaviour of optional elements depend on the `exactOptionalPropertyTypes` compiler option. When the option is disabled, the target type must include `undefined` for a successful match.
1105
-
1106
- ```
1107
- // @exactOptionalPropertyTypes: true
1108
- import type {AllExtend} from 'type-fest';
1109
-
1110
- type A = AllExtend<[1?, 2?, 3?], number>;
1111
- //=> true
1112
- ```
1113
-
1114
- ```
1115
- // @exactOptionalPropertyTypes: false
1116
- import type {AllExtend} from 'type-fest';
1117
-
1118
- type A = AllExtend<[1?, 2?, 3?], number>;
1119
- //=> boolean
1120
-
1121
- type B = AllExtend<[1?, 2?, 3?], number | undefined>;
1122
- //=> true
1123
- ```
1124
-
1125
- @see {@link AllExtendOptions}
1126
-
1127
- @category Utilities
1128
- @category Array
1129
- */
1130
- type AllExtend<TArray extends UnknownArray, Type, Options extends AllExtendOptions = {}> =
1131
- _AllExtend<CollapseRestElement<TArray>, Type, ApplyDefaultOptions<AllExtendOptions, DefaultAllExtendOptions, Options>>;
1132
-
1133
- type _AllExtend<TArray extends UnknownArray, Type, Options extends Required<AllExtendOptions>> = IfNotAnyOrNever<TArray, If<IsAny<Type>, true,
1134
- TArray extends readonly [infer First, ...infer Rest]
1135
- ? IsNever<First> extends true
1136
- ? Or<IsNever<Type>, Not<Options['strictNever']>> extends true
1137
- // If target `Type` is also `never` OR `strictNever` is disabled, recurse further.
1138
- ? _AllExtend<Rest, Type, Options>
1139
- : false
1140
- : First extends Type
1141
- ? _AllExtend<Rest, Type, Options>
1142
- : false
1143
- : true
1144
- >, false, false>;
1145
-
1146
- /**
1147
- Allows creating a union type by combining primitive types and literal types without sacrificing auto-completion in IDEs for the literal type part of the union.
1148
-
1149
- Currently, when a union type of a primitive type is combined with literal types, TypeScript loses all information about the combined literals. Thus, when such type is used in an IDE with autocompletion, no suggestions are made for the declared literals.
1150
-
1151
- This type is a workaround for [Microsoft/TypeScript#29729](https://github.com/Microsoft/TypeScript/issues/29729). It will be removed as soon as it's not needed anymore.
1152
-
1153
- @example
1154
- ```
1155
- import type {LiteralUnion} from 'type-fest';
1156
-
1157
- // Before
1158
-
1159
- type Pet = 'dog' | 'cat' | string;
1160
-
1161
- const petWithoutAutocomplete: Pet = '';
1162
- // Start typing in your TypeScript-enabled IDE.
1163
- // You **will not** get auto-completion for `dog` and `cat` literals.
1164
-
1165
- // After
1166
-
1167
- type Pet2 = LiteralUnion<'dog' | 'cat', string>;
1168
-
1169
- const petWithAutoComplete: Pet2 = '';
1170
- // You **will** get auto-completion for `dog` and `cat` literals.
1171
- ```
1172
-
1173
- @category Type
1174
- */
1175
- type LiteralUnion<
1176
- LiteralType,
1177
- BaseType extends Primitive,
1178
- > = LiteralType | (BaseType & Record<never, never>);
1179
-
1180
- /**
1181
- Returns a boolean for whether the given string literal is lowercase.
1182
-
1183
- @example
1184
- ```
1185
- import type {IsLowercase} from 'type-fest';
1186
-
1187
- type A = IsLowercase<'abc'>;
1188
- //=> true
1189
-
1190
- type B = IsLowercase<'Abc'>;
1191
- //=> false
1192
-
1193
- type C = IsLowercase<string>;
1194
- //=> boolean
1195
- ```
1196
- */
1197
- type IsLowercase<S extends string> = AllExtend<_IsLowercase<S>, true>;
1198
-
1199
- /**
1200
- Loops through each part in the string and returns a boolean array indicating whether each part is lowercase.
1201
- */
1202
- type _IsLowercase<S extends string, Accumulator extends boolean[] = []> = S extends `${infer First}${infer Rest}`
1203
- ? _IsLowercase<Rest, [...Accumulator, IsLowercaseHelper<First>]>
1204
- : [...Accumulator, IsLowercaseHelper<S>];
1205
-
1206
- /**
1207
- Returns a boolean for whether an individual part of the string is lowercase.
1208
- */
1209
- type IsLowercaseHelper<S extends string> = S extends Lowercase<string>
1210
- ? true
1211
- : S extends Uppercase<string> | Capitalize<string> | `${string}${Uppercase<string>}${string}`
1212
- ? false
1213
- : boolean;
1214
-
1215
- /**
1216
- Returns a boolean for whether the given string literal is uppercase.
1217
-
1218
- @example
1219
- ```
1220
- import type {IsUppercase} from 'type-fest';
1221
-
1222
- type A = IsUppercase<'ABC'>;
1223
- //=> true
1224
-
1225
- type B = IsUppercase<'Abc'>;
1226
- //=> false
1227
-
1228
- type C = IsUppercase<string>;
1229
- //=> boolean
1230
- ```
1231
- */
1232
- type IsUppercase<S extends string> = AllExtend<_IsUppercase<S>, true>;
1233
-
1234
- /**
1235
- Loops through each part in the string and returns a boolean array indicating whether each part is uppercase.
1236
- */
1237
- type _IsUppercase<S extends string, Accumulator extends boolean[] = []> = S extends `${infer First}${infer Rest}`
1238
- ? _IsUppercase<Rest, [...Accumulator, IsUppercaseHelper<First>]>
1239
- : [...Accumulator, IsUppercaseHelper<S>];
1240
-
1241
- /**
1242
- Returns a boolean for whether an individual part of the string is uppercase.
1243
- */
1244
- type IsUppercaseHelper<S extends string> = S extends Uppercase<string>
1245
- ? true
1246
- : S extends Lowercase<string> | Uncapitalize<string> | `${string}${Lowercase<string>}${string}`
1247
- ? false
1248
- : boolean;
1249
-
1250
- type SkipEmptyWord<Word extends string> = Word extends '' ? [] : [Word];
1251
-
1252
- type RemoveLastCharacter<
1253
- Sentence extends string,
1254
- Character extends string,
1255
- > = Sentence extends `${infer LeftSide}${Character}`
1256
- ? SkipEmptyWord<LeftSide>
1257
- : never;
1258
-
1259
- /**
1260
- Words options.
1261
-
1262
- @see {@link Words}
1263
- */
1264
- type WordsOptions = {
1265
- /**
1266
- Split on numeric sequence.
1267
-
1268
- @default true
1269
-
1270
- @example
1271
- ```
1272
- import type {Words} from 'type-fest';
1273
-
1274
- type Example1 = Words<'p2pNetwork', {splitOnNumbers: true}>;
1275
- //=> ['p', '2', 'p', 'Network']
1276
-
1277
- type Example2 = Words<'p2pNetwork', {splitOnNumbers: false}>;
1278
- //=> ['p2p', 'Network']
1279
- ```
1280
- */
1281
- splitOnNumbers?: boolean;
1282
- };
1283
-
1284
- type _DefaultWordsOptions = {
1285
- splitOnNumbers: true;
1286
- };
1287
-
1288
- /**
1289
- Split a string (almost) like Lodash's `_.words()` function.
1290
-
1291
- - Split on each word that begins with a capital letter.
1292
- - Split on each {@link WordSeparators}.
1293
- - Split on numeric sequence.
1294
-
1295
- @example
1296
- ```
1297
- import type {Words} from 'type-fest';
1298
-
1299
- type Words0 = Words<'helloWorld'>;
1300
- //=> ['hello', 'World']
1301
-
1302
- type Words1 = Words<'helloWORLD'>;
1303
- //=> ['hello', 'WORLD']
1304
-
1305
- type Words2 = Words<'hello-world'>;
1306
- //=> ['hello', 'world']
1307
-
1308
- type Words3 = Words<'--hello the_world'>;
1309
- //=> ['hello', 'the', 'world']
1310
-
1311
- type Words4 = Words<'lifeIs42'>;
1312
- //=> ['life', 'Is', '42']
1313
-
1314
- type Words5 = Words<'p2pNetwork', {splitOnNumbers: false}>;
1315
- //=> ['p2p', 'Network']
1316
- ```
1317
-
1318
- @category Change case
1319
- @category Template literal
1320
- */
1321
- type Words<Sentence extends string, Options extends WordsOptions = {}> =
1322
- WordsImplementation<Sentence, ApplyDefaultOptions<WordsOptions, _DefaultWordsOptions, Options>>;
1323
-
1324
- type WordsImplementation<
1325
- Sentence extends string,
1326
- Options extends Required<WordsOptions>,
1327
- LastCharacter extends string = '',
1328
- CurrentWord extends string = '',
1329
- > = Sentence extends `${infer FirstCharacter}${infer RemainingCharacters}`
1330
- ? FirstCharacter extends WordSeparators
1331
- // Skip word separator
1332
- ? [...SkipEmptyWord<CurrentWord>, ...WordsImplementation<RemainingCharacters, Options>]
1333
- : LastCharacter extends ''
1334
- // Fist char of word
1335
- ? WordsImplementation<RemainingCharacters, Options, FirstCharacter, FirstCharacter>
1336
- // Case change: non-numeric to numeric
1337
- : [false, true] extends [IsNumeric<LastCharacter>, IsNumeric<FirstCharacter>]
1338
- ? Options['splitOnNumbers'] extends true
1339
- // Split on number: push word
1340
- ? [...SkipEmptyWord<CurrentWord>, ...WordsImplementation<RemainingCharacters, Options, FirstCharacter, FirstCharacter>]
1341
- // No split on number: concat word
1342
- : WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${CurrentWord}${FirstCharacter}`>
1343
- // Case change: numeric to non-numeric
1344
- : [true, false] extends [IsNumeric<LastCharacter>, IsNumeric<FirstCharacter>]
1345
- ? Options['splitOnNumbers'] extends true
1346
- // Split on number: push word
1347
- ? [...SkipEmptyWord<CurrentWord>, ...WordsImplementation<RemainingCharacters, Options, FirstCharacter, FirstCharacter>]
1348
- // No split on number: concat word
1349
- : WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${CurrentWord}${FirstCharacter}`>
1350
- // No case change: concat word
1351
- : [true, true] extends [IsNumeric<LastCharacter>, IsNumeric<FirstCharacter>]
1352
- ? WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${CurrentWord}${FirstCharacter}`>
1353
- // Case change: lower to upper, push word
1354
- : [true, true] extends [IsLowercase<LastCharacter>, IsUppercase<FirstCharacter>]
1355
- ? [...SkipEmptyWord<CurrentWord>, ...WordsImplementation<RemainingCharacters, Options, FirstCharacter, FirstCharacter>]
1356
- // Case change: upper to lower, brings back the last character, push word
1357
- : [true, true] extends [IsUppercase<LastCharacter>, IsLowercase<FirstCharacter>]
1358
- ? [...RemoveLastCharacter<CurrentWord, LastCharacter>, ...WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${LastCharacter}${FirstCharacter}`>]
1359
- // No case change: concat word
1360
- : WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${CurrentWord}${FirstCharacter}`>
1361
- : [...SkipEmptyWord<CurrentWord>];
1362
-
1363
- /**
1364
- CamelCase options.
1365
-
1366
- @see {@link CamelCase}
1367
- */
1368
- type CamelCaseOptions = WordsOptions & {
1369
- /**
1370
- Whether to preserved consecutive uppercase letter.
1371
-
1372
- @default false
1373
- */
1374
- preserveConsecutiveUppercase?: boolean;
1375
- };
1376
-
1377
- type _DefaultCamelCaseOptions = {
1378
- splitOnNumbers: true;
1379
- preserveConsecutiveUppercase: false;
1380
- };
1381
-
1382
- /**
1383
- Convert an array of words to camel-case.
1384
- */
1385
- type CamelCaseFromArray<
1386
- Words extends string[],
1387
- Options extends Required<CamelCaseOptions>,
1388
- OutputString extends string = '',
1389
- > = Words extends [
1390
- infer FirstWord extends string,
1391
- ...infer RemainingWords extends string[],
1392
- ]
1393
- ? Options['preserveConsecutiveUppercase'] extends true
1394
- ? `${Capitalize<FirstWord>}${CamelCaseFromArray<RemainingWords, Options>}`
1395
- : `${Capitalize<Lowercase<FirstWord>>}${CamelCaseFromArray<RemainingWords, Options>}`
1396
- : OutputString;
1397
-
1398
- /**
1399
- Convert a string literal to camel-case.
1400
-
1401
- This can be useful when, for example, converting some kebab-cased command-line flags or a snake-cased database result.
1402
-
1403
- By default, consecutive uppercase letter are preserved. See {@link CamelCaseOptions.preserveConsecutiveUppercase preserveConsecutiveUppercase} option to change this behaviour.
1404
-
1405
- @example
1406
- ```
1407
- import type {CamelCase} from 'type-fest';
1408
-
1409
- // Simple
1410
-
1411
- const someVariable: CamelCase<'foo-bar'> = 'fooBar';
1412
- const preserveConsecutiveUppercase: CamelCase<'foo-BAR-baz', {preserveConsecutiveUppercase: true}> = 'fooBARBaz';
1413
-
1414
- // Advanced
1415
-
1416
- type CamelCasedProperties<T> = {
1417
- [K in keyof T as CamelCase<K>]: T[K]
1418
- };
1419
-
1420
- type RawOptions = {
1421
- 'dry-run': boolean;
1422
- 'full_family_name': string;
1423
- foo: number;
1424
- BAR: string;
1425
- QUZ_QUX: number;
1426
- 'OTHER-FIELD': boolean;
1427
- };
1428
-
1429
- const dbResult: CamelCasedProperties<RawOptions> = {
1430
- dryRun: true,
1431
- fullFamilyName: 'bar.js',
1432
- foo: 123,
1433
- bar: 'foo',
1434
- quzQux: 6,
1435
- otherField: false,
1436
- };
1437
- ```
1438
-
1439
- @category Change case
1440
- @category Template literal
1441
- */
1442
- type CamelCase<Type, Options extends CamelCaseOptions = {}> = Type extends string
1443
- ? string extends Type
1444
- ? Type
1445
- : Uncapitalize<CamelCaseFromArray<
1446
- Words<Type extends Uppercase<Type> ? Lowercase<Type> : Type, Options>,
1447
- ApplyDefaultOptions<CamelCaseOptions, _DefaultCamelCaseOptions, Options>
1448
- >>
1449
- : Type;
1450
-
1451
- /**
1452
- Convert object properties to camel case but not recursively.
1453
-
1454
- This can be useful when, for example, converting some API types from a different style.
1455
-
1456
- @see {@link CamelCasedPropertiesDeep}
1457
- @see {@link CamelCase}
1458
-
1459
- @example
1460
- ```
1461
- import type {CamelCasedProperties} from 'type-fest';
1462
-
1463
- type User = {
1464
- UserId: number;
1465
- UserName: string;
1466
- };
1467
-
1468
- const result: CamelCasedProperties<User> = {
1469
- userId: 1,
1470
- userName: 'Tom',
1471
- };
1472
-
1473
- const preserveConsecutiveUppercase: CamelCasedProperties<{fooBAR: string}, {preserveConsecutiveUppercase: true}> = {
1474
- fooBAR: 'string',
1475
- };
1476
- ```
1477
-
1478
- @category Change case
1479
- @category Template literal
1480
- @category Object
1481
- */
1482
- type CamelCasedProperties<Value, Options extends CamelCaseOptions = {}> = Value extends Function
1483
- ? Value
1484
- : Value extends Array<infer U>
1485
- ? Value
1486
- : {
1487
- [K in keyof Value as
1488
- CamelCase<K, ApplyDefaultOptions<CamelCaseOptions, _DefaultCamelCaseOptions, Options>>
1489
- ]: Value[K];
1490
- };
1491
-
1492
- declare namespace PackageJson {
1493
- /**
1494
- A person who has been involved in creating or maintaining the package.
1495
- */
1496
- type Person =
1497
- | string
1498
- | {
1499
- name: string;
1500
- url?: string;
1501
- email?: string;
1502
- };
1503
-
1504
- type BugsLocation =
1505
- | string
1506
- | {
1507
- /**
1508
- The URL to the package's issue tracker.
1509
- */
1510
- url?: string;
1511
-
1512
- /**
1513
- The email address to which issues should be reported.
1514
- */
1515
- email?: string;
1516
- };
1517
-
1518
- type DirectoryLocations = {
1519
- [directoryType: string]: JsonValue | undefined;
1520
-
1521
- /**
1522
- Location for executable scripts. Sugar to generate entries in the `bin` property by walking the folder.
1523
- */
1524
- bin?: string;
1525
-
1526
- /**
1527
- Location for Markdown files.
1528
- */
1529
- doc?: string;
1530
-
1531
- /**
1532
- Location for example scripts.
1533
- */
1534
- example?: string;
1535
-
1536
- /**
1537
- Location for the bulk of the library.
1538
- */
1539
- lib?: string;
1540
-
1541
- /**
1542
- Location for man pages. Sugar to generate a `man` array by walking the folder.
1543
- */
1544
- man?: string;
1545
-
1546
- /**
1547
- Location for test files.
1548
- */
1549
- test?: string;
1550
- };
1551
-
1552
- type Scripts = {
1553
- /**
1554
- Run **before** the package is published (Also run on local `npm install` without any arguments).
1555
- */
1556
- prepublish?: string;
1557
-
1558
- /**
1559
- Run both **before** the package is packed and published, and on local `npm install` without any arguments. This is run **after** `prepublish`, but **before** `prepublishOnly`.
1560
- */
1561
- prepare?: string;
1562
-
1563
- /**
1564
- Run **before** the package is prepared and packed, **only** on `npm publish`.
1565
- */
1566
- prepublishOnly?: string;
1567
-
1568
- /**
1569
- Run **before** a tarball is packed (on `npm pack`, `npm publish`, and when installing git dependencies).
1570
- */
1571
- prepack?: string;
1572
-
1573
- /**
1574
- Run **after** the tarball has been generated and moved to its final destination.
1575
- */
1576
- postpack?: string;
1577
-
1578
- /**
1579
- Run **after** the package is published.
1580
- */
1581
- publish?: string;
1582
-
1583
- /**
1584
- Run **after** the package is published.
1585
- */
1586
- postpublish?: string;
1587
-
1588
- /**
1589
- Run **before** the package is installed.
1590
- */
1591
- preinstall?: string;
1592
-
1593
- /**
1594
- Run **after** the package is installed.
1595
- */
1596
- install?: string;
1597
-
1598
- /**
1599
- Run **after** the package is installed and after `install`.
1600
- */
1601
- postinstall?: string;
1602
-
1603
- /**
1604
- Run **before** the package is uninstalled and before `uninstall`.
1605
- */
1606
- preuninstall?: string;
1607
-
1608
- /**
1609
- Run **before** the package is uninstalled.
1610
- */
1611
- uninstall?: string;
1612
-
1613
- /**
1614
- Run **after** the package is uninstalled.
1615
- */
1616
- postuninstall?: string;
1617
-
1618
- /**
1619
- Run **before** bump the package version and before `version`.
1620
- */
1621
- preversion?: string;
1622
-
1623
- /**
1624
- Run **before** bump the package version.
1625
- */
1626
- version?: string;
1627
-
1628
- /**
1629
- Run **after** bump the package version.
1630
- */
1631
- postversion?: string;
1632
-
1633
- /**
1634
- Run with the `npm test` command, before `test`.
1635
- */
1636
- pretest?: string;
1637
-
1638
- /**
1639
- Run with the `npm test` command.
1640
- */
1641
- test?: string;
1642
-
1643
- /**
1644
- Run with the `npm test` command, after `test`.
1645
- */
1646
- posttest?: string;
1647
-
1648
- /**
1649
- Run with the `npm stop` command, before `stop`.
1650
- */
1651
- prestop?: string;
1652
-
1653
- /**
1654
- Run with the `npm stop` command.
1655
- */
1656
- stop?: string;
1657
-
1658
- /**
1659
- Run with the `npm stop` command, after `stop`.
1660
- */
1661
- poststop?: string;
1662
-
1663
- /**
1664
- Run with the `npm start` command, before `start`.
1665
- */
1666
- prestart?: string;
1667
-
1668
- /**
1669
- Run with the `npm start` command.
1670
- */
1671
- start?: string;
1672
-
1673
- /**
1674
- Run with the `npm start` command, after `start`.
1675
- */
1676
- poststart?: string;
1677
-
1678
- /**
1679
- Run with the `npm restart` command, before `restart`. Note: `npm restart` will run the `stop` and `start` scripts if no `restart` script is provided.
1680
- */
1681
- prerestart?: string;
1682
-
1683
- /**
1684
- Run with the `npm restart` command. Note: `npm restart` will run the `stop` and `start` scripts if no `restart` script is provided.
1685
- */
1686
- restart?: string;
1687
-
1688
- /**
1689
- Run with the `npm restart` command, after `restart`. Note: `npm restart` will run the `stop` and `start` scripts if no `restart` script is provided.
1690
- */
1691
- postrestart?: string;
1692
- } & Partial<Record<string, string>>;
1693
-
1694
- /**
1695
- Dependencies of the package. The version range is a string which has one or more space-separated descriptors. Dependencies can also be identified with a tarball or Git URL.
1696
- */
1697
- type Dependency = Partial<Record<string, string>>;
1698
-
1699
- /**
1700
- Recursive map describing selective dependency version overrides supported by npm.
1701
- */
1702
- type DependencyOverrides = {
1703
- [packageName in string]: string | undefined | DependencyOverrides;
1704
- };
1705
-
1706
- /**
1707
- Specifies requirements for development environment components such as operating systems, runtimes, or package managers. Used to ensure consistent development environments across the team.
1708
- */
1709
- type DevEngineDependency = {
1710
- name: string;
1711
- version?: string;
1712
- onFail?: 'ignore' | 'warn' | 'error' | 'download';
1713
- };
1714
-
1715
- /**
1716
- A mapping of conditions and the paths to which they resolve.
1717
- */
1718
- type ExportConditions = {
1719
- [condition: string]: Exports;
1720
- };
1721
-
1722
- /**
1723
- Entry points of a module, optionally with conditions and subpath exports.
1724
- */
1725
- type Exports =
1726
- | null
1727
- | string
1728
- | Array<string | ExportConditions>
1729
- | ExportConditions;
1730
-
1731
- /**
1732
- Import map entries of a module, optionally with conditions and subpath imports.
1733
- */
1734
- type Imports = {
1735
- [key: `#${string}`]: Exports;
1736
- };
1737
-
1738
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions
1739
- interface NonStandardEntryPoints {
1740
- /**
1741
- An ECMAScript module ID that is the primary entry point to the program.
1742
- */
1743
- module?: string;
1744
-
1745
- /**
1746
- A module ID with untranspiled code that is the primary entry point to the program.
1747
- */
1748
- esnext?:
1749
- | string
1750
- | {
1751
- [moduleName: string]: string | undefined;
1752
- main?: string;
1753
- browser?: string;
1754
- };
1755
-
1756
- /**
1757
- A hint to JavaScript bundlers or component tools when packaging modules for client side use.
1758
- */
1759
- browser?:
1760
- | string
1761
- | Partial<Record<string, string | false>>;
1762
-
1763
- /**
1764
- Denote which files in your project are "pure" and therefore safe for Webpack to prune if unused.
1765
-
1766
- [Read more.](https://webpack.js.org/guides/tree-shaking/)
1767
- */
1768
- sideEffects?: boolean | string[];
1769
- }
1770
-
1771
- type TypeScriptConfiguration = {
1772
- /**
1773
- Location of the bundled TypeScript declaration file.
1774
- */
1775
- types?: string;
1776
-
1777
- /**
1778
- Version selection map of TypeScript.
1779
- */
1780
- typesVersions?: Partial<Record<string, Partial<Record<string, string[]>>>>;
1781
-
1782
- /**
1783
- Location of the bundled TypeScript declaration file. Alias of `types`.
1784
- */
1785
- typings?: string;
1786
- };
1787
-
1788
- /**
1789
- An alternative configuration for workspaces.
1790
- */
1791
- type WorkspaceConfig = {
1792
- /**
1793
- An array of workspace pattern strings which contain the workspace packages.
1794
- */
1795
- packages?: WorkspacePattern[];
1796
-
1797
- /**
1798
- Designed to solve the problem of packages which break when their `node_modules` are moved to the root workspace directory - a process known as hoisting. For these packages, both within your workspace, and also some that have been installed via `node_modules`, it is important to have a mechanism for preventing the default Yarn workspace behavior. By adding workspace pattern strings here, Yarn will resume non-workspace behavior for any package which matches the defined patterns.
1799
-
1800
- [Supported](https://classic.yarnpkg.com/blog/2018/02/15/nohoist/) by Yarn.
1801
- [Not supported](https://github.com/npm/rfcs/issues/287) by npm.
1802
- */
1803
- nohoist?: WorkspacePattern[];
1804
- };
1805
-
1806
- /**
1807
- A workspace pattern points to a directory or group of directories which contain packages that should be included in the workspace installation process.
1808
-
1809
- The patterns are handled with [minimatch](https://github.com/isaacs/minimatch).
1810
-
1811
- @example
1812
- `docs` → Include the docs directory and install its dependencies.
1813
- `packages/*` → Include all nested directories within the packages directory, like `packages/cli` and `packages/core`.
1814
- */
1815
- type WorkspacePattern = string;
1816
-
1817
- type YarnConfiguration = {
1818
- /**
1819
- If your package only allows one version of a given dependency, and you’d like to enforce the same behavior as `yarn install --flat` on the command-line, set this to `true`.
1820
-
1821
- Note that if your `package.json` contains `"flat": true` and other packages depend on yours (e.g. you are building a library rather than an app), those other packages will also need `"flat": true` in their `package.json` or be installed with `yarn install --flat` on the command-line.
1822
- */
1823
- flat?: boolean;
1824
-
1825
- /**
1826
- Selective version resolutions. Allows the definition of custom package versions inside dependencies without manual edits in the `yarn.lock` file.
1827
- */
1828
- resolutions?: Dependency;
1829
- };
1830
-
1831
- type JSPMConfiguration = {
1832
- /**
1833
- JSPM configuration.
1834
- */
1835
- jspm?: PackageJson;
1836
- };
1837
-
1838
- /**
1839
- Type for [npm's `package.json` file](https://docs.npmjs.com/creating-a-package-json-file). Containing standard npm properties.
1840
- */
1841
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions
1842
- interface PackageJsonStandard {
1843
- /**
1844
- The name of the package.
1845
- */
1846
- name?: string;
1847
-
1848
- /**
1849
- Package version, parseable by [`node-semver`](https://github.com/npm/node-semver).
1850
- */
1851
- version?: string;
1852
-
1853
- /**
1854
- Package description, listed in `npm search`.
1855
- */
1856
- description?: string;
1857
-
1858
- /**
1859
- Keywords associated with package, listed in `npm search`.
1860
- */
1861
- keywords?: string[];
1862
-
1863
- /**
1864
- The URL to the package's homepage.
1865
- */
1866
- homepage?: LiteralUnion<'.', string>;
1867
-
1868
- /**
1869
- The URL to the package's issue tracker and/or the email address to which issues should be reported.
1870
- */
1871
- bugs?: BugsLocation;
1872
-
1873
- /**
1874
- The license for the package.
1875
- */
1876
- license?: string;
1877
-
1878
- /**
1879
- The licenses for the package.
1880
- */
1881
- licenses?: Array<{
1882
- type?: string;
1883
- url?: string;
1884
- }>;
1885
-
1886
- author?: Person;
1887
-
1888
- /**
1889
- A list of people who contributed to the package.
1890
- */
1891
- contributors?: Person[];
1892
-
1893
- /**
1894
- A list of people who maintain the package.
1895
- */
1896
- maintainers?: Person[];
1897
-
1898
- /**
1899
- The files included in the package.
1900
- */
1901
- files?: string[];
1902
-
1903
- /**
1904
- Resolution algorithm for importing ".js" files from the package's scope.
1905
-
1906
- [Read more.](https://nodejs.org/api/esm.html#esm_package_json_type_field)
1907
- */
1908
- type?: 'module' | 'commonjs';
1909
-
1910
- /**
1911
- The module ID that is the primary entry point to the program.
1912
- */
1913
- main?: string;
1914
-
1915
- /**
1916
- Subpath exports to define entry points of the package.
1917
-
1918
- [Read more.](https://nodejs.org/api/packages.html#subpath-exports)
1919
- */
1920
- exports?: Exports;
1921
-
1922
- /**
1923
- Subpath imports to define internal package import maps that only apply to import specifiers from within the package itself.
1924
-
1925
- [Read more.](https://nodejs.org/api/packages.html#subpath-imports)
1926
- */
1927
- imports?: Imports;
1928
-
1929
- /**
1930
- The executable files that should be installed into the `PATH`.
1931
- */
1932
- bin?:
1933
- | string
1934
- | Partial<Record<string, string>>;
1935
-
1936
- /**
1937
- Filenames to put in place for the `man` program to find.
1938
- */
1939
- man?: string | string[];
1940
-
1941
- /**
1942
- Indicates the structure of the package.
1943
- */
1944
- directories?: DirectoryLocations;
1945
-
1946
- /**
1947
- Location for the code repository.
1948
- */
1949
- repository?:
1950
- | string
1951
- | {
1952
- type: string;
1953
- url: string;
1954
-
1955
- /**
1956
- Relative path to package.json if it is placed in non-root directory (for example if it is part of a monorepo).
1957
-
1958
- [Read more.](https://github.com/npm/rfcs/blob/latest/implemented/0010-monorepo-subdirectory-declaration.md)
1959
- */
1960
- directory?: string;
1961
- };
1962
-
1963
- /**
1964
- Script commands that are run at various times in the lifecycle of the package. The key is the lifecycle event, and the value is the command to run at that point.
1965
- */
1966
- scripts?: Scripts;
1967
-
1968
- /**
1969
- Is used to set configuration parameters used in package scripts that persist across upgrades.
1970
- */
1971
- config?: JsonObject;
1972
-
1973
- /**
1974
- The dependencies of the package.
1975
- */
1976
- dependencies?: Dependency;
1977
-
1978
- /**
1979
- Additional tooling dependencies that are not required for the package to work. Usually test, build, or documentation tooling.
1980
- */
1981
- devDependencies?: Dependency;
1982
-
1983
- /**
1984
- Dependencies that are skipped if they fail to install.
1985
- */
1986
- optionalDependencies?: Dependency;
1987
-
1988
- /**
1989
- Dependencies that will usually be required by the package user directly or via another dependency.
1990
- */
1991
- peerDependencies?: Dependency;
1992
-
1993
- /**
1994
- Indicate peer dependencies that are optional.
1995
- */
1996
- peerDependenciesMeta?: Partial<Record<string, {optional: true}>>;
1997
-
1998
- /**
1999
- Package names that are bundled when the package is published.
2000
- */
2001
- bundledDependencies?: string[];
2002
-
2003
- /**
2004
- Alias of `bundledDependencies`.
2005
- */
2006
- bundleDependencies?: string[];
2007
-
2008
- /**
2009
- Overrides is used to support selective version overrides using npm, which lets you define custom package versions or ranges inside your dependencies.
2010
- */
2011
- overrides?: DependencyOverrides;
2012
-
2013
- /**
2014
- Engines that this package runs on.
2015
- */
2016
- engines?: {
2017
- [EngineName in LiteralUnion<'npm' | 'node', string>]?: string;
2018
- };
2019
-
2020
- /**
2021
- @deprecated
2022
- */
2023
- engineStrict?: boolean;
2024
-
2025
- /**
2026
- Operating systems the module runs on.
2027
- */
2028
- os?: Array<LiteralUnion<
2029
- | 'aix'
2030
- | 'darwin'
2031
- | 'freebsd'
2032
- | 'linux'
2033
- | 'openbsd'
2034
- | 'sunos'
2035
- | 'win32'
2036
- | '!aix'
2037
- | '!darwin'
2038
- | '!freebsd'
2039
- | '!linux'
2040
- | '!openbsd'
2041
- | '!sunos'
2042
- | '!win32',
2043
- string
2044
- >>;
2045
-
2046
- /**
2047
- CPU architectures the module runs on.
2048
- */
2049
- cpu?: Array<LiteralUnion<
2050
- | 'arm'
2051
- | 'arm64'
2052
- | 'ia32'
2053
- | 'mips'
2054
- | 'mipsel'
2055
- | 'ppc'
2056
- | 'ppc64'
2057
- | 's390'
2058
- | 's390x'
2059
- | 'x32'
2060
- | 'x64'
2061
- | '!arm'
2062
- | '!arm64'
2063
- | '!ia32'
2064
- | '!mips'
2065
- | '!mipsel'
2066
- | '!ppc'
2067
- | '!ppc64'
2068
- | '!s390'
2069
- | '!s390x'
2070
- | '!x32'
2071
- | '!x64',
2072
- string
2073
- >>;
2074
-
2075
- /**
2076
- Define the runtime and package manager for developing the current project.
2077
- */
2078
- devEngines?: {
2079
- os?: DevEngineDependency | DevEngineDependency[];
2080
- cpu?: DevEngineDependency | DevEngineDependency[];
2081
- libc?: DevEngineDependency | DevEngineDependency[];
2082
- runtime?: DevEngineDependency | DevEngineDependency[];
2083
- packageManager?: DevEngineDependency | DevEngineDependency[];
2084
- };
2085
-
2086
- /**
2087
- If set to `true`, a warning will be shown if package is installed locally. Useful if the package is primarily a command-line application that should be installed globally.
2088
-
2089
- @deprecated
2090
- */
2091
- preferGlobal?: boolean;
2092
-
2093
- /**
2094
- If set to `true`, then npm will refuse to publish it.
2095
- */
2096
- private?: boolean;
2097
-
2098
- /**
2099
- A set of config values that will be used at publish-time. It's especially handy to set the tag, registry or access, to ensure that a given package is not tagged with 'latest', published to the global public registry or that a scoped module is private by default.
2100
- */
2101
- publishConfig?: PublishConfig;
2102
-
2103
- /**
2104
- Describes and notifies consumers of a package's monetary support information.
2105
-
2106
- [Read more.](https://github.com/npm/rfcs/blob/main/implemented/0017-add-funding-support.md)
2107
- */
2108
- funding?: string | {
2109
- /**
2110
- The type of funding.
2111
- */
2112
- type?: LiteralUnion<
2113
- | 'github'
2114
- | 'opencollective'
2115
- | 'patreon'
2116
- | 'individual'
2117
- | 'foundation'
2118
- | 'corporation',
2119
- string
2120
- >;
2121
-
2122
- /**
2123
- The URL to the funding page.
2124
- */
2125
- url: string;
2126
- };
2127
-
2128
- /**
2129
- Used to configure [npm workspaces](https://docs.npmjs.com/cli/using-npm/workspaces) / [Yarn workspaces](https://classic.yarnpkg.com/docs/workspaces/).
2130
-
2131
- Workspaces allow you to manage multiple packages within the same repository in such a way that you only need to run your install command once in order to install all of them in a single pass.
2132
-
2133
- Please note that the top-level `private` property of `package.json` **must** be set to `true` in order to use workspaces.
2134
- */
2135
- workspaces?: WorkspacePattern[] | WorkspaceConfig;
2136
- }
2137
-
2138
- /**
2139
- Type for [`package.json` file used by the Node.js runtime](https://nodejs.org/api/packages.html#nodejs-packagejson-field-definitions).
2140
- */
2141
- type NodeJsStandard = {
2142
- /**
2143
- Defines which package manager is expected to be used when working on the current project. It can set to any of the [supported package managers](https://nodejs.org/api/corepack.html#supported-package-managers), and will ensure that your teams use the exact same package manager versions without having to install anything else than Node.js.
2144
-
2145
- __This field is currently experimental and needs to be opted-in; check the [Corepack](https://nodejs.org/api/corepack.html) page for details about the procedure.__
2146
-
2147
- @example
2148
- ```json
2149
- {
2150
- "packageManager": "<package manager name>@<version>"
2151
- }
2152
- ```
2153
- */
2154
- packageManager?: string;
2155
- };
2156
-
2157
- type PublishConfig = {
2158
- /**
2159
- Additional, less common properties from the [npm docs on `publishConfig`](https://docs.npmjs.com/cli/v7/configuring-npm/package-json#publishconfig).
2160
- */
2161
- [additionalProperties: string]: JsonValue | undefined;
2162
-
2163
- /**
2164
- When publishing scoped packages, the access level defaults to restricted. If you want your scoped package to be publicly viewable (and installable) set `--access=public`. The only valid values for access are public and restricted. Unscoped packages always have an access level of public.
2165
- */
2166
- access?: 'public' | 'restricted';
2167
-
2168
- /**
2169
- The base URL of the npm registry.
2170
-
2171
- Default: `'https://registry.npmjs.org/'`
2172
- */
2173
- registry?: string;
2174
-
2175
- /**
2176
- The tag to publish the package under.
2177
-
2178
- Default: `'latest'`
2179
- */
2180
- tag?: string;
2181
- };
2182
- }
2183
-
2184
- /**
2185
- Type for [npm's `package.json` file](https://docs.npmjs.com/creating-a-package-json-file). Also includes types for fields used by other popular projects, like TypeScript and Yarn.
2186
-
2187
- @category File
2188
- */
2189
- type PackageJson =
2190
- JsonObject &
2191
- PackageJson.NodeJsStandard &
2192
- PackageJson.PackageJsonStandard &
2193
- PackageJson.NonStandardEntryPoints &
2194
- PackageJson.TypeScriptConfiguration &
2195
- PackageJson.YarnConfiguration &
2196
- PackageJson.JSPMConfiguration;
2197
-
2198
- type FlagType = 'string' | 'boolean' | 'number';
2199
-
2200
- /**
2201
- Callback function to determine if a flag is required during runtime.
2202
-
2203
- @param flags - Contains the flags converted to camel-case excluding aliases.
2204
- @param input - Contains the non-flag arguments.
2205
-
2206
- @returns True if the flag is required, otherwise false.
2207
- */
2208
- type IsRequiredPredicate = (flags: Readonly<AnyFlags>, input: readonly string[]) => boolean;
2209
-
2210
- type Flag<PrimitiveType extends FlagType, Type, IsMultiple = false> = {
2211
- /**
2212
- Type of value. (Possible values: `string` `boolean` `number`)
2213
- */
2214
- readonly type?: PrimitiveType;
2215
-
2216
- /**
2217
- Limit valid values to a predefined set of choices.
2218
-
2219
- @example
2220
- ```
2221
- unicorn: {
2222
- isMultiple: true,
2223
- choices: ['rainbow', 'cat', 'unicorn']
2224
- }
2225
- ```
2226
- */
2227
- readonly choices?: Type extends unknown[] ? Type : Type[];
2228
-
2229
- /**
2230
- Default value when the flag is not specified.
2231
-
2232
- @example
2233
- ```
2234
- unicorn: {
2235
- type: 'boolean',
2236
- default: true
2237
- }
2238
- ```
2239
- */
2240
- readonly default?: Type;
2241
-
2242
- /**
2243
- A short flag alias.
2244
-
2245
- @example
2246
- ```
2247
- unicorn: {
2248
- shortFlag: 'u'
2249
- }
2250
- ```
2251
- */
2252
- readonly shortFlag?: string;
2253
-
2254
- /**
2255
- Other names for the flag.
2256
-
2257
- @example
2258
- ```
2259
- unicorn: {
2260
- aliases: ['unicorns', 'uni']
2261
- }
2262
- ```
2263
- */
2264
- readonly aliases?: string[];
2265
-
2266
- /**
2267
- Indicates a flag can be set multiple times. Values are turned into an array.
2268
-
2269
- Multiple values are provided by specifying the flag multiple times, for example, `$ foo -u rainbow -u cat`. Space- or comma-separated values [currently *not* supported](https://github.com/sindresorhus/meow/issues/164).
2270
-
2271
- @default false
2272
- */
2273
- readonly isMultiple?: IsMultiple;
2274
-
2275
- /**
2276
- Determine if the flag is required.
2277
-
2278
- If it's only known at runtime whether the flag is required or not you can pass a Function instead of a boolean, which based on the given flags and other non-flag arguments should decide if the flag is required.
2279
-
2280
- - The first argument is the **flags** object, which contains the flags converted to camel-case excluding aliases.
2281
- - The second argument is the **input** string array, which contains the non-flag arguments.
2282
- - The function should return a `boolean`, true if the flag is required, otherwise false.
2283
-
2284
- @default false
2285
-
2286
- @example
2287
- ```
2288
- isRequired: (flags, input) => {
2289
- if (flags.otherFlag) {
2290
- return true;
2291
- }
2292
-
2293
- return false;
2294
- }
2295
- ```
2296
- */
2297
- readonly isRequired?: boolean | IsRequiredPredicate;
2298
- };
2299
-
2300
- type StringFlag = Flag<'string', string> | Flag<'string', string[], true>;
2301
- type BooleanFlag = Flag<'boolean', boolean> | Flag<'boolean', boolean[], true>;
2302
- type NumberFlag = Flag<'number', number> | Flag<'number', number[], true>;
2303
- type AnyFlag = StringFlag | BooleanFlag | NumberFlag;
2304
- type AnyFlags = Record<string, AnyFlag>;
2305
-
2306
- type InputOptionType = 'string' | 'boolean' | 'number' | 'array' | 'string-array' | 'boolean-array' | 'number-array';
2307
-
2308
- type InputOption = {
2309
- /**
2310
- The data type the input arguments should be parsed to.
2311
- */
2312
- readonly type?: InputOptionType;
2313
-
2314
- /**
2315
- Determine if at least one non-flag input argument is required.
2316
-
2317
- If it's only known at runtime whether the input is required or not, you can pass a `Function` instead of a `boolean`, which based on the given input should decide if it's required.
2318
-
2319
- @default false
2320
-
2321
- @example
2322
- ```
2323
- input: {
2324
- isRequired: true
2325
- }
2326
- ```
2327
- */
2328
- readonly isRequired?: boolean | ((input: readonly string[]) => boolean);
2329
- };
2330
-
2331
- type Options<Flags extends AnyFlags> = {
2332
- /**
2333
- Pass in [`import.meta`](https://nodejs.org/dist/latest/docs/api/esm.html#esm_import_meta). This is used to find the correct package.json file.
2334
- */
2335
- readonly importMeta: ImportMeta;
2336
-
2337
- /**
2338
- Define argument flags.
2339
-
2340
- The key is the flag name in camel-case and the value is an object with any of:
2341
-
2342
- - `type`: Type of value. (Possible values: `string` `boolean` `number`)
2343
- - `choices`: Limit valid values to a predefined set of choices.
2344
- - `default`: Default value when the flag is not specified.
2345
- - `shortFlag`: A short flag alias.
2346
- - `aliases`: Other names for the flag.
2347
- - `isMultiple`: Indicates a flag can be set multiple times. Values are turned into an array. (Default: false)
2348
- - Multiple values are provided by specifying the flag multiple times, for example, `$ foo -u rainbow -u cat`. Space- or comma-separated values [currently *not* supported](https://github.com/sindresorhus/meow/issues/164).
2349
- - `isRequired`: Determine if the flag is required. (Default: false)
2350
- - If it's only known at runtime whether the flag is required or not, you can pass a `Function` instead of a `boolean`, which based on the given flags and other non-flag arguments, should decide if the flag is required. Two arguments are passed to the function:
2351
- - The first argument is the **flags** object, which contains the flags converted to camel-case excluding aliases.
2352
- - The second argument is the **input** string array, which contains the non-flag arguments.
2353
- - The function should return a `boolean`, true if the flag is required, otherwise false.
2354
-
2355
- Note that flags are always defined using a camel-case key (`myKey`), but will match arguments in kebab-case (`--my-key`).
2356
-
2357
- @example
2358
- ```
2359
- flags: {
2360
- unicorn: {
2361
- type: 'string',
2362
- choices: ['rainbow', 'cat', 'unicorn'],
2363
- default: ['rainbow', 'cat'],
2364
- shortFlag: 'u',
2365
- aliases: ['unicorns'],
2366
- isMultiple: true,
2367
- isRequired: (flags, input) => {
2368
- if (flags.otherFlag) {
2369
- return true;
2370
- }
2371
-
2372
- return false;
2373
- }
2374
- }
2375
- }
2376
- ```
2377
- */
2378
- readonly flags?: Flags;
2379
-
2380
- /**
2381
- Options for non-flag input arguments.
2382
-
2383
- @example
2384
- ```
2385
- input: 'number'
2386
- ```
2387
-
2388
- @example
2389
- ```
2390
- input: {
2391
- type: 'number',
2392
- isRequired: true
2393
- }
2394
- ```
2395
- */
2396
- readonly input?: InputOption | InputOptionType;
2397
-
2398
- /**
2399
- List of valid commands. Commands must be a single argument without whitespace and must not start with `-`.
2400
-
2401
- When set, parsing stops at the first non-flag argument and treats it as the command. The remaining arguments are returned in `input` so they can be passed to a subcommand parser. An unknown command will show help and exit with code 2. Parent flags must appear before the command.
2402
-
2403
- If no command is given, `cli.command` is `undefined` and meow does not exit — you decide what to do (show help, run a default, etc.).
2404
-
2405
- @example
2406
- ```
2407
- import meow from 'meow';
2408
-
2409
- const cli = meow({
2410
- importMeta: import.meta,
2411
- commands: ['run', 'list'],
2412
- flags: {
2413
- verbose: {
2414
- type: 'boolean',
2415
- shortFlag: 'v'
2416
- }
2417
- }
2418
- });
2419
-
2420
- if (!cli.command) {
2421
- cli.showHelp(0);
2422
- }
2423
-
2424
- if (cli.command === 'run') {
2425
- const runCli = meow({importMeta: import.meta, argv: cli.input});
2426
- }
2427
- ```
2428
- */
2429
- readonly commands?: readonly string[];
2430
-
2431
- /**
2432
- Description to show above the help text. Default: The package.json `"description"` property.
2433
-
2434
- Set it to `false` to disable it altogether.
2435
- */
2436
- readonly description?: string | false;
2437
-
2438
- /**
2439
- The help text you want shown.
2440
-
2441
- The input is reindented and starting/ending newlines are trimmed which means you can use a [template literal](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/template_strings) without having to care about using the correct amount of indent.
2442
-
2443
- The description will be shown above your help text automatically.
2444
-
2445
- Set it to `false` to disable it altogether.
2446
- */
2447
- readonly help?: string | false;
2448
-
2449
- /**
2450
- Set a custom version output. Default: The package.json `"version"` property.
2451
- */
2452
- readonly version?: string;
2453
-
2454
- /**
2455
- Automatically show the help text when the `--help` flag is present. Useful to set this value to `false` when a CLI manages child CLIs with their own help text.
2456
-
2457
- This is only triggered when `--help` is the only argument.
2458
- */
2459
- readonly autoHelp?: boolean;
2460
-
2461
- /**
2462
- Automatically show the version text when the `--version` flag is present. Useful to set this value to `false` when a CLI manages child CLIs with their own version text.
2463
-
2464
- This is only triggered when `--version` is the only argument.
2465
- */
2466
- readonly autoVersion?: boolean;
2467
-
2468
- /**
2469
- `package.json` as an `Object`. Default: Closest `package.json` upwards.
2470
-
2471
- Note: Setting this stops `meow` from finding a package.json.
2472
-
2473
- _You most likely don't need this option._
2474
- */
2475
- readonly pkg?: Record<string, unknown>;
2476
-
2477
- /**
2478
- Custom arguments object.
2479
-
2480
- @default process.argv.slice(2)
2481
- */
2482
- readonly argv?: readonly string[];
2483
-
2484
- /**
2485
- Infer the argument type.
2486
-
2487
- By default, the argument `5` in `$ foo 5` becomes a string. Enabling this would infer it as a number.
2488
-
2489
- @default false
2490
- */
2491
- readonly inferType?: boolean;
2492
-
2493
- /**
2494
- Value of `boolean` flags not defined in `argv`.
2495
-
2496
- If set to `undefined`, the flags not defined in `argv` will be excluded from the result. The `default` value set in `boolean` flags take precedence over `booleanDefault`.
2497
-
2498
- _Note: If used in conjunction with `isMultiple`, the default flag value is set to `[]`._
2499
-
2500
- __Caution: Explicitly specifying `undefined` for `booleanDefault` has different meaning from omitting key itself.__
2501
-
2502
- @example
2503
- ```
2504
- import meow from 'meow';
2505
-
2506
- const cli = meow(`
2507
- Usage
2508
- $ foo
2509
-
2510
- Options
2511
- --rainbow, -r Include a rainbow
2512
- --unicorn, -u Include a unicorn
2513
- --no-sparkles Exclude sparkles
2514
-
2515
- Examples
2516
- $ foo
2517
- 🌈 unicorns✨🌈
2518
- `, {
2519
- importMeta: import.meta,
2520
- booleanDefault: undefined,
2521
- flags: {
2522
- rainbow: {
2523
- type: 'boolean',
2524
- default: true,
2525
- shortFlag: 'r'
2526
- },
2527
- unicorn: {
2528
- type: 'boolean',
2529
- default: false,
2530
- shortFlag: 'u'
2531
- },
2532
- cake: {
2533
- type: 'boolean',
2534
- shortFlag: 'c'
2535
- },
2536
- sparkles: {
2537
- type: 'boolean',
2538
- default: true
2539
- }
2540
- }
2541
- });
2542
-
2543
- //{
2544
- // flags: {
2545
- // rainbow: true,
2546
- // unicorn: false,
2547
- // sparkles: true
2548
- // },
2549
- // unnormalizedFlags: {
2550
- // rainbow: true,
2551
- // r: true,
2552
- // unicorn: false,
2553
- // u: false,
2554
- // sparkles: true
2555
- // },
2556
- // …
2557
- //}
2558
- ```
2559
- */
2560
- readonly booleanDefault?: boolean | undefined;
2561
-
2562
- /**
2563
- Whether to allow unknown flags or not.
2564
-
2565
- @default true
2566
- */
2567
- readonly allowUnknownFlags?: boolean;
2568
-
2569
- /**
2570
- The number of spaces to use for indenting the help text.
2571
-
2572
- @default 2
2573
- */
2574
- readonly helpIndent?: number;
2575
- };
2576
-
2577
- type TypedFlag<Flag extends AnyFlag> =
2578
- Flag extends {type: 'number'}
2579
- ? number
2580
- : Flag extends {type: 'string'}
2581
- ? string
2582
- : Flag extends {type: 'boolean'}
2583
- ? boolean
2584
- : unknown;
2585
-
2586
- type PossiblyOptionalFlag<Flag extends AnyFlag, FlagType> =
2587
- Flag extends {isRequired: true}
2588
- ? FlagType
2589
- : Flag extends {default: any}
2590
- ? FlagType
2591
- : FlagType | undefined;
2592
-
2593
- type TypedFlags<Flags extends AnyFlags> = {
2594
- [F in keyof Flags]: Flags[F] extends {isMultiple: true}
2595
- ? PossiblyOptionalFlag<Flags[F], Array<TypedFlag<Flags[F]>>>
2596
- : PossiblyOptionalFlag<Flags[F], TypedFlag<Flags[F]>>
2597
- };
2598
-
2599
- type Result<Flags extends AnyFlags> = {
2600
- /**
2601
- Non-flag arguments.
2602
- */
2603
- input: string[];
2604
-
2605
- /**
2606
- Command name when using the `commands` option.
2607
- */
2608
- command?: string;
2609
-
2610
- /**
2611
- Flags converted to camelCase excluding aliases.
2612
- */
2613
- flags: CamelCasedProperties<TypedFlags<Flags>> & Record<string, unknown>;
2614
-
2615
- /**
2616
- Flags converted camelCase including aliases.
2617
- */
2618
- unnormalizedFlags: TypedFlags<Flags> & Record<string, unknown>;
2619
-
2620
- /**
2621
- The `package.json` object.
2622
- */
2623
- pkg: PackageJson;
2624
-
2625
- /**
2626
- The help text used with `--help`.
2627
- */
2628
- help: string;
2629
-
2630
- /**
2631
- Show the help text and exit with code.
2632
-
2633
- @param exitCode - The exit code to use. Default: `2`.
2634
- */
2635
- showHelp: (exitCode?: number) => never;
2636
-
2637
- /**
2638
- Show the version text and exit.
2639
- */
2640
- showVersion: () => never;
2641
- };
2642
- /**
2643
- @param helpMessage - Shortcut for the `help` option.
2644
-
2645
- @example
2646
- ```
2647
- #!/usr/bin/env node
2648
- import meow from 'meow';
2649
- import foo from './index.js';
2650
-
2651
- const cli = meow(`
2652
- Usage
2653
- $ foo <input>
2654
-
2655
- Options
2656
- --rainbow, -r Include a rainbow
2657
-
2658
- Examples
2659
- $ foo unicorns --rainbow
2660
- 🌈 unicorns 🌈
2661
- `, {
2662
- importMeta: import.meta, // This is required
2663
- flags: {
2664
- rainbow: {
2665
- type: 'boolean',
2666
- shortFlag: 'r'
2667
- }
2668
- }
2669
- });
2670
-
2671
- //{
2672
- // input: ['unicorns'],
2673
- // flags: {rainbow: true},
2674
- // ...
2675
- //}
2676
-
2677
- foo(cli.input.at(0), cli.flags);
2678
- ```
2679
- */
2680
- declare function meow<Flags extends AnyFlags>(helpMessage: string, options: Options<Flags>): Result<Flags>;
2681
- declare function meow<Flags extends AnyFlags>(options: Options<Flags>): Result<Flags>;
2682
-
2683
- export { meow as default };
2684
- export type { AnyFlag, AnyFlags, Flag, FlagType, InputOption, InputOptionType, IsRequiredPredicate, Options, Result, TypedFlags };