@astryxdesign/cli 0.7.2-canary.a3f5dbf → 0.7.2-canary.a44ebd5

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 (474) hide show
  1. package/README.md +169 -148
  2. package/api/build/_adapter.d.mts +8 -0
  3. package/api/build/_adapter.mjs +12 -1
  4. package/api/build/build.doc.mjs +4 -0
  5. package/api/build/help/help.mjs +1 -1
  6. package/api/build/kit/kit.mjs +3 -11
  7. package/api/component/_adapter.d.mts +31 -0
  8. package/api/component/_adapter.mjs +119 -11
  9. package/api/component/component.doc.mjs +6 -1
  10. package/api/component/component.mjs +60 -10
  11. package/api/component/doc-links.test.mjs +386 -0
  12. package/api/discover/_adapter.d.mts +132 -12
  13. package/api/discover/_adapter.mjs +488 -27
  14. package/api/discover/_adapter.test.mjs +599 -17
  15. package/api/discover/_catalog-view.d.mts +16 -5
  16. package/api/discover/_catalog-view.mjs +32 -8
  17. package/api/discover/detail/doc/doc.mjs +9 -1
  18. package/api/discover/discover.d.mts +11 -0
  19. package/api/discover/discover.doc.mjs +9 -7
  20. package/api/discover/discover.mjs +121 -19
  21. package/api/discover/discover.type.d.mts +20 -7
  22. package/api/discover/discover.type.mjs +17 -7
  23. package/api/discover/list/list.d.mts +4 -3
  24. package/api/discover/list/list.mjs +17 -10
  25. package/api/docs/_adapter.d.mts +74 -0
  26. package/api/docs/_adapter.mjs +348 -17
  27. package/api/docs/docs.doc.mjs +2 -1
  28. package/api/docs/docs.mjs +2 -1
  29. package/api/docs/docs.test.mjs +5 -2
  30. package/api/docs/integration-tree.test.mjs +22 -0
  31. package/api/docs/list/list.mjs +12 -2
  32. package/api/docs/reference-blocks.test.mjs +1 -3
  33. package/api/doctor/_adapter.d.mts +108 -0
  34. package/api/doctor/_adapter.mjs +223 -4
  35. package/api/doctor/doctor.d.mts +199 -0
  36. package/api/doctor/doctor.doc.mjs +3 -2
  37. package/api/doctor/doctor.mjs +530 -34
  38. package/api/doctor/doctor.test.mjs +180 -14
  39. package/api/doctor/release-checks.test.mjs +156 -0
  40. package/api/doctor/theme-checks.mjs +17 -4
  41. package/api/doctor/theme-checks.test.mjs +223 -7
  42. package/api/error.d.mts +10 -0
  43. package/api/error.mjs +25 -0
  44. package/api/gap-report/gap-report.d.mts +3 -0
  45. package/api/gap-report/gap-report.doc.mjs +11 -3
  46. package/api/gap-report/gap-report.mjs +152 -48
  47. package/api/gap-report/gap-report.test.mjs +233 -0
  48. package/api/gap-report/gap-report.type.d.mts +41 -0
  49. package/api/gap-report/gap-report.type.mjs +18 -0
  50. package/api/hook/_adapter.mjs +3 -11
  51. package/api/hook/hook.doc.mjs +4 -0
  52. package/api/hook/list/list.d.mts +1 -1
  53. package/api/index.d.mts +2 -0
  54. package/api/index.mjs +2 -0
  55. package/api/init/_adapter.d.mts +22 -0
  56. package/api/init/_adapter.mjs +59 -0
  57. package/api/init/init.d.mts +7 -5
  58. package/api/init/init.doc.mjs +28 -7
  59. package/api/init/init.mjs +28 -4
  60. package/api/init/init.type.d.mts +48 -3
  61. package/api/init/init.type.mjs +37 -3
  62. package/api/init/run/run.d.mts +1 -1
  63. package/api/init/run/run.mjs +17 -6
  64. package/api/init/user/user.d.mts +14 -0
  65. package/api/init/user/user.mjs +87 -0
  66. package/api/init/user/user.test.mjs +232 -0
  67. package/api/integration/_adapter.d.mts +33 -0
  68. package/api/integration/_adapter.mjs +58 -0
  69. package/api/integration/add-contribution.mjs +1 -1
  70. package/api/integration/add-contribution.test.mjs +4 -2
  71. package/api/integration/authoring-checks.mjs +100 -5
  72. package/api/integration/authoring-checks.test.mjs +769 -0
  73. package/api/integration/authoring-checks.type.d.mts +134 -0
  74. package/api/integration/authoring-checks.type.mjs +60 -1
  75. package/api/integration/check/check.d.mts +96 -0
  76. package/api/integration/check/check.mjs +357 -0
  77. package/api/integration/check/check.test.mjs +489 -0
  78. package/api/integration/integration-check.type.d.mts +118 -0
  79. package/api/integration/integration-check.type.mjs +84 -0
  80. package/api/integration/integrationCheck.doc.d.mts +10 -0
  81. package/api/integration/integrationCheck.doc.mjs +73 -0
  82. package/api/integration/integrationComponentConflicts.doc.mjs +29 -6
  83. package/api/integration/integrationDocConflicts.doc.mjs +22 -5
  84. package/api/integration/pack-check.mjs +303 -13
  85. package/api/integration/pack-check.test.mjs +371 -10
  86. package/api/integration/validate-integration-fixes.test.mjs +67 -0
  87. package/api/integration/validate-integration.d.mts +8 -0
  88. package/api/integration/validate-integration.mjs +63 -9
  89. package/api/integration/validate-integration.test.mjs +77 -8
  90. package/api/integration/validate-integration.type.d.mts +16 -0
  91. package/api/integration/validate-integration.type.mjs +14 -1
  92. package/api/integration/validate-unread-theme-folders.test.mjs +3 -2
  93. package/api/integration/validateIntegration.doc.mjs +19 -3
  94. package/api/search/_adapter.d.mts +11 -0
  95. package/api/search/_adapter.mjs +25 -0
  96. package/api/search/search.d.mts +73 -13
  97. package/api/search/search.doc.mjs +8 -3
  98. package/api/search/search.domain-priority.test.mjs +108 -18
  99. package/api/search/search.integration-check.test.mjs +24 -0
  100. package/api/search/search.mjs +541 -52
  101. package/api/search/search.test.mjs +143 -1
  102. package/api/search/search.type.d.mts +14 -1
  103. package/api/search/search.type.mjs +6 -1
  104. package/api/swizzle/_adapter.mjs +2 -2
  105. package/api/swizzle/copy/copy.mjs +1 -1
  106. package/api/template/template-integration.test.mjs +1 -1
  107. package/api/theme/_adapter.d.mts +16 -0
  108. package/api/theme/_adapter.mjs +32 -5
  109. package/api/theme/build/build.d.mts +2 -1
  110. package/api/theme/build/build.family.test.mjs +54 -6
  111. package/api/theme/build/build.mjs +184 -31
  112. package/api/theme/build/build.packed-old-core.test.mjs +20 -3
  113. package/api/theme/build/font-warning.mjs +5 -3
  114. package/api/theme/build/font-warning.test.mjs +2 -1
  115. package/api/theme/remove/remove.test.mjs +2 -2
  116. package/api/theme/targets/targets.mjs +3 -10
  117. package/api/theme/themeBuild.doc.mjs +4 -4
  118. package/api/theme/themeTargets.doc.mjs +4 -0
  119. package/api/theme/use/use.test.mjs +1 -1
  120. package/api/upgrade/_adapter.d.mts +40 -2
  121. package/api/upgrade/_adapter.mjs +118 -5
  122. package/api/upgrade/run/cli-behind-core.test.mjs +438 -0
  123. package/api/upgrade/run/run.mjs +35 -2
  124. package/api/upgrade/status/status.d.mts +21 -5
  125. package/api/upgrade/status/status.mjs +45 -8
  126. package/api/upgrade/upgrade.doc.mjs +6 -3
  127. package/api/upgrade/upgrade.mjs +5 -1
  128. package/api/upgrade/upgrade.type.d.mts +23 -0
  129. package/api/upgrade/upgrade.type.mjs +16 -1
  130. package/assets/codemods/runner.mjs +7 -1
  131. package/assets/discover/official-packages.json +367 -0
  132. package/assets/docs/README.md +10 -0
  133. package/assets/docs/author-a-theme.doc.mjs +3 -3
  134. package/assets/docs/browser-support.doc.mjs +1 -1
  135. package/assets/docs/getting-started.doc.mjs +26 -6
  136. package/assets/docs/styling-overview.doc.mjs +1 -1
  137. package/assets/docs/theme.doc.dense.mjs +1 -1
  138. package/assets/docs/theme.doc.mjs +2 -2
  139. package/assets/docs/theme.doc.zh.mjs +1 -1
  140. package/assets/docs/tree/add-a-component.doc.mjs +12 -2
  141. package/assets/docs/tree/add-a-theme.doc.mjs +13 -3
  142. package/assets/docs/tree/add-a-topic.doc.mjs +54 -9
  143. package/assets/docs/tree/agent-guidance.doc.mjs +19 -5
  144. package/assets/docs/tree/block-template.doc.mjs +8 -20
  145. package/assets/docs/tree/build-the-template.doc.mjs +1 -1
  146. package/assets/docs/tree/building-blocks.doc.mjs +4 -0
  147. package/assets/docs/tree/check-the-props.doc.mjs +59 -3
  148. package/assets/docs/tree/check-your-docs.doc.mjs +69 -11
  149. package/assets/docs/tree/checks.doc.mjs +30 -22
  150. package/assets/docs/tree/ci-and-containers.doc.mjs +88 -0
  151. package/assets/docs/tree/cli-command.doc.mjs +142 -0
  152. package/assets/docs/tree/cli.doc.mjs +6 -0
  153. package/assets/docs/tree/codemods.doc.mjs +17 -7
  154. package/assets/docs/tree/commands.doc.mjs +7 -1
  155. package/assets/docs/tree/component-family.doc.mjs +3 -5
  156. package/assets/docs/tree/component-imports.doc.mjs +13 -3
  157. package/assets/docs/tree/components.doc.mjs +7 -1
  158. package/assets/docs/tree/computer-agent-guide.doc.mjs +160 -0
  159. package/assets/docs/tree/computer-integrations.doc.mjs +93 -0
  160. package/assets/docs/tree/configuration.doc.mjs +7 -3
  161. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +41 -22
  162. package/assets/docs/tree/define-the-theme.doc.mjs +6 -5
  163. package/assets/docs/tree/describe-the-component.doc.mjs +2 -2
  164. package/assets/docs/tree/docs.doc.mjs +9 -3
  165. package/assets/docs/tree/document-the-template.doc.mjs +1 -1
  166. package/assets/docs/tree/document-the-theme.doc.mjs +3 -3
  167. package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
  168. package/assets/docs/tree/extend-or-replace.doc.mjs +19 -9
  169. package/assets/docs/tree/fonts-and-assets.doc.mjs +2 -2
  170. package/assets/docs/tree/generate-a-palette.doc.mjs +7 -5
  171. package/assets/docs/tree/global-integrations.doc.mjs +124 -0
  172. package/assets/docs/tree/global.doc.mjs +131 -0
  173. package/assets/docs/tree/grade-template-with-agent.doc.mjs +5 -5
  174. package/assets/docs/tree/install-once.doc.mjs +105 -0
  175. package/assets/docs/tree/integrations.doc.mjs +13 -1
  176. package/assets/docs/tree/layout-spacing.doc.mjs +2 -3
  177. package/assets/docs/tree/layout.doc.mjs +6 -6
  178. package/assets/docs/tree/links.doc.mjs +6 -5
  179. package/assets/docs/tree/migration-setup.doc.mjs +3 -2
  180. package/assets/docs/tree/migration-verification.doc.mjs +0 -1
  181. package/assets/docs/tree/migration.doc.mjs +0 -1
  182. package/assets/docs/tree/monorepos.doc.mjs +84 -0
  183. package/assets/docs/tree/package-and-test.doc.mjs +1 -1
  184. package/assets/docs/tree/page-template.doc.mjs +4 -8
  185. package/assets/docs/tree/problems.doc.mjs +205 -0
  186. package/assets/docs/tree/project-global-or-both.doc.mjs +131 -0
  187. package/assets/docs/tree/publishing.doc.mjs +6 -6
  188. package/assets/docs/tree/quick-start.doc.mjs +53 -27
  189. package/assets/docs/tree/reference.doc.mjs +192 -0
  190. package/assets/docs/tree/replace-a-core-component.doc.mjs +15 -7
  191. package/assets/docs/tree/replace-a-core-template.doc.mjs +10 -12
  192. package/assets/docs/tree/scaffold.doc.mjs +1 -1
  193. package/assets/docs/tree/sections-and-placement.doc.mjs +9 -11
  194. package/assets/docs/tree/see-it-in-an-app.doc.mjs +17 -5
  195. package/assets/docs/tree/short-and-findable.doc.mjs +9 -8
  196. package/assets/docs/tree/single-component.doc.mjs +14 -6
  197. package/assets/docs/tree/start-a-template.doc.mjs +18 -8
  198. package/assets/docs/tree/subcomponent.doc.mjs +6 -6
  199. package/assets/docs/tree/template-assets.doc.mjs +2 -2
  200. package/assets/docs/tree/template-doc-overview.doc.mjs +6 -17
  201. package/assets/docs/tree/template-fonts.doc.mjs +1 -1
  202. package/assets/docs/tree/template-icons.doc.mjs +1 -1
  203. package/assets/docs/tree/template-images-media.doc.mjs +1 -1
  204. package/assets/docs/tree/template-styles.doc.mjs +2 -2
  205. package/assets/docs/tree/templates.doc.mjs +7 -1
  206. package/assets/docs/tree/test-in-an-app.doc.mjs +7 -7
  207. package/assets/docs/tree/test-template-in-app.doc.mjs +5 -5
  208. package/assets/docs/tree/themes.doc.mjs +4 -0
  209. package/assets/docs/tree/tokens-and-setup.doc.mjs +19 -15
  210. package/assets/docs/tree/troubleshooting.doc.mjs +22 -14
  211. package/assets/docs/tree/type-scale.doc.mjs +3 -3
  212. package/assets/docs/tree/uninstall.doc.mjs +109 -0
  213. package/assets/docs/tree/updates.doc.mjs +92 -0
  214. package/assets/docs/tree/upgrading.doc.mjs +6 -6
  215. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +14 -2
  216. package/assets/docs/tree/verify-packed-template.doc.mjs +3 -3
  217. package/assets/docs/tree/versioning.doc.mjs +9 -9
  218. package/assets/docs/tree/who-answers.doc.mjs +119 -0
  219. package/assets/docs/tree/write-the-template-file.doc.mjs +7 -6
  220. package/assets/docs/use-a-theme.doc.mjs +2 -2
  221. package/assets/docs/working-with-ai.doc.mjs +23 -9
  222. package/assets/theme.template.ts +1 -1
  223. package/authoring/codemod/codemod.doc.mjs +7 -3
  224. package/authoring/config/config.doc.mjs +9 -6
  225. package/authoring/config/type.ts +4 -2
  226. package/authoring/debug/parse.d.mts +5 -5
  227. package/authoring/discover/discover.doc.mjs +7 -1
  228. package/authoring/doctypes/_schema.d.mts +8 -3
  229. package/authoring/doctypes/_schema.mjs +1 -0
  230. package/authoring/doctypes/base/graph-fields.doc.mjs +6 -4
  231. package/authoring/doctypes/command/command.doc.mjs +20 -12
  232. package/authoring/doctypes/command/type.ts +14 -0
  233. package/authoring/doctypes/component/component.doc.mjs +29 -26
  234. package/authoring/doctypes/component/type.ts +15 -5
  235. package/authoring/doctypes/enum/enum.doc.mjs +7 -4
  236. package/authoring/doctypes/function/function.doc.mjs +9 -8
  237. package/authoring/doctypes/hook/hook.doc.mjs +5 -4
  238. package/authoring/doctypes/hook/type.ts +4 -0
  239. package/authoring/doctypes/namespace/namespace.doc.mjs +7 -6
  240. package/authoring/doctypes/reference/reference.doc.mjs +12 -11
  241. package/authoring/doctypes/schema/schema.doc.mjs +9 -9
  242. package/authoring/doctypes/template/integration-template.doc.d.mts +11 -0
  243. package/authoring/doctypes/template/integration-template.doc.mjs +49 -0
  244. package/authoring/doctypes/template/parse.d.mts +6 -2
  245. package/authoring/doctypes/template/parse.mjs +3 -1
  246. package/authoring/doctypes/template/template.doc.mjs +3 -3
  247. package/authoring/doctypes/template/type.ts +22 -0
  248. package/authoring/doctypes/theme/theme.doc.mjs +2 -2
  249. package/authoring/gap-report/gap-report.doc.mjs +2 -2
  250. package/authoring/identity/identity.doc.mjs +3 -3
  251. package/authoring/index.d.ts +2 -0
  252. package/authoring/integration/integration.doc.mjs +22 -5
  253. package/authoring/integration/parse.test.mjs +11 -0
  254. package/authoring/integration/schema.d.mts +14 -3
  255. package/authoring/integration/schema.mjs +33 -2
  256. package/authoring/integration/type.ts +8 -0
  257. package/clients/cli/bin/astryx.mjs +20 -3
  258. package/clients/cli/cli-command.test.mjs +166 -0
  259. package/clients/cli/commands/blog.doc.mjs +1 -0
  260. package/clients/cli/commands/build-theme.batch-report.test.mjs +17 -3
  261. package/clients/cli/commands/build-theme.font-warning.test.mjs +3 -3
  262. package/clients/cli/commands/build-theme.mjs +26 -13
  263. package/clients/cli/commands/build-theme.path-safety.test.mjs +155 -21
  264. package/clients/cli/commands/build.doc.mjs +1 -0
  265. package/clients/cli/commands/build.exit-codes-doc.test.mjs +4 -0
  266. package/clients/cli/commands/cli-postinstall.test.mjs +49 -1
  267. package/clients/cli/commands/component.doc.mjs +1 -0
  268. package/clients/cli/commands/discover.broken-integration.test.mjs +11 -7
  269. package/clients/cli/commands/discover.doc.mjs +9 -1
  270. package/clients/cli/commands/discover.mjs +144 -93
  271. package/clients/cli/commands/discover.no-source.test.mjs +448 -33
  272. package/clients/cli/commands/discover.sources.test.mjs +20 -1
  273. package/clients/cli/commands/docs.doc.mjs +1 -0
  274. package/clients/cli/commands/docs.mjs +49 -19
  275. package/clients/cli/commands/docs.test.mjs +2 -2
  276. package/clients/cli/commands/doctor-integration-components.doc.mjs +15 -6
  277. package/clients/cli/commands/doctor-integration-docs.doc.mjs +20 -5
  278. package/clients/cli/commands/doctor-integration-templates.doc.mjs +1 -0
  279. package/clients/cli/commands/doctor-integration-validate.doc.mjs +22 -2
  280. package/clients/cli/commands/doctor-integration.test.mjs +498 -5
  281. package/clients/cli/commands/doctor.doc.mjs +12 -2
  282. package/clients/cli/commands/doctor.mjs +218 -7
  283. package/clients/cli/commands/doctor.test.mjs +10 -4
  284. package/clients/cli/commands/gap-report.doc.mjs +15 -2
  285. package/clients/cli/commands/gap-report.mjs +24 -2
  286. package/clients/cli/commands/gap-report.test.mjs +79 -0
  287. package/clients/cli/commands/hook.doc.mjs +1 -0
  288. package/clients/cli/commands/init.behavior.test.mjs +5 -0
  289. package/clients/cli/commands/init.doc.mjs +29 -3
  290. package/clients/cli/commands/integration-add.doc.mjs +7 -0
  291. package/clients/cli/commands/integration-authoring.test.mjs +49 -3
  292. package/clients/cli/commands/integration-check.doc.mjs +93 -0
  293. package/clients/cli/commands/integration-check.test.mjs +441 -0
  294. package/clients/cli/commands/integration-pack.doc.mjs +8 -1
  295. package/clients/cli/commands/integration-verify.doc.mjs +8 -1
  296. package/clients/cli/commands/integration.doc.mjs +6 -2
  297. package/clients/cli/commands/integration.mjs +119 -7
  298. package/clients/cli/commands/json-contract.test.mjs +11 -2
  299. package/clients/cli/commands/manifest.doc.mjs +1 -0
  300. package/clients/cli/commands/outside-project.test.mjs +774 -0
  301. package/clients/cli/commands/search.doc.mjs +1 -0
  302. package/clients/cli/commands/search.mjs +16 -11
  303. package/clients/cli/commands/search.test.mjs +429 -296
  304. package/clients/cli/commands/setup-nudge.test.mjs +102 -2
  305. package/clients/cli/commands/swizzle.doc.mjs +7 -0
  306. package/clients/cli/commands/swizzle.mjs +5 -3
  307. package/clients/cli/commands/swizzle.routing.test.mjs +19 -2
  308. package/clients/cli/commands/template.doc.mjs +1 -0
  309. package/clients/cli/commands/text-json-parity.test.mjs +5 -0
  310. package/clients/cli/commands/theme-add-lifecycle.test.mjs +3 -3
  311. package/clients/cli/commands/theme-add.doc.mjs +8 -1
  312. package/clients/cli/commands/theme-build.doc.mjs +3 -2
  313. package/clients/cli/commands/theme-eject.doc.mjs +1 -0
  314. package/clients/cli/commands/theme-list.behavior.test.mjs +6 -0
  315. package/clients/cli/commands/theme-list.doc.mjs +1 -0
  316. package/clients/cli/commands/theme-palette-generate.doc.mjs +1 -0
  317. package/clients/cli/commands/theme-remove.doc.mjs +7 -0
  318. package/clients/cli/commands/theme-targets.doc.mjs +1 -0
  319. package/clients/cli/commands/theme-template.doc.mjs +1 -0
  320. package/clients/cli/commands/theme-use.doc.mjs +7 -0
  321. package/clients/cli/commands/upgrade.config-ordering.test.mjs +2 -1
  322. package/clients/cli/commands/upgrade.doc.mjs +22 -1
  323. package/clients/cli/commands/upgrade.file-protection.test.mjs +3 -2
  324. package/clients/cli/commands/upgrade.hook-output.test.mjs +2 -1
  325. package/clients/cli/commands/upgrade.older-cli.test.mjs +160 -0
  326. package/clients/cli/index.mjs +112 -16
  327. package/clients/cli/lib/cli-error.mjs +4 -1
  328. package/clients/cli/lib/component-format.test.mjs +1 -1
  329. package/clients/cli/lib/define-command.mjs +2 -2
  330. package/clients/cli/lib/json-shim.mjs +3 -1
  331. package/clients/cli/lib/manifest.d.ts +9 -0
  332. package/clients/cli/lib/manifest.mjs +17 -1
  333. package/clients/cli/lib/manifest.test.mjs +25 -0
  334. package/foundation/agent-docs/agent-doc-state.d.mts +35 -6
  335. package/foundation/agent-docs/agent-doc-state.mjs +66 -6
  336. package/foundation/agent-docs/agent-docs.d.mts +4 -3
  337. package/foundation/agent-docs/agent-docs.mjs +11 -9
  338. package/foundation/agent-docs/computer-agent-text.d.mts +133 -0
  339. package/foundation/agent-docs/computer-agent-text.mjs +623 -0
  340. package/foundation/agent-docs/computer-agent-text.test.mjs +602 -0
  341. package/foundation/config/project.d.mts +35 -3
  342. package/foundation/config/project.mjs +145 -8
  343. package/foundation/config/project.test.mjs +66 -0
  344. package/foundation/config/theme-state.mjs +5 -4
  345. package/foundation/discovery/authoring-self-docs.mjs +2 -1
  346. package/foundation/discovery/cli-self-docs.mjs +20 -3
  347. package/foundation/discovery/cli-self-docs.test.mjs +3 -2
  348. package/foundation/discovery/component-replacement.mjs +2 -1
  349. package/foundation/discovery/copied-passages.d.mts +216 -0
  350. package/foundation/discovery/copied-passages.mjs +720 -0
  351. package/foundation/discovery/copied-passages.test.mjs +124 -0
  352. package/foundation/discovery/doc-consistency.d.mts +34 -0
  353. package/foundation/discovery/doc-consistency.mjs +513 -0
  354. package/foundation/discovery/doc-consistency.test.mjs +347 -0
  355. package/foundation/discovery/doc-fluff.d.mts +112 -0
  356. package/foundation/discovery/doc-fluff.mjs +328 -0
  357. package/foundation/discovery/doc-fluff.test.mjs +142 -0
  358. package/foundation/discovery/doc-types.d.mts +157 -0
  359. package/foundation/discovery/doc-types.mjs +1231 -0
  360. package/foundation/discovery/doc-types.test.mjs +744 -0
  361. package/foundation/discovery/docs-discovery.d.mts +7 -0
  362. package/foundation/discovery/docs-discovery.mjs +26 -2
  363. package/foundation/discovery/integration-doc-files.d.mts +22 -0
  364. package/foundation/discovery/integration-doc-files.mjs +231 -0
  365. package/foundation/discovery/integration-doc-files.test.mjs +246 -0
  366. package/foundation/discovery/project-typescript.d.mts +11 -2
  367. package/foundation/discovery/project-typescript.mjs +32 -4
  368. package/foundation/discovery/prop-drift.d.mts +81 -4
  369. package/foundation/discovery/prop-drift.mjs +727 -64
  370. package/foundation/discovery/prop-drift.test.mjs +1150 -10
  371. package/foundation/discovery/runner-allowlist.d.mts +40 -0
  372. package/foundation/discovery/runner-allowlist.mjs +53 -0
  373. package/foundation/discovery/stray-pointers.d.mts +52 -0
  374. package/foundation/discovery/stray-pointers.mjs +293 -0
  375. package/foundation/discovery/stray-pointers.test.mjs +86 -0
  376. package/foundation/discovery/template-needs.mjs +5 -2
  377. package/foundation/discovery/theme-imports.mjs +8 -4
  378. package/foundation/discovery/theme-imports.test.mjs +1 -1
  379. package/foundation/discovery/type-text.mjs +1 -1
  380. package/foundation/discovery/type-text.test.mjs +1 -1
  381. package/foundation/doc-compiler/doc-loads.test.mjs +44 -2
  382. package/foundation/doc-compiler/inputs.mjs +4 -1
  383. package/foundation/doc-compiler/links.d.mts +32 -0
  384. package/foundation/doc-compiler/links.mjs +163 -26
  385. package/foundation/doc-compiler/links.test.mjs +97 -4
  386. package/foundation/doc-compiler/read.d.mts +1 -1
  387. package/foundation/doc-compiler/tree.mjs +30 -1
  388. package/foundation/doc-compiler/tree.test.mjs +8 -1
  389. package/foundation/env/cli-command.d.mts +83 -0
  390. package/foundation/env/cli-command.mjs +152 -0
  391. package/foundation/env/cli-command.test.mjs +129 -0
  392. package/foundation/env/node-version.test.mjs +15 -3
  393. package/foundation/env/package-manager.d.mts +93 -9
  394. package/foundation/env/package-manager.global.test.mjs +66 -0
  395. package/foundation/env/package-manager.mjs +184 -13
  396. package/foundation/env/package-manager.test.mjs +341 -15
  397. package/foundation/env/project-scope.d.mts +9 -0
  398. package/foundation/env/project-scope.mjs +33 -0
  399. package/foundation/env/search-path.d.mts +42 -0
  400. package/foundation/env/search-path.mjs +205 -0
  401. package/foundation/env/search-path.test.mjs +122 -0
  402. package/foundation/env/user-dirs.d.mts +39 -0
  403. package/foundation/env/user-dirs.mjs +93 -0
  404. package/foundation/env/user-dirs.test.mjs +72 -0
  405. package/foundation/env/user-settings.d.mts +46 -0
  406. package/foundation/env/user-settings.mjs +106 -0
  407. package/foundation/env/user-settings.test.mjs +64 -0
  408. package/foundation/fs/file-protection.mjs +15 -1
  409. package/foundation/fs/module-loader.d.mts +2 -1
  410. package/foundation/fs/module-loader.mjs +60 -4
  411. package/foundation/fs/module-loader.stdout.test.mjs +3 -2
  412. package/foundation/fs/module-loader.test.mjs +194 -0
  413. package/foundation/fs/path-compare.d.mts +33 -0
  414. package/foundation/fs/path-compare.mjs +73 -0
  415. package/foundation/fs/paths.d.mts +57 -1
  416. package/foundation/fs/paths.mjs +131 -3
  417. package/foundation/fs/paths.test.mjs +10 -1
  418. package/foundation/integrations/computer-integrations.d.mts +78 -0
  419. package/foundation/integrations/computer-integrations.mjs +316 -0
  420. package/foundation/integrations/computer-integrations.test.mjs +292 -0
  421. package/foundation/integrations/contribution-inventory.d.mts +11 -0
  422. package/foundation/integrations/contribution-inventory.mjs +50 -2
  423. package/foundation/integrations/integration-warnings.mjs +3 -2
  424. package/foundation/integrations/integration-warnings.test.mjs +8 -9
  425. package/foundation/integrations/integrations.d.mts +25 -1
  426. package/foundation/integrations/integrations.mjs +46 -3
  427. package/foundation/integrations/issue.ts +6 -0
  428. package/foundation/integrations/validate-contributions.d.mts +2 -0
  429. package/foundation/integrations/validate-contributions.mjs +41 -1
  430. package/foundation/release/agent-text-worker.d.mts +4 -0
  431. package/foundation/release/agent-text-worker.mjs +52 -0
  432. package/foundation/release/cache.d.mts +310 -0
  433. package/foundation/release/cache.mjs +1216 -0
  434. package/foundation/release/cache.test.mjs +920 -0
  435. package/foundation/release/choose.d.mts +207 -0
  436. package/foundation/release/choose.mjs +677 -0
  437. package/foundation/release/choose.test.mjs +427 -0
  438. package/foundation/release/core-worker.d.mts +4 -0
  439. package/foundation/release/core-worker.mjs +38 -0
  440. package/foundation/release/global-state.d.mts +259 -0
  441. package/foundation/release/global-state.mjs +472 -0
  442. package/foundation/release/global-state.test.mjs +381 -0
  443. package/foundation/release/handoff.d.mts +60 -0
  444. package/foundation/release/handoff.e2e.test.mjs +278 -0
  445. package/foundation/release/handoff.mjs +357 -0
  446. package/foundation/release/lock-lease.d.mts +23 -0
  447. package/foundation/release/lock-lease.mjs +80 -0
  448. package/foundation/release/notices.d.mts +253 -0
  449. package/foundation/release/notices.mjs +596 -0
  450. package/foundation/release/notices.test.mjs +565 -0
  451. package/foundation/release/npm-guard.d.mts +4 -0
  452. package/foundation/release/npm-guard.mjs +126 -0
  453. package/foundation/release/project.d.mts +141 -0
  454. package/foundation/release/project.mjs +466 -0
  455. package/foundation/release/project.test.mjs +288 -0
  456. package/foundation/release/refresh-worker.d.mts +4 -0
  457. package/foundation/release/refresh-worker.mjs +27 -0
  458. package/foundation/release/run-context.d.mts +47 -0
  459. package/foundation/release/run-context.mjs +149 -0
  460. package/foundation/release/update-notice-env.d.mts +28 -0
  461. package/foundation/release/update-notice-env.mjs +39 -0
  462. package/foundation/response/base.d.ts +26 -3
  463. package/foundation/response/error-codes.d.mts +3 -1
  464. package/foundation/response/error-codes.doc.mjs +12 -0
  465. package/foundation/response/error-codes.mjs +17 -0
  466. package/foundation/response/error-codes.test.mjs +2 -0
  467. package/foundation/response/json-contract.test.mjs +7 -2
  468. package/foundation/response/json.mjs +4 -1
  469. package/foundation/response/response-types.doc.mjs +22 -11
  470. package/foundation/response/response-types.doc.test.mjs +46 -0
  471. package/foundation/response/response.doc.mjs +3 -3
  472. package/foundation/xle/browser-imports.test.mjs +74 -0
  473. package/package.json +11 -11
  474. package/scripts/postinstall.mjs +24 -5
