typedoc 0.28.18 → 0.28.20

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 (397) hide show
  1. package/README.md +12 -13
  2. package/bin/typedoc +1 -1
  3. package/dist/browser-locales/fr.d.ts +2 -0
  4. package/dist/browser-locales/fr.js +62 -0
  5. package/dist/browser-utils.js +29 -2
  6. package/dist/cli.js +111 -0
  7. package/dist/index.js +17888 -44
  8. package/dist/models.js +3736 -0
  9. package/dist/node-utils.js +7018 -0
  10. package/dist/serialization.js +430 -0
  11. package/dist/{lib → types}/application-events.d.ts +2 -0
  12. package/dist/{lib → types}/application.d.ts +51 -8
  13. package/dist/{lib → types}/converter/comments/declarationReferenceResolver.d.ts +1 -1
  14. package/dist/{lib → types}/converter/comments/discovery.d.ts +3 -3
  15. package/dist/{lib → types}/converter/comments/index.d.ts +4 -4
  16. package/dist/{lib → types}/converter/comments/lexer.d.ts +1 -1
  17. package/dist/{lib → types}/converter/comments/linkResolver.d.ts +1 -1
  18. package/dist/{lib → types}/converter/comments/parser.d.ts +3 -4
  19. package/dist/{lib → types}/converter/comments/textParser.d.ts +8 -2
  20. package/dist/{lib → types}/converter/components.d.ts +1 -1
  21. package/dist/{lib → types}/converter/context.d.ts +2 -2
  22. package/dist/{lib → types}/converter/converter.d.ts +6 -8
  23. package/dist/{lib → types}/converter/factories/signature.d.ts +1 -1
  24. package/dist/{lib → types}/converter/index.d.ts +1 -0
  25. package/dist/{lib → types}/converter/plugins/CategoryPlugin.d.ts +2 -2
  26. package/dist/{lib → types}/converter/plugins/GroupPlugin.d.ts +2 -3
  27. package/dist/{lib → types}/converter/plugins/IncludePlugin.d.ts +1 -1
  28. package/dist/{lib → types}/converter/plugins/InheritDocPlugin.d.ts +1 -1
  29. package/dist/{lib → types}/converter/plugins/LinkResolverPlugin.d.ts +3 -3
  30. package/dist/{lib → types}/converter/plugins/SourcePlugin.d.ts +1 -2
  31. package/dist/{lib → types}/converter/plugins/TypePlugin.d.ts +1 -1
  32. package/dist/{lib → types}/converter/types.d.ts +1 -1
  33. package/dist/{lib/converter/utils → types/converter/utilities}/reflections.d.ts +1 -1
  34. package/dist/{lib/converter/utils → types/converter/utilities}/repository.d.ts +14 -13
  35. package/dist/{index.d.ts → types/index.d.ts} +15 -16
  36. package/dist/{lib → types}/internationalization/internationalization.d.ts +0 -8
  37. package/dist/types/internationalization/locale-utils.d.ts +3 -0
  38. package/dist/types/internationalization/locales/de.d.ts +368 -0
  39. package/dist/{lib/internationalization/locales/en.d.cts → types/internationalization/locales/en.d.ts} +2 -1
  40. package/dist/types/internationalization/locales/fr.d.ts +346 -0
  41. package/dist/types/internationalization/locales/ja.d.ts +307 -0
  42. package/dist/types/internationalization/locales/ko.d.ts +221 -0
  43. package/dist/types/internationalization/locales/zh.d.ts +452 -0
  44. package/dist/{lib → types}/internationalization/translatable.d.ts +1 -1
  45. package/dist/{lib → types}/models/FileRegistry.d.ts +6 -1
  46. package/dist/{lib → types}/models/ReflectionSymbolId.d.ts +9 -3
  47. package/dist/{lib → types}/models/SourceReference.d.ts +5 -3
  48. package/dist/types/models.d.ts +1 -0
  49. package/dist/types/node-utils.d.ts +1 -0
  50. package/dist/{lib → types}/output/components.d.ts +3 -3
  51. package/dist/{lib → types}/output/events.d.ts +1 -2
  52. package/dist/{lib → types}/output/formatter.d.ts +1 -2
  53. package/dist/{lib → types}/output/output.d.ts +2 -2
  54. package/dist/{lib → types}/output/renderer.d.ts +4 -5
  55. package/dist/{lib → types}/output/router.d.ts +3 -2
  56. package/dist/{lib → types}/output/themes/MarkedPlugin.d.ts +3 -3
  57. package/dist/{lib → types}/output/themes/default/DefaultTheme.d.ts +1 -1
  58. package/dist/{lib → types}/output/themes/default/DefaultThemeRenderContext.d.ts +25 -25
  59. package/dist/{lib → types}/output/themes/default/layouts/default.d.ts +1 -1
  60. package/dist/{lib → types}/output/themes/default/partials/anchor-icon.d.ts +1 -1
  61. package/dist/{lib → types}/output/themes/default/partials/breadcrumb.d.ts +1 -1
  62. package/dist/{lib → types}/output/themes/default/partials/comment.d.ts +1 -1
  63. package/dist/{lib → types}/output/themes/default/partials/header.d.ts +1 -1
  64. package/dist/{lib → types}/output/themes/default/partials/hierarchy.d.ts +1 -1
  65. package/dist/{lib → types}/output/themes/default/partials/icon.d.ts +1 -1
  66. package/dist/{lib → types}/output/themes/default/partials/index.d.ts +1 -1
  67. package/dist/{lib → types}/output/themes/default/partials/member.d.ts +1 -1
  68. package/dist/{lib → types}/output/themes/default/partials/member.getterSetter.d.ts +1 -1
  69. package/dist/{lib → types}/output/themes/default/partials/member.signature.body.d.ts +1 -1
  70. package/dist/{lib → types}/output/themes/default/partials/member.signature.title.d.ts +2 -2
  71. package/dist/{lib → types}/output/themes/default/partials/member.signatures.d.ts +1 -1
  72. package/dist/{lib → types}/output/themes/default/partials/member.sources.d.ts +1 -1
  73. package/dist/{lib → types}/output/themes/default/partials/members.d.ts +1 -1
  74. package/dist/{lib → types}/output/themes/default/partials/moduleReflection.d.ts +1 -1
  75. package/dist/{lib → types}/output/themes/default/partials/navigation.d.ts +1 -1
  76. package/dist/{lib → types}/output/themes/default/partials/reflectionPreview.d.ts +1 -1
  77. package/dist/{lib → types}/output/themes/default/partials/toolbar.d.ts +1 -1
  78. package/dist/{lib → types}/output/themes/default/partials/type.d.ts +2 -2
  79. package/dist/{lib → types}/output/themes/default/partials/typeDetails.d.ts +2 -2
  80. package/dist/{lib → types}/output/themes/default/partials/typeParameters.d.ts +1 -1
  81. package/dist/{lib → types}/output/themes/default/templates/document.d.ts +1 -1
  82. package/dist/{lib → types}/output/themes/default/templates/hierarchy.d.ts +1 -1
  83. package/dist/{lib → types}/output/themes/default/templates/index.d.ts +1 -1
  84. package/dist/{lib → types}/output/themes/default/templates/reflection.d.ts +1 -1
  85. package/dist/{lib → types}/output/themes/lib.d.ts +1 -1
  86. package/dist/types/serialization.d.ts +1 -0
  87. package/dist/types/tsconfig.tsbuildinfo +1 -0
  88. package/dist/{lib → types}/utils/ValidatingFileRegistry.d.ts +1 -1
  89. package/dist/{lib → types}/utils/entry-point.d.ts +2 -2
  90. package/dist/{lib → types}/utils/general.d.ts +3 -0
  91. package/dist/types/utils/index.d.ts +22 -0
  92. package/dist/{lib → types}/utils/options/declaration.d.ts +2 -1
  93. package/dist/{lib → types}/utils/options/defaults.d.ts +1 -1
  94. package/dist/{lib → types}/utils/options/index.d.ts +2 -1
  95. package/dist/{lib → types}/utils/options/options.d.ts +1 -1
  96. package/dist/{lib → types}/utils/options/tsdoc-defaults.d.ts +1 -1
  97. package/dist/{lib → types}/utils/reflections.d.ts +1 -1
  98. package/dist/{lib → types}/utils/sort.d.ts +1 -2
  99. package/dist/{lib → types}/utils-common/general.d.ts +4 -4
  100. package/dist/{lib → types}/utils-common/jsx.elements.d.ts +16 -0
  101. package/dist/types/utils-common.d.ts +1 -0
  102. package/dist/{lib → types}/validation/documentation.d.ts +1 -1
  103. package/dist/{lib → types}/validation/exports.d.ts +1 -1
  104. package/dist/types/validation/filePaths.d.ts +3 -0
  105. package/dist/{lib → types}/validation/links.d.ts +1 -1
  106. package/dist/{lib → types}/validation/unusedMergeModuleWith.d.ts +1 -1
  107. package/dist/utils-common.js +1311 -0
  108. package/package.json +46 -37
  109. package/static/main.js +4 -4
  110. package/static/style.css +18 -3
  111. package/tsdoc.json +4 -0
  112. package/typedoc-config.schema.json +2 -0
  113. package/dist/lib/application-events.js +0 -5
  114. package/dist/lib/application.js +0 -716
  115. package/dist/lib/cli.js +0 -111
  116. package/dist/lib/converter/comments/blockLexer.js +0 -391
  117. package/dist/lib/converter/comments/declarationReferenceResolver.js +0 -218
  118. package/dist/lib/converter/comments/discovery.js +0 -563
  119. package/dist/lib/converter/comments/index.js +0 -241
  120. package/dist/lib/converter/comments/lexer.js +0 -10
  121. package/dist/lib/converter/comments/lineLexer.js +0 -279
  122. package/dist/lib/converter/comments/linkResolver.js +0 -186
  123. package/dist/lib/converter/comments/parser.js +0 -538
  124. package/dist/lib/converter/comments/rawLexer.js +0 -218
  125. package/dist/lib/converter/comments/tagName.js +0 -58
  126. package/dist/lib/converter/comments/textParser.js +0 -372
  127. package/dist/lib/converter/components.js +0 -3
  128. package/dist/lib/converter/context.js +0 -311
  129. package/dist/lib/converter/convert-expression.js +0 -58
  130. package/dist/lib/converter/converter-events.js +0 -13
  131. package/dist/lib/converter/converter.js +0 -705
  132. package/dist/lib/converter/factories/index-signature.js +0 -50
  133. package/dist/lib/converter/factories/signature.js +0 -353
  134. package/dist/lib/converter/factories/symbol-id.js +0 -50
  135. package/dist/lib/converter/index.js +0 -3
  136. package/dist/lib/converter/jsdoc.js +0 -135
  137. package/dist/lib/converter/plugins/CategoryPlugin.js +0 -278
  138. package/dist/lib/converter/plugins/CommentPlugin.js +0 -770
  139. package/dist/lib/converter/plugins/GroupPlugin.js +0 -281
  140. package/dist/lib/converter/plugins/ImplementsPlugin.js +0 -438
  141. package/dist/lib/converter/plugins/IncludePlugin.js +0 -254
  142. package/dist/lib/converter/plugins/InheritDocPlugin.js +0 -220
  143. package/dist/lib/converter/plugins/LinkResolverPlugin.js +0 -88
  144. package/dist/lib/converter/plugins/MergeModuleWithPlugin.js +0 -50
  145. package/dist/lib/converter/plugins/PackagePlugin.js +0 -188
  146. package/dist/lib/converter/plugins/SourcePlugin.js +0 -215
  147. package/dist/lib/converter/plugins/TypePlugin.js +0 -108
  148. package/dist/lib/converter/plugins/index.js +0 -10
  149. package/dist/lib/converter/symbols.js +0 -861
  150. package/dist/lib/converter/types.js +0 -833
  151. package/dist/lib/converter/utils/nodes.js +0 -26
  152. package/dist/lib/converter/utils/reflections.js +0 -17
  153. package/dist/lib/converter/utils/repository.js +0 -295
  154. package/dist/lib/converter/utils/symbols.js +0 -12
  155. package/dist/lib/debug/index.js +0 -2
  156. package/dist/lib/debug/reflectionLifetimes.js +0 -27
  157. package/dist/lib/debug/rendererUrls.js +0 -68
  158. package/dist/lib/internationalization/index.js +0 -7
  159. package/dist/lib/internationalization/internationalization.js +0 -64
  160. package/dist/lib/internationalization/locale-utils.cjs +0 -8
  161. package/dist/lib/internationalization/locale-utils.d.cts +0 -8
  162. package/dist/lib/internationalization/locales/de.cjs +0 -401
  163. package/dist/lib/internationalization/locales/de.d.cts +0 -368
  164. package/dist/lib/internationalization/locales/en.cjs +0 -411
  165. package/dist/lib/internationalization/locales/ja.cjs +0 -320
  166. package/dist/lib/internationalization/locales/ja.d.cts +0 -307
  167. package/dist/lib/internationalization/locales/ko.cjs +0 -233
  168. package/dist/lib/internationalization/locales/ko.d.cts +0 -221
  169. package/dist/lib/internationalization/locales/zh.cjs +0 -488
  170. package/dist/lib/internationalization/locales/zh.d.cts +0 -452
  171. package/dist/lib/internationalization/translatable.js +0 -8
  172. package/dist/lib/models/Comment.js +0 -534
  173. package/dist/lib/models/ContainerReflection.js +0 -159
  174. package/dist/lib/models/DeclarationReflection.js +0 -287
  175. package/dist/lib/models/DocumentReflection.js +0 -66
  176. package/dist/lib/models/FileRegistry.js +0 -133
  177. package/dist/lib/models/ParameterReflection.js +0 -39
  178. package/dist/lib/models/ProjectReflection.js +0 -417
  179. package/dist/lib/models/ReferenceReflection.js +0 -85
  180. package/dist/lib/models/Reflection.js +0 -495
  181. package/dist/lib/models/ReflectionCategory.js +0 -56
  182. package/dist/lib/models/ReflectionGroup.js +0 -72
  183. package/dist/lib/models/ReflectionSymbolId.js +0 -85
  184. package/dist/lib/models/SignatureReflection.js +0 -96
  185. package/dist/lib/models/SourceReference.js +0 -50
  186. package/dist/lib/models/TypeParameterReflection.js +0 -45
  187. package/dist/lib/models/index.js +0 -19
  188. package/dist/lib/models/kind.js +0 -231
  189. package/dist/lib/models/types.js +0 -1296
  190. package/dist/lib/models/utils.js +0 -26
  191. package/dist/lib/models/variant.js +0 -1
  192. package/dist/lib/output/components.js +0 -133
  193. package/dist/lib/output/events.js +0 -195
  194. package/dist/lib/output/formatter.js +0 -660
  195. package/dist/lib/output/index.js +0 -7
  196. package/dist/lib/output/output.js +0 -92
  197. package/dist/lib/output/plugins/AssetsPlugin.js +0 -160
  198. package/dist/lib/output/plugins/HierarchyPlugin.js +0 -65
  199. package/dist/lib/output/plugins/IconsPlugin.js +0 -54
  200. package/dist/lib/output/plugins/JavascriptIndexPlugin.js +0 -222
  201. package/dist/lib/output/plugins/NavigationPlugin.js +0 -23
  202. package/dist/lib/output/plugins/SitemapPlugin.js +0 -82
  203. package/dist/lib/output/plugins/index.js +0 -7
  204. package/dist/lib/output/renderer.js +0 -387
  205. package/dist/lib/output/router.js +0 -520
  206. package/dist/lib/output/theme.js +0 -17
  207. package/dist/lib/output/themes/MarkedPlugin.js +0 -461
  208. package/dist/lib/output/themes/default/DefaultTheme.js +0 -367
  209. package/dist/lib/output/themes/default/DefaultThemeRenderContext.js +0 -151
  210. package/dist/lib/output/themes/default/Slugger.js +0 -60
  211. package/dist/lib/output/themes/default/layouts/default.js +0 -89
  212. package/dist/lib/output/themes/default/partials/anchor-icon.js +0 -9
  213. package/dist/lib/output/themes/default/partials/breadcrumb.js +0 -11
  214. package/dist/lib/output/themes/default/partials/comment.js +0 -80
  215. package/dist/lib/output/themes/default/partials/footer.js +0 -37
  216. package/dist/lib/output/themes/default/partials/header.js +0 -39
  217. package/dist/lib/output/themes/default/partials/hierarchy.js +0 -32
  218. package/dist/lib/output/themes/default/partials/icon.js +0 -101
  219. package/dist/lib/output/themes/default/partials/index.js +0 -24
  220. package/dist/lib/output/themes/default/partials/member.declaration.js +0 -35
  221. package/dist/lib/output/themes/default/partials/member.getterSetter.js +0 -12
  222. package/dist/lib/output/themes/default/partials/member.js +0 -36
  223. package/dist/lib/output/themes/default/partials/member.signature.body.js +0 -33
  224. package/dist/lib/output/themes/default/partials/member.signature.title.js +0 -9
  225. package/dist/lib/output/themes/default/partials/member.signatures.js +0 -9
  226. package/dist/lib/output/themes/default/partials/member.sources.js +0 -55
  227. package/dist/lib/output/themes/default/partials/members.js +0 -17
  228. package/dist/lib/output/themes/default/partials/moduleReflection.js +0 -68
  229. package/dist/lib/output/themes/default/partials/navigation.js +0 -144
  230. package/dist/lib/output/themes/default/partials/reflectionPreview.js +0 -26
  231. package/dist/lib/output/themes/default/partials/toolbar.js +0 -13
  232. package/dist/lib/output/themes/default/partials/type.js +0 -9
  233. package/dist/lib/output/themes/default/partials/typeAndParent.js +0 -28
  234. package/dist/lib/output/themes/default/partials/typeDetails.js +0 -284
  235. package/dist/lib/output/themes/default/partials/typeParameters.js +0 -26
  236. package/dist/lib/output/themes/default/templates/document.js +0 -3
  237. package/dist/lib/output/themes/default/templates/hierarchy.js +0 -31
  238. package/dist/lib/output/themes/default/templates/index.js +0 -3
  239. package/dist/lib/output/themes/default/templates/reflection.js +0 -53
  240. package/dist/lib/output/themes/lib.js +0 -218
  241. package/dist/lib/serialization/components.js +0 -1
  242. package/dist/lib/serialization/deserializer.js +0 -235
  243. package/dist/lib/serialization/events.js +0 -18
  244. package/dist/lib/serialization/index.js +0 -4
  245. package/dist/lib/serialization/schema.js +0 -32
  246. package/dist/lib/serialization/serializer.js +0 -65
  247. package/dist/lib/utils/ValidatingFileRegistry.js +0 -52
  248. package/dist/lib/utils/component.js +0 -41
  249. package/dist/lib/utils/compress.js +0 -13
  250. package/dist/lib/utils/declaration-maps.js +0 -51
  251. package/dist/lib/utils/entry-point.js +0 -330
  252. package/dist/lib/utils/fs.js +0 -372
  253. package/dist/lib/utils/general.js +0 -25
  254. package/dist/lib/utils/highlighter.js +0 -150
  255. package/dist/lib/utils/html-entities.js +0 -2329
  256. package/dist/lib/utils/html.js +0 -635
  257. package/dist/lib/utils/index.d.ts +0 -17
  258. package/dist/lib/utils/index.js +0 -15
  259. package/dist/lib/utils/loggers.js +0 -71
  260. package/dist/lib/utils/options/declaration.js +0 -443
  261. package/dist/lib/utils/options/defaults.js +0 -104
  262. package/dist/lib/utils/options/help.js +0 -63
  263. package/dist/lib/utils/options/index.js +0 -4
  264. package/dist/lib/utils/options/options.js +0 -273
  265. package/dist/lib/utils/options/readers/arguments.js +0 -109
  266. package/dist/lib/utils/options/readers/index.js +0 -4
  267. package/dist/lib/utils/options/readers/package-json.js +0 -40
  268. package/dist/lib/utils/options/readers/tsconfig.js +0 -172
  269. package/dist/lib/utils/options/readers/typedoc.js +0 -136
  270. package/dist/lib/utils/options/sources/index.js +0 -1
  271. package/dist/lib/utils/options/sources/typedoc.js +0 -876
  272. package/dist/lib/utils/options/tsdoc-defaults.js +0 -94
  273. package/dist/lib/utils/package-manifest.js +0 -84
  274. package/dist/lib/utils/paths.js +0 -127
  275. package/dist/lib/utils/perf.js +0 -86
  276. package/dist/lib/utils/plugins.js +0 -61
  277. package/dist/lib/utils/reflections.js +0 -64
  278. package/dist/lib/utils/sort.js +0 -153
  279. package/dist/lib/utils/tsconfig.js +0 -60
  280. package/dist/lib/utils/tsutils.js +0 -23
  281. package/dist/lib/utils-common/array.js +0 -152
  282. package/dist/lib/utils-common/declarationReference.js +0 -341
  283. package/dist/lib/utils-common/enum.js +0 -27
  284. package/dist/lib/utils-common/events.js +0 -49
  285. package/dist/lib/utils-common/general.js +0 -22
  286. package/dist/lib/utils-common/hooks.js +0 -90
  287. package/dist/lib/utils-common/i18n.js +0 -39
  288. package/dist/lib/utils-common/index.js +0 -17
  289. package/dist/lib/utils-common/jsx.elements.js +0 -3
  290. package/dist/lib/utils-common/jsx.js +0 -187
  291. package/dist/lib/utils-common/logger.js +0 -129
  292. package/dist/lib/utils-common/map.js +0 -63
  293. package/dist/lib/utils-common/minimalSourceFile.js +0 -43
  294. package/dist/lib/utils-common/path.js +0 -130
  295. package/dist/lib/utils-common/set.js +0 -23
  296. package/dist/lib/utils-common/string.js +0 -84
  297. package/dist/lib/utils-common/validation.js +0 -50
  298. package/dist/lib/validation/documentation.js +0 -91
  299. package/dist/lib/validation/exports.js +0 -65
  300. package/dist/lib/validation/links.js +0 -78
  301. package/dist/lib/validation/unusedMergeModuleWith.js +0 -12
  302. /package/dist/{browser-utils.d.ts → types/browser-utils.d.ts} +0 -0
  303. /package/dist/{lib → types}/cli.d.ts +0 -0
  304. /package/dist/{lib → types}/converter/comments/blockLexer.d.ts +0 -0
  305. /package/dist/{lib → types}/converter/comments/lineLexer.d.ts +0 -0
  306. /package/dist/{lib → types}/converter/comments/rawLexer.d.ts +0 -0
  307. /package/dist/{lib → types}/converter/comments/tagName.d.ts +0 -0
  308. /package/dist/{lib → types}/converter/convert-expression.d.ts +0 -0
  309. /package/dist/{lib → types}/converter/converter-events.d.ts +0 -0
  310. /package/dist/{lib → types}/converter/factories/index-signature.d.ts +0 -0
  311. /package/dist/{lib → types}/converter/factories/symbol-id.d.ts +0 -0
  312. /package/dist/{lib → types}/converter/jsdoc.d.ts +0 -0
  313. /package/dist/{lib → types}/converter/plugins/CommentPlugin.d.ts +0 -0
  314. /package/dist/{lib → types}/converter/plugins/ImplementsPlugin.d.ts +0 -0
  315. /package/dist/{lib → types}/converter/plugins/MergeModuleWithPlugin.d.ts +0 -0
  316. /package/dist/{lib → types}/converter/plugins/PackagePlugin.d.ts +0 -0
  317. /package/dist/{lib → types}/converter/plugins/index.d.ts +0 -0
  318. /package/dist/{lib → types}/converter/symbols.d.ts +0 -0
  319. /package/dist/{lib/converter/utils → types/converter/utilities}/nodes.d.ts +0 -0
  320. /package/dist/{lib/converter/utils → types/converter/utilities}/symbols.d.ts +0 -0
  321. /package/dist/{lib → types}/debug/index.d.ts +0 -0
  322. /package/dist/{lib → types}/debug/reflectionLifetimes.d.ts +0 -0
  323. /package/dist/{lib → types}/debug/rendererUrls.d.ts +0 -0
  324. /package/dist/{lib → types}/internationalization/index.d.ts +0 -0
  325. /package/dist/{lib → types}/models/Comment.d.ts +0 -0
  326. /package/dist/{lib → types}/models/ContainerReflection.d.ts +0 -0
  327. /package/dist/{lib → types}/models/DeclarationReflection.d.ts +0 -0
  328. /package/dist/{lib → types}/models/DocumentReflection.d.ts +0 -0
  329. /package/dist/{lib → types}/models/ParameterReflection.d.ts +0 -0
  330. /package/dist/{lib → types}/models/ProjectReflection.d.ts +0 -0
  331. /package/dist/{lib → types}/models/ReferenceReflection.d.ts +0 -0
  332. /package/dist/{lib → types}/models/Reflection.d.ts +0 -0
  333. /package/dist/{lib → types}/models/ReflectionCategory.d.ts +0 -0
  334. /package/dist/{lib → types}/models/ReflectionGroup.d.ts +0 -0
  335. /package/dist/{lib → types}/models/SignatureReflection.d.ts +0 -0
  336. /package/dist/{lib → types}/models/TypeParameterReflection.d.ts +0 -0
  337. /package/dist/{lib → types}/models/index.d.ts +0 -0
  338. /package/dist/{lib → types}/models/kind.d.ts +0 -0
  339. /package/dist/{lib → types}/models/types.d.ts +0 -0
  340. /package/dist/{lib → types}/models/utils.d.ts +0 -0
  341. /package/dist/{lib → types}/models/variant.d.ts +0 -0
  342. /package/dist/{lib → types}/output/index.d.ts +0 -0
  343. /package/dist/{lib → types}/output/plugins/AssetsPlugin.d.ts +0 -0
  344. /package/dist/{lib → types}/output/plugins/HierarchyPlugin.d.ts +0 -0
  345. /package/dist/{lib → types}/output/plugins/IconsPlugin.d.ts +0 -0
  346. /package/dist/{lib → types}/output/plugins/JavascriptIndexPlugin.d.ts +0 -0
  347. /package/dist/{lib → types}/output/plugins/NavigationPlugin.d.ts +0 -0
  348. /package/dist/{lib → types}/output/plugins/SitemapPlugin.d.ts +0 -0
  349. /package/dist/{lib → types}/output/plugins/index.d.ts +0 -0
  350. /package/dist/{lib → types}/output/theme.d.ts +0 -0
  351. /package/dist/{lib → types}/output/themes/default/Slugger.d.ts +0 -0
  352. /package/dist/{lib → types}/output/themes/default/partials/footer.d.ts +0 -0
  353. /package/dist/{lib → types}/output/themes/default/partials/member.declaration.d.ts +0 -0
  354. /package/dist/{lib → types}/output/themes/default/partials/typeAndParent.d.ts +0 -0
  355. /package/dist/{lib → types}/serialization/components.d.ts +0 -0
  356. /package/dist/{lib → types}/serialization/deserializer.d.ts +0 -0
  357. /package/dist/{lib → types}/serialization/events.d.ts +0 -0
  358. /package/dist/{lib → types}/serialization/index.d.ts +0 -0
  359. /package/dist/{lib → types}/serialization/schema.d.ts +0 -0
  360. /package/dist/{lib → types}/serialization/serializer.d.ts +0 -0
  361. /package/dist/{lib → types}/utils/component.d.ts +0 -0
  362. /package/dist/{lib → types}/utils/compress.d.ts +0 -0
  363. /package/dist/{lib → types}/utils/declaration-maps.d.ts +0 -0
  364. /package/dist/{lib → types}/utils/fs.d.ts +0 -0
  365. /package/dist/{lib → types}/utils/highlighter.d.ts +0 -0
  366. /package/dist/{lib → types}/utils/html-entities.d.ts +0 -0
  367. /package/dist/{lib → types}/utils/html.d.ts +0 -0
  368. /package/dist/{lib → types}/utils/loggers.d.ts +0 -0
  369. /package/dist/{lib → types}/utils/options/help.d.ts +0 -0
  370. /package/dist/{lib → types}/utils/options/readers/arguments.d.ts +0 -0
  371. /package/dist/{lib → types}/utils/options/readers/index.d.ts +0 -0
  372. /package/dist/{lib → types}/utils/options/readers/package-json.d.ts +0 -0
  373. /package/dist/{lib → types}/utils/options/readers/tsconfig.d.ts +0 -0
  374. /package/dist/{lib → types}/utils/options/readers/typedoc.d.ts +0 -0
  375. /package/dist/{lib → types}/utils/options/sources/index.d.ts +0 -0
  376. /package/dist/{lib → types}/utils/options/sources/typedoc.d.ts +0 -0
  377. /package/dist/{lib → types}/utils/package-manifest.d.ts +0 -0
  378. /package/dist/{lib → types}/utils/paths.d.ts +0 -0
  379. /package/dist/{lib → types}/utils/perf.d.ts +0 -0
  380. /package/dist/{lib → types}/utils/plugins.d.ts +0 -0
  381. /package/dist/{lib → types}/utils/tsconfig.d.ts +0 -0
  382. /package/dist/{lib → types}/utils/tsutils.d.ts +0 -0
  383. /package/dist/{lib → types}/utils-common/array.d.ts +0 -0
  384. /package/dist/{lib → types}/utils-common/declarationReference.d.ts +0 -0
  385. /package/dist/{lib → types}/utils-common/enum.d.ts +0 -0
  386. /package/dist/{lib → types}/utils-common/events.d.ts +0 -0
  387. /package/dist/{lib → types}/utils-common/hooks.d.ts +0 -0
  388. /package/dist/{lib → types}/utils-common/i18n.d.ts +0 -0
  389. /package/dist/{lib → types}/utils-common/index.d.ts +0 -0
  390. /package/dist/{lib → types}/utils-common/jsx.d.ts +0 -0
  391. /package/dist/{lib → types}/utils-common/logger.d.ts +0 -0
  392. /package/dist/{lib → types}/utils-common/map.d.ts +0 -0
  393. /package/dist/{lib → types}/utils-common/minimalSourceFile.d.ts +0 -0
  394. /package/dist/{lib → types}/utils-common/path.d.ts +0 -0
  395. /package/dist/{lib → types}/utils-common/set.d.ts +0 -0
  396. /package/dist/{lib → types}/utils-common/string.d.ts +0 -0
  397. /package/dist/{lib → types}/utils-common/validation.d.ts +0 -0
