@depup/typedoc 0.28.17-depup.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (390) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +34 -0
  3. package/bin/package.json +3 -0
  4. package/bin/typedoc +24 -0
  5. package/changes.json +22 -0
  6. package/dist/browser-locales/de.d.ts +2 -0
  7. package/dist/browser-locales/de.js +62 -0
  8. package/dist/browser-locales/en.d.ts +2 -0
  9. package/dist/browser-locales/en.js +62 -0
  10. package/dist/browser-locales/ja.d.ts +2 -0
  11. package/dist/browser-locales/ja.js +62 -0
  12. package/dist/browser-locales/ko.d.ts +2 -0
  13. package/dist/browser-locales/ko.js +62 -0
  14. package/dist/browser-locales/zh.d.ts +2 -0
  15. package/dist/browser-locales/zh.js +62 -0
  16. package/dist/browser-utils.d.ts +3 -0
  17. package/dist/browser-utils.js +3 -0
  18. package/dist/index.d.ts +49 -0
  19. package/dist/index.js +46 -0
  20. package/dist/lib/application-events.d.ts +5 -0
  21. package/dist/lib/application-events.js +5 -0
  22. package/dist/lib/application.d.ts +195 -0
  23. package/dist/lib/application.js +715 -0
  24. package/dist/lib/cli.d.ts +1 -0
  25. package/dist/lib/cli.js +111 -0
  26. package/dist/lib/converter/comments/blockLexer.d.ts +4 -0
  27. package/dist/lib/converter/comments/blockLexer.js +391 -0
  28. package/dist/lib/converter/comments/declarationReferenceResolver.d.ts +3 -0
  29. package/dist/lib/converter/comments/declarationReferenceResolver.js +218 -0
  30. package/dist/lib/converter/comments/discovery.d.ts +14 -0
  31. package/dist/lib/converter/comments/discovery.js +563 -0
  32. package/dist/lib/converter/comments/index.d.ts +37 -0
  33. package/dist/lib/converter/comments/index.js +241 -0
  34. package/dist/lib/converter/comments/lexer.d.ts +17 -0
  35. package/dist/lib/converter/comments/lexer.js +10 -0
  36. package/dist/lib/converter/comments/lineLexer.d.ts +3 -0
  37. package/dist/lib/converter/comments/lineLexer.js +279 -0
  38. package/dist/lib/converter/comments/linkResolver.d.ts +20 -0
  39. package/dist/lib/converter/comments/linkResolver.js +186 -0
  40. package/dist/lib/converter/comments/parser.d.ts +18 -0
  41. package/dist/lib/converter/comments/parser.js +538 -0
  42. package/dist/lib/converter/comments/rawLexer.d.ts +8 -0
  43. package/dist/lib/converter/comments/rawLexer.js +218 -0
  44. package/dist/lib/converter/comments/tagName.d.ts +8 -0
  45. package/dist/lib/converter/comments/tagName.js +58 -0
  46. package/dist/lib/converter/comments/textParser.d.ts +33 -0
  47. package/dist/lib/converter/comments/textParser.js +372 -0
  48. package/dist/lib/converter/components.d.ts +4 -0
  49. package/dist/lib/converter/components.js +3 -0
  50. package/dist/lib/converter/context.d.ts +101 -0
  51. package/dist/lib/converter/context.js +311 -0
  52. package/dist/lib/converter/convert-expression.d.ts +9 -0
  53. package/dist/lib/converter/convert-expression.js +58 -0
  54. package/dist/lib/converter/converter-events.d.ts +13 -0
  55. package/dist/lib/converter/converter-events.js +13 -0
  56. package/dist/lib/converter/converter.d.ts +238 -0
  57. package/dist/lib/converter/converter.js +705 -0
  58. package/dist/lib/converter/factories/index-signature.d.ts +3 -0
  59. package/dist/lib/converter/factories/index-signature.js +50 -0
  60. package/dist/lib/converter/factories/signature.d.ts +14 -0
  61. package/dist/lib/converter/factories/signature.js +353 -0
  62. package/dist/lib/converter/factories/symbol-id.d.ts +3 -0
  63. package/dist/lib/converter/factories/symbol-id.js +47 -0
  64. package/dist/lib/converter/index.d.ts +5 -0
  65. package/dist/lib/converter/index.js +3 -0
  66. package/dist/lib/converter/jsdoc.d.ts +4 -0
  67. package/dist/lib/converter/jsdoc.js +135 -0
  68. package/dist/lib/converter/plugins/CategoryPlugin.d.ts +48 -0
  69. package/dist/lib/converter/plugins/CategoryPlugin.js +278 -0
  70. package/dist/lib/converter/plugins/CommentPlugin.d.ts +128 -0
  71. package/dist/lib/converter/plugins/CommentPlugin.js +770 -0
  72. package/dist/lib/converter/plugins/GroupPlugin.d.ts +48 -0
  73. package/dist/lib/converter/plugins/GroupPlugin.js +281 -0
  74. package/dist/lib/converter/plugins/ImplementsPlugin.d.ts +42 -0
  75. package/dist/lib/converter/plugins/ImplementsPlugin.js +438 -0
  76. package/dist/lib/converter/plugins/IncludePlugin.d.ts +14 -0
  77. package/dist/lib/converter/plugins/IncludePlugin.js +254 -0
  78. package/dist/lib/converter/plugins/InheritDocPlugin.d.ts +32 -0
  79. package/dist/lib/converter/plugins/InheritDocPlugin.js +220 -0
  80. package/dist/lib/converter/plugins/LinkResolverPlugin.d.ts +13 -0
  81. package/dist/lib/converter/plugins/LinkResolverPlugin.js +88 -0
  82. package/dist/lib/converter/plugins/MergeModuleWithPlugin.d.ts +12 -0
  83. package/dist/lib/converter/plugins/MergeModuleWithPlugin.js +50 -0
  84. package/dist/lib/converter/plugins/PackagePlugin.d.ts +31 -0
  85. package/dist/lib/converter/plugins/PackagePlugin.js +188 -0
  86. package/dist/lib/converter/plugins/SourcePlugin.d.ts +36 -0
  87. package/dist/lib/converter/plugins/SourcePlugin.js +215 -0
  88. package/dist/lib/converter/plugins/TypePlugin.d.ts +16 -0
  89. package/dist/lib/converter/plugins/TypePlugin.js +108 -0
  90. package/dist/lib/converter/plugins/index.d.ts +10 -0
  91. package/dist/lib/converter/plugins/index.js +10 -0
  92. package/dist/lib/converter/symbols.d.ts +3 -0
  93. package/dist/lib/converter/symbols.js +861 -0
  94. package/dist/lib/converter/types.d.ts +10 -0
  95. package/dist/lib/converter/types.js +833 -0
  96. package/dist/lib/converter/utils/nodes.d.ts +7 -0
  97. package/dist/lib/converter/utils/nodes.js +26 -0
  98. package/dist/lib/converter/utils/reflections.d.ts +2 -0
  99. package/dist/lib/converter/utils/reflections.js +17 -0
  100. package/dist/lib/converter/utils/repository.d.ts +96 -0
  101. package/dist/lib/converter/utils/repository.js +295 -0
  102. package/dist/lib/converter/utils/symbols.d.ts +2 -0
  103. package/dist/lib/converter/utils/symbols.js +12 -0
  104. package/dist/lib/debug/index.d.ts +2 -0
  105. package/dist/lib/debug/index.js +2 -0
  106. package/dist/lib/debug/reflectionLifetimes.d.ts +3 -0
  107. package/dist/lib/debug/reflectionLifetimes.js +27 -0
  108. package/dist/lib/debug/rendererUrls.d.ts +6 -0
  109. package/dist/lib/debug/rendererUrls.js +68 -0
  110. package/dist/lib/internationalization/index.d.ts +7 -0
  111. package/dist/lib/internationalization/index.js +7 -0
  112. package/dist/lib/internationalization/internationalization.d.ts +65 -0
  113. package/dist/lib/internationalization/internationalization.js +64 -0
  114. package/dist/lib/internationalization/locale-utils.cjs +8 -0
  115. package/dist/lib/internationalization/locale-utils.d.cts +8 -0
  116. package/dist/lib/internationalization/locales/de.cjs +401 -0
  117. package/dist/lib/internationalization/locales/de.d.cts +368 -0
  118. package/dist/lib/internationalization/locales/en.cjs +411 -0
  119. package/dist/lib/internationalization/locales/en.d.cts +380 -0
  120. package/dist/lib/internationalization/locales/ja.cjs +320 -0
  121. package/dist/lib/internationalization/locales/ja.d.cts +307 -0
  122. package/dist/lib/internationalization/locales/ko.cjs +233 -0
  123. package/dist/lib/internationalization/locales/ko.d.cts +221 -0
  124. package/dist/lib/internationalization/locales/zh.cjs +488 -0
  125. package/dist/lib/internationalization/locales/zh.d.cts +452 -0
  126. package/dist/lib/internationalization/translatable.d.ts +21 -0
  127. package/dist/lib/internationalization/translatable.js +8 -0
  128. package/dist/lib/models/Comment.d.ts +241 -0
  129. package/dist/lib/models/Comment.js +534 -0
  130. package/dist/lib/models/ContainerReflection.d.ts +56 -0
  131. package/dist/lib/models/ContainerReflection.js +159 -0
  132. package/dist/lib/models/DeclarationReflection.d.ts +149 -0
  133. package/dist/lib/models/DeclarationReflection.js +287 -0
  134. package/dist/lib/models/DocumentReflection.d.ts +32 -0
  135. package/dist/lib/models/DocumentReflection.js +66 -0
  136. package/dist/lib/models/FileRegistry.d.ts +46 -0
  137. package/dist/lib/models/FileRegistry.js +133 -0
  138. package/dist/lib/models/ParameterReflection.d.ts +21 -0
  139. package/dist/lib/models/ParameterReflection.js +39 -0
  140. package/dist/lib/models/ProjectReflection.d.ts +112 -0
  141. package/dist/lib/models/ProjectReflection.js +417 -0
  142. package/dist/lib/models/ReferenceReflection.d.ts +49 -0
  143. package/dist/lib/models/ReferenceReflection.js +85 -0
  144. package/dist/lib/models/Reflection.d.ts +229 -0
  145. package/dist/lib/models/Reflection.js +495 -0
  146. package/dist/lib/models/ReflectionCategory.d.ts +31 -0
  147. package/dist/lib/models/ReflectionCategory.js +56 -0
  148. package/dist/lib/models/ReflectionGroup.d.ts +38 -0
  149. package/dist/lib/models/ReflectionGroup.js +72 -0
  150. package/dist/lib/models/ReflectionSymbolId.d.ts +63 -0
  151. package/dist/lib/models/ReflectionSymbolId.js +85 -0
  152. package/dist/lib/models/SignatureReflection.d.ts +50 -0
  153. package/dist/lib/models/SignatureReflection.js +96 -0
  154. package/dist/lib/models/SourceReference.d.ts +33 -0
  155. package/dist/lib/models/SourceReference.js +50 -0
  156. package/dist/lib/models/TypeParameterReflection.d.ts +30 -0
  157. package/dist/lib/models/TypeParameterReflection.js +45 -0
  158. package/dist/lib/models/index.d.ts +19 -0
  159. package/dist/lib/models/index.js +19 -0
  160. package/dist/lib/models/kind.d.ts +84 -0
  161. package/dist/lib/models/kind.js +231 -0
  162. package/dist/lib/models/types.d.ts +553 -0
  163. package/dist/lib/models/types.js +1296 -0
  164. package/dist/lib/models/utils.d.ts +1 -0
  165. package/dist/lib/models/utils.js +26 -0
  166. package/dist/lib/models/variant.d.ts +21 -0
  167. package/dist/lib/models/variant.js +1 -0
  168. package/dist/lib/output/components.d.ts +53 -0
  169. package/dist/lib/output/components.js +133 -0
  170. package/dist/lib/output/events.d.ts +175 -0
  171. package/dist/lib/output/events.js +195 -0
  172. package/dist/lib/output/formatter.d.ts +88 -0
  173. package/dist/lib/output/formatter.js +660 -0
  174. package/dist/lib/output/index.d.ts +9 -0
  175. package/dist/lib/output/index.js +7 -0
  176. package/dist/lib/output/output.d.ts +14 -0
  177. package/dist/lib/output/output.js +92 -0
  178. package/dist/lib/output/plugins/AssetsPlugin.d.ts +20 -0
  179. package/dist/lib/output/plugins/AssetsPlugin.js +160 -0
  180. package/dist/lib/output/plugins/HierarchyPlugin.d.ts +7 -0
  181. package/dist/lib/output/plugins/HierarchyPlugin.js +65 -0
  182. package/dist/lib/output/plugins/IconsPlugin.d.ts +12 -0
  183. package/dist/lib/output/plugins/IconsPlugin.js +54 -0
  184. package/dist/lib/output/plugins/JavascriptIndexPlugin.d.ts +22 -0
  185. package/dist/lib/output/plugins/JavascriptIndexPlugin.js +222 -0
  186. package/dist/lib/output/plugins/NavigationPlugin.d.ts +7 -0
  187. package/dist/lib/output/plugins/NavigationPlugin.js +23 -0
  188. package/dist/lib/output/plugins/SitemapPlugin.d.ts +8 -0
  189. package/dist/lib/output/plugins/SitemapPlugin.js +82 -0
  190. package/dist/lib/output/plugins/index.d.ts +7 -0
  191. package/dist/lib/output/plugins/index.js +7 -0
  192. package/dist/lib/output/renderer.d.ts +227 -0
  193. package/dist/lib/output/renderer.js +387 -0
  194. package/dist/lib/output/router.d.ts +187 -0
  195. package/dist/lib/output/router.js +520 -0
  196. package/dist/lib/output/theme.d.ts +22 -0
  197. package/dist/lib/output/theme.js +17 -0
  198. package/dist/lib/output/themes/MarkedPlugin.d.ts +62 -0
  199. package/dist/lib/output/themes/MarkedPlugin.js +461 -0
  200. package/dist/lib/output/themes/default/DefaultTheme.d.ts +72 -0
  201. package/dist/lib/output/themes/default/DefaultTheme.js +367 -0
  202. package/dist/lib/output/themes/default/DefaultThemeRenderContext.d.ts +105 -0
  203. package/dist/lib/output/themes/default/DefaultThemeRenderContext.js +151 -0
  204. package/dist/lib/output/themes/default/Slugger.d.ts +13 -0
  205. package/dist/lib/output/themes/default/Slugger.js +60 -0
  206. package/dist/lib/output/themes/default/layouts/default.d.ts +6 -0
  207. package/dist/lib/output/themes/default/layouts/default.js +89 -0
  208. package/dist/lib/output/themes/default/partials/anchor-icon.d.ts +5 -0
  209. package/dist/lib/output/themes/default/partials/anchor-icon.js +9 -0
  210. package/dist/lib/output/themes/default/partials/breadcrumb.d.ts +4 -0
  211. package/dist/lib/output/themes/default/partials/breadcrumb.js +11 -0
  212. package/dist/lib/output/themes/default/partials/comment.d.ts +8 -0
  213. package/dist/lib/output/themes/default/partials/comment.js +80 -0
  214. package/dist/lib/output/themes/default/partials/footer.d.ts +3 -0
  215. package/dist/lib/output/themes/default/partials/footer.js +37 -0
  216. package/dist/lib/output/themes/default/partials/header.d.ts +5 -0
  217. package/dist/lib/output/themes/default/partials/header.js +39 -0
  218. package/dist/lib/output/themes/default/partials/hierarchy.d.ts +4 -0
  219. package/dist/lib/output/themes/default/partials/hierarchy.js +32 -0
  220. package/dist/lib/output/themes/default/partials/icon.d.ts +20 -0
  221. package/dist/lib/output/themes/default/partials/icon.js +101 -0
  222. package/dist/lib/output/themes/default/partials/index.d.ts +4 -0
  223. package/dist/lib/output/themes/default/partials/index.js +24 -0
  224. package/dist/lib/output/themes/default/partials/member.d.ts +4 -0
  225. package/dist/lib/output/themes/default/partials/member.declaration.d.ts +4 -0
  226. package/dist/lib/output/themes/default/partials/member.declaration.js +35 -0
  227. package/dist/lib/output/themes/default/partials/member.getterSetter.d.ts +4 -0
  228. package/dist/lib/output/themes/default/partials/member.getterSetter.js +12 -0
  229. package/dist/lib/output/themes/default/partials/member.js +36 -0
  230. package/dist/lib/output/themes/default/partials/member.signature.body.d.ts +6 -0
  231. package/dist/lib/output/themes/default/partials/member.signature.body.js +33 -0
  232. package/dist/lib/output/themes/default/partials/member.signature.title.d.ts +5 -0
  233. package/dist/lib/output/themes/default/partials/member.signature.title.js +9 -0
  234. package/dist/lib/output/themes/default/partials/member.signatures.d.ts +4 -0
  235. package/dist/lib/output/themes/default/partials/member.signatures.js +9 -0
  236. package/dist/lib/output/themes/default/partials/member.sources.d.ts +4 -0
  237. package/dist/lib/output/themes/default/partials/member.sources.js +55 -0
  238. package/dist/lib/output/themes/default/partials/members.d.ts +4 -0
  239. package/dist/lib/output/themes/default/partials/members.js +17 -0
  240. package/dist/lib/output/themes/default/partials/moduleReflection.d.ts +5 -0
  241. package/dist/lib/output/themes/default/partials/moduleReflection.js +68 -0
  242. package/dist/lib/output/themes/default/partials/navigation.d.ts +10 -0
  243. package/dist/lib/output/themes/default/partials/navigation.js +144 -0
  244. package/dist/lib/output/themes/default/partials/reflectionPreview.d.ts +4 -0
  245. package/dist/lib/output/themes/default/partials/reflectionPreview.js +26 -0
  246. package/dist/lib/output/themes/default/partials/toolbar.d.ts +5 -0
  247. package/dist/lib/output/themes/default/partials/toolbar.js +13 -0
  248. package/dist/lib/output/themes/default/partials/type.d.ts +5 -0
  249. package/dist/lib/output/themes/default/partials/type.js +9 -0
  250. package/dist/lib/output/themes/default/partials/typeAndParent.d.ts +4 -0
  251. package/dist/lib/output/themes/default/partials/typeAndParent.js +28 -0
  252. package/dist/lib/output/themes/default/partials/typeDetails.d.ts +8 -0
  253. package/dist/lib/output/themes/default/partials/typeDetails.js +284 -0
  254. package/dist/lib/output/themes/default/partials/typeParameters.d.ts +4 -0
  255. package/dist/lib/output/themes/default/partials/typeParameters.js +26 -0
  256. package/dist/lib/output/themes/default/templates/document.d.ts +5 -0
  257. package/dist/lib/output/themes/default/templates/document.js +3 -0
  258. package/dist/lib/output/themes/default/templates/hierarchy.d.ts +5 -0
  259. package/dist/lib/output/themes/default/templates/hierarchy.js +31 -0
  260. package/dist/lib/output/themes/default/templates/index.d.ts +5 -0
  261. package/dist/lib/output/themes/default/templates/index.js +3 -0
  262. package/dist/lib/output/themes/default/templates/reflection.d.ts +5 -0
  263. package/dist/lib/output/themes/default/templates/reflection.js +53 -0
  264. package/dist/lib/output/themes/lib.d.ts +44 -0
  265. package/dist/lib/output/themes/lib.js +218 -0
  266. package/dist/lib/serialization/components.d.ts +22 -0
  267. package/dist/lib/serialization/components.js +1 -0
  268. package/dist/lib/serialization/deserializer.d.ts +70 -0
  269. package/dist/lib/serialization/deserializer.js +235 -0
  270. package/dist/lib/serialization/events.d.ts +17 -0
  271. package/dist/lib/serialization/events.js +18 -0
  272. package/dist/lib/serialization/index.d.ts +5 -0
  273. package/dist/lib/serialization/index.js +4 -0
  274. package/dist/lib/serialization/schema.d.ts +283 -0
  275. package/dist/lib/serialization/schema.js +32 -0
  276. package/dist/lib/serialization/serializer.d.ts +52 -0
  277. package/dist/lib/serialization/serializer.js +65 -0
  278. package/dist/lib/utils/ValidatingFileRegistry.d.ts +12 -0
  279. package/dist/lib/utils/ValidatingFileRegistry.js +52 -0
  280. package/dist/lib/utils/component.d.ts +38 -0
  281. package/dist/lib/utils/component.js +41 -0
  282. package/dist/lib/utils/compress.d.ts +7 -0
  283. package/dist/lib/utils/compress.js +13 -0
  284. package/dist/lib/utils/declaration-maps.d.ts +3 -0
  285. package/dist/lib/utils/declaration-maps.js +51 -0
  286. package/dist/lib/utils/entry-point.d.ts +50 -0
  287. package/dist/lib/utils/entry-point.js +330 -0
  288. package/dist/lib/utils/fs.d.ts +65 -0
  289. package/dist/lib/utils/fs.js +372 -0
  290. package/dist/lib/utils/general.d.ts +4 -0
  291. package/dist/lib/utils/general.js +25 -0
  292. package/dist/lib/utils/highlighter.d.ts +9 -0
  293. package/dist/lib/utils/highlighter.js +150 -0
  294. package/dist/lib/utils/html-entities.d.ts +8926 -0
  295. package/dist/lib/utils/html-entities.js +2329 -0
  296. package/dist/lib/utils/html.d.ts +67 -0
  297. package/dist/lib/utils/html.js +635 -0
  298. package/dist/lib/utils/index.d.ts +17 -0
  299. package/dist/lib/utils/index.js +15 -0
  300. package/dist/lib/utils/loggers.d.ts +10 -0
  301. package/dist/lib/utils/loggers.js +71 -0
  302. package/dist/lib/utils/options/declaration.d.ts +514 -0
  303. package/dist/lib/utils/options/declaration.js +443 -0
  304. package/dist/lib/utils/options/defaults.d.ts +20 -0
  305. package/dist/lib/utils/options/defaults.js +104 -0
  306. package/dist/lib/utils/options/help.d.ts +7 -0
  307. package/dist/lib/utils/options/help.js +63 -0
  308. package/dist/lib/utils/options/index.d.ts +6 -0
  309. package/dist/lib/utils/options/index.js +4 -0
  310. package/dist/lib/utils/options/options.d.ts +199 -0
  311. package/dist/lib/utils/options/options.js +273 -0
  312. package/dist/lib/utils/options/readers/arguments.d.ts +15 -0
  313. package/dist/lib/utils/options/readers/arguments.js +109 -0
  314. package/dist/lib/utils/options/readers/index.d.ts +4 -0
  315. package/dist/lib/utils/options/readers/index.js +4 -0
  316. package/dist/lib/utils/options/readers/package-json.d.ts +9 -0
  317. package/dist/lib/utils/options/readers/package-json.js +40 -0
  318. package/dist/lib/utils/options/readers/tsconfig.d.ts +14 -0
  319. package/dist/lib/utils/options/readers/tsconfig.js +172 -0
  320. package/dist/lib/utils/options/readers/typedoc.d.ts +33 -0
  321. package/dist/lib/utils/options/readers/typedoc.js +136 -0
  322. package/dist/lib/utils/options/sources/index.d.ts +1 -0
  323. package/dist/lib/utils/options/sources/index.js +1 -0
  324. package/dist/lib/utils/options/sources/typedoc.d.ts +2 -0
  325. package/dist/lib/utils/options/sources/typedoc.js +876 -0
  326. package/dist/lib/utils/options/tsdoc-defaults.d.ts +6 -0
  327. package/dist/lib/utils/options/tsdoc-defaults.js +94 -0
  328. package/dist/lib/utils/package-manifest.d.ts +11 -0
  329. package/dist/lib/utils/package-manifest.js +84 -0
  330. package/dist/lib/utils/paths.d.ts +27 -0
  331. package/dist/lib/utils/paths.js +127 -0
  332. package/dist/lib/utils/perf.d.ts +6 -0
  333. package/dist/lib/utils/perf.js +86 -0
  334. package/dist/lib/utils/plugins.d.ts +3 -0
  335. package/dist/lib/utils/plugins.js +61 -0
  336. package/dist/lib/utils/reflections.d.ts +5 -0
  337. package/dist/lib/utils/reflections.js +64 -0
  338. package/dist/lib/utils/sort.d.ts +11 -0
  339. package/dist/lib/utils/sort.js +153 -0
  340. package/dist/lib/utils/tsconfig.d.ts +5 -0
  341. package/dist/lib/utils/tsconfig.js +60 -0
  342. package/dist/lib/utils/tsutils.d.ts +3 -0
  343. package/dist/lib/utils/tsutils.js +23 -0
  344. package/dist/lib/utils-common/array.d.ts +57 -0
  345. package/dist/lib/utils-common/array.js +152 -0
  346. package/dist/lib/utils-common/declarationReference.d.ts +42 -0
  347. package/dist/lib/utils-common/declarationReference.js +341 -0
  348. package/dist/lib/utils-common/enum.d.ts +9 -0
  349. package/dist/lib/utils-common/enum.js +27 -0
  350. package/dist/lib/utils-common/events.d.ts +29 -0
  351. package/dist/lib/utils-common/events.js +49 -0
  352. package/dist/lib/utils-common/general.d.ts +40 -0
  353. package/dist/lib/utils-common/general.js +22 -0
  354. package/dist/lib/utils-common/hooks.d.ts +51 -0
  355. package/dist/lib/utils-common/hooks.js +90 -0
  356. package/dist/lib/utils-common/i18n.d.ts +18 -0
  357. package/dist/lib/utils-common/i18n.js +39 -0
  358. package/dist/lib/utils-common/index.d.ts +16 -0
  359. package/dist/lib/utils-common/index.js +17 -0
  360. package/dist/lib/utils-common/jsx.d.ts +53 -0
  361. package/dist/lib/utils-common/jsx.elements.d.ts +949 -0
  362. package/dist/lib/utils-common/jsx.elements.js +3 -0
  363. package/dist/lib/utils-common/jsx.js +187 -0
  364. package/dist/lib/utils-common/logger.d.ts +97 -0
  365. package/dist/lib/utils-common/logger.js +129 -0
  366. package/dist/lib/utils-common/map.d.ts +23 -0
  367. package/dist/lib/utils-common/map.js +63 -0
  368. package/dist/lib/utils-common/minimalSourceFile.d.ts +12 -0
  369. package/dist/lib/utils-common/minimalSourceFile.js +43 -0
  370. package/dist/lib/utils-common/path.d.ts +42 -0
  371. package/dist/lib/utils-common/path.js +130 -0
  372. package/dist/lib/utils-common/set.d.ts +3 -0
  373. package/dist/lib/utils-common/set.js +23 -0
  374. package/dist/lib/utils-common/string.d.ts +11 -0
  375. package/dist/lib/utils-common/string.js +84 -0
  376. package/dist/lib/utils-common/validation.d.ts +33 -0
  377. package/dist/lib/utils-common/validation.js +50 -0
  378. package/dist/lib/validation/documentation.d.ts +3 -0
  379. package/dist/lib/validation/documentation.js +91 -0
  380. package/dist/lib/validation/exports.d.ts +3 -0
  381. package/dist/lib/validation/exports.js +65 -0
  382. package/dist/lib/validation/links.d.ts +3 -0
  383. package/dist/lib/validation/links.js +78 -0
  384. package/dist/lib/validation/unusedMergeModuleWith.d.ts +3 -0
  385. package/dist/lib/validation/unusedMergeModuleWith.js +12 -0
  386. package/package.json +161 -0
  387. package/static/main.js +58 -0
  388. package/static/style.css +1633 -0
  389. package/tsdoc.json +247 -0
  390. package/typedoc-config.schema.json +941 -0
@@ -0,0 +1,833 @@
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
+ }