@@ -28,7 +28,14 @@
28
28
  * pass the prop (one only some members of the props type require, or that
29
29
  * the package's `defaultProps` fills, is optional, as it is to JSX
30
30
  * callers; an entry that names several props claims its `required` for
31
- * each).
31
+ * each);
32
+ * - `type_mismatch`: for a prop declared in the package, the documented type
33
+ * differs from the code's where both sides read exactly (type-match.mjs
34
+ * states the rules); every other type is listed as not compared;
35
+ * - `default_mismatch`: the doc's `default` and the literal default the
36
+ * component writes in its props parameter's destructuring (`size = 'md'`)
37
+ * differ, quotes and whitespace aside; where both write a default and
38
+ * either is not a literal, it is listed under `typesNotCompared`.
32
39
  *
33
40
  * @input Component records (name, docPath, sourcePath), or prop tables, the
34
41
  * package root, and the directories to resolve `typescript` from.
@@ -44,15 +51,18 @@ import {loadComponentDoc} from './component-loader.mjs';
44
51
  import {readPackageTsconfig} from './package-tsconfig.mjs';
45
52
  import {
46
53
  resolveProjectTypeScript,
54
+ TYPESCRIPT_FIX,
47
55
  unusableTypeScriptReason,
48
56
  } from './project-typescript.mjs';
