@microsoft/api-extractor 7.56.2 → 7.57.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 (298) hide show
  1. package/CHANGELOG.json +41 -0
  2. package/CHANGELOG.md +15 -1
  3. package/bin/api-extractor +1 -1
  4. package/lib-esm/aedoc/PackageDocComment.js +56 -0
  5. package/lib-esm/aedoc/PackageDocComment.js.map +1 -0
  6. package/lib-esm/analyzer/AstDeclaration.js +214 -0
  7. package/lib-esm/analyzer/AstDeclaration.js.map +1 -0
  8. package/lib-esm/analyzer/AstEntity.js +35 -0
  9. package/lib-esm/analyzer/AstEntity.js.map +1 -0
  10. package/lib-esm/analyzer/AstImport.js +76 -0
  11. package/lib-esm/analyzer/AstImport.js.map +1 -0
  12. package/lib-esm/analyzer/AstModule.js +22 -0
  13. package/lib-esm/analyzer/AstModule.js.map +1 -0
  14. package/lib-esm/analyzer/AstNamespaceExport.js +38 -0
  15. package/lib-esm/analyzer/AstNamespaceExport.js.map +1 -0
  16. package/lib-esm/analyzer/AstNamespaceImport.js +57 -0
  17. package/lib-esm/analyzer/AstNamespaceImport.js.map +1 -0
  18. package/lib-esm/analyzer/AstReferenceResolver.js +202 -0
  19. package/lib-esm/analyzer/AstReferenceResolver.js.map +1 -0
  20. package/lib-esm/analyzer/AstSymbol.js +104 -0
  21. package/lib-esm/analyzer/AstSymbol.js.map +1 -0
  22. package/lib-esm/analyzer/AstSymbolTable.js +524 -0
  23. package/lib-esm/analyzer/AstSymbolTable.js.map +1 -0
  24. package/lib-esm/analyzer/ExportAnalyzer.js +725 -0
  25. package/lib-esm/analyzer/ExportAnalyzer.js.map +1 -0
  26. package/lib-esm/analyzer/PackageMetadataManager.js +235 -0
  27. package/lib-esm/analyzer/PackageMetadataManager.js.map +1 -0
  28. package/lib-esm/analyzer/SourceFileLocationFormatter.js +44 -0
  29. package/lib-esm/analyzer/SourceFileLocationFormatter.js.map +1 -0
  30. package/lib-esm/analyzer/Span.js +545 -0
  31. package/lib-esm/analyzer/Span.js.map +1 -0
  32. package/lib-esm/analyzer/SyntaxHelpers.js +72 -0
  33. package/lib-esm/analyzer/SyntaxHelpers.js.map +1 -0
  34. package/lib-esm/analyzer/TypeScriptHelpers.js +242 -0
  35. package/lib-esm/analyzer/TypeScriptHelpers.js.map +1 -0
  36. package/lib-esm/analyzer/TypeScriptInternals.js +114 -0
  37. package/lib-esm/analyzer/TypeScriptInternals.js.map +1 -0
  38. package/lib-esm/api/CompilerState.js +149 -0
  39. package/lib-esm/api/CompilerState.js.map +1 -0
  40. package/lib-esm/api/ConsoleMessageId.js +82 -0
  41. package/lib-esm/api/ConsoleMessageId.js.map +1 -0
  42. package/lib-esm/api/Extractor.js +290 -0
  43. package/lib-esm/api/Extractor.js.map +1 -0
  44. package/lib-esm/api/ExtractorConfig.js +801 -0
  45. package/lib-esm/api/ExtractorConfig.js.map +1 -0
  46. package/lib-esm/api/ExtractorLogLevel.js +46 -0
  47. package/lib-esm/api/ExtractorLogLevel.js.map +1 -0
  48. package/lib-esm/api/ExtractorMessage.js +140 -0
  49. package/lib-esm/api/ExtractorMessage.js.map +1 -0
  50. package/lib-esm/api/ExtractorMessageId.js +128 -0
  51. package/lib-esm/api/ExtractorMessageId.js.map +1 -0
  52. package/lib-esm/api/IConfigFile.js +4 -0
  53. package/lib-esm/api/IConfigFile.js.map +1 -0
  54. package/lib-esm/cli/ApiExtractorCommandLine.js +51 -0
  55. package/lib-esm/cli/ApiExtractorCommandLine.js.map +1 -0
  56. package/lib-esm/cli/InitAction.js +35 -0
  57. package/lib-esm/cli/InitAction.js.map +1 -0
  58. package/lib-esm/cli/RunAction.js +123 -0
  59. package/lib-esm/cli/RunAction.js.map +1 -0
  60. package/lib-esm/collector/ApiItemMetadata.js +55 -0
  61. package/lib-esm/collector/ApiItemMetadata.js.map +1 -0
  62. package/lib-esm/collector/Collector.js +794 -0
  63. package/lib-esm/collector/Collector.js.map +1 -0
  64. package/lib-esm/collector/CollectorEntity.js +219 -0
  65. package/lib-esm/collector/CollectorEntity.js.map +1 -0
  66. package/lib-esm/collector/DeclarationMetadata.js +24 -0
  67. package/lib-esm/collector/DeclarationMetadata.js.map +1 -0
  68. package/lib-esm/collector/MessageRouter.js +476 -0
  69. package/lib-esm/collector/MessageRouter.js.map +1 -0
  70. package/lib-esm/collector/SourceMapper.js +171 -0
  71. package/lib-esm/collector/SourceMapper.js.map +1 -0
  72. package/lib-esm/collector/SymbolMetadata.js +12 -0
  73. package/lib-esm/collector/SymbolMetadata.js.map +1 -0
  74. package/lib-esm/collector/VisitorState.js +23 -0
  75. package/lib-esm/collector/VisitorState.js.map +1 -0
  76. package/lib-esm/collector/WorkingPackage.js +30 -0
  77. package/lib-esm/collector/WorkingPackage.js.map +1 -0
  78. package/lib-esm/enhancers/DocCommentEnhancer.js +213 -0
  79. package/lib-esm/enhancers/DocCommentEnhancer.js.map +1 -0
  80. package/lib-esm/enhancers/ValidationEnhancer.js +217 -0
  81. package/lib-esm/enhancers/ValidationEnhancer.js.map +1 -0
  82. package/lib-esm/generators/ApiModelGenerator.js +852 -0
  83. package/lib-esm/generators/ApiModelGenerator.js.map +1 -0
  84. package/lib-esm/generators/ApiReportGenerator.js +518 -0
  85. package/lib-esm/generators/ApiReportGenerator.js.map +1 -0
  86. package/lib-esm/generators/DeclarationReferenceGenerator.js +292 -0
  87. package/lib-esm/generators/DeclarationReferenceGenerator.js.map +1 -0
  88. package/lib-esm/generators/DtsEmitHelpers.js +227 -0
  89. package/lib-esm/generators/DtsEmitHelpers.js.map +1 -0
  90. package/lib-esm/generators/DtsRollupGenerator.js +391 -0
  91. package/lib-esm/generators/DtsRollupGenerator.js.map +1 -0
  92. package/lib-esm/generators/ExcerptBuilder.js +259 -0
  93. package/lib-esm/generators/ExcerptBuilder.js.map +1 -0
  94. package/lib-esm/generators/IndentedWriter.js +238 -0
  95. package/lib-esm/generators/IndentedWriter.js.map +1 -0
  96. package/lib-esm/index.js +17 -0
  97. package/lib-esm/index.js.map +1 -0
  98. package/lib-esm/schemas/api-extractor-defaults.json +94 -0
  99. package/lib-esm/schemas/api-extractor-template.json +454 -0
  100. package/lib-esm/schemas/api-extractor.schema.json +257 -0
  101. package/lib-esm/start.js +14 -0
  102. package/lib-esm/start.js.map +1 -0
  103. package/package.json +38 -12
  104. /package/{lib → lib-commonjs}/aedoc/PackageDocComment.js +0 -0
  105. /package/{lib → lib-commonjs}/aedoc/PackageDocComment.js.map +0 -0
  106. /package/{lib → lib-commonjs}/analyzer/AstDeclaration.js +0 -0
  107. /package/{lib → lib-commonjs}/analyzer/AstDeclaration.js.map +0 -0
  108. /package/{lib → lib-commonjs}/analyzer/AstEntity.js +0 -0
  109. /package/{lib → lib-commonjs}/analyzer/AstEntity.js.map +0 -0
  110. /package/{lib → lib-commonjs}/analyzer/AstImport.js +0 -0
  111. /package/{lib → lib-commonjs}/analyzer/AstImport.js.map +0 -0
  112. /package/{lib → lib-commonjs}/analyzer/AstModule.js +0 -0
  113. /package/{lib → lib-commonjs}/analyzer/AstModule.js.map +0 -0
  114. /package/{lib → lib-commonjs}/analyzer/AstNamespaceExport.js +0 -0
  115. /package/{lib → lib-commonjs}/analyzer/AstNamespaceExport.js.map +0 -0
  116. /package/{lib → lib-commonjs}/analyzer/AstNamespaceImport.js +0 -0
  117. /package/{lib → lib-commonjs}/analyzer/AstNamespaceImport.js.map +0 -0
  118. /package/{lib → lib-commonjs}/analyzer/AstReferenceResolver.js +0 -0
  119. /package/{lib → lib-commonjs}/analyzer/AstReferenceResolver.js.map +0 -0
  120. /package/{lib → lib-commonjs}/analyzer/AstSymbol.js +0 -0
  121. /package/{lib → lib-commonjs}/analyzer/AstSymbol.js.map +0 -0
  122. /package/{lib → lib-commonjs}/analyzer/AstSymbolTable.js +0 -0
  123. /package/{lib → lib-commonjs}/analyzer/AstSymbolTable.js.map +0 -0
  124. /package/{lib → lib-commonjs}/analyzer/ExportAnalyzer.js +0 -0
  125. /package/{lib → lib-commonjs}/analyzer/ExportAnalyzer.js.map +0 -0
  126. /package/{lib → lib-commonjs}/analyzer/PackageMetadataManager.js +0 -0
  127. /package/{lib → lib-commonjs}/analyzer/PackageMetadataManager.js.map +0 -0
  128. /package/{lib → lib-commonjs}/analyzer/SourceFileLocationFormatter.js +0 -0
  129. /package/{lib → lib-commonjs}/analyzer/SourceFileLocationFormatter.js.map +0 -0
  130. /package/{lib → lib-commonjs}/analyzer/Span.js +0 -0
  131. /package/{lib → lib-commonjs}/analyzer/Span.js.map +0 -0
  132. /package/{lib → lib-commonjs}/analyzer/SyntaxHelpers.js +0 -0
  133. /package/{lib → lib-commonjs}/analyzer/SyntaxHelpers.js.map +0 -0
  134. /package/{lib → lib-commonjs}/analyzer/TypeScriptHelpers.js +0 -0
  135. /package/{lib → lib-commonjs}/analyzer/TypeScriptHelpers.js.map +0 -0
  136. /package/{lib → lib-commonjs}/analyzer/TypeScriptInternals.js +0 -0
  137. /package/{lib → lib-commonjs}/analyzer/TypeScriptInternals.js.map +0 -0
  138. /package/{lib → lib-commonjs}/api/CompilerState.js +0 -0
  139. /package/{lib → lib-commonjs}/api/CompilerState.js.map +0 -0
  140. /package/{lib → lib-commonjs}/api/ConsoleMessageId.js +0 -0
  141. /package/{lib → lib-commonjs}/api/ConsoleMessageId.js.map +0 -0
  142. /package/{lib → lib-commonjs}/api/Extractor.js +0 -0
  143. /package/{lib → lib-commonjs}/api/Extractor.js.map +0 -0
  144. /package/{lib → lib-commonjs}/api/ExtractorConfig.js +0 -0
  145. /package/{lib → lib-commonjs}/api/ExtractorConfig.js.map +0 -0
  146. /package/{lib → lib-commonjs}/api/ExtractorLogLevel.js +0 -0
  147. /package/{lib → lib-commonjs}/api/ExtractorLogLevel.js.map +0 -0
  148. /package/{lib → lib-commonjs}/api/ExtractorMessage.js +0 -0
  149. /package/{lib → lib-commonjs}/api/ExtractorMessage.js.map +0 -0
  150. /package/{lib → lib-commonjs}/api/ExtractorMessageId.js +0 -0
  151. /package/{lib → lib-commonjs}/api/ExtractorMessageId.js.map +0 -0
  152. /package/{lib → lib-commonjs}/api/IConfigFile.js +0 -0
  153. /package/{lib → lib-commonjs}/api/IConfigFile.js.map +0 -0
  154. /package/{lib → lib-commonjs}/cli/ApiExtractorCommandLine.js +0 -0
  155. /package/{lib → lib-commonjs}/cli/ApiExtractorCommandLine.js.map +0 -0
  156. /package/{lib → lib-commonjs}/cli/InitAction.js +0 -0
  157. /package/{lib → lib-commonjs}/cli/InitAction.js.map +0 -0
  158. /package/{lib → lib-commonjs}/cli/RunAction.js +0 -0
  159. /package/{lib → lib-commonjs}/cli/RunAction.js.map +0 -0
  160. /package/{lib → lib-commonjs}/collector/ApiItemMetadata.js +0 -0
  161. /package/{lib → lib-commonjs}/collector/ApiItemMetadata.js.map +0 -0
  162. /package/{lib → lib-commonjs}/collector/Collector.js +0 -0
  163. /package/{lib → lib-commonjs}/collector/Collector.js.map +0 -0
  164. /package/{lib → lib-commonjs}/collector/CollectorEntity.js +0 -0
  165. /package/{lib → lib-commonjs}/collector/CollectorEntity.js.map +0 -0
  166. /package/{lib → lib-commonjs}/collector/DeclarationMetadata.js +0 -0
  167. /package/{lib → lib-commonjs}/collector/DeclarationMetadata.js.map +0 -0
  168. /package/{lib → lib-commonjs}/collector/MessageRouter.js +0 -0
  169. /package/{lib → lib-commonjs}/collector/MessageRouter.js.map +0 -0
  170. /package/{lib → lib-commonjs}/collector/SourceMapper.js +0 -0
  171. /package/{lib → lib-commonjs}/collector/SourceMapper.js.map +0 -0
  172. /package/{lib → lib-commonjs}/collector/SymbolMetadata.js +0 -0
  173. /package/{lib → lib-commonjs}/collector/SymbolMetadata.js.map +0 -0
  174. /package/{lib → lib-commonjs}/collector/VisitorState.js +0 -0
  175. /package/{lib → lib-commonjs}/collector/VisitorState.js.map +0 -0
  176. /package/{lib → lib-commonjs}/collector/WorkingPackage.js +0 -0
  177. /package/{lib → lib-commonjs}/collector/WorkingPackage.js.map +0 -0
  178. /package/{lib → lib-commonjs}/enhancers/DocCommentEnhancer.js +0 -0
  179. /package/{lib → lib-commonjs}/enhancers/DocCommentEnhancer.js.map +0 -0
  180. /package/{lib → lib-commonjs}/enhancers/ValidationEnhancer.js +0 -0
  181. /package/{lib → lib-commonjs}/enhancers/ValidationEnhancer.js.map +0 -0
  182. /package/{lib → lib-commonjs}/generators/ApiModelGenerator.js +0 -0
  183. /package/{lib → lib-commonjs}/generators/ApiModelGenerator.js.map +0 -0
  184. /package/{lib → lib-commonjs}/generators/ApiReportGenerator.js +0 -0
  185. /package/{lib → lib-commonjs}/generators/ApiReportGenerator.js.map +0 -0
  186. /package/{lib → lib-commonjs}/generators/DeclarationReferenceGenerator.js +0 -0
  187. /package/{lib → lib-commonjs}/generators/DeclarationReferenceGenerator.js.map +0 -0
  188. /package/{lib → lib-commonjs}/generators/DtsEmitHelpers.js +0 -0
  189. /package/{lib → lib-commonjs}/generators/DtsEmitHelpers.js.map +0 -0
  190. /package/{lib → lib-commonjs}/generators/DtsRollupGenerator.js +0 -0
  191. /package/{lib → lib-commonjs}/generators/DtsRollupGenerator.js.map +0 -0
  192. /package/{lib → lib-commonjs}/generators/ExcerptBuilder.js +0 -0
  193. /package/{lib → lib-commonjs}/generators/ExcerptBuilder.js.map +0 -0
  194. /package/{lib → lib-commonjs}/generators/IndentedWriter.js +0 -0
  195. /package/{lib → lib-commonjs}/generators/IndentedWriter.js.map +0 -0
  196. /package/{lib → lib-commonjs}/index.js +0 -0
  197. /package/{lib → lib-commonjs}/index.js.map +0 -0
  198. /package/{lib → lib-commonjs}/schemas/api-extractor-defaults.json +0 -0
  199. /package/{lib → lib-commonjs}/schemas/api-extractor-template.json +0 -0
  200. /package/{lib → lib-commonjs}/schemas/api-extractor.schema.json +0 -0
  201. /package/{lib → lib-commonjs}/start.js +0 -0
  202. /package/{lib → lib-commonjs}/start.js.map +0 -0
  203. /package/{lib → lib-dts}/aedoc/PackageDocComment.d.ts +0 -0
  204. /package/{lib → lib-dts}/aedoc/PackageDocComment.d.ts.map +0 -0
  205. /package/{lib → lib-dts}/analyzer/AstDeclaration.d.ts +0 -0
  206. /package/{lib → lib-dts}/analyzer/AstDeclaration.d.ts.map +0 -0
  207. /package/{lib → lib-dts}/analyzer/AstEntity.d.ts +0 -0
  208. /package/{lib → lib-dts}/analyzer/AstEntity.d.ts.map +0 -0
  209. /package/{lib → lib-dts}/analyzer/AstImport.d.ts +0 -0
  210. /package/{lib → lib-dts}/analyzer/AstImport.d.ts.map +0 -0
  211. /package/{lib → lib-dts}/analyzer/AstModule.d.ts +0 -0
  212. /package/{lib → lib-dts}/analyzer/AstModule.d.ts.map +0 -0
  213. /package/{lib → lib-dts}/analyzer/AstNamespaceExport.d.ts +0 -0
  214. /package/{lib → lib-dts}/analyzer/AstNamespaceExport.d.ts.map +0 -0
  215. /package/{lib → lib-dts}/analyzer/AstNamespaceImport.d.ts +0 -0
  216. /package/{lib → lib-dts}/analyzer/AstNamespaceImport.d.ts.map +0 -0
  217. /package/{lib → lib-dts}/analyzer/AstReferenceResolver.d.ts +0 -0
  218. /package/{lib → lib-dts}/analyzer/AstReferenceResolver.d.ts.map +0 -0
  219. /package/{lib → lib-dts}/analyzer/AstSymbol.d.ts +0 -0
  220. /package/{lib → lib-dts}/analyzer/AstSymbol.d.ts.map +0 -0
  221. /package/{lib → lib-dts}/analyzer/AstSymbolTable.d.ts +0 -0
  222. /package/{lib → lib-dts}/analyzer/AstSymbolTable.d.ts.map +0 -0
  223. /package/{lib → lib-dts}/analyzer/ExportAnalyzer.d.ts +0 -0
  224. /package/{lib → lib-dts}/analyzer/ExportAnalyzer.d.ts.map +0 -0
  225. /package/{lib → lib-dts}/analyzer/PackageMetadataManager.d.ts +0 -0
  226. /package/{lib → lib-dts}/analyzer/PackageMetadataManager.d.ts.map +0 -0
  227. /package/{lib → lib-dts}/analyzer/SourceFileLocationFormatter.d.ts +0 -0
  228. /package/{lib → lib-dts}/analyzer/SourceFileLocationFormatter.d.ts.map +0 -0
  229. /package/{lib → lib-dts}/analyzer/Span.d.ts +0 -0
  230. /package/{lib → lib-dts}/analyzer/Span.d.ts.map +0 -0
  231. /package/{lib → lib-dts}/analyzer/SyntaxHelpers.d.ts +0 -0
  232. /package/{lib → lib-dts}/analyzer/SyntaxHelpers.d.ts.map +0 -0
  233. /package/{lib → lib-dts}/analyzer/TypeScriptHelpers.d.ts +0 -0
  234. /package/{lib → lib-dts}/analyzer/TypeScriptHelpers.d.ts.map +0 -0
  235. /package/{lib → lib-dts}/analyzer/TypeScriptInternals.d.ts +0 -0
  236. /package/{lib → lib-dts}/analyzer/TypeScriptInternals.d.ts.map +0 -0
  237. /package/{lib → lib-dts}/api/CompilerState.d.ts +0 -0
  238. /package/{lib → lib-dts}/api/CompilerState.d.ts.map +0 -0
  239. /package/{lib → lib-dts}/api/ConsoleMessageId.d.ts +0 -0
  240. /package/{lib → lib-dts}/api/ConsoleMessageId.d.ts.map +0 -0
  241. /package/{lib → lib-dts}/api/Extractor.d.ts +0 -0
  242. /package/{lib → lib-dts}/api/Extractor.d.ts.map +0 -0
  243. /package/{lib → lib-dts}/api/ExtractorConfig.d.ts +0 -0
  244. /package/{lib → lib-dts}/api/ExtractorConfig.d.ts.map +0 -0
  245. /package/{lib → lib-dts}/api/ExtractorLogLevel.d.ts +0 -0
  246. /package/{lib → lib-dts}/api/ExtractorLogLevel.d.ts.map +0 -0
  247. /package/{lib → lib-dts}/api/ExtractorMessage.d.ts +0 -0
  248. /package/{lib → lib-dts}/api/ExtractorMessage.d.ts.map +0 -0
  249. /package/{lib → lib-dts}/api/ExtractorMessageId.d.ts +0 -0
  250. /package/{lib → lib-dts}/api/ExtractorMessageId.d.ts.map +0 -0
  251. /package/{lib → lib-dts}/api/IConfigFile.d.ts +0 -0
  252. /package/{lib → lib-dts}/api/IConfigFile.d.ts.map +0 -0
  253. /package/{lib → lib-dts}/cli/ApiExtractorCommandLine.d.ts +0 -0
  254. /package/{lib → lib-dts}/cli/ApiExtractorCommandLine.d.ts.map +0 -0
  255. /package/{lib → lib-dts}/cli/InitAction.d.ts +0 -0
  256. /package/{lib → lib-dts}/cli/InitAction.d.ts.map +0 -0
  257. /package/{lib → lib-dts}/cli/RunAction.d.ts +0 -0
  258. /package/{lib → lib-dts}/cli/RunAction.d.ts.map +0 -0
  259. /package/{lib → lib-dts}/collector/ApiItemMetadata.d.ts +0 -0
  260. /package/{lib → lib-dts}/collector/ApiItemMetadata.d.ts.map +0 -0
  261. /package/{lib → lib-dts}/collector/Collector.d.ts +0 -0
  262. /package/{lib → lib-dts}/collector/Collector.d.ts.map +0 -0
  263. /package/{lib → lib-dts}/collector/CollectorEntity.d.ts +0 -0
  264. /package/{lib → lib-dts}/collector/CollectorEntity.d.ts.map +0 -0
  265. /package/{lib → lib-dts}/collector/DeclarationMetadata.d.ts +0 -0
  266. /package/{lib → lib-dts}/collector/DeclarationMetadata.d.ts.map +0 -0
  267. /package/{lib → lib-dts}/collector/MessageRouter.d.ts +0 -0
  268. /package/{lib → lib-dts}/collector/MessageRouter.d.ts.map +0 -0
  269. /package/{lib → lib-dts}/collector/SourceMapper.d.ts +0 -0
  270. /package/{lib → lib-dts}/collector/SourceMapper.d.ts.map +0 -0
  271. /package/{lib → lib-dts}/collector/SymbolMetadata.d.ts +0 -0
  272. /package/{lib → lib-dts}/collector/SymbolMetadata.d.ts.map +0 -0
  273. /package/{lib → lib-dts}/collector/VisitorState.d.ts +0 -0
  274. /package/{lib → lib-dts}/collector/VisitorState.d.ts.map +0 -0
  275. /package/{lib → lib-dts}/collector/WorkingPackage.d.ts +0 -0
  276. /package/{lib → lib-dts}/collector/WorkingPackage.d.ts.map +0 -0
  277. /package/{lib → lib-dts}/enhancers/DocCommentEnhancer.d.ts +0 -0
  278. /package/{lib → lib-dts}/enhancers/DocCommentEnhancer.d.ts.map +0 -0
  279. /package/{lib → lib-dts}/enhancers/ValidationEnhancer.d.ts +0 -0
  280. /package/{lib → lib-dts}/enhancers/ValidationEnhancer.d.ts.map +0 -0
  281. /package/{lib → lib-dts}/generators/ApiModelGenerator.d.ts +0 -0
  282. /package/{lib → lib-dts}/generators/ApiModelGenerator.d.ts.map +0 -0
  283. /package/{lib → lib-dts}/generators/ApiReportGenerator.d.ts +0 -0
  284. /package/{lib → lib-dts}/generators/ApiReportGenerator.d.ts.map +0 -0
  285. /package/{lib → lib-dts}/generators/DeclarationReferenceGenerator.d.ts +0 -0
  286. /package/{lib → lib-dts}/generators/DeclarationReferenceGenerator.d.ts.map +0 -0
  287. /package/{lib → lib-dts}/generators/DtsEmitHelpers.d.ts +0 -0
  288. /package/{lib → lib-dts}/generators/DtsEmitHelpers.d.ts.map +0 -0
  289. /package/{lib → lib-dts}/generators/DtsRollupGenerator.d.ts +0 -0
  290. /package/{lib → lib-dts}/generators/DtsRollupGenerator.d.ts.map +0 -0
  291. /package/{lib → lib-dts}/generators/ExcerptBuilder.d.ts +0 -0
  292. /package/{lib → lib-dts}/generators/ExcerptBuilder.d.ts.map +0 -0
  293. /package/{lib → lib-dts}/generators/IndentedWriter.d.ts +0 -0
  294. /package/{lib → lib-dts}/generators/IndentedWriter.d.ts.map +0 -0
  295. /package/{lib → lib-dts}/index.d.ts +0 -0
  296. /package/{lib → lib-dts}/index.d.ts.map +0 -0
  297. /package/{lib → lib-dts}/start.d.ts +0 -0
  298. /package/{lib → lib-dts}/start.d.ts.map +0 -0