@@ -1,833 +0,0 @@
1
- import assert from "assert";
2
- import ts from "typescript";
3
- import { ArrayType, ConditionalType, DeclarationReflection, IndexedAccessType, InferredType, IntersectionType, IntrinsicType, LiteralType, MappedType, NamedTupleMember, OptionalType, PredicateType, QueryType, ReferenceType, ReflectionFlag, ReflectionKind, ReflectionType, RestType, SignatureReflection, TemplateLiteralType, TupleType, TypeOperatorType, UnionType, UnknownType, } from "../models/index.js";
4
- import { zip } from "#utils";
5
- import { ConverterEvents } from "./converter-events.js";
6
- import { convertIndexSignatures } from "./factories/index-signature.js";
7
- import { convertParameterNodes, convertTypeParameterNodes, createSignature } from "./factories/signature.js";
8
- import { convertSymbol } from "./symbols.js";
9
- import { isObjectType, isTypeReference } from "./utils/nodes.js";
10
- import { removeUndefined } from "./utils/reflections.js";
11
- const converters = new Map();
12
- export function loadConverters() {
13
- if (converters.size)
14
- return;
15
- for (const actor of [
16
- arrayConverter,
17
- conditionalConverter,
18
- constructorConverter,
19
- exprWithTypeArgsConverter,
20
- functionTypeConverter,
21
- importType,
22
- indexedAccessConverter,
23
- inferredConverter,
24
- intersectionConverter,
25
- intrinsicConverter,
26
- jsDocVariadicTypeConverter,
27
- keywordConverter,
28
- optionalConverter,
29
- parensConverter,
30
- predicateConverter,
31
- queryConverter,
32
- typeLiteralConverter,
33
- referenceConverter,
34
- restConverter,
35
- namedTupleMemberConverter,
36
- mappedConverter,
37
- literalTypeConverter,
38
- templateLiteralConverter,
39
- thisConverter,
40
- tupleConverter,
41
- typeOperatorConverter,
42
- unionConverter,
43
- jSDocTypeExpressionConverter,
44
- // Only used if skipLibCheck: true
45
- jsDocNullableTypeConverter,
46
- jsDocNonNullableTypeConverter,
47
- jsDocAllTypeConverter,
48
- ]) {
49
- for (const key of actor.kind) {
50
- if (key === undefined) {
51
- // Might happen if running on an older TS version.
52
- continue;
53
- }
54
- assert(!converters.has(key));
55
- converters.set(key, actor);
56
- }
57
- }
58
- }
59
- // This ought not be necessary, but we need some way to discover recursively
60
- // typed symbols which do not have type nodes. See the `recursive` symbol in the variables test.
61
- const seenTypes = new Set();
62
- function maybeConvertType(context, typeOrNode) {
63
- if (!typeOrNode) {
64
- return;
65
- }
66
- return convertType(context, typeOrNode);
67
- }
68
- let typeConversionDepth = 0;
69
- export function convertType(context, typeOrNode, maybeNode) {
70
- if (!typeOrNode) {
71
- return new IntrinsicType("any");
72
- }
73
- if (typeConversionDepth > context.converter.maxTypeConversionDepth) {
74
- return new UnknownType("...");
75
- }
76
- loadConverters();
77
- if ("kind" in typeOrNode) {
78
- const converter = converters.get(typeOrNode.kind);
79
- if (converter) {
80
- ++typeConversionDepth;
81
- const result = converter.convert(context, typeOrNode);
82
- --typeConversionDepth;
83
- return result;
84
- }
85
- return requestBugReport(context, typeOrNode);
86
- }
87
- // TS 4.2 added this to enable better tracking of type aliases.
88
- // We need to check it here, not just in the union checker, because typeToTypeNode
89
- // will use the origin when serializing
90
- // aliasSymbol check is important - #2468
91
- if (typeOrNode.isUnion() && typeOrNode.origin && !typeOrNode.aliasSymbol) {
92
- // Don't increment typeConversionDepth as this is a transparent step to the user.
93
- return convertType(context, typeOrNode.origin);
94
- }
95
- // IgnoreErrors is important, without it, we can't assert that we will get a node.
96
- const node = context.checker.typeToTypeNode(typeOrNode, void 0, ts.NodeBuilderFlags.IgnoreErrors);
97
- assert(node); // According to the TS source of typeToString, this is a bug if it does not hold.
98
- if (seenTypes.has(typeOrNode.id)) {
99
- const typeString = context.checker.typeToString(typeOrNode);
100
- context.logger.verbose(`Refusing to recurse when converting type: ${typeString}`);
101
- return new UnknownType(typeString);
102
- }
103
- let converter = converters.get(node.kind);
104
- if (converter) {
105
- // Hacky fix for #2011, need to find a better way to choose the converter.
106
- if (converter === intersectionConverter &&
107
- !typeOrNode.isIntersection()) {
108
- converter = typeLiteralConverter;
109
- }
110
- seenTypes.add(typeOrNode.id);
111
- ++typeConversionDepth;
112
- const result = converter.convertType(context, typeOrNode, node, maybeNode);
113
- --typeConversionDepth;
114
- seenTypes.delete(typeOrNode.id);
115
- return result;
116
- }
117
- return requestBugReport(context, typeOrNode);
118
- }
119
- const arrayConverter = {
120
- kind: [ts.SyntaxKind.ArrayType],
121
- convert(context, node) {
122
- return new ArrayType(convertType(context, node.elementType));
123
- },
124
- convertType(context, type) {
125
- const params = type.aliasTypeArguments || context.checker.getTypeArguments(type);
126
- // This is *almost* always true... except for when this type is in the constraint of a type parameter see GH#1408
127
- // assert(params.length === 1);
128
- assert(params.length > 0);
129
- return new ArrayType(convertType(context, params[0]));
130
- },
131
- };
132
- const conditionalConverter = {
133
- kind: [ts.SyntaxKind.ConditionalType],
134
- convert(context, node) {
135
- return new ConditionalType(convertType(context, node.checkType), convertType(context, node.extendsType), convertType(context, node.trueType), convertType(context, node.falseType));
136
- },
137
- convertType(context, type) {
138
- return new ConditionalType(convertType(context, type.checkType), convertType(context, type.extendsType), convertType(context, type.resolvedTrueType), convertType(context, type.resolvedFalseType));
139
- },
140
- };
141
- const constructorConverter = {
142
- kind: [ts.SyntaxKind.ConstructorType],
143
- convert(context, node) {
144
- const symbol = context.getSymbolAtLocation(node) ?? node.symbol;
145
- const type = context.getTypeAtLocation(node);
146
- if (!symbol || !type) {
147
- return new IntrinsicType("Function");
148
- }
149
- const reflection = new DeclarationReflection("__type", ReflectionKind.Constructor, context.scope);
150
- const rc = context.withScope(reflection);
151
- rc.convertingTypeNode = true;
152
- context.registerReflection(reflection, symbol);
153
- context.converter.trigger(ConverterEvents.CREATE_DECLARATION, context, reflection);
154
- const signature = new SignatureReflection("__type", ReflectionKind.ConstructorSignature, reflection);
155
- // This is unfortunate... but seems the obvious place to put this with the current
156
- // architecture. Ideally, this would be a property on a "ConstructorType"... but that
157
- // needs to wait until TypeDoc 0.22 when making other breaking changes.
158
- if (node.modifiers?.some((m) => m.kind === ts.SyntaxKind.AbstractKeyword)) {
159
- signature.setFlag(ReflectionFlag.Abstract);
160
- }
161
- context.project.registerSymbolId(signature, context.createSymbolId(symbol, node));
162
- context.registerReflection(signature, void 0);
163
- const signatureCtx = rc.withScope(signature);
164
- reflection.signatures = [signature];
165
- signature.type = convertType(signatureCtx, node.type);
166
- signature.parameters = convertParameterNodes(signatureCtx, signature, node.parameters);
167
- signature.typeParameters = convertTypeParameterNodes(signatureCtx, node.typeParameters);
168
- return new ReflectionType(reflection);
169
- },
170
- convertType(context, type) {
171
- const symbol = type.getSymbol();
172
- if (!symbol) {
173
- return new IntrinsicType("Function");
174
- }
175
- const reflection = new DeclarationReflection("__type", ReflectionKind.Constructor, context.scope);
176
- context.registerReflection(reflection, symbol);
177
- context.converter.trigger(ConverterEvents.CREATE_DECLARATION, context, reflection);
178
- createSignature(context.withScope(reflection), ReflectionKind.ConstructorSignature, type.getConstructSignatures()[0], symbol);
179
- return new ReflectionType(reflection);
180
- },
181
- };
182
- const exprWithTypeArgsConverter = {
183
- kind: [ts.SyntaxKind.ExpressionWithTypeArguments],
184
- convert(context, node) {
185
- const targetSymbol = context.getSymbolAtLocation(node.expression);
186
- // Mixins... we might not have a symbol here.
187
- if (!targetSymbol) {
188
- return convertType(context, context.checker.getTypeAtLocation(node));
189
- }
190
- const parameters = node.typeArguments?.map((type) => convertType(context, type)) ?? [];
191
- const ref = context.createSymbolReference(context.resolveAliasedSymbol(targetSymbol), context);
192
- ref.typeArguments = parameters;
193
- return ref;
194
- },
195
- convertType: requestBugReport,
196
- };
197
- const functionTypeConverter = {
198
- kind: [ts.SyntaxKind.FunctionType],
199
- convert(context, node) {
200
- const symbol = context.getSymbolAtLocation(node) ?? node.symbol;
201
- const type = context.getTypeAtLocation(node);
202
- if (!symbol || !type) {
203
- return new IntrinsicType("Function");
204
- }
205
- const reflection = new DeclarationReflection("__type", ReflectionKind.TypeLiteral, context.scope);
206
- const rc = context.withScope(reflection);
207
- context.registerReflection(reflection, symbol);
208
- context.converter.trigger(ConverterEvents.CREATE_DECLARATION, context, reflection);
209
- const signature = new SignatureReflection("__type", ReflectionKind.CallSignature, reflection);
210
- context.project.registerSymbolId(signature, context.createSymbolId(symbol, node));
211
- context.registerReflection(signature, undefined);
212
- const signatureCtx = rc.withScope(signature);
213
- reflection.signatures = [signature];
214
- signature.type = convertType(signatureCtx, node.type);
215
- signature.parameters = convertParameterNodes(signatureCtx, signature, node.parameters);
216
- signature.typeParameters = convertTypeParameterNodes(signatureCtx, node.typeParameters);
217
- return new ReflectionType(reflection);
218
- },
219
- convertType(context, type) {
220
- const symbol = type.getSymbol();
221
- if (!symbol) {
222
- return new IntrinsicType("Function");
223
- }
224
- const reflection = new DeclarationReflection("__type", ReflectionKind.TypeLiteral, context.scope);
225
- context.registerReflection(reflection, symbol);
226
- context.converter.trigger(ConverterEvents.CREATE_DECLARATION, context, reflection);
227
- createSignature(context.withScope(reflection), ReflectionKind.CallSignature, type.getCallSignatures()[0], type.getSymbol());
228
- return new ReflectionType(reflection);
229
- },
230
- };
231
- const importType = {
232
- kind: [ts.SyntaxKind.ImportType],
233
- convert(context, node) {
234
- const name = node.qualifier?.getText() ?? "__module";
235
- const symbol = context.getSymbolAtLocation(node.qualifier || node);
236
- // #2792, we should always have a symbol here unless there is a compiler
237
- // error ignored with ts-expect-error or ts-ignore.
238
- if (!symbol) {
239
- return new IntrinsicType("any");
240
- }
241
- return context.createSymbolReference(context.resolveAliasedSymbol(symbol), context, name);
242
- },
243
- convertType(context, type) {
244
- const symbol = type.getSymbol();
245
- assert(symbol, "Missing symbol when converting import type"); // Should be a compiler error
246
- return context.createSymbolReference(context.resolveAliasedSymbol(symbol), context, "__module");
247
- },
248
- };
249
- const indexedAccessConverter = {
250
- kind: [ts.SyntaxKind.IndexedAccessType],
251
- convert(context, node) {
252
- return new IndexedAccessType(convertType(context, node.objectType), convertType(context, node.indexType));
253
- },
254
- convertType(context, type) {
255
- return new IndexedAccessType(convertType(context, type.objectType), convertType(context, type.indexType));
256
- },
257
- };
258
- const inferredConverter = {
259
- kind: [ts.SyntaxKind.InferType],
260
- convert(context, node) {
261
- return new InferredType(node.typeParameter.name.text, maybeConvertType(context, node.typeParameter.constraint));
262
- },
263
- convertType(context, type) {
264
- return new InferredType(type.getSymbol().name, maybeConvertType(context, type.getConstraint()));
265
- },
266
- };
267
- const intersectionConverter = {
268
- kind: [ts.SyntaxKind.IntersectionType],
269
- convert(context, node) {
270
- return new IntersectionType(node.types.map((type) => convertType(context, type)));
271
- },
272
- convertType(context, type) {
273
- return new IntersectionType(type.types.map((type) => convertType(context, type)));
274
- },
275
- };
276
- const intrinsicConverter = {
277
- kind: [ts.SyntaxKind.IntrinsicKeyword],
278
- convert() {
279
- return new IntrinsicType("intrinsic");
280
- },
281
- convertType() {
282
- return new IntrinsicType("intrinsic");
283
- },
284
- };
285
- const jsDocVariadicTypeConverter = {
286
- kind: [ts.SyntaxKind.JSDocVariadicType],
287
- convert(context, node) {
288
- return new ArrayType(convertType(context, node.type));
289
- },
290
- convertType(context, type, _node, origNode) {
291
- assert(isTypeReference(type));
292
- return arrayConverter.convertType(context, type, null, origNode);
293
- },
294
- };
295
- const keywordNames = {
296
- [ts.SyntaxKind.AnyKeyword]: "any",
297
- [ts.SyntaxKind.BigIntKeyword]: "bigint",
298
- [ts.SyntaxKind.BooleanKeyword]: "boolean",
299
- [ts.SyntaxKind.NeverKeyword]: "never",
300
- [ts.SyntaxKind.NumberKeyword]: "number",
301
- [ts.SyntaxKind.ObjectKeyword]: "object",
302
- [ts.SyntaxKind.StringKeyword]: "string",
303
- [ts.SyntaxKind.SymbolKeyword]: "symbol",
304
- [ts.SyntaxKind.UndefinedKeyword]: "undefined",
305
- [ts.SyntaxKind.UnknownKeyword]: "unknown",
306
- [ts.SyntaxKind.VoidKeyword]: "void",
307
- [ts.SyntaxKind.IntrinsicKeyword]: "intrinsic",
308
- };
309
- const keywordConverter = {
310
- kind: [
311
- ts.SyntaxKind.AnyKeyword,
312
- ts.SyntaxKind.BigIntKeyword,
313
- ts.SyntaxKind.BooleanKeyword,
314
- ts.SyntaxKind.NeverKeyword,
315
- ts.SyntaxKind.NumberKeyword,
316
- ts.SyntaxKind.ObjectKeyword,
317
- ts.SyntaxKind.StringKeyword,
318
- ts.SyntaxKind.SymbolKeyword,
319
- ts.SyntaxKind.UndefinedKeyword,
320
- ts.SyntaxKind.UnknownKeyword,
321
- ts.SyntaxKind.VoidKeyword,
322
- ],
323
- convert(_context, node) {
324
- return new IntrinsicType(keywordNames[node.kind]);
325
- },
326
- convertType(_context, _type, node) {
327
- return new IntrinsicType(keywordNames[node.kind]);
328
- },
329
- };
330
- const optionalConverter = {
331
- kind: [ts.SyntaxKind.OptionalType],
332
- convert(context, node) {
333
- return new OptionalType(removeUndefined(convertType(context, node.type)));
334
- },
335
- // Handled by the tuple converter
336
- convertType: requestBugReport,
337
- };
338
- const parensConverter = {
339
- kind: [ts.SyntaxKind.ParenthesizedType],
340
- convert(context, node) {
341
- return convertType(context, node.type);
342
- },
343
- // TS strips these out too... shouldn't run into this.
344
- convertType: requestBugReport,
345
- };
346
- const predicateConverter = {
347
- kind: [ts.SyntaxKind.TypePredicate],
348
- convert(context, node) {
349
- const name = ts.isThisTypeNode(node.parameterName)
350
- ? "this"
351
- : node.parameterName.getText();
352
- const asserts = !!node.assertsModifier;
353
- const targetType = node.type ? convertType(context, node.type) : void 0;
354
- return new PredicateType(name, asserts, targetType);
355
- },
356
- // Never inferred by TS 4.0, could potentially change in a future TS version.
357
- convertType: requestBugReport,
358
- };
359
- // This is a horrible thing... we're going to want to split this into converters
360
- // for different types at some point.
361
- const typeLiteralConverter = {
362
- kind: [ts.SyntaxKind.TypeLiteral],
363
- convert(context, node) {
364
- const symbol = context.getSymbolAtLocation(node) ?? node.symbol;
365
- const type = context.getTypeAtLocation(node);
366
- if (!symbol || !type) {
367
- return new IntrinsicType("Object");
368
- }
369
- const reflection = new DeclarationReflection("__type", ReflectionKind.TypeLiteral, context.scope);
370
- const rc = context.withScope(reflection);
371
- rc.convertingTypeNode = true;
372
- context.registerReflection(reflection, symbol);
373
- context.converter.trigger(ConverterEvents.CREATE_DECLARATION, context, reflection);
374
- for (const prop of context.checker.getPropertiesOfType(type)) {
375
- convertSymbol(rc, prop);
376
- }
377
- for (const signature of type.getCallSignatures()) {
378
- createSignature(rc, ReflectionKind.CallSignature, signature, symbol);
379
- }
380
- for (const signature of type.getConstructSignatures()) {
381
- createSignature(rc, ReflectionKind.ConstructorSignature, signature, symbol);
382
- }
383
- convertIndexSignatures(rc, type);
384
- return new ReflectionType(reflection);
385
- },
386
- convertType(context, type) {
387
- const symbol = type.getSymbol();
388
- const reflection = new DeclarationReflection("__type", ReflectionKind.TypeLiteral, context.scope);
389
- context.registerReflection(reflection, symbol);
390
- context.converter.trigger(ConverterEvents.CREATE_DECLARATION, context, reflection);
391
- for (const prop of context.checker.getPropertiesOfType(type)) {
392
- convertSymbol(context.withScope(reflection), prop);
393
- }
394
- for (const signature of type.getCallSignatures()) {
395
- createSignature(context.withScope(reflection), ReflectionKind.CallSignature, signature, symbol);
396
- }
397
- for (const signature of type.getConstructSignatures()) {
398
- createSignature(context.withScope(reflection), ReflectionKind.ConstructorSignature, signature, symbol);
399
- }
400
- if (symbol) {
401
- convertIndexSignatures(context.withScope(reflection), type);
402
- }
403
- return new ReflectionType(reflection);
404
- },
405
- };
406
- const queryConverter = {
407
- kind: [ts.SyntaxKind.TypeQuery],
408
- convert(context, node) {
409
- const querySymbol = context.getSymbolAtLocation(node.exprName);
410
- if (!querySymbol) {
411
- // This can happen if someone uses `typeof` on some property
412
- // on a variable typed as `any` with a name that doesn't exist.
413
- return new QueryType(ReferenceType.createBrokenReference(node.exprName.getText(), context.project, undefined));
414
- }
415
- const ref = context.createSymbolReference(context.resolveAliasedSymbol(querySymbol), context, node.exprName.getText());
416
- ref.preferValues = true;
417
- return new QueryType(ref);
418
- },
419
- convertType(context, type, node) {
420
- // Order matters here - check the node location first so that if the typeof is targeting
421
- // an instantiation expression we get the user's exprName.
422
- const symbol = context.getSymbolAtLocation(node.exprName) || type.getSymbol();
423
- assert(symbol, `Query type failed to get a symbol for: ${context.checker.typeToString(type)}. This is a bug.`);
424
- const ref = context.createSymbolReference(context.resolveAliasedSymbol(symbol), context);
425
- ref.preferValues = true;
426
- return new QueryType(ref);
427
- },
428
- };
429
- const referenceConverter = {
430
- kind: [ts.SyntaxKind.TypeReference],
431
- convert(context, node) {
432
- const type = context.checker.getTypeAtLocation(node.typeName);
433
- const isArray = context.checker.typeToTypeNode(type, void 0, ts.NodeBuilderFlags.IgnoreErrors)?.kind === ts.SyntaxKind.ArrayType;
434
- if (isArray) {
435
- return new ArrayType(convertType(context, node.typeArguments?.[0]));
436
- }
437
- const symbol = context.expectSymbolAtLocation(node.typeName);
438
- const name = node.typeName.getText();
439
- // Ignore @inline if there are type arguments, as they won't be resolved
440
- // in the type we just retrieved from node.typeName.
441
- if (!node.typeArguments &&
442
- context.shouldInline(symbol, name)) {
443
- return convertTypeInlined(context, type);
444
- }
445
- const ref = context.createSymbolReference(context.resolveAliasedSymbol(symbol), context, name);
446
- ref.typeArguments = node.typeArguments?.map((type) => convertType(context, type));
447
- return ref;
448
- },
449
- convertType(context, type, node, originalNode) {
450
- // typeName.symbol handles the case where this is a union which happens to refer
451
- // to an enumeration. TS doesn't put the symbol on the type for some reason, but
452
- // does add it to the constructed type node.
453
- const symbol = type.aliasSymbol ?? type.getSymbol() ?? node.typeName.symbol;
454
- if (!symbol) {
455
- // This happens when we get a reference to a type parameter
456
- // created within a mapped type, `K` in: `{ [K in T]: string }`
457
- const ref = ReferenceType.createBrokenReference(context.checker.typeToString(type), context.project, undefined);
458
- ref.refersToTypeParameter = true;
459
- return ref;
460
- }
461
- // #2954 mapped type aliases are special! The type that we have here will
462
- // not point at the type alias which names it like we want, but instead at
463
- // the mapped type instantiation. Fall back to converting via the original
464
- // type node to avoid creating a reference which points to the mapped type.
465
- if (originalNode && ts.isTypeReferenceNode(originalNode) && isObjectType(type) &&
466
- type.objectFlags & ts.ObjectFlags.Mapped) {
467
- return referenceConverter.convert(context, originalNode);
468
- }
469
- let name;
470
- if (ts.isIdentifier(node.typeName)) {
471
- name = node.typeName.text;
472
- }
473
- else {
474
- name = node.typeName.right.text;
475
- }
476
- if (context.shouldInline(symbol, name)) {
477
- return convertTypeInlined(context, type);
478
- }
479
- const ref = context.createSymbolReference(context.resolveAliasedSymbol(symbol), context, name);
480
- if ((type.flags & ts.TypeFlags.Substitution) && name === "NoInfer" && ref.package === "typescript") {
481
- // NoInfer<T>
482
- ref.typeArguments = [
483
- convertType(context, type.baseType),
484
- ];
485
- }
486
- else if (type.flags & ts.TypeFlags.StringMapping) {
487
- ref.typeArguments = [
488
- convertType(context, type.type),
489
- ];
490
- }
491
- else {
492
- const args = type.aliasSymbol
493
- ? type.aliasTypeArguments
494
- : type.typeArguments;
495
- const maxArgLength = originalNode && ts.isTypeReferenceNode(originalNode)
496
- ? (originalNode.typeArguments?.length ?? 0)
497
- : args?.length;
498
- ref.typeArguments = args
499
- ?.slice(0, maxArgLength)
500
- .map((ref) => convertType(context, ref));
501
- }
502
- return ref;
503
- },
504
- };
505
- const restConverter = {
506
- kind: [ts.SyntaxKind.RestType],
507
- convert(context, node) {
508
- return new RestType(convertType(context, node.type));
509
- },
510
- // This is handled in the tuple converter
511
- convertType: requestBugReport,
512
- };
513
- const namedTupleMemberConverter = {
514
- kind: [ts.SyntaxKind.NamedTupleMember],
515
- convert(context, node) {
516
- const innerType = convertType(context, node.type);
517
- return new NamedTupleMember(node.name.getText(), !!node.questionToken, innerType);
518
- },
519
- // This ought to be impossible.
520
- convertType: requestBugReport,
521
- };
522
- // { -readonly [K in string]-?: number}
523
- // ^ readonlyToken
524
- // ^ typeParameter
525
- // ^^^^^^ typeParameter.constraint
526
- // ^ questionToken
527
- // ^^^^^^ type
528
- const mappedConverter = {
529
- kind: [ts.SyntaxKind.MappedType],
530
- convert(context, node) {
531
- const optionalModifier = kindToModifier(node.questionToken?.kind);
532
- const templateType = convertType(context, node.type);
533
- return new MappedType(node.typeParameter.name.text, convertType(context, node.typeParameter.constraint), optionalModifier === "+"
534
- ? removeUndefined(templateType)
535
- : templateType, kindToModifier(node.readonlyToken?.kind), optionalModifier, node.nameType ? convertType(context, node.nameType) : void 0);
536
- },
537
- convertType(context, type, node) {
538
- // This can happen if a generic function does not have a return type annotated.
539
- const optionalModifier = kindToModifier(node.questionToken?.kind);
540
- const templateType = convertType(context, type.templateType);
541
- return new MappedType(type.typeParameter.symbol.name || "__type", convertType(context, type.typeParameter.getConstraint()), optionalModifier === "+"
542
- ? removeUndefined(templateType)
543
- : templateType, kindToModifier(node.readonlyToken?.kind), optionalModifier, type.nameType ? convertType(context, type.nameType) : void 0);
544
- },
545
- };
546
- const literalTypeConverter = {
547
- kind: [ts.SyntaxKind.LiteralType],
548
- convert(context, node) {
549
- switch (node.literal.kind) {
550
- case ts.SyntaxKind.TrueKeyword:
551
- case ts.SyntaxKind.FalseKeyword:
552
- return new LiteralType(node.literal.kind === ts.SyntaxKind.TrueKeyword);
553
- case ts.SyntaxKind.StringLiteral:
554
- return new LiteralType(node.literal.text);
555
- case ts.SyntaxKind.NumericLiteral:
556
- return new LiteralType(Number(node.literal.text));
557
- case ts.SyntaxKind.NullKeyword:
558
- return new LiteralType(null);
559
- case ts.SyntaxKind.PrefixUnaryExpression: {
560
- const operand = node.literal
561
- .operand;
562
- switch (operand.kind) {
563
- case ts.SyntaxKind.NumericLiteral:
564
- return new LiteralType(Number(node.literal.getText()));
565
- case ts.SyntaxKind.BigIntLiteral:
566
- return new LiteralType(BigInt(node.literal.getText().replace("n", "")));
567
- default:
568
- return requestBugReport(context, node.literal);
569
- }
570
- }
571
- case ts.SyntaxKind.BigIntLiteral:
572
- return new LiteralType(BigInt(node.literal.getText().replace("n", "")));
573
- case ts.SyntaxKind.NoSubstitutionTemplateLiteral:
574
- return new LiteralType(node.literal.text);
575
- }
576
- return requestBugReport(context, node.literal);
577
- },
578
- convertType(_context, type, node) {
579
- switch (node.literal.kind) {
580
- case ts.SyntaxKind.StringLiteral:
581
- return new LiteralType(node.literal.text);
582
- case ts.SyntaxKind.NumericLiteral:
583
- return new LiteralType(+node.literal.text);
584
- case ts.SyntaxKind.TrueKeyword:
585
- case ts.SyntaxKind.FalseKeyword:
586
- return new LiteralType(node.literal.kind === ts.SyntaxKind.TrueKeyword);
587
- case ts.SyntaxKind.NullKeyword:
588
- return new LiteralType(null);
589
- }
590
- if (typeof type.value === "object") {
591
- return new LiteralType(BigInt(`${type.value.negative ? "-" : ""}${type.value.base10Value}`));
592
- }
593
- return new LiteralType(type.value);
594
- },
595
- };
596
- const templateLiteralConverter = {
597
- kind: [ts.SyntaxKind.TemplateLiteralType],
598
- convert(context, node) {
599
- return new TemplateLiteralType(node.head.text, node.templateSpans.map((span) => {
600
- return [convertType(context, span.type), span.literal.text];
601
- }));
602
- },
603
- convertType(context, type) {
604
- assert(type.texts.length === type.types.length + 1);
605
- const parts = [];
606
- for (const [a, b] of zip(type.types, type.texts.slice(1))) {
607
- parts.push([convertType(context, a), b]);
608
- }
609
- return new TemplateLiteralType(type.texts[0], parts);
610
- },
611
- };
612
- const thisConverter = {
613
- kind: [ts.SyntaxKind.ThisType],
614
- convert() {
615
- return new IntrinsicType("this");
616
- },
617
- convertType() {
618
- return new IntrinsicType("this");
619
- },
620
- };
621
- const tupleConverter = {
622
- kind: [ts.SyntaxKind.TupleType],
623
- convert(context, node) {
624
- const elements = node.elements.map((node) => convertType(context, node));
625
- return new TupleType(elements);
626
- },
627
- convertType(context, type, node) {
628
- const types = type.typeArguments?.slice(0, node.elements.length);
629
- let elements = types?.map((type) => convertType(context, type));
630
- if (type.target.labeledElementDeclarations) {
631
- const namedDeclarations = type.target.labeledElementDeclarations;
632
- elements = elements?.map((el, i) => {
633
- const namedDecl = namedDeclarations[i];
634
- return namedDecl
635
- ? new NamedTupleMember(namedDecl.name.getText(), !!namedDecl.questionToken, removeUndefined(el))
636
- : el;
637
- });
638
- }
639
- elements = elements?.map((el, i) => {
640
- if (type.target.elementFlags[i] & ts.ElementFlags.Variable) {
641
- // In the node case, we don't need to add the wrapping Array type... but we do here.
642
- if (el instanceof NamedTupleMember) {
643
- return new RestType(new NamedTupleMember(el.name, el.isOptional, new ArrayType(el.element)));
644
- }
645
- return new RestType(new ArrayType(el));
646
- }
647
- if (type.target.elementFlags[i] & ts.ElementFlags.Optional &&
648
- !(el instanceof NamedTupleMember)) {
649
- return new OptionalType(removeUndefined(el));
650
- }
651
- return el;
652
- });
653
- return new TupleType(elements ?? []);
654
- },
655
- };
656
- const supportedOperatorNames = {
657
- [ts.SyntaxKind.KeyOfKeyword]: "keyof",
658
- [ts.SyntaxKind.UniqueKeyword]: "unique",
659
- [ts.SyntaxKind.ReadonlyKeyword]: "readonly",
660
- };
661
- const typeOperatorConverter = {
662
- kind: [ts.SyntaxKind.TypeOperator],
663
- convert(context, node) {
664
- return new TypeOperatorType(convertType(context, node.type), supportedOperatorNames[node.operator]);
665
- },
666
- convertType(context, type, node) {
667
- // readonly is only valid on array and tuple literal types.
668
- if (node.operator === ts.SyntaxKind.ReadonlyKeyword) {
669
- const resolved = resolveReference(type);
670
- assert(isObjectType(resolved));
671
- const args = context.checker
672
- .getTypeArguments(type)
673
- .map((type) => convertType(context, type));
674
- const inner = resolved.objectFlags & ts.ObjectFlags.Tuple
675
- ? new TupleType(args)
676
- : new ArrayType(args[0]);
677
- return new TypeOperatorType(inner, "readonly");
678
- }
679
- // keyof will only show up with generic functions, otherwise it gets eagerly
680
- // resolved to a union of strings.
681
- if (node.operator === ts.SyntaxKind.KeyOfKeyword) {
682
- // There's probably an interface for this somewhere... I couldn't find it.
683
- const targetType = type.type;
684
- return new TypeOperatorType(convertType(context, targetType), "keyof");
685
- }
686
- // TS drops `unique` in `unique symbol` everywhere. If someone used it, we ought
687
- // to have a type node. This shouldn't ever happen.
688
- return requestBugReport(context, type);
689
- },
690
- };
691
- const unionConverter = {
692
- kind: [ts.SyntaxKind.UnionType],
693
- convert(context, node) {
694
- return new UnionType(node.types.map((type) => convertType(context, type)));
695
- },
696
- convertType(context, type) {
697
- const types = type.types.map((type) => convertType(context, type));
698
- normalizeUnion(types);
699
- sortUnion(types);
700
- return new UnionType(types);
701
- },
702
- };
703
- const jSDocTypeExpressionConverter = {
704
- kind: [ts.SyntaxKind.JSDocTypeExpression],
705
- convert(context, node) {
706
- return convertType(context, node.type);
707
- },
708
- convertType: requestBugReport,
709
- };
710
- const jsDocNullableTypeConverter = {
711
- kind: [ts.SyntaxKind.JSDocNullableType],
712
- convert(context, node) {
713
- return new UnionType([
714
- convertType(context, node.type),
715
- new LiteralType(null),
716
- ]);
717
- },
718
- // Should be a UnionType
719
- convertType: requestBugReport,
720
- };
721
- const jsDocNonNullableTypeConverter = {
722
- kind: [ts.SyntaxKind.JSDocNonNullableType],
723
- convert(context, node) {
724
- return convertType(context, node.type);
725
- },
726
- // Should be a UnionType
727
- convertType: requestBugReport,
728
- };
729
- const jsDocAllTypeConverter = {
730
- kind: [ts.SyntaxKind.JSDocAllType],
731
- convert() {
732
- return new IntrinsicType("any");
733
- },
734
- // Should be a UnionType
735
- convertType: requestBugReport,
736
- };
737
- function requestBugReport(context, nodeOrType) {
738
- if ("kind" in nodeOrType) {
739
- const kindName = ts.SyntaxKind[nodeOrType.kind];
740
- context.logger.warn(`Failed to convert type node with kind: ${kindName} and text ${nodeOrType.getText()}. Please report a bug.`, nodeOrType);
741
- return new UnknownType(nodeOrType.getText());
742
- }
743
- else {
744
- const typeString = context.checker.typeToString(nodeOrType);
745
- context.logger.warn(`Failed to convert type: ${typeString} when converting ${context.scope.getFullName()}. Please report a bug.`);
746
- return new UnknownType(typeString);
747
- }
748
- }
749
- function resolveReference(type) {
750
- if (isObjectType(type) && type.objectFlags & ts.ObjectFlags.Reference) {
751
- return type.target;
752
- }
753
- return type;
754
- }
755
- function kindToModifier(kind) {
756
- switch (kind) {
757
- case ts.SyntaxKind.ReadonlyKeyword:
758
- case ts.SyntaxKind.QuestionToken:
759
- case ts.SyntaxKind.PlusToken:
760
- return "+";
761
- case ts.SyntaxKind.MinusToken:
762
- return "-";
763
- default:
764
- return undefined;
765
- }
766
- }
767
- function sortUnion(types) {
768
- // If every member of the union is a literal numeric type, sort in ascending order
769
- if (types.every(t => t.type === "literal" && typeof t.value === "number")) {
770
- types.sort((a, b) => {
771
- const aLit = a;
772
- const bLit = b;
773
- return aLit.value - bLit.value;
774
- });
775
- return;
776
- }
777
- // #3024 Otherwise, leave the union in the converted order with the exception of null
778
- // and undefined, which should be sorted last, with null before undefined.
779
- types.sort((a, b) => {
780
- const aIsNull = a.type === "literal" && a.value === null;
781
- const aIsUndef = a.type === "intrinsic" && a.name === "undefined";
782
- const bIsNull = b.type === "literal" && b.value === null;
783
- const bIsUndef = b.type === "intrinsic" && b.name === "undefined";
784
- const aWeight = aIsNull ? 1 : aIsUndef ? 2 : 0;
785
- const bWeight = bIsNull ? 1 : bIsUndef ? 2 : 0;
786
- return aWeight - bWeight;
787
- });
788
- }
789
- function normalizeUnion(types) {
790
- let trueIndex = -1;
791
- let falseIndex = -1;
792
- for (let i = 0; i < types.length && (trueIndex === -1 || falseIndex === -1); i++) {
793
- const t = types[i];
794
- if (t instanceof LiteralType) {
795
- if (t.value === true) {
796
- trueIndex = i;
797
- }
798
- if (t.value === false) {
799
- falseIndex = i;
800
- }
801
- }
802
- }
803
- if (trueIndex !== -1 && falseIndex !== -1) {
804
- types.splice(Math.max(trueIndex, falseIndex), 1);
805
- types.splice(Math.min(trueIndex, falseIndex), 1, new IntrinsicType("boolean"));
806
- }
807
- }
808
- function convertTypeInlined(context, type) {
809
- if (type.isUnion()) {
810
- const types = type.types.map(type => convertType(context, type));
811
- return new UnionType(types);
812
- }
813
- if (type.isIntersection()) {
814
- const types = type.types.map(type => convertType(context, type));
815
- return new IntersectionType(types);
816
- }
817
- if (type.isLiteral()) {
818
- return new LiteralType(typeof type.value === "object"
819
- ? BigInt(type.value.base10Value) * (type.value.negative ? -1n : 1n)
820
- : type.value);
821
- }
822
- if (context.checker.isArrayType(type)) {
823
- const elementType = convertType(context, context.checker.getTypeArguments(type)[0]);
824
- return new ArrayType(elementType);
825
- }
826
- if (isTypeReference(type) && context.checker.isTupleType(type)) {
827
- const tupleNode = context.checker.typeToTypeNode(type.target, void 0, ts.NodeBuilderFlags.IgnoreErrors);
828
- if (ts.isTupleTypeNode(tupleNode)) {
829
- return tupleConverter.convertType(context, type, tupleNode);
830
- }
831
- }
832
- return typeLiteralConverter.convertType(context, type);
833
- }