57
+ import {judgeType} from './type-match.mjs';
58
+ import {typeTextTooOld} from './type-text.mjs';
49
59
  import {
50
60
  unresolvedGlobals,
51
61
  unresolvedReference,
52
62
  } from './unresolved-references.mjs';
53
63
 
54
64
  /**
55
- * @typedef {'not_in_code' | 'not_in_doc' | 'required_mismatch'} PropDriftKind
65
+ * @typedef {'not_in_code' | 'not_in_doc' | 'required_mismatch' | 'type_mismatch' | 'default_mismatch'} PropDriftKind
56
66
  */
57
67
 
58
68
  /**
@@ -68,6 +78,9 @@ import {
68
78
  * @property {string} [codeType] the type as the source declares it
69
79
  * @property {boolean} [docRequired]
70
80
  * @property {boolean} [codeRequired]
81
+ * @property {string} [docDefault] the documented default, as written
82
+ * @property {string} [codeDefault] the literal default the code writes
83
+ * @property {string} [fix] what to change, ready to paste
71
84
  */
72
85
 
73
86
  /**
@@ -77,6 +90,18 @@ import {
77
90
  * @property {string} reason why its props could not be read
78
91
  */
79
92
 
93
+ /**
94
+ * @typedef {object} PropDriftTypesNotCompared
95
+ * @property {string} component
96
+ * @property {string} doc the doc file, relative to the package root
97
+ * @property {string} reason why: not a form the check judges exactly, a
98
+ * field the prop's variants give different types, a standard prop
99
+ * (`className`, `style`, …), a prop declared outside the package, or a
100
+ * default that is not a literal on one side
101
+ * @property {string[]} props documented props whose types, or defaults, were
102
+ * not compared
103
+ */
104
+
80
105
  /**
81
106
  * @typedef {object} PropDriftReport
82
107
  * @property {'checked' | 'skipped'} status `skipped` means nothing was
@@ -84,12 +109,16 @@ import {
84
109
  * @property {string} [reason]
85
110
  * @property {string} [typescript] the version of the compiler that read the props
86
111
  * @property {number} components how many documented prop tables were compared
112
+ * @property {number} typesCompared how many documented prop types were judged
113
+ * @property {string} [typesSkipped] why no prop type was judged
87
114
  * @property {PropDriftFinding[]} findings
88
115
  * @property {PropDriftUnchecked[]} unchecked documented components whose props
89
116
  * could not be read from the source
90
117
  * @property {Array<PropDriftUnchecked & {props: string[]}>} [propsNotChecked]
91
118
  * props a mapped type builds from keys the check can't trace, which a doc
92
119
  * leaving out draws no warning for
120
+ * @property {PropDriftTypesNotCompared[]} typesNotCompared every other
121
+ * documented prop type, grouped by why it was not judged
93
122
  */