@@ -0,0 +1,72 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
+ // See LICENSE in the project root for license information.
3
+ import * as ts from 'typescript';
4
+ /**
5
+ * Helpers for validating various text string formats.
6
+ */
7
+ export class SyntaxHelpers {
8
+ /**
9
+ * Tests whether the input string is safe to use as an ECMAScript identifier without quotes.
10
+ *
11
+ * @remarks
12
+ * For example:
13
+ *
14
+ * ```ts
15
+ * class X {
16
+ * public okay: number = 1;
17
+ * public "not okay!": number = 2;
18
+ * }
19
+ * ```
20
+ *
21
+ * A precise check is extremely complicated and highly dependent on the ECMAScript standard version
22
+ * and how faithfully the interpreter implements it. To keep things simple, `isSafeUnquotedMemberIdentifier()`
23
+ * conservatively accepts any identifier that would be valid with ECMAScript 5, and returns false otherwise.
24
+ */
25
+ static isSafeUnquotedMemberIdentifier(identifier) {
26
+ if (identifier.length === 0) {
27
+ return false; // cannot be empty
28
+ }
29
+ if (!ts.isIdentifierStart(identifier.charCodeAt(0), ts.ScriptTarget.ES5)) {
30
+ return false;
31
+ }
32
+ for (let i = 1; i < identifier.length; i++) {
33
+ if (!ts.isIdentifierPart(identifier.charCodeAt(i), ts.ScriptTarget.ES5)) {
34
+ return false;
35
+ }
36
+ }
37
+ return true;
38
+ }
39
+ /**
40
+ * Given an arbitrary input string, return a regular TypeScript identifier name.
41
+ *
42
+ * @remarks
43
+ * Example input: "api-extractor-lib1-test"
44
+ * Example output: "apiExtractorLib1Test"
45
+ */
46
+ static makeCamelCaseIdentifier(input) {
47
+ const parts = input.split(/\W+/).filter((x) => x.length > 0);
48
+ if (parts.length === 0) {
49
+ return '_';
50
+ }
51
+ for (let i = 0; i < parts.length; ++i) {
52
+ let part = parts[i];
53
+ if (part.toUpperCase() === part) {
54
+ // Preserve existing case unless the part is all upper-case
55
+ part = part.toLowerCase();
56
+ }
57
+ if (i === 0) {
58
+ // If the first part starts with a number, prepend "_"
59
+ if (/[0-9]/.test(part.charAt(0))) {
60
+ part = '_' + part;
61
+ }
62
+ }
63
+ else {
64
+ // Capitalize the first letter of each part, except for the first one
65
+ part = part.charAt(0).toUpperCase() + part.slice(1);
66
+ }
67
+ parts[i] = part;
68
+ }
69
+ return parts.join('');
70
+ }
71
+ }
72
+ //# sourceMappingURL=SyntaxHelpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SyntaxHelpers.js","sourceRoot":"","sources":["../../src/analyzer/SyntaxHelpers.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC;;GAEG;AACH,MAAM,OAAO,aAAa;IACxB;;;;;;;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,CAAC;YACD,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;gBACZ,sDAAsD;gBACtD,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;oBACjC,IAAI,GAAG,GAAG,GAAG,IAAI,CAAC;gBACpB,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,qEAAqE;gBACrE,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACtD,CAAC;YACD,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;QAClB,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACxB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as ts from 'typescript';\n\n/**\n * Helpers for validating various text string formats.\n */\nexport class SyntaxHelpers {\n /**\n * Tests whether the input string is safe to use as an ECMAScript identifier without quotes.\n *\n * @remarks\n * For example:\n *\n * ```ts\n * class X {\n * public okay: number = 1;\n * public \"not okay!\": number = 2;\n * }\n * ```\n *\n * A precise check is extremely complicated and highly dependent on the ECMAScript standard version\n * and how faithfully the interpreter implements it. To keep things simple, `isSafeUnquotedMemberIdentifier()`\n * conservatively accepts any identifier that would be valid with ECMAScript 5, and returns false otherwise.\n */\n public static isSafeUnquotedMemberIdentifier(identifier: string): boolean {\n if (identifier.length === 0) {\n return false; // cannot be empty\n }\n\n if (!ts.isIdentifierStart(identifier.charCodeAt(0), ts.ScriptTarget.ES5)) {\n return false;\n }\n\n for (let i: number = 1; i < identifier.length; i++) {\n if (!ts.isIdentifierPart(identifier.charCodeAt(i), ts.ScriptTarget.ES5)) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Given an arbitrary input string, return a regular TypeScript identifier name.\n *\n * @remarks\n * Example input: \"api-extractor-lib1-test\"\n * Example output: \"apiExtractorLib1Test\"\n */\n public static makeCamelCaseIdentifier(input: string): string {\n const parts: string[] = input.split(/\\W+/).filter((x) => x.length > 0);\n if (parts.length === 0) {\n return '_';\n }\n\n for (let i: number = 0; i < parts.length; ++i) {\n let part: string = parts[i];\n if (part.toUpperCase() === part) {\n // Preserve existing case unless the part is all upper-case\n part = part.toLowerCase();\n }\n if (i === 0) {\n // If the first part starts with a number, prepend \"_\"\n if (/[0-9]/.test(part.charAt(0))) {\n part = '_' + part;\n }\n } else {\n // Capitalize the first letter of each part, except for the first one\n part = part.charAt(0).toUpperCase() + part.slice(1);\n }\n parts[i] = part;\n }\n return parts.join('');\n }\n}\n"]}
@@ -0,0 +1,242 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
+ // See LICENSE in the project root for license information.
3
+ /* eslint-disable no-bitwise */
4
+ import * as ts from 'typescript';
5
+ import { InternalError } from '@rushstack/node-core-library';
6
+ import { SourceFileLocationFormatter } from './SourceFileLocationFormatter';
7
+ import { TypeScriptInternals } from './TypeScriptInternals';
8
+ export class TypeScriptHelpers {
9
+ /**
10
+ * This traverses any symbol aliases to find the original place where an item was defined.
11
+ * For example, suppose a class is defined as "export default class MyClass { }"
12
+ * but exported from the package's index.ts like this:
13
+ *
14
+ * export { default as _MyClass } from './MyClass';
15
+ *
16
+ * In this example, calling followAliases() on the _MyClass symbol will return the
17
+ * original definition of MyClass, traversing any intermediary places where the
18
+ * symbol was imported and re-exported.
19
+ */
20
+ static followAliases(symbol, typeChecker) {
21
+ let current = symbol;
22
+ for (;;) {
23
+ if (!(current.flags & ts.SymbolFlags.Alias)) {
24
+ break;
25
+ }
26
+ const currentAlias = typeChecker.getAliasedSymbol(current);
27
+ if (!currentAlias || currentAlias === current) {
28
+ break;
29
+ }
30
+ current = currentAlias;
31
+ }
32
+ return current;
33
+ }
34
+ /**
35
+ * Returns true if TypeScriptHelpers.followAliases() would return something different
36
+ * from the input `symbol`.
37
+ */
38
+ static isFollowableAlias(symbol, typeChecker) {
39
+ if (!(symbol.flags & ts.SymbolFlags.Alias)) {
40
+ return false;
41
+ }
42
+ const alias = typeChecker.getAliasedSymbol(symbol);
43
+ if (!alias || alias === symbol) {
44
+ return false;
45
+ }
46
+ return true;
47
+ }
48
+ /**
49
+ * Certain virtual symbols do not have any declarations. For example, `ts.TypeChecker.getExportsOfModule()` can
50
+ * sometimes return a "prototype" symbol for an object, even though there is no corresponding declaration in the
51
+ * source code. API Extractor generally ignores such symbols.
52
+ */
53
+ static tryGetADeclaration(symbol) {
54
+ if (symbol.declarations && symbol.declarations.length > 0) {
55
+ return symbol.declarations[0];
56
+ }
57
+ return undefined;
58
+ }
59
+ /**
60
+ * Returns true if the specified symbol is an ambient declaration.
61
+ */
62
+ static isAmbient(symbol, typeChecker) {
63
+ const followedSymbol = TypeScriptHelpers.followAliases(symbol, typeChecker);
64
+ if (followedSymbol.declarations && followedSymbol.declarations.length > 0) {
65
+ const firstDeclaration = followedSymbol.declarations[0];
66
+ // Test 1: Are we inside the sinister "declare global {" construct?
67
+ const highestModuleDeclaration = TypeScriptHelpers.findHighestParent(firstDeclaration, ts.SyntaxKind.ModuleDeclaration);
68
+ if (highestModuleDeclaration) {
69
+ if (highestModuleDeclaration.name.getText().trim() === 'global') {
70
+ return true;
71
+ }
72
+ }
73
+ // Test 2: Otherwise, the main heuristic for ambient declarations is by looking at the
74
+ // ts.SyntaxKind.SourceFile node to see whether it has a symbol or not (i.e. whether it
75
+ // is acting as a module or not).
76
+ const sourceFile = firstDeclaration.getSourceFile();
77
+ if (typeChecker.getSymbolAtLocation(sourceFile)) {
78
+ return false;
79
+ }
80
+ }
81
+ return true;
82
+ }
83
+ /**
84
+ * Same semantics as tryGetSymbolForDeclaration(), but throws an exception if the symbol
85
+ * cannot be found.
86
+ */
87
+ static getSymbolForDeclaration(declaration, checker) {
88
+ const symbol = TypeScriptInternals.tryGetSymbolForDeclaration(declaration, checker);
89
+ if (!symbol) {
90
+ throw new InternalError('Unable to determine semantic information for declaration:\n' +
91
+ SourceFileLocationFormatter.formatDeclaration(declaration));
92
+ }
93
+ return symbol;
94
+ }
95
+ // Return name of the module, which could be like "./SomeLocalFile' or like 'external-package/entry/point'
96
+ static getModuleSpecifier(nodeWithModuleSpecifier) {
97
+ if (nodeWithModuleSpecifier.kind === ts.SyntaxKind.ImportType) {
98
+ // As specified internally in typescript:/src/compiler/types.ts#ValidImportTypeNode
99
+ if (nodeWithModuleSpecifier.argument.kind !== ts.SyntaxKind.LiteralType ||
100
+ nodeWithModuleSpecifier.argument.literal.kind !== ts.SyntaxKind.StringLiteral) {
101
+ throw new InternalError(`Invalid ImportTypeNode: ${nodeWithModuleSpecifier.getText()}\n` +
102
+ SourceFileLocationFormatter.formatDeclaration(nodeWithModuleSpecifier));
103
+ }
104
+ const literalTypeNode = nodeWithModuleSpecifier.argument;
105
+ const stringLiteral = literalTypeNode.literal;
106
+ return stringLiteral.text.trim();
107
+ }
108
+ // Node is a declaration
109
+ if (nodeWithModuleSpecifier.moduleSpecifier &&
110
+ ts.isStringLiteralLike(nodeWithModuleSpecifier.moduleSpecifier)) {
111
+ return TypeScriptInternals.getTextOfIdentifierOrLiteral(nodeWithModuleSpecifier.moduleSpecifier);
112
+ }
113
+ return undefined;
114
+ }
115
+ /**
116
+ * Returns an ancestor of "node", such that the ancestor, any intermediary nodes,
117
+ * and the starting node match a list of expected kinds. Undefined is returned
118
+ * if there aren't enough ancestors, or if the kinds are incorrect.
119
+ *
120
+ * For example, suppose child "C" has parents A --> B --> C.
121
+ *
122
+ * Calling _matchAncestor(C, [ExportSpecifier, NamedExports, ExportDeclaration])
123
+ * would return A only if A is of kind ExportSpecifier, B is of kind NamedExports,
124
+ * and C is of kind ExportDeclaration.
125
+ *
126
+ * Calling _matchAncestor(C, [ExportDeclaration]) would return C.
127
+ */
128
+ static matchAncestor(node, kindsToMatch) {
129
+ // (slice(0) clones an array)
130
+ const reversedParentKinds = kindsToMatch.slice(0).reverse();
131
+ let current = undefined;
132
+ for (const parentKind of reversedParentKinds) {
133
+ if (!current) {
134
+ // The first time through, start with node
135
+ current = node;
136
+ }
137
+ else {
138
+ // Then walk the parents
139
+ current = current.parent;
140
+ }
141
+ // If we ran out of items, or if the kind doesn't match, then fail
142
+ if (!current || current.kind !== parentKind) {
143
+ return undefined;
144
+ }
145
+ }
146
+ // If we matched everything, then return the node that matched the last parentKinds item
147
+ return current;
148
+ }
149
+ /**
150
+ * Does a depth-first search of the children of the specified node. Returns the first child
151
+ * with the specified kind, or undefined if there is no match.
152
+ */
153
+ static findFirstChildNode(node, kindToMatch) {
154
+ for (const child of node.getChildren()) {
155
+ if (child.kind === kindToMatch) {
156
+ return child;
157
+ }
158
+ const recursiveMatch = TypeScriptHelpers.findFirstChildNode(child, kindToMatch);
159
+ if (recursiveMatch) {
160
+ return recursiveMatch;
161
+ }
162
+ }
163
+ return undefined;
164
+ }
165
+ /**
166
+ * Returns the first parent node with the specified SyntaxKind, or undefined if there is no match.
167
+ */
168
+ static findFirstParent(node, kindToMatch) {
169
+ let current = node.parent;
170
+ while (current) {
171
+ if (current.kind === kindToMatch) {
172
+ return current;
173
+ }
174
+ current = current.parent;
175
+ }
176
+ return undefined;
177
+ }
178
+ /**
179
+ * Returns the highest parent node with the specified SyntaxKind, or undefined if there is no match.
180
+ * @remarks
181
+ * Whereas findFirstParent() returns the first match, findHighestParent() returns the last match.
182
+ */
183
+ static findHighestParent(node, kindToMatch) {
184
+ let current = node;
185
+ let highest = undefined;
186
+ for (;;) {
187
+ current = TypeScriptHelpers.findFirstParent(current, kindToMatch);
188
+ if (!current) {
189
+ break;
190
+ }
191
+ highest = current;
192
+ }
193
+ return highest;
194
+ }
195
+ /**
196
+ * Decodes the names that the compiler generates for a built-in ECMAScript symbol.
197
+ *
198
+ * @remarks
199
+ * TypeScript binds well-known ECMAScript symbols like `[Symbol.iterator]` as `__@iterator`.
200
+ * If `name` is of this form, then `tryGetWellKnownSymbolName()` converts it back into e.g. `[Symbol.iterator]`.
201
+ * If the string does not start with `__@` then `undefined` is returned.
202
+ */
203
+ static tryDecodeWellKnownSymbolName(name) {
204
+ const match = TypeScriptHelpers._wellKnownSymbolNameRegExp.exec(name);
205
+ if (match) {
206
+ const identifier = match[1];
207
+ return `[Symbol.${identifier}]`;
208
+ }
209
+ return undefined;
210
+ }
211
+ /**
212
+ * Returns whether the provided name was generated for a TypeScript `unique symbol`.
213
+ */
214
+ static isUniqueSymbolName(name) {
215
+ return TypeScriptHelpers._uniqueSymbolNameRegExp.test(name);
216
+ }
217
+ /**
218
+ * Derives the string representation of a TypeScript late-bound symbol.
219
+ */
220
+ static tryGetLateBoundName(declarationName) {
221
+ // Create a node printer that ignores comments and indentation that we can use to convert
222
+ // declarationName to a string.
223
+ const printer = ts.createPrinter({ removeComments: true }, {
224
+ onEmitNode(hint, node, emitCallback) {
225
+ ts.setEmitFlags(declarationName, ts.EmitFlags.NoIndentation | ts.EmitFlags.SingleLine);
226
+ emitCallback(hint, node);
227
+ }
228
+ });
229
+ const sourceFile = declarationName.getSourceFile();
230
+ const text = printer.printNode(ts.EmitHint.Unspecified, declarationName, sourceFile);
231
+ // clean up any emit flags we've set on any nodes in the tree.
232
+ ts.disposeEmitNodes(sourceFile);
233
+ return text;
234
+ }
235
+ }
236
+ // Matches TypeScript's encoded names for well-known ECMAScript symbols like
237
+ // "__@iterator" or "__@toStringTag".
238
+ TypeScriptHelpers._wellKnownSymbolNameRegExp = /^__@(\w+)$/;
239
+ // Matches TypeScript's encoded names for late-bound symbols derived from `unique symbol` declarations
240
+ // which have the form of "__@<variableName>@<symbolId>", i.e. "__@someSymbol@12345".
241
+ TypeScriptHelpers._uniqueSymbolNameRegExp = /^__@.*@\d+$/;
242
+ //# sourceMappingURL=TypeScriptHelpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TypeScriptHelpers.js","sourceRoot":"","sources":["../../src/analyzer/TypeScriptHelpers.ts"],"names":[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AS,CAAC,EAAE,CAAC,QAAQ,CAAC,WAAW,EAAE,eAAe,EAAE,UAAU,CAAC,CAAC;QAC7F,8DAA8D;QAC9D,EAAE,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;;AAxSD,4EAA4E;AAC5E,qCAAqC;AACb,4CAA0B,GAAW,YAAY,CAAC;AAE1E,sGAAsG;AACtG,qFAAqF;AAC7D,yCAAuB,GAAW,aAAa,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/* eslint-disable no-bitwise */\n\nimport * as ts from 'typescript';\n\nimport { InternalError } from '@rushstack/node-core-library';\n\nimport { SourceFileLocationFormatter } from './SourceFileLocationFormatter';\nimport { TypeScriptInternals } from './TypeScriptInternals';\n\nexport class TypeScriptHelpers {\n // Matches TypeScript's encoded names for well-known ECMAScript symbols like\n // \"__@iterator\" or \"__@toStringTag\".\n private static readonly _wellKnownSymbolNameRegExp: RegExp = /^__@(\\w+)$/;\n\n // Matches TypeScript's encoded names for late-bound symbols derived from `unique symbol` declarations\n // which have the form of \"__@<variableName>@<symbolId>\", i.e. \"__@someSymbol@12345\".\n private static readonly _uniqueSymbolNameRegExp: RegExp = /^__@.*@\\d+$/;\n\n /**\n * This traverses any symbol aliases to find the original place where an item was defined.\n * For example, suppose a class is defined as \"export default class MyClass { }\"\n * but exported from the package's index.ts like this:\n *\n * export { default as _MyClass } from './MyClass';\n *\n * In this example, calling followAliases() on the _MyClass symbol will return the\n * original definition of MyClass, traversing any intermediary places where the\n * symbol was imported and re-exported.\n */\n public static followAliases(symbol: ts.Symbol, typeChecker: ts.TypeChecker): ts.Symbol {\n let current: ts.Symbol = symbol;\n for (;;) {\n if (!(current.flags & ts.SymbolFlags.Alias)) {\n break;\n }\n const currentAlias: ts.Symbol = typeChecker.getAliasedSymbol(current);\n if (!currentAlias || currentAlias === current) {\n break;\n }\n current = currentAlias;\n }\n\n return current;\n }\n\n /**\n * Returns true if TypeScriptHelpers.followAliases() would return something different\n * from the input `symbol`.\n */\n public static isFollowableAlias(symbol: ts.Symbol, typeChecker: ts.TypeChecker): boolean {\n if (!(symbol.flags & ts.SymbolFlags.Alias)) {\n return false;\n }\n\n const alias: ts.Symbol = typeChecker.getAliasedSymbol(symbol);\n if (!alias || alias === symbol) {\n return false;\n }\n\n return true;\n }\n\n /**\n * Certain virtual symbols do not have any declarations. For example, `ts.TypeChecker.getExportsOfModule()` can\n * sometimes return a \"prototype\" symbol for an object, even though there is no corresponding declaration in the\n * source code. API Extractor generally ignores such symbols.\n */\n public static tryGetADeclaration(symbol: ts.Symbol): ts.Declaration | undefined {\n if (symbol.declarations && symbol.declarations.length > 0) {\n return symbol.declarations[0];\n }\n return undefined;\n }\n\n /**\n * Returns true if the specified symbol is an ambient declaration.\n */\n public static isAmbient(symbol: ts.Symbol, typeChecker: ts.TypeChecker): boolean {\n const followedSymbol: ts.Symbol = TypeScriptHelpers.followAliases(symbol, typeChecker);\n\n if (followedSymbol.declarations && followedSymbol.declarations.length > 0) {\n const firstDeclaration: ts.Declaration = followedSymbol.declarations[0];\n\n // Test 1: Are we inside the sinister \"declare global {\" construct?\n const highestModuleDeclaration: ts.ModuleDeclaration | undefined = TypeScriptHelpers.findHighestParent(\n firstDeclaration,\n ts.SyntaxKind.ModuleDeclaration\n );\n if (highestModuleDeclaration) {\n if (highestModuleDeclaration.name.getText().trim() === 'global') {\n return true;\n }\n }\n\n // Test 2: Otherwise, the main heuristic for ambient declarations is by looking at the\n // ts.SyntaxKind.SourceFile node to see whether it has a symbol or not (i.e. whether it\n // is acting as a module or not).\n const sourceFile: ts.SourceFile = firstDeclaration.getSourceFile();\n\n if (typeChecker.getSymbolAtLocation(sourceFile)) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Same semantics as tryGetSymbolForDeclaration(), but throws an exception if the symbol\n * cannot be found.\n */\n public static getSymbolForDeclaration(declaration: ts.Declaration, checker: ts.TypeChecker): ts.Symbol {\n const symbol: ts.Symbol | undefined = TypeScriptInternals.tryGetSymbolForDeclaration(\n declaration,\n checker\n );\n if (!symbol) {\n throw new InternalError(\n 'Unable to determine semantic information for declaration:\\n' +\n SourceFileLocationFormatter.formatDeclaration(declaration)\n );\n }\n return symbol;\n }\n\n // Return name of the module, which could be like \"./SomeLocalFile' or like 'external-package/entry/point'\n public static getModuleSpecifier(\n nodeWithModuleSpecifier: ts.ImportDeclaration | ts.ExportDeclaration | ts.ImportTypeNode\n ): string | undefined {\n if (nodeWithModuleSpecifier.kind === ts.SyntaxKind.ImportType) {\n // As specified internally in typescript:/src/compiler/types.ts#ValidImportTypeNode\n if (\n nodeWithModuleSpecifier.argument.kind !== ts.SyntaxKind.LiteralType ||\n (nodeWithModuleSpecifier.argument as ts.LiteralTypeNode).literal.kind !== ts.SyntaxKind.StringLiteral\n ) {\n throw new InternalError(\n `Invalid ImportTypeNode: ${nodeWithModuleSpecifier.getText()}\\n` +\n SourceFileLocationFormatter.formatDeclaration(nodeWithModuleSpecifier)\n );\n }\n const literalTypeNode: ts.LiteralTypeNode = nodeWithModuleSpecifier.argument as ts.LiteralTypeNode;\n const stringLiteral: ts.StringLiteral = literalTypeNode.literal as ts.StringLiteral;\n return stringLiteral.text.trim();\n }\n\n // Node is a declaration\n if (\n nodeWithModuleSpecifier.moduleSpecifier &&\n ts.isStringLiteralLike(nodeWithModuleSpecifier.moduleSpecifier)\n ) {\n return TypeScriptInternals.getTextOfIdentifierOrLiteral(nodeWithModuleSpecifier.moduleSpecifier);\n }\n\n return undefined;\n }\n\n /**\n * Returns an ancestor of \"node\", such that the ancestor, any intermediary nodes,\n * and the starting node match a list of expected kinds. Undefined is returned\n * if there aren't enough ancestors, or if the kinds are incorrect.\n *\n * For example, suppose child \"C\" has parents A --> B --> C.\n *\n * Calling _matchAncestor(C, [ExportSpecifier, NamedExports, ExportDeclaration])\n * would return A only if A is of kind ExportSpecifier, B is of kind NamedExports,\n * and C is of kind ExportDeclaration.\n *\n * Calling _matchAncestor(C, [ExportDeclaration]) would return C.\n */\n public static matchAncestor<T extends ts.Node>(\n node: ts.Node,\n kindsToMatch: ts.SyntaxKind[]\n ): T | undefined {\n // (slice(0) clones an array)\n const reversedParentKinds: ts.SyntaxKind[] = kindsToMatch.slice(0).reverse();\n\n let current: ts.Node | undefined = undefined;\n\n for (const parentKind of reversedParentKinds) {\n if (!current) {\n // The first time through, start with node\n current = node;\n } else {\n // Then walk the parents\n current = current.parent;\n }\n\n // If we ran out of items, or if the kind doesn't match, then fail\n if (!current || current.kind !== parentKind) {\n return undefined;\n }\n }\n\n // If we matched everything, then return the node that matched the last parentKinds item\n return current as T;\n }\n\n /**\n * Does a depth-first search of the children of the specified node. Returns the first child\n * with the specified kind, or undefined if there is no match.\n */\n public static findFirstChildNode<T extends ts.Node>(\n node: ts.Node,\n kindToMatch: ts.SyntaxKind\n ): T | undefined {\n for (const child of node.getChildren()) {\n if (child.kind === kindToMatch) {\n return child as T;\n }\n\n const recursiveMatch: T | undefined = TypeScriptHelpers.findFirstChildNode(child, kindToMatch);\n if (recursiveMatch) {\n return recursiveMatch;\n }\n }\n\n return undefined;\n }\n\n /**\n * Returns the first parent node with the specified SyntaxKind, or undefined if there is no match.\n */\n public static findFirstParent<T extends ts.Node>(node: ts.Node, kindToMatch: ts.SyntaxKind): T | undefined {\n let current: ts.Node | undefined = node.parent;\n\n while (current) {\n if (current.kind === kindToMatch) {\n return current as T;\n }\n current = current.parent;\n }\n\n return undefined;\n }\n\n /**\n * Returns the highest parent node with the specified SyntaxKind, or undefined if there is no match.\n * @remarks\n * Whereas findFirstParent() returns the first match, findHighestParent() returns the last match.\n */\n public static findHighestParent<T extends ts.Node>(\n node: ts.Node,\n kindToMatch: ts.SyntaxKind\n ): T | undefined {\n let current: ts.Node | undefined = node;\n let highest: T | undefined = undefined;\n\n for (;;) {\n current = TypeScriptHelpers.findFirstParent<T>(current, kindToMatch);\n if (!current) {\n break;\n }\n highest = current as T;\n }\n\n return highest;\n }\n\n /**\n * Decodes the names that the compiler generates for a built-in ECMAScript symbol.\n *\n * @remarks\n * TypeScript binds well-known ECMAScript symbols like `[Symbol.iterator]` as `__@iterator`.\n * If `name` is of this form, then `tryGetWellKnownSymbolName()` converts it back into e.g. `[Symbol.iterator]`.\n * If the string does not start with `__@` then `undefined` is returned.\n */\n public static tryDecodeWellKnownSymbolName(name: ts.__String): string | undefined {\n const match: RegExpExecArray | null = TypeScriptHelpers._wellKnownSymbolNameRegExp.exec(name as string);\n if (match) {\n const identifier: string = match[1];\n return `[Symbol.${identifier}]`;\n }\n return undefined;\n }\n\n /**\n * Returns whether the provided name was generated for a TypeScript `unique symbol`.\n */\n public static isUniqueSymbolName(name: ts.__String): boolean {\n return TypeScriptHelpers._uniqueSymbolNameRegExp.test(name as string);\n }\n\n /**\n * Derives the string representation of a TypeScript late-bound symbol.\n */\n public static tryGetLateBoundName(declarationName: ts.ComputedPropertyName): string | undefined {\n // Create a node printer that ignores comments and indentation that we can use to convert\n // declarationName to a string.\n const printer: ts.Printer = ts.createPrinter(\n { removeComments: true },\n {\n onEmitNode(\n hint: ts.EmitHint,\n node: ts.Node,\n emitCallback: (hint: ts.EmitHint, node: ts.Node) => void\n ): void {\n ts.setEmitFlags(declarationName, ts.EmitFlags.NoIndentation | ts.EmitFlags.SingleLine);\n emitCallback(hint, node);\n }\n }\n );\n const sourceFile: ts.SourceFile = declarationName.getSourceFile();\n const text: string = printer.printNode(ts.EmitHint.Unspecified, declarationName, sourceFile);\n // clean up any emit flags we've set on any nodes in the tree.\n ts.disposeEmitNodes(sourceFile);\n return text;\n }\n}\n"]}
@@ -0,0 +1,114 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
+ // See LICENSE in the project root for license information.
3
+ /* eslint-disable @typescript-eslint/no-explicit-any */
4
+ import * as ts from 'typescript';
5
+ import { InternalError } from '@rushstack/node-core-library';
6
+ export class TypeScriptInternals {
7
+ static getImmediateAliasedSymbol(symbol, typeChecker) {
8
+ // Compiler internal:
9
+ // https://github.com/microsoft/TypeScript/blob/v3.2.2/src/compiler/checker.ts
10
+ return typeChecker.getImmediateAliasedSymbol(symbol);
11
+ }
12
+ /**
13
+ * Returns the Symbol for the provided Declaration. This is a workaround for a missing
14
+ * feature of the TypeScript Compiler API. It is the only apparent way to reach
15
+ * certain data structures, and seems to always work, but is not officially documented.
16
+ *
17
+ * @returns The associated Symbol. If there is no semantic information (e.g. if the
18
+ * declaration is an extra semicolon somewhere), then "undefined" is returned.
19
+ */
20
+ static tryGetSymbolForDeclaration(declaration, checker) {
21
+ let symbol = declaration.symbol;
22
+ if (symbol && symbol.escapedName === ts.InternalSymbolName.Computed) {
23
+ const name = ts.getNameOfDeclaration(declaration);
24
+ symbol = (name && checker.getSymbolAtLocation(name)) || symbol;
25
+ }
26
+ return symbol;
27
+ }
28
+ /**
29
+ * Returns whether the provided Symbol is a TypeScript "late-bound" Symbol (i.e. was created by the Checker
30
+ * for a computed property based on its type, rather than by the Binder).
31
+ */
32
+ static isLateBoundSymbol(symbol) {
33
+ if (
34
+ // eslint-disable-next-line no-bitwise
35
+ symbol.flags & ts.SymbolFlags.Transient &&
36
+ ts.getCheckFlags(symbol) === ts.CheckFlags.Late) {
37
+ return true;
38
+ }
39
+ return false;
40
+ }
41
+ /**
42
+ * Retrieves the comment ranges associated with the specified node.
43
+ */
44
+ static getJSDocCommentRanges(node, text) {
45
+ // Compiler internal:
46
+ // https://github.com/microsoft/TypeScript/blob/v2.4.2/src/compiler/utilities.ts#L616
47
+ return ts.getJSDocCommentRanges.apply(this, arguments);
48
+ }
49
+ /**
50
+ * Retrieves the (unescaped) value of an string literal, numeric literal, or identifier.
51
+ */
52
+ static getTextOfIdentifierOrLiteral(node) {
53
+ // Compiler internal:
54
+ // https://github.com/microsoft/TypeScript/blob/v3.2.2/src/compiler/utilities.ts#L2721
55
+ return ts.getTextOfIdentifierOrLiteral(node);
56
+ }
57
+ /**
58
+ * Retrieves the (cached) module resolution information for a module name that was exported from a SourceFile.
59
+ * The compiler populates this cache as part of analyzing the source file.
60
+ */
61
+ static getResolvedModule(program, sourceFile, moduleNameText, mode) {
62
+ // Compiler internal:
63
+ // https://github.com/microsoft/TypeScript/blob/v5.3.3/src/compiler/types.ts#L4698
64
+ const result = program.getResolvedModule(sourceFile, moduleNameText, mode);
65
+ return result === null || result === void 0 ? void 0 : result.resolvedModule;
66
+ }
67
+ /**
68
+ * Gets the mode required for module resolution required with the addition of Node16/nodenext
69
+ */
70
+ static getModeForUsageLocation(file, usage, compilerOptions) {
71
+ // Compiler internal:
72
+ // https://github.com/microsoft/TypeScript/blob/v5.8.2/src/compiler/program.ts#L931
73
+ var _a;
74
+ return (_a = ts.getModeForUsageLocation) === null || _a === void 0 ? void 0 : _a.call(ts, file, usage, compilerOptions);
75
+ }
76
+ /**
77
+ * Returns ts.Symbol.parent if it exists.
78
+ */
79
+ static getSymbolParent(symbol) {
80
+ return symbol.parent;
81
+ }
82
+ /**
83
+ * In an statement like `export default class X { }`, the `Symbol.name` will be `default`
84
+ * whereas the `localSymbol` is `X`.
85
+ */
86
+ static tryGetLocalSymbol(declaration) {
87
+ return declaration.localSymbol;
88
+ }
89
+ static getGlobalVariableAnalyzer(program) {
90
+ var _a;
91
+ const anyProgram = program;
92
+ const typeCheckerInstance = (_a = anyProgram.getDiagnosticsProducingTypeChecker) !== null && _a !== void 0 ? _a : anyProgram.getTypeChecker;
93
+ if (!typeCheckerInstance) {
94
+ throw new InternalError('Missing Program.getDiagnosticsProducingTypeChecker or Program.getTypeChecker');
95
+ }
96
+ const typeChecker = typeCheckerInstance();
97
+ if (!typeChecker.getEmitResolver) {
98
+ throw new InternalError('Missing TypeChecker.getEmitResolver');
99
+ }
100
+ const resolver = typeChecker.getEmitResolver();
101
+ if (!resolver.hasGlobalName) {
102
+ throw new InternalError('Missing EmitResolver.hasGlobalName');
103
+ }
104
+ return resolver;
105
+ }
106
+ /**
107
+ * Returns whether a variable is declared with the const keyword
108
+ */
109
+ static isVarConst(node) {
110
+ // Compiler internal: https://github.com/microsoft/TypeScript/blob/71286e3d49c10e0e99faac360a6bbd40f12db7b6/src/compiler/utilities.ts#L925
111
+ return ts.isVarConst(node);
112
+ }
113
+ }
114
+ //# sourceMappingURL=TypeScriptInternals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TypeScriptInternals.js","sourceRoot":"","sources":["../../src/analyzer/TypeScriptInternals.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,uDAAuD;AAEvD,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAS7D,MAAM,OAAO,mBAAmB;IACvB,MAAM,CAAC,yBAAyB,CAAC,MAAiB,EAAE,WAA2B;QACpF,qBAAqB;QACrB,8EAA8E;QAC9E,OAAQ,WAAmB,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC;IAChE,CAAC;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,0BAA0B,CACtC,WAA2B,EAC3B,OAAuB;QAEvB,IAAI,MAAM,GAA2B,WAAmB,CAAC,MAAM,CAAC;QAChE,IAAI,MAAM,IAAI,MAAM,CAAC,WAAW,KAAK,EAAE,CAAC,kBAAkB,CAAC,QAAQ,EAAE,CAAC;YACpE,MAAM,IAAI,GAAmC,EAAE,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC;YAClF,MAAM,GAAG,CAAC,IAAI,IAAI,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,IAAI,MAAM,CAAC;QACjE,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,iBAAiB,CAAC,MAAiB;QAC/C;QACE,sCAAsC;QACtC,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,SAAS;YACtC,EAAU,CAAC,aAAa,CAAC,MAAM,C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;QAChC,MAAM,mBAAmB,GACvB,MAAA,UAAU,CAAC,kCAAkC,mCAAI,UAAU,CAAC,cAAc,CAAC;QAE7E,IAAI,CAAC,mBAAmB,EAAE,CAAC;YACzB,MAAM,IAAI,aAAa,CAAC,8EAA8E,CAAC,CAAC;QAC1G,CAAC;QACD,MAAM,WAAW,GAAQ,mBAAmB,EAAE,CAAC;QAC/C,IAAI,CAAC,WAAW,CAAC,eAAe,EAAE,CAAC;YACjC,MAAM,IAAI,aAAa,CAAC,qCAAqC,CAAC,CAAC;QACjE,CAAC;QACD,MAAM,QAAQ,GAAQ,WAAW,CAAC,eAAe,EAAE,CAAC;QACpD,IAAI,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAC;YAC5B,MAAM,IAAI,aAAa,CAAC,oCAAoC,CAAC,CAAC;QAChE,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,UAAU,CAAC,IAAyD;QAChF,0IAA0I;QAC1I,OAAQ,EAAU,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport * as ts from 'typescript';\n\nimport { InternalError } from '@rushstack/node-core-library';\n\n/**\n * Exposes the TypeScript compiler internals for detecting global variable names.\n */\nexport interface IGlobalVariableAnalyzer {\n hasGlobalName(name: string): boolean;\n}\n\nexport class TypeScriptInternals {\n public static getImmediateAliasedSymbol(symbol: ts.Symbol, typeChecker: ts.TypeChecker): ts.Symbol {\n // Compiler internal:\n // https://github.com/microsoft/TypeScript/blob/v3.2.2/src/compiler/checker.ts\n return (typeChecker as any).getImmediateAliasedSymbol(symbol);\n }\n\n /**\n * Returns the Symbol for the provided Declaration. This is a workaround for a missing\n * feature of the TypeScript Compiler API. It is the only apparent way to reach\n * certain data structures, and seems to always work, but is not officially documented.\n *\n * @returns The associated Symbol. If there is no semantic information (e.g. if the\n * declaration is an extra semicolon somewhere), then \"undefined\" is returned.\n */\n public static tryGetSymbolForDeclaration(\n declaration: ts.Declaration,\n checker: ts.TypeChecker\n ): ts.Symbol | undefined {\n let symbol: ts.Symbol | undefined = (declaration as any).symbol;\n if (symbol && symbol.escapedName === ts.InternalSymbolName.Computed) {\n const name: ts.DeclarationName | undefined = ts.getNameOfDeclaration(declaration);\n symbol = (name && checker.getSymbolAtLocation(name)) || symbol;\n }\n return symbol;\n }\n\n /**\n * Returns whether the provided Symbol is a TypeScript \"late-bound\" Symbol (i.e. was created by the Checker\n * for a computed property based on its type, rather than by the Binder).\n */\n public static isLateBoundSymbol(symbol: ts.Symbol): boolean {\n if (\n // eslint-disable-next-line no-bitwise\n symbol.flags & ts.SymbolFlags.Transient &&\n (ts as any).getCheckFlags(symbol) === (ts as any).CheckFlags.Late\n ) {\n return true;\n }\n return false;\n }\n\n /**\n * Retrieves the comment ranges associated with the specified node.\n */\n public static getJSDocCommentRanges(node: ts.Node, text: string): ts.CommentRange[] | undefined {\n // Compiler internal:\n // https://github.com/microsoft/TypeScript/blob/v2.4.2/src/compiler/utilities.ts#L616\n\n return (ts as any).getJSDocCommentRanges.apply(this, arguments);\n }\n\n /**\n * Retrieves the (unescaped) value of an string literal, numeric literal, or identifier.\n */\n public static getTextOfIdentifierOrLiteral(\n node: ts.Identifier | ts.StringLiteralLike | ts.NumericLiteral\n ): string {\n // Compiler internal:\n // https://github.com/microsoft/TypeScript/blob/v3.2.2/src/compiler/utilities.ts#L2721\n\n return (ts as any).getTextOfIdentifierOrLiteral(node);\n }\n\n /**\n * Retrieves the (cached) module resolution information for a module name that was exported from a SourceFile.\n * The compiler populates this cache as part of analyzing the source file.\n */\n public static getResolvedModule(\n program: ts.Program,\n sourceFile: ts.SourceFile,\n moduleNameText: string,\n mode: ts.ModuleKind.CommonJS | ts.ModuleKind.ESNext | undefined\n ): ts.ResolvedModuleFull | undefined {\n // Compiler internal:\n // https://github.com/microsoft/TypeScript/blob/v5.3.3/src/compiler/types.ts#L4698\n const result: ts.ResolvedModuleWithFailedLookupLocations | undefined = (program as any).getResolvedModule(\n sourceFile,\n moduleNameText,\n mode\n );\n return result?.resolvedModule;\n }\n\n /**\n * Gets the mode required for module resolution required with the addition of Node16/nodenext\n */\n public static getModeForUsageLocation(\n file: ts.SourceFile,\n usage: ts.StringLiteralLike,\n compilerOptions: ts.CompilerOptions\n ): ts.ModuleKind.CommonJS | ts.ModuleKind.ESNext | undefined {\n // Compiler internal:\n // https://github.com/microsoft/TypeScript/blob/v5.8.2/src/compiler/program.ts#L931\n\n return ts.getModeForUsageLocation?.(file, usage, compilerOptions);\n }\n\n /**\n * Returns ts.Symbol.parent if it exists.\n */\n public static getSymbolParent(symbol: ts.Symbol): ts.Symbol | undefined {\n return (symbol as any).parent;\n }\n\n /**\n * In an statement like `export default class X { }`, the `Symbol.name` will be `default`\n * whereas the `localSymbol` is `X`.\n */\n public static tryGetLocalSymbol(declaration: ts.Declaration): ts.Symbol | undefined {\n return (declaration as any).localSymbol;\n }\n\n public static getGlobalVariableAnalyzer(program: ts.Program): IGlobalVariableAnalyzer {\n const anyProgram: any = program;\n const typeCheckerInstance: any =\n anyProgram.getDiagnosticsProducingTypeChecker ?? anyProgram.getTypeChecker;\n\n if (!typeCheckerInstance) {\n throw new InternalError('Missing Program.getDiagnosticsProducingTypeChecker or Program.getTypeChecker');\n }\n const typeChecker: any = typeCheckerInstance();\n if (!typeChecker.getEmitResolver) {\n throw new InternalError('Missing TypeChecker.getEmitResolver');\n }\n const resolver: any = typeChecker.getEmitResolver();\n if (!resolver.hasGlobalName) {\n throw new InternalError('Missing EmitResolver.hasGlobalName');\n }\n return resolver;\n }\n\n /**\n * Returns whether a variable is declared with the const keyword\n */\n public static isVarConst(node: ts.VariableDeclaration | ts.VariableDeclarationList): boolean {\n // Compiler internal: https://github.com/microsoft/TypeScript/blob/71286e3d49c10e0e99faac360a6bbd40f12db7b6/src/compiler/utilities.ts#L925\n return (ts as any).isVarConst(node);\n }\n}\n"]}
@@ -0,0 +1,149 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
+ // See LICENSE in the project root for license information.
3
+ import * as path from 'node:path';
4
+ import * as ts from 'typescript';
5
+ import { JsonFile } from '@rushstack/node-core-library';
6
+ import { Colorize } from '@rushstack/terminal';
7
+ import { ExtractorConfig } from './ExtractorConfig';
8
+ /**
9
+ * This class represents the TypeScript compiler state. This allows an optimization where multiple invocations
10
+ * of API Extractor can reuse the same TypeScript compiler analysis.
11
+ *
12
+ * @public
13
+ */
14
+ export class CompilerState {
15
+ constructor(properties) {
16
+ this.program = properties.program;
17
+ }
18
+ /**
19
+ * Create a compiler state for use with the specified `IExtractorInvokeOptions`.
20
+ */
21
+ static create(extractorConfig, options) {
22
+ let tsconfig = extractorConfig.overrideTsconfig;
23
+ let configBasePath = extractorConfig.projectFolder;
24
+ if (!tsconfig) {
25
+ // If it wasn't overridden, then load it from disk
26
+ tsconfig = JsonFile.load(extractorConfig.tsconfigFilePath);
27
+ configBasePath = path.resolve(path.dirname(extractorConfig.tsconfigFilePath));
28
+ }
29
+ const commandLine = ts.parseJsonConfigFileContent(tsconfig, ts.sys, configBasePath);
30
+ if (!commandLine.options.skipLibCheck && extractorConfig.skipLibCheck) {
31
+ commandLine.options.skipLibCheck = true;
32
+ console.log(Colorize.cyan('API Extractor was invoked with skipLibCheck. This is not recommended and may cause ' +
33
+ 'incorrect type analysis.'));
34
+ }
35
+ // Delete outDir and declarationDir to prevent TypeScript from redirecting self-package
36
+ // imports to source files. When these options are set, TypeScript's module resolution
37
+ // tries to map output .d.ts files back to their source .ts files to avoid analyzing
38
+ // build outputs during compilation. However, API Extractor specifically wants to analyze
39
+ // the .d.ts build artifacts, not the source files. Since API Extractor doesn't emit any
40
+ // files, these options are unnecessary and interfere with correct module resolution.
41
+ delete commandLine.options.outDir;
42
+ delete commandLine.options.declarationDir;
43
+ const inputFilePaths = commandLine.fileNames.concat(extractorConfig.mainEntryPointFilePath);
44
+ if (options && options.additionalEntryPoints) {
45
+ inputFilePaths.push(...options.additionalEntryPoints);
46
+ }
47
+ // Append the entry points and remove any non-declaration files from the list
48
+ const analysisFilePaths = CompilerState._generateFilePathsForAnalysis(inputFilePaths);
49
+ const compilerHost = CompilerState._createCompilerHost(commandLine, options);
50
+ const program = ts.createProgram(analysisFilePaths, commandLine.options, compilerHost);
51
+ if (commandLine.errors.length > 0) {
52
+ const errorText = ts.flattenDiagnosticMessageText(commandLine.errors[0].messageText, '\n');
53
+ throw new Error(`Error parsing tsconfig.json content: ${errorText}`);
54
+ }
55
+ return new CompilerState({
56
+ program
57
+ });
58
+ }
59
+ /**
60
+ * Given a list of absolute file paths, return a list containing only the declaration
61
+ * files. Duplicates are also eliminated.
62
+ *
63
+ * @remarks
64
+ * The tsconfig.json settings specify the compiler's input (a set of *.ts source files,
65
+ * plus some *.d.ts declaration files used for legacy typings). However API Extractor
66
+ * analyzes the compiler's output (a set of *.d.ts entry point files, plus any legacy
67
+ * typings). This requires API Extractor to generate a special file list when it invokes
68
+ * the compiler.
69
+ *
70
+ * Duplicates are removed so that entry points can be appended without worrying whether they
71
+ * may already appear in the tsconfig.json file list.
72
+ */
73
+ static _generateFilePathsForAnalysis(inputFilePaths) {
74
+ const analysisFilePaths = [];
75
+ const seenFiles = new Set();
76
+ for (const inputFilePath of inputFilePaths) {
77
+ const inputFileToUpper = inputFilePath.toUpperCase();
78
+ if (!seenFiles.has(inputFileToUpper)) {
79
+ seenFiles.add(inputFileToUpper);
80
+ if (!path.isAbsolute(inputFilePath)) {
81
+ throw new Error('Input file is not an absolute path: ' + inputFilePath);
82
+ }
83
+ if (ExtractorConfig.hasDtsFileExtension(inputFilePath)) {
84
+ analysisFilePaths.push(inputFilePath);
85
+ }
86
+ }
87
+ }
88
+ return analysisFilePaths;
89
+ }
90
+ static _createCompilerHost(commandLine, options) {
91
+ // Create a default CompilerHost that we will override
92
+ const compilerHost = ts.createCompilerHost(commandLine.options);
93
+ // Save a copy of the original members. Note that "compilerHost" cannot be the copy, because
94
+ // createCompilerHost() captures that instance in a closure that is used by the members.
95
+ const defaultCompilerHost = { ...compilerHost };
96
+ if (options && options.typescriptCompilerFolder) {
97
+ // Prevent a closure parameter
98
+ const typescriptCompilerLibFolder = path.join(options.typescriptCompilerFolder, 'lib');
99
+ compilerHost.getDefaultLibLocation = () => typescriptCompilerLibFolder;
100
+ }
101
+ // Used by compilerHost.fileExists()
102
+ // .d.ts file path --> whether the file exists
103
+ const dtsExistsCache = new Map();
104
+ // Used by compilerHost.fileExists()
105
+ // Example: "c:/folder/file.part.ts"
106
+ const fileExtensionRegExp = /^(.+)(\.[a-z0-9_]+)$/i;
107
+ compilerHost.fileExists = (fileName) => {
108
+ // In certain deprecated setups, the compiler may write its output files (.js and .d.ts)
109
+ // in the same folder as the corresponding input file (.ts or .tsx). When following imports,
110
+ // API Extractor wants to analyze the .d.ts file; however recent versions of the compiler engine
111
+ // will instead choose the .ts file. To work around this, we hook fileExists() to hide the
112
+ // existence of those files.
113
+ // Is "fileName" a .d.ts file? The double extension ".d.ts" needs to be matched specially.
114
+ if (!ExtractorConfig.hasDtsFileExtension(fileName)) {
115
+ // It's not a .d.ts file. Is the file extension a potential source file?
116
+ const match = fileExtensionRegExp.exec(fileName);
117
+ if (match) {
118
+ // Example: "c:/folder/file.part"
119
+ const pathWithoutExtension = match[1];
120
+ // Example: ".ts"
121
+ const fileExtension = match[2];
122
+ switch (fileExtension.toLocaleLowerCase()) {
123
+ case '.ts':
124
+ case '.tsx':
125
+ case '.js':
126
+ case '.jsx':
127
+ // Yes, this is a possible source file. Is there a corresponding .d.ts file in the same folder?
128
+ const dtsFileName = `${pathWithoutExtension}.d.ts`;
129
+ let dtsFileExists = dtsExistsCache.get(dtsFileName);
130
+ if (dtsFileExists === undefined) {
131
+ dtsFileExists = defaultCompilerHost.fileExists(dtsFileName);
132
+ dtsExistsCache.set(dtsFileName, dtsFileExists);
133
+ }
134
+ if (dtsFileExists) {
135
+ // fileName is a potential source file and a corresponding .d.ts file exists.
136
+ // Thus, API Extractor should ignore this file (so the .d.ts file will get analyzed instead).
137
+ return false;
138
+ }
139
+ break;
140
+ }
141
+ }
142
+ }
143
+ // Fall through to the default implementation
144
+ return defaultCompilerHost.fileExists(fileName);
145
+ };
146
+ return compilerHost;
147
+ }
148
+ }
149
+ //# sourceMappingURL=CompilerState.js.map