94
123
 
95
124
  /**
@@ -125,11 +154,30 @@ export const PROPS_NOT_DOCUMENTED = Object.freeze([
125
154
 
126
155
  /** The guidance's internal props: a declaration tagged `@internal`. */
127
156
  const SKIP_TAGS = new Set(['internal']);
157
+ /** Why a documented prop type was not judged (`typesNotCompared`). */
158
+ const NOT_EXACT = 'not a form the check judges exactly';
159
+ /** A field documented with one variant's type, where they differ. */
160
+ const VARIANTS = "the prop's variants give this field different types";
161
+
162
+ /** A default the code writes that is not a literal (a constant, a call). */
163
+ const NOT_LITERAL = Symbol('not a literal');
164
+
165
+ /** Why a documented default was not compared with the code's. */
166
+ const CODE_DEFAULT_NOT_LITERAL =
167
+ 'its default in the code is not a literal, so the documented default was not compared';
168
+ const DOC_DEFAULT_NOT_LITERAL =
169
+ "its documented default is not a literal, so it was not compared with the code's";
170
+ /** @type {(name: string, code?: CodeProp) => string} why a prop is not judged */
171
+ const outside = (name, code) =>
172
+ code?.untraced
173
+ ? NOT_EXACT
174
+ : PROPS_NOT_DOCUMENTED.includes(name)
175
+ ? 'standard prop, not compared'
176
+ : 'declared outside the package, not compared';
128
177
  const HOOK_NAME = /^use[A-Z0-9]/;
129
178
 
130
179
  /** The line both surfaces print when the compiler is missing. */
131
- export const TYPESCRIPT_MISSING_REASON =
132
- 'TypeScript is not installed in this project, so documented props were not compared with the code. Install typescript and run this check again.';
180
+ export const TYPESCRIPT_MISSING_REASON = `TypeScript is not installed in this project, so documented props were not compared with the code. ${TYPESCRIPT_FIX}`;
133
181
 
134
182
  /**
135
183
  * @template T
@@ -201,8 +249,14 @@ function ownFileTest(root) {
201
249
  * @property {boolean} [untraced] built from keys the check can't trace
202
250
  * @property {boolean} skipTagged its declaration carries an internal JSDoc tag
203
251
  * @property {string[]} declared the type as written, per own declaration
204
- * @property {() => string[]} renderings the compiler's renderings, computed on demand
252
+ * @property {() => string[][]} renderings the compiler's renderings, computed on demand
205
253
  * @property {() => any[]} types the prop's type in each member of the props type
254
+ * @property {boolean} intersected one member declares it more than once (an
255
+ * intersection), so no one declaration's text is its type
256
+ * @property {() => any[] | null} indexed the type an index signature gives
257
+ * the name in each member that lacks the prop; null when two signatures
258
+ * in one member take it
259
+ * @property {any} location where names in the prop's type resolve
206
260
  */
207
261
 
208
262
  /**
@@ -216,7 +270,7 @@ function ownFileTest(root) {
216
270
  * @param {import('./unresolved-references.mjs').UnresolvedReference | null} ambient
217
271
  * what the program's other roots cannot resolve, which any component may
218
272
  * use
219
- * @returns {{ok: true, props: Map<string, CodeProp>, accepts: (name: string) => boolean} | {ok: false, reason: string}}
273
+ * @returns {{ok: true, props: Map<string, CodeProp>, accepts: (name: string) => any, defaults?: Map<string, string | number | boolean | null | symbol>} | {ok: false, reason: string}}
220
274
  */
221
275
  function readCodeProps(
222
276
  ts,
@@ -328,7 +382,7 @@ function readCodeProps(
328
382
  }
329
383
  /** @type {Map<string, CodeProp>} */
330
384
  const props = new Map();
331
- if (propsTypes.length === 0) return {ok: true, props, accepts: () => false};
385
+ if (propsTypes.length === 0) return {ok: true, props, accepts: () => []};
332
386
 
333
387
  // Props that are `any`, written so or made from it (`FC<any>`, or
334
388
  // `forwardRef<E, any>`'s `Omit<any, 'ref'>`).
@@ -475,43 +529,187 @@ function readCodeProps(
475
529
  ),
476
530
  ),
477
531
  // A property's `type` is the prop's type; a method's is its return
478
- // type, so a method prop reads as the compiler renders it.
479
- declared: ownDeclarations
480
- .filter(
481
- /** @param {any} d */ d =>
482
- d.type && !ts.isMethodSignature(d) && !ts.isMethodDeclaration(d),
483
- )
484
- .map(/** @param {any} d */ d => d.type.getText(d.getSourceFile())),
532
+ // type, so a method prop reads as the compiler renders it. A
533
+ // declaration's text counts only for its own symbol, or where a mapping
534
+ // copies its type unchanged (`Pick`, `Omit`): one that rewrites it
535
+ // (`{[K in keyof T]: T[K][]}`, `Required<T>`) is judged by its type.
536
+ declared: symbols.flatMap(
537
+ /** @param {any} s */ s =>
538
+ (s.declarations ?? [])
539
+ .filter(
540
+ /** @param {any} d */ d =>
541
+ ownDeclarations.includes(d) &&
542
+ d.type &&
543
+ !ts.isMethodSignature(d) &&
544
+ !ts.isMethodDeclaration(d) &&
545
+ copiesType(ts, checker, s, d, sourceFile),
546
+ )
547
+ .map(/** @param {any} d */ d => d.type.getText(d.getSourceFile())),
548
+ ),
485
549
  types: () =>
486
550
  symbols.map(
487
551
  /** @param {any} s */ s =>
488
552
  checker.getTypeOfSymbolAtLocation(s, sourceFile),
489
553
  ),
554
+ intersected: symbols.some(
555
+ /** @param {any} s */ s =>
556
+ (s.declarations ?? []).filter(/** @param {any} d */ d => d.type)
557
+ .length > 1,
558
+ ),
559
+ indexed: memo(() => {
560
+ const lacking = members.filter(
561
+ /** @param {any} m */ m => !checker.getPropertyOfType(m, name),
562
+ );
563
+ const each = lacking.map(
564
+ /** @param {any} m */ m => indexesFor(ts, checker, [m], name),
565
+ );
566
+ return each.some(indexes => indexes.length > 1)
567
+ ? null
568
+ : each.flatMap(indexes => indexes.map(info => info.type));
569
+ }),
570
+ location: ownDeclarations[0] ?? sourceFile,
571
+ // Printed where the prop is declared, where a documented type's names
572
+ // resolve: a type another file imports under another name prints as
573
+ // that file names it.
490
574
  renderings: memo(() => {
575
+ const at = ownDeclarations[0] ?? sourceFile;
491
576
  /** @type {string[]} */
492
577
  const printed = [];
578
+ /** @type {string[]} */
579
+ const expanded = [];
493
580
  for (const s of symbols) {
494
581
  const propType = checker.getTypeOfSymbolAtLocation(s, sourceFile);
495
582
  for (const part of inDeclaredOrder(ts, checker, propType, s)) {
496
- printed.push(checker.typeToString(part, sourceFile, flags));
583
+ printed.push(checker.typeToString(part, at, flags));
584
+ expanded.push(
585
+ checker.typeToString(
586
+ part,
587
+ at,
588
+ flags | ts.TypeFormatFlags.InTypeAlias,
589
+ ),
590
+ );
497
591
  }
498
592
  }
499
- return printed;
593
+ return [printed, expanded];
500
594
  }),
501
595
  });
502
596
  }
503
597
 
504
- /** Does an index signature of the props type accept this name? */
598
+ /** The index signatures of the props type that take this name. */
505
599
  const accepts = (/** @type {string} */ name) =>
506
- members.some(
507
- /** @param {any} member */ member =>
508
- (checker.getIndexInfosOfType?.(member) ?? []).some(
509
- /** @param {any} info */ info =>
510
- !holdsNothing(ts, info.type) &&
511
- keyAccepts(ts, checker, info.keyType, name),
512
- ),
513
- );
514
- return {ok: true, props, accepts};
600
+ indexesFor(ts, checker, members, name);
601
+ return {ok: true, props, accepts, defaults: literalDefaults(ts, symbol)};
602
+ }
603
+
604
+ /**
605
+ * The defaults a component writes in its props parameter's destructuring
606
+ * (`{size = 'md'}`), by prop name, each as its value: a string, number,
607
+ * boolean, or null, or NOT_LITERAL for any other default (a constant, a call,
608
+ * an object), which is listed as not compared.
609
+ * @param {any} ts
610
+ * @param {any} symbol the component
611
+ * @returns {Map<string, string | number | boolean | null | symbol>}
612
+ */
613
+ function literalDefaults(ts, symbol) {
614
+ /** @type {Map<string, string | number | boolean | null | symbol>} */
615
+ const out = new Map();
616
+ /** @param {any} node @param {number} depth @returns {any} */
617
+ const fnOf = (node, depth) => {
618
+ if (!node || depth > 4) return null;
619
+ if (
620
+ ts.isFunctionDeclaration(node) ||
621
+ ts.isArrowFunction(node) ||
622
+ ts.isFunctionExpression(node)
623
+ ) {
624
+ return node;
625
+ }
626
+ if (ts.isVariableDeclaration(node))
627
+ return fnOf(node.initializer, depth + 1);
628
+ if (
629
+ ts.isParenthesizedExpression(node) ||
630
+ ts.isAsExpression(node) ||
631
+ (ts.isSatisfiesExpression && ts.isSatisfiesExpression(node))
632
+ ) {
633
+ return fnOf(node.expression, depth + 1);
634
+ }
635
+ // `forwardRef(function …)`, `memo(…)`: the function they wrap.
636
+ if (ts.isCallExpression(node)) {
637
+ for (const argument of node.arguments) {
638
+ const found = fnOf(argument, depth + 1);
639
+ if (found) return found;
640
+ }
641
+ }
642
+ return null;
643
+ };
644
+ const fn = fnOf(symbol?.valueDeclaration, 0);
645
+ const pattern = fn?.parameters?.[0]?.name;
646
+ if (!pattern || !ts.isObjectBindingPattern(pattern)) return out;
647
+ for (const element of pattern.elements) {
648
+ if (element.dotDotDotToken || !element.initializer) continue;
649
+ const key = element.propertyName ?? element.name;
650
+ if (!(
651
+ ts.isIdentifier(key) ||
652
+ ts.isStringLiteral(key) ||
653
+ ts.isNumericLiteral(key)
654
+ )) {
655
+ continue;
656
+ }
657
+ const value = literalValue(ts, element.initializer);
658
+ out.set(key.text, value === undefined ? NOT_LITERAL : value);
659
+ }
660
+ return out;
661
+ }
662
+
663
+ /**
664
+ * A literal expression's value, or undefined for anything else.
665
+ * @param {any} ts
666
+ * @param {any} node
667
+ * @returns {string | number | boolean | null | undefined}
668
+ */
669
+ function literalValue(ts, node) {
670
+ if (ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node)) {
671
+ return node.text;
672
+ }
673
+ if (ts.isNumericLiteral(node)) return Number(node.text);
674
+ if (
675
+ ts.isPrefixUnaryExpression(node) &&
676
+ node.operator === ts.SyntaxKind.MinusToken &&
677
+ ts.isNumericLiteral(node.operand)
678
+ ) {
679
+ return -Number(node.operand.text);
680
+ }
681
+ if (node.kind === ts.SyntaxKind.TrueKeyword) return true;
682
+ if (node.kind === ts.SyntaxKind.FalseKeyword) return false;
683
+ if (node.kind === ts.SyntaxKind.NullKeyword) return null;
684
+ return undefined;
685
+ }
686
+
687
+ /**
688
+ * A documented default as a literal value: a quoted string (quotes of any
689
+ * kind, whitespace around it ignored), a number, `true`, `false`, or
690
+ * `null`; undefined for prose or an expression, which is never compared.
691
+ * @param {unknown} written
692
+ * @returns {string | number | boolean | null | undefined}
693
+ */
694
+ function documentedDefault(written) {
695
+ if (typeof written === 'number' || typeof written === 'boolean') {
696
+ return written;
697
+ }
698
+ if (written === null) return null;
699
+ if (typeof written !== 'string') return undefined;
700
+ const text = written.trim();
701
+ const quoted = /^(['"`])([^'"`]*)\1$/.exec(text);
702
+ if (quoted) return quoted[2];
703
+ if (/^-?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i.test(text)) return Number(text);
704
+ if (text === 'true') return true;
705
+ if (text === 'false') return false;
706
+ if (text === 'null') return null;
707
+ return undefined;
708
+ }
709
+
710
+ /** @param {string | number | boolean | null} value */
711
+ function defaultText(value) {
712
+ return typeof value === 'string' ? `'${value}'` : String(value);
515
713
  }
516
714
 
517
715
  /**
@@ -567,30 +765,140 @@ function inDeclaredOrder(ts, checker, type, symbol) {
567
765
  );
568
766
  }
569
767
 
768
+ /**
769
+ * Whether a declaration's text reads as the prop's type: it is the prop's own
770
+ * declaration, or the generic type's prop it instantiates when the result
771
+ * prints as the declared type in the component's file (a generic component
772
+ * passing its own type parameters on), or a mapping copies its type
773
+ * unchanged. Instantiated with another type (`Box<string>`, `ListProps<T[]>`,
774
+ * or an imported `Item` the file names another way), its text names a type
775
+ * the prop no longer has.
776
+ * @param {any} ts
777
+ * @param {any} checker
778
+ * @param {any} symbol the prop
779
+ * @param {any} declaration one of its declarations
780
+ * @param {any} location
781
+ */
782
+ function copiesType(ts, checker, symbol, declaration, location) {
783
+ const own = declaration.name && checker.getSymbolAtLocation(declaration.name);
784
+ if (!own) return false;
785
+ if (own === symbol) return true;
786
+ const type = checker.getTypeOfSymbolAtLocation(symbol, location);
787
+ const declared = checker.getTypeOfSymbolAtLocation(own, location);
788
+ /** @param {any} t */
789
+ const print = t =>
790
+ checker.typeToString(t, location, ts.TypeFormatFlags.NoTruncation);
791
+ return (
792
+ declared === type ||
793
+ (own === (symbol.links ?? symbol).target && print(type) === print(declared))
794
+ );
795
+ }
796
+
797
+ /**
798
+ * Does the code take `undefined` itself, written or through an alias? With
799
+ * `exactOptionalPropertyTypes` that is part of the type a message shows;
800
+ * otherwise an optional prop takes `undefined` anyway.
801
+ * @param {any} checker
802
+ * @param {CodeProp} code
803
+ * @param {boolean} exactOptional
804
+ */
805
+ function ownUndefined(checker, code, exactOptional) {
806
+ const undefinedType = checker.getUndefinedType?.();
807
+ return (
808
+ exactOptional &&
809
+ (code.declared.some(text => /\bundefined\b/.test(text)) ||
810
+ code
811
+ .types()
812
+ .some(t => (t.isUnion() ? t.types : [t]).includes(undefinedType)))
813
+ );
814
+ }
815
+
816
+ /**
817
+ * One of a prop's renderings for a message, without the `undefined` an
818
+ * optional prop adds, unless the code takes it itself.
819
+ * @param {CodeProp} code
820
+ * @param {number} which 0 as printed, 1 expanded
821
+ * @param {boolean} keepUndefined
822
+ */
823
+ function rendered(code, which, keepUndefined) {
824
+ const parts = code.renderings()[which];
825
+ return [
826
+ ...new Set(
827
+ parts.filter(
828
+ part =>
829
+ !(code.required !== true && part === 'undefined' && !keepUndefined),
830
+ ),
831
+ ),
832
+ ].join(' | ');
833
+ }
834
+
570
835
  /**
571
836
  * The prop's type for a message: as the source writes it when its
572
837
  * declarations agree, else (a method or accessor, or declarations that differ
573
- * or narrow each other in an intersection) as the compiler prints it, without
574
- * the `undefined` an optional prop adds.
838
+ * or narrow each other in an intersection) as the compiler prints it.
575
839
  * @param {CodeProp} code
840
+ * @param {boolean} keepUndefined
576
841
  */
577
- function codeTypeText(code) {
842
+ function codeTypeText(code, keepUndefined) {
578
843
  const written = [...new Set(code.declared)];
579
844
  const text =
580
- written.length === 1
581
- ? written[0]
582
- : [
583
- ...new Set(
584
- code
585
- .renderings()
586
- .filter(
587
- part => !(code.required !== true && part === 'undefined'),
588
- ),
589
- ),
590
- ].join(' | ');
845
+ written.length === 1 ? written[0] : rendered(code, 0, keepUndefined);
591
846
  return text.replace(/\s+/g, ' ').trim();
592
847
  }
593
848
 
849
+ /**
850
+ * Judge a documented type against a prop's code type (type-match.mjs).
851
+ * @param {any} ts
852
+ * @param {any} checker
853
+ * @param {string} docType
854
+ * @param {CodeProp} code
855
+ * @param {{nullable: boolean, exactOptional: boolean, isDefaultLibrary: (file: any) => boolean}} reading
856
+ * how the project checks null, and which files are TypeScript's own
857
+ */
858
+ function judgeProp(ts, checker, docType, code, reading) {
859
+ // A member that lacks the prop may take its name through an index
860
+ // signature, which a doc may describe too.
861
+ const indexed = code.indexed();
862
+ if (indexed == null) return 'not_compared';
863
+ return judgeMembers(docType, [...code.types(), ...indexed], {
864
+ ts,
865
+ checker,
866
+ location: code.location,
867
+ optional: code.required !== true && !reading.exactOptional,
868
+ ...reading,
869
+ // Declared text reads as the type only when each declaration is one
870
+ // member's; intersected declarations narrow each other.
871
+ written: code.intersected
872
+ ? code.renderings()
873
+ : [
874
+ code.declared,
875
+ ...code.declared.map(text => [text]),
876
+ ...code.renderings(),
877
+ ],
878
+ });
879
+ }
880
+
881
+ /**
882
+ * Judge a documented type against the types a prop has in the members of a
883
+ * union of props types: a doc may describe one member, so any member's type,
884
+ * or their union, matches, and it is a mismatch only against every one.
885
+ * @param {string} docType
886
+ * @param {any[]} types the type in each member
887
+ * @param {import('./type-match.mjs').JudgeContext} ctx
888
+ * @returns {import('./type-match.mjs').TypeVerdict}
889
+ */
890
+ function judgeMembers(docType, types, ctx) {
891
+ const candidates =
892
+ types.length > 1 ? [types, ...types.map(type => [type])] : [types];
893
+ const verdicts = candidates.map(candidate =>
894
+ judgeType(docType, candidate, ctx),
895
+ );
896
+ if (verdicts.includes('match')) return 'match';
897
+ return verdicts.every(verdict => verdict === 'mismatch')
898
+ ? 'mismatch'
899
+ : 'not_compared';
900
+ }
901
+
594
902
  /**
595
903
  * The props one doc entry names. `a / b` documents each of `a` and `b`, with
596
904
  * the entry's `required` (and the type split the same way when it splits
@@ -656,37 +964,101 @@ function holders(ts, checker, type, depth = 0) {
656
964
  }
657
965
 
658
966
  /**
659
- * Does a field path exist in a prop's type, in at least one member of a
660
- * union (through arrays)?
967
+ * Whether a type takes `undefined` (an index signature's value type, which
968
+ * TypeScript holds an explicit `undefined` to).
969
+ * @param {any} ts
970
+ * @param {any} type
971
+ */
972
+ function takesUndefined(ts, type) {
973
+ return (type.isUnion() ? type.types : [type]).some(
974
+ /** @param {any} t */ t => t.flags & ts.TypeFlags.Undefined,
975
+ );
976
+ }
977
+
978
+ /**
979
+ * The types a field path reaches in a prop's type (in each member of a union
980
+ * that has it, through arrays at any depth), and whether its last field is
981
+ * optional: null when no member has the path, `any` when a type on the way
982
+ * is `any` or `unknown`, which holds any field.
661
983
  * @param {any} ts
662
984
  * @param {any} checker
663
985
  * @param {CodeProp} code
664
986
  * @param {string[]} fieldPath
987
+ * @returns {{types: any[], optional: boolean, ambiguous: boolean, indexed: boolean} | 'any' | null}
988
+ * `ambiguous` when two index signatures take a field on the path, and
989
+ * `indexed` when only index signatures take the last field
665
990
  */
666
- function fieldExists(ts, checker, code, fieldPath) {
991
+ function fieldTypes(ts, checker, code, fieldPath) {
667
992
  /** @type {any[]} */
668
993
  let current = code.types();
994
+ let optional = false;
995
+ let ambiguous = false;
996
+ let indexed = false;
669
997
  for (const field of fieldPath) {
670
998
  /** @type {any[]} */
671
999
  const next = [];
1000
+ optional = false;
1001
+ let byName = false;
672
1002
  for (const holder of current.flatMap(t => holders(ts, checker, t))) {
673
- if (holder.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)) return true;
1003
+ if (holder.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)) {
1004
+ return 'any';
1005
+ }
674
1006
  const prop = checker.getPropertyOfType(holder, field);
675
- // Or a field an index signature takes (`Record<string, string>`).
676
- const index = prop
677
- ? null
678
- : (checker.getIndexInfosOfType?.(holder) ?? []).find(
679
- /** @param {any} info */ info =>
680
- !holdsNothing(ts, info.type) &&
681
- keyAccepts(ts, checker, info.keyType, field),
682
- );
683
- if (prop) next.push(checker.getTypeOfSymbol(prop));
684
- else if (index) next.push(index.type);
1007
+ if (prop) {
1008
+ next.push(checker.getTypeOfSymbol(prop));
1009
+ if (prop.flags & ts.SymbolFlags.Optional) optional = true;
1010
+ byName = true;
1011
+ continue;
1012
+ }
1013
+ // A field an index signature takes (`Record<string, string>`) is of the
1014
+ // index's type, which takes `undefined` only when it says so; two that
1015
+ // take it hold it to both.
1016
+ const indexes = indexesFor(ts, checker, [holder], field);
1017
+ if (indexes.length > 1) ambiguous = true;
1018
+ if (indexes.length > 0) {
1019
+ next.push(indexes[0].type);
1020
+ if (takesUndefined(ts, indexes[0].type)) optional = true;
1021
+ }
685
1022
  }
686
- if (next.length === 0) return false;
1023
+ if (next.length === 0) return null;
687
1024
  current = next;
1025
+ indexed = !byName;
688
1026
  }
689
- return true;
1027
+ return {types: current, optional, ambiguous, indexed};
1028
+ }
1029
+
1030
+ /**
1031
+ * The types a field path reaches, printed where the prop is declared, where
1032
+ * a documented type's names resolve.
1033
+ * @param {any} ts
1034
+ * @param {any} checker
1035
+ * @param {{types: any[], optional: boolean}} reached
1036
+ * @param {boolean} exactOptional the project sets `exactOptionalPropertyTypes`
1037
+ * @param {any} location where the prop is declared
1038
+ * @returns {string[]}
1039
+ */
1040
+ function fieldTypeText(ts, checker, reached, exactOptional, location) {
1041
+ // An optional field's `undefined` is the compiler's own; with
1042
+ // `exactOptionalPropertyTypes` it is a marker of its own, and one the code
1043
+ // declares stays.
1044
+ const own = /** @param {any} t */ t =>
1045
+ reached.optional &&
1046
+ t.flags & ts.TypeFlags.Undefined &&
1047
+ (!exactOptional || t !== checker.getUndefinedType?.());
1048
+ return [
1049
+ ...new Set(
1050
+ reached.types
1051
+ .flatMap(t => (t.isUnion() ? t.types : [t]))
1052
+ .filter(t => !own(t))
1053
+ .map(t =>
1054
+ checker.typeToString(
1055
+ t,
1056
+ location,
1057
+ ts.TypeFormatFlags.UseSingleQuotesForStringLiteralType,
1058
+ ),
1059
+ ),
1060
+ ),
1061
+ ];
690
1062
  }
691
1063
 
692
1064
  /**
@@ -902,6 +1274,33 @@ function keyAccepts(ts, checker, key, name) {
902
1274
  return new RegExp(`^${pattern}$`).test(name);
903
1275
  }
904
1276
 
1277
+ /**
1278
+ * The index signatures of these types that take a name, as TypeScript
1279
+ * matches keys. TypeScript holds a value to every one of them.
1280
+ * @param {any} ts
1281
+ * @param {any} checker
1282
+ * @param {any[]} types
1283
+ * @param {string} name
1284
+ * @returns {any[]}
1285
+ */
1286
+ function indexesFor(ts, checker, types, name) {
1287
+ // One signature seen through several union members is one signature.
1288
+ const seen = new Set();
1289
+ return types
1290
+ .flatMap(type => checker.getIndexInfosOfType?.(type) ?? [])
1291
+ .filter(
1292
+ /** @param {any} info */ info => {
1293
+ const key = `${checker.typeToString(info.keyType)}\0${checker.typeToString(info.type)}`;
1294
+ if (seen.has(key)) return false;
1295
+ seen.add(key);
1296
+ return (
1297
+ !holdsNothing(ts, info.type) &&
1298
+ keyAccepts(ts, checker, info.keyType, name)
1299
+ );
1300
+ },
1301
+ );
1302
+ }
1303
+
905
1304
  /**
906
1305
  * Can a value of this type be passed at all? `never`, or only `undefined`
907
1306
  * (`Record<string, never>`, the usual way to write "no props"), cannot.
@@ -1348,8 +1747,10 @@ export function comparePropTables(tables, options) {
1348
1747
  )
1349
1748
  : TYPESCRIPT_MISSING_REASON,
1350
1749
  components: 0,
1750
+ typesCompared: 0,
1351
1751
  findings: [],
1352
1752
  unchecked: [],
1753
+ typesNotCompared: [],
1353
1754
  };
1354
1755
  }
1355
1756
  const {ts, version} = compiler;
@@ -1369,8 +1770,10 @@ export function comparePropTables(tables, options) {
1369
1770
  status: 'checked',
1370
1771
  typescript: version,
1371
1772
  components: 0,
1773
+ typesCompared: 0,
1372
1774
  findings: [],
1373
1775
  unchecked,
1776
+ typesNotCompared: [],
1374
1777
  };
1375
1778
  }
1376
1779
 
@@ -1393,8 +1796,10 @@ export function comparePropTables(tables, options) {
1393
1796
  status: 'checked',
1394
1797
  typescript: version,
1395
1798
  components: 0,
1799
+ typesCompared: 0,
1396
1800
  findings: [],
1397
1801
  unchecked,
1802
+ typesNotCompared: [],
1398
1803
  };
1399
1804
  }
1400
1805
  const program = ts.createProgram({
@@ -1416,12 +1821,30 @@ export function comparePropTables(tables, options) {
1416
1821
  project.options,
1417
1822
  isOwnFile,
1418
1823
  );
1824
+ // Without strict null checks the compiler drops `null` and `undefined`.
1825
+ // Whether they are on by default depends on the TypeScript version.
1826
+ const compilerOptions = program.getCompilerOptions();
1827
+ const nullable = !(typeof ts.getStrictOptionValue === 'function'
1828
+ ? ts.getStrictOptionValue(compilerOptions, 'strictNullChecks')
1829
+ : (compilerOptions.strictNullChecks ?? compilerOptions.strict ?? false));
1830
+ const reading = {
1831
+ nullable,
1832
+ // An optional prop takes `undefined` only when the project lets it.
1833
+ exactOptional:
1834
+ !nullable && compilerOptions.exactOptionalPropertyTypes === true,
1835
+ isDefaultLibrary: (/** @type {any} */ file) =>
1836
+ program.isSourceFileDefaultLibrary(file),
1837
+ };
1419
1838
 
1420
1839
  /** @type {PropDriftFinding[]} */
1421
1840
  const findings = [];
1422
1841
  /** @type {Array<PropDriftUnchecked & {props: string[]}>} */
1423
1842
  const propsNotChecked = [];
1424
1843
  let compared = 0;
1844
+ let typesCompared = 0;
1845
+ /** @type {PropDriftTypesNotCompared[]} */
1846
+ const typesNotCompared = [];
1847
+ const typesSkipped = typeTextTooOld(ts);
1425
1848
  for (const table of tables) {
1426
1849
  /** @type {ReturnType<typeof readCodeProps> | null} */
1427
1850
  let read = null;
@@ -1456,14 +1879,41 @@ export function comparePropTables(tables, options) {
1456
1879
  compared++;
1457
1880
  const source = rel(sourcePath);
1458
1881
  const documented = new Set();
1882
+ /** @type {Map<string, Set<string>>} */
1883
+ const notCompared = new Map();
1884
+ /** @type {(reason: string, name: string) => void} */
1885
+ const skip = (reason, name) => {
1886
+ notCompared.set(reason, (notCompared.get(reason) ?? new Set()).add(name));
1887
+ };
1459
1888
  for (const raw of table.props) {
1460
1889
  if (!raw || typeof raw.name !== 'string') continue;
1461
1890
  const entries = documentedProps(raw);
1462
1891
  for (const entry of entries) {
1463
1892
  const propName = entry.name;
1464
1893
  if (entry.spread) continue;
1894
+ const docType = entry.type;
1895
+ if (typesSkipped) entry.type = undefined;
1465
1896
  documented.add(propName);
1466
1897
  const code = read.props.get(propName);
1898
+ const reached =
1899
+ code && entry.path.length > 0
1900
+ ? fieldTypes(ts, checker, code, entry.path)
1901
+ : null;
1902
+ if (
1903
+ entry.type === undefined &&
1904
+ !typesSkipped &&
1905
+ typeof raw.type === 'string' &&
1906
+ (code && entry.path.length > 0
1907
+ ? reached
1908
+ : code || read.accepts(propName).length > 0)
1909
+ ) {
1910
+ // `a / b` with one type that does not split across the names (a
1911
+ // field only once it is found).
1912
+ skip(
1913
+ code && !code.own ? outside(propName, code) : NOT_EXACT,
1914
+ entry.written,
1915
+ );
1916
+ }
1467
1917
  const base = {
1468
1918
  component: table.name,
1469
1919
  prop: entry.written,
@@ -1472,11 +1922,74 @@ export function comparePropTables(tables, options) {
1472
1922
  source,
1473
1923
  };
1474
1924
  if (entry.path.length > 0) {
1475
- if (
1476
- code
1477
- ? fieldExists(ts, checker, code, entry.path)
1478
- : read.accepts(propName)
1479
- ) {
1925
+ // Listed only once the field is found; a missing one is reported.
1926
+ if (code && !code.own && reached && typeof entry.type === 'string') {
1927
+ skip(outside(propName, code), entry.written);
1928
+ }
1929
+ if (reached === 'any') {
1930
+ // A field of an `any` or `unknown` prop has no type to judge.
1931
+ if (code?.own && typeof entry.type === 'string') {
1932
+ skip(NOT_EXACT, entry.written);
1933
+ }
1934
+ continue;
1935
+ }
1936
+ if (code && reached) {
1937
+ const fieldText = fieldTypeText(
1938
+ ts,
1939
+ checker,
1940
+ reached,
1941
+ reading.exactOptional,
1942
+ code.location,
1943
+ );
1944
+ const ctx = {
1945
+ ts,
1946
+ checker,
1947
+ location: code.location,
1948
+ // A name an index signature takes sets the index's
1949
+ // `undefined` aside, as a prop of that name does.
1950
+ optional:
1951
+ reached.optional && (!reading.exactOptional || reached.indexed),
1952
+ ...reading,
1953
+ written: [fieldText],
1954
+ };
1955
+ const verdict =
1956
+ code.own && typeof entry.type === 'string'
1957
+ ? reached.ambiguous
1958
+ ? 'not_compared'
1959
+ : judgeType(entry.type, reached.types, ctx)
1960
+ : null;
1961
+ // The field takes every variant's type: the types of only some
1962
+ // variants are neither its type nor wrong. Past six, the sets of
1963
+ // them are not tried, and the type is never reported.
1964
+ const variants = [...new Set(reached.types)];
1965
+ const someVariants =
1966
+ (verdict === 'mismatch' || verdict === 'not_compared') &&
1967
+ !reached.ambiguous &&
1968
+ variants.length > 1 &&
1969
+ (variants.length > 6 ||
1970
+ Array.from({length: 2 ** variants.length - 2}, (_, i) =>
1971
+ variants.filter((__, j) => ((i + 1) >> j) & 1),
1972
+ ).some(
1973
+ some => judgeType(entry.type ?? '', some, ctx) === 'match',
1974
+ ));
1975
+ if (someVariants) skip(VARIANTS, entry.written);
1976
+ else if (verdict === 'not_compared') skip(NOT_EXACT, entry.written);
1977
+ else if (verdict) typesCompared++;
1978
+ if (verdict === 'mismatch' && !someVariants) {
1979
+ const codeType = fieldText.join(' | ');
1980
+ findings.push({
1981
+ ...base,
1982
+ kind: 'type_mismatch',
1983
+ message: `"${entry.written}" is documented as ${entry.type}, but the code declares ${codeType}.`,
1984
+ docType: entry.type,
1985
+ codeType,
1986
+ });
1987
+ }
1988
+ continue;
1989
+ }
1990
+ if (!code && read.accepts(propName).length > 0) {
1991
+ // A field of a name only an index signature takes.
1992
+ if (typeof entry.type === 'string') skip(NOT_EXACT, entry.written);
1480
1993
  continue;
1481
1994
  }
1482
1995
  findings.push({
@@ -1489,12 +2002,70 @@ export function comparePropTables(tables, options) {
1489
2002
  continue;
1490
2003
  }
1491
2004
  if (!code) {
1492
- if (read.accepts(propName)) continue;
2005
+ // A name an index signature takes is a prop of the index's type;
2006
+ // TypeScript holds it to every signature that takes it, so with
2007
+ // several its type is not compared. Another package's signature is
2008
+ // not the package's to judge, and a mapped type's (`Record`) has no
2009
+ // declaration to say whose it is.
2010
+ const indexes = read.accepts(propName);
2011
+ const own = indexes.filter(
2012
+ (/** @type {any} */ i) =>
2013
+ i.declaration &&
2014
+ isOwnFile(i.declaration.getSourceFile().fileName),
2015
+ );
2016
+ const index = indexes.length === 1 ? own[0] : null;
2017
+ if (indexes.length > 0 && !index && typeof entry.type === 'string') {
2018
+ const declared = indexes.every(
2019
+ (/** @type {any} */ i) => i.declaration,
2020
+ );
2021
+ skip(
2022
+ own.length || !declared ? NOT_EXACT : outside(propName),
2023
+ propName,
2024
+ );
2025
+ }
2026
+ if (index && typeof entry.type === 'string') {
2027
+ const verdict = judgeType(entry.type, [index.type], {
2028
+ ts,
2029
+ checker,
2030
+ location: index.declaration,
2031
+ // An index signature takes `undefined` only when its type does.
2032
+ optional: takesUndefined(ts, index.type),
2033
+ ...reading,
2034
+ // Printed where the index is declared, as the doc's names
2035
+ // resolve there.
2036
+ written: [
2037
+ [
2038
+ checker.typeToString(
2039
+ index.type,
2040
+ index.declaration,
2041
+ ts.TypeFormatFlags.UseSingleQuotesForStringLiteralType,
2042
+ ),
2043
+ ],
2044
+ ],
2045
+ });
2046
+ if (verdict === 'not_compared') skip(NOT_EXACT, propName);
2047
+ else typesCompared++;
2048
+ if (verdict === 'mismatch') {
2049
+ const codeType = checker.typeToString(
2050
+ index.type,
2051
+ index.declaration,
2052
+ ts.TypeFormatFlags.UseSingleQuotesForStringLiteralType,
2053
+ );
2054
+ findings.push({
2055
+ ...base,
2056
+ kind: 'type_mismatch',
2057
+ message: `"${propName}" is documented as ${entry.type}, but ${table.name}'s props take it as ${codeType}.`,
2058
+ docType: entry.type,
2059
+ codeType,
2060
+ });
2061
+ }
2062
+ }
2063
+ if (indexes.length > 0) continue;
1493
2064
  findings.push({
1494
2065
  ...base,
1495
2066
  kind: 'not_in_code',
1496
2067
  message: `"${propName}" is documented, but ${table.name}'s props have no "${propName}".`,
1497
- ...(typeof entry.type === 'string' ? {docType: entry.type} : {}),
2068
+ ...(typeof docType === 'string' ? {docType} : {}),
1498
2069
  });
1499
2070
  continue;
1500
2071
  }
@@ -1510,6 +2081,78 @@ export function comparePropTables(tables, options) {
1510
2081
  codeRequired: code.required,
1511
2082
  });
1512
2083
  }
2084
+ // A literal default the code writes in its props destructuring and a
2085
+ // literal the doc writes must agree; where both write a default and
2086
+ // either is not a literal, the default is listed as not compared.
2087
+ const codeDefault = read.defaults?.get(propName);
2088
+ const docWrites =
2089
+ entries.length === 1 &&
2090
+ raw.default !== undefined &&
2091
+ raw.default !== '';
2092
+ const docDefault = docWrites
2093
+ ? documentedDefault(raw.default)
2094
+ : undefined;
2095
+ if (codeDefault !== undefined && docWrites) {
2096
+ if (codeDefault === NOT_LITERAL) {
2097
+ skip(CODE_DEFAULT_NOT_LITERAL, propName);
2098
+ } else if (docDefault === undefined) {
2099
+ skip(DOC_DEFAULT_NOT_LITERAL, propName);
2100
+ }
2101
+ }
2102
+ if (
2103
+ codeDefault !== undefined &&
2104
+ codeDefault !== NOT_LITERAL &&
2105
+ docDefault !== undefined &&
2106
+ codeDefault !== docDefault
2107
+ ) {
2108
+ const shown = defaultText(
2109
+ /** @type {string | number | boolean | null} */ (codeDefault),
2110
+ );
2111
+ findings.push({
2112
+ ...base,
2113
+ kind: 'default_mismatch',
2114
+ message: `"${propName}" is documented with default ${String(raw.default).trim()}, but the code defaults it to ${shown}.`,
2115
+ fix: `In ${table.doc}, set the "${propName}" prop's default to the code's: default: ${JSON.stringify(shown)}.`,
2116
+ docDefault: String(raw.default),
2117
+ codeDefault: shown,
2118
+ });
2119
+ }
2120
+ if (!code.own && typeof entry.type === 'string') {
2121
+ skip(outside(propName, code), propName);
2122
+ }
2123
+ if (code.own && typeof entry.type === 'string') {
2124
+ const verdict = judgeProp(
2125
+ ts,
2126
+ checker,
2127
+ String(entry.type),
2128
+ code,
2129
+ reading,
2130
+ );
2131
+ if (verdict === 'not_compared') skip(NOT_EXACT, propName);
2132
+ else typesCompared++;
2133
+ if (verdict === 'mismatch') {
2134
+ const keep = ownUndefined(checker, code, reading.exactOptional);
2135
+ const codeType = codeTypeText(code, keep);
2136
+ const expanded = rendered(code, 1, keep);
2137
+ // The optional prop's `undefined` the expansion sets aside is no
2138
+ // difference to show.
2139
+ const bare = codeType
2140
+ .split(' | ')
2141
+ .filter(part => part !== 'undefined')
2142
+ .join(' | ');
2143
+ const shown =
2144
+ expanded && expanded !== codeType && expanded !== bare
2145
+ ? `${codeType} (${expanded.length <= 400 ? expanded : `${expanded.slice(0, 400)}…`})`
2146
+ : codeType;
2147
+ findings.push({
2148
+ ...base,
2149
+ kind: 'type_mismatch',
2150
+ message: `"${propName}" is documented as ${entry.type}, but the code declares ${shown}.`,
2151
+ docType: entry.type,
2152
+ codeType,
2153
+ });
2154
+ }
2155
+ }
1513
2156
  }
1514
2157
  }
1515
2158
  /** @type {string[]} */
@@ -1526,6 +2169,10 @@ export function comparePropTables(tables, options) {
1526
2169
  if (code.untraced) untraced.push(code.name);
1527
2170
  continue;
1528
2171
  }
2172
+ const codeType = codeTypeText(
2173
+ code,
2174
+ ownUndefined(checker, code, reading.exactOptional),
2175
+ );
1529
2176
  findings.push({
1530
2177
  component: table.name,
1531
2178
  prop: code.name,
@@ -1534,7 +2181,7 @@ export function comparePropTables(tables, options) {
1534
2181
  message: `${table.name} declares "${code.name}", but the doc does not list it.`,
1535
2182
  doc: table.doc,
1536
2183
  source,
1537
- codeType: codeTypeText(code),
2184
+ codeType,
1538
2185
  codeRequired: code.required,
1539
2186
  });
1540
2187
  }
@@ -1546,6 +2193,14 @@ export function comparePropTables(tables, options) {
1546
2193
  props: untraced.sort(),
1547
2194
  });
1548
2195
  }
2196
+ for (const [reason, props] of notCompared) {
2197
+ typesNotCompared.push({
2198
+ component: table.name,
2199
+ doc: table.doc,
2200
+ reason,
2201
+ props: [...props].sort(),
2202
+ });
2203
+ }
1549
2204
  }
1550
2205
 
1551
2206
  // Field by field: collation ignores a separator such as NUL, which would
@@ -1557,12 +2212,20 @@ export function comparePropTables(tables, options) {
1557
2212
  a.kind.localeCompare(b.kind),
1558
2213
  );
1559
2214
  unchecked.sort((a, b) => a.component.localeCompare(b.component));
2215
+ typesNotCompared.sort(
2216
+ (a, b) =>
2217
+ a.component.localeCompare(b.component) ||
2218
+ a.reason.localeCompare(b.reason),
2219
+ );
1560
2220
  return {
1561
2221
  status: 'checked',
1562
2222
  typescript: version,
1563
2223
  components: compared,
2224
+ typesCompared,
1564
2225
  findings,
1565
2226
  unchecked,
2227
+ typesNotCompared,
2228
+ ...(typesSkipped ? {typesSkipped} : {}),
1566
2229
  ...(propsNotChecked.length > 0 ? {propsNotChecked} : {}),
1567
2230
  };
1568
2231
  }