tstyche 7.2.4 → 8.0.0-beta.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 (393) hide show
  1. package/README.md +4 -0
  2. package/dist/api.d.ts +16 -761
  3. package/dist/api.js +16 -6170
  4. package/dist/bin.js +2 -3
  5. package/dist/checker/BaseCheckerAdapter.d.ts +15 -0
  6. package/dist/checker/BaseCheckerAdapter.js +32 -0
  7. package/dist/checker/CompatCheckerAdapter.d.ts +70 -0
  8. package/dist/checker/CompatCheckerAdapter.js +221 -0
  9. package/dist/checker/NativeCheckerAdapter.d.ts +70 -0
  10. package/dist/checker/NativeCheckerAdapter.js +200 -0
  11. package/dist/checker/index.d.ts +3 -0
  12. package/dist/checker/index.js +2 -0
  13. package/dist/checker/types.d.ts +9 -0
  14. package/dist/checker/types.js +1 -0
  15. package/dist/cli/Cli.d.ts +5 -0
  16. package/dist/cli/Cli.js +144 -0
  17. package/dist/cli/CliDIagnosticText.d.ts +3 -0
  18. package/dist/cli/CliDIagnosticText.js +9 -0
  19. package/dist/cli/index.d.ts +1 -0
  20. package/dist/cli/index.js +1 -0
  21. package/dist/collect/CollectDiagnosticText.d.ts +3 -0
  22. package/dist/collect/CollectDiagnosticText.js +5 -0
  23. package/dist/collect/CollectService.d.ts +9 -0
  24. package/dist/collect/CollectService.js +150 -0
  25. package/dist/collect/ExpectNode.d.ts +16 -0
  26. package/dist/collect/ExpectNode.js +30 -0
  27. package/dist/collect/IdentifierLookup.d.ts +18 -0
  28. package/dist/collect/IdentifierLookup.js +90 -0
  29. package/dist/collect/TestTree.d.ts +16 -0
  30. package/dist/collect/TestTree.js +15 -0
  31. package/dist/collect/TestTreeNode.d.ts +15 -0
  32. package/dist/collect/TestTreeNode.js +27 -0
  33. package/dist/collect/TestTreeNodeBrand.enum.d.ts +6 -0
  34. package/dist/collect/TestTreeNodeBrand.enum.js +7 -0
  35. package/dist/collect/TestTreeNodeFlags.enum.d.ts +6 -0
  36. package/dist/collect/TestTreeNodeFlags.enum.js +7 -0
  37. package/dist/collect/index.d.ts +6 -0
  38. package/dist/collect/index.js +6 -0
  39. package/dist/config/CommandParser.d.ts +7 -0
  40. package/dist/config/CommandParser.js +107 -0
  41. package/dist/config/Config.d.ts +18 -0
  42. package/dist/config/Config.js +59 -0
  43. package/dist/config/ConfigDiagnosticText.d.ts +19 -0
  44. package/dist/config/ConfigDiagnosticText.js +57 -0
  45. package/dist/config/ConfigParser.d.ts +10 -0
  46. package/dist/config/ConfigParser.js +165 -0
  47. package/dist/config/Directive.d.ts +9 -0
  48. package/dist/config/Directive.js +119 -0
  49. package/dist/config/DirectiveDiagnosticText.d.ts +5 -0
  50. package/dist/config/DirectiveDiagnosticText.js +11 -0
  51. package/dist/config/OptionBrand.enum.d.ts +8 -0
  52. package/dist/config/OptionBrand.enum.js +9 -0
  53. package/dist/config/OptionGroup.enum.d.ts +5 -0
  54. package/dist/config/OptionGroup.enum.js +6 -0
  55. package/dist/config/Options.d.ts +29 -0
  56. package/dist/config/Options.js +290 -0
  57. package/dist/config/Target.d.ts +7 -0
  58. package/dist/config/Target.js +47 -0
  59. package/dist/config/defaultOptions.d.ts +2 -0
  60. package/dist/config/defaultOptions.js +14 -0
  61. package/dist/config/index.d.ts +8 -0
  62. package/dist/config/index.js +7 -0
  63. package/dist/config/types.d.ts +55 -0
  64. package/dist/config/types.js +1 -0
  65. package/dist/diagnostic/Diagnostic.d.ts +19 -0
  66. package/dist/diagnostic/Diagnostic.js +51 -0
  67. package/dist/diagnostic/DiagnosticCategory.enum.d.ts +4 -0
  68. package/dist/diagnostic/DiagnosticCategory.enum.js +5 -0
  69. package/dist/diagnostic/DiagnosticOrigin.d.ts +13 -0
  70. package/dist/diagnostic/DiagnosticOrigin.js +27 -0
  71. package/dist/diagnostic/helpers.d.ts +6 -0
  72. package/dist/diagnostic/helpers.js +74 -0
  73. package/dist/diagnostic/index.d.ts +5 -0
  74. package/dist/diagnostic/index.js +4 -0
  75. package/dist/diagnostic/types.d.ts +2 -0
  76. package/dist/diagnostic/types.js +1 -0
  77. package/dist/editor/TextEditor.d.ts +15 -0
  78. package/dist/editor/TextEditor.js +88 -0
  79. package/dist/editor/index.d.ts +2 -0
  80. package/dist/editor/index.js +1 -0
  81. package/dist/editor/types.d.ts +4 -0
  82. package/dist/editor/types.js +1 -0
  83. package/dist/environment/Environment.d.ts +5 -0
  84. package/dist/environment/Environment.js +89 -0
  85. package/dist/environment/environmentOptions.d.ts +1 -0
  86. package/dist/environment/environmentOptions.js +2 -0
  87. package/dist/environment/index.d.ts +2 -0
  88. package/dist/environment/index.js +1 -0
  89. package/dist/environment/types.d.ts +10 -0
  90. package/dist/environment/types.js +1 -0
  91. package/dist/events/EventEmitter.d.ts +14 -0
  92. package/dist/events/EventEmitter.js +42 -0
  93. package/dist/events/index.d.ts +2 -0
  94. package/dist/events/index.js +1 -0
  95. package/dist/events/types.d.ts +88 -0
  96. package/dist/events/types.js +1 -0
  97. package/dist/expect/AbilityMatcherBase.d.ts +16 -0
  98. package/dist/expect/AbilityMatcherBase.js +52 -0
  99. package/dist/expect/Ensure.d.ts +10 -0
  100. package/dist/expect/Ensure.js +51 -0
  101. package/dist/expect/ExpectDiagnosticText.d.ts +29 -0
  102. package/dist/expect/ExpectDiagnosticText.js +87 -0
  103. package/dist/expect/ExpectService.d.ts +21 -0
  104. package/dist/expect/ExpectService.js +90 -0
  105. package/dist/expect/RelationMatcherBase.d.ts +12 -0
  106. package/dist/expect/RelationMatcherBase.js +16 -0
  107. package/dist/expect/ToAcceptProps.d.ts +10 -0
  108. package/dist/expect/ToAcceptProps.js +52 -0
  109. package/dist/expect/ToBe.d.ts +13 -0
  110. package/dist/expect/ToBe.js +18 -0
  111. package/dist/expect/ToBeApplicable.d.ts +10 -0
  112. package/dist/expect/ToBeApplicable.js +72 -0
  113. package/dist/expect/ToBeAssignableFrom.d.ts +9 -0
  114. package/dist/expect/ToBeAssignableFrom.js +12 -0
  115. package/dist/expect/ToBeAssignableTo.d.ts +9 -0
  116. package/dist/expect/ToBeAssignableTo.js +12 -0
  117. package/dist/expect/ToBeCallableWith.d.ts +11 -0
  118. package/dist/expect/ToBeCallableWith.js +29 -0
  119. package/dist/expect/ToBeConstructableWith.d.ts +11 -0
  120. package/dist/expect/ToBeConstructableWith.js +29 -0
  121. package/dist/expect/ToBeInstantiableWith.d.ts +10 -0
  122. package/dist/expect/ToBeInstantiableWith.js +31 -0
  123. package/dist/expect/ToHaveProperty.d.ts +10 -0
  124. package/dist/expect/ToHaveProperty.js +59 -0
  125. package/dist/expect/ToRaiseError.d.ts +9 -0
  126. package/dist/expect/ToRaiseError.js +82 -0
  127. package/dist/expect/index.d.ts +2 -0
  128. package/dist/expect/index.js +1 -0
  129. package/dist/expect/types.d.ts +7 -0
  130. package/dist/expect/types.js +1 -0
  131. package/dist/file/FilePosition.d.ts +7 -0
  132. package/dist/file/FilePosition.js +16 -0
  133. package/dist/file/index.d.ts +1 -0
  134. package/dist/file/index.js +1 -0
  135. package/dist/glob/Braces.d.ts +4 -0
  136. package/dist/glob/Braces.js +56 -0
  137. package/dist/glob/Glob.d.ts +4 -0
  138. package/dist/glob/Glob.js +47 -0
  139. package/dist/glob/index.d.ts +1 -0
  140. package/dist/glob/index.js +1 -0
  141. package/dist/handlers/CancellationHandler.d.ts +7 -0
  142. package/dist/handlers/CancellationHandler.js +15 -0
  143. package/dist/handlers/ExitCodeHandler.d.ts +7 -0
  144. package/dist/handlers/ExitCodeHandler.js +20 -0
  145. package/dist/handlers/ResultHandler.d.ts +5 -0
  146. package/dist/handlers/ResultHandler.js +206 -0
  147. package/dist/handlers/index.d.ts +3 -0
  148. package/dist/handlers/index.js +3 -0
  149. package/dist/index.cjs +5 -5
  150. package/dist/index.d.cts +40 -45
  151. package/dist/index.d.ts +40 -45
  152. package/dist/index.js +1 -2
  153. package/dist/input/InputService.d.ts +6 -0
  154. package/dist/input/InputService.js +16 -0
  155. package/dist/input/index.d.ts +1 -0
  156. package/dist/input/index.js +1 -0
  157. package/dist/json/JsonNode.d.ts +11 -0
  158. package/dist/json/JsonNode.js +28 -0
  159. package/dist/json/JsonScanner.d.ts +14 -0
  160. package/dist/json/JsonScanner.js +105 -0
  161. package/dist/json/index.d.ts +3 -0
  162. package/dist/json/index.js +2 -0
  163. package/dist/json/types.d.ts +1 -0
  164. package/dist/json/types.js +1 -0
  165. package/dist/layers/AbilityLayer.d.ts +10 -0
  166. package/dist/layers/AbilityLayer.js +186 -0
  167. package/dist/layers/Layers.d.ts +11 -0
  168. package/dist/layers/Layers.js +47 -0
  169. package/dist/layers/SuppressedLayer.d.ts +11 -0
  170. package/dist/layers/SuppressedLayer.js +93 -0
  171. package/dist/layers/index.d.ts +2 -0
  172. package/dist/layers/index.js +1 -0
  173. package/dist/layers/types.d.ts +8 -0
  174. package/dist/layers/types.js +1 -0
  175. package/dist/output/CodeFrameText.d.ts +10 -0
  176. package/dist/output/CodeFrameText.js +71 -0
  177. package/dist/output/OutputService.d.ts +13 -0
  178. package/dist/output/OutputService.js +38 -0
  179. package/dist/output/StreamController.d.ts +10 -0
  180. package/dist/output/StreamController.js +16 -0
  181. package/dist/output/addsText.d.ts +4 -0
  182. package/dist/output/addsText.js +8 -0
  183. package/dist/output/describeNameText.d.ts +2 -0
  184. package/dist/output/describeNameText.js +5 -0
  185. package/dist/output/diagnosticText.d.ts +4 -0
  186. package/dist/output/diagnosticText.js +23 -0
  187. package/dist/output/dotText.d.ts +3 -0
  188. package/dist/output/dotText.js +11 -0
  189. package/dist/output/fileStatusText.d.ts +4 -0
  190. package/dist/output/fileStatusText.js +26 -0
  191. package/dist/output/formattedText.d.ts +2 -0
  192. package/dist/output/formattedText.js +19 -0
  193. package/dist/output/helpText.d.ts +3 -0
  194. package/dist/output/helpText.js +52 -0
  195. package/dist/output/helpers.d.ts +5 -0
  196. package/dist/output/helpers.js +23 -0
  197. package/dist/output/index.d.ts +16 -0
  198. package/dist/output/index.js +15 -0
  199. package/dist/output/prologueText.d.ts +2 -0
  200. package/dist/output/prologueText.js +5 -0
  201. package/dist/output/summaryText.d.ts +12 -0
  202. package/dist/output/summaryText.js +31 -0
  203. package/dist/output/testNameText.d.ts +3 -0
  204. package/dist/output/testNameText.js +24 -0
  205. package/dist/output/types.d.ts +5 -0
  206. package/dist/output/types.js +1 -0
  207. package/dist/output/usesText.d.ts +5 -0
  208. package/dist/output/usesText.js +22 -0
  209. package/dist/output/waitingForFileChangesText.d.ts +2 -0
  210. package/dist/output/waitingForFileChangesText.js +5 -0
  211. package/dist/output/watchUsageText.d.ts +2 -0
  212. package/dist/output/watchUsageText.js +12 -0
  213. package/dist/path/Path.d.ts +7 -0
  214. package/dist/path/Path.js +28 -0
  215. package/dist/path/index.d.ts +1 -0
  216. package/dist/path/index.js +1 -0
  217. package/dist/project/CompatMappedDiagnostic.d.ts +12 -0
  218. package/dist/project/CompatMappedDiagnostic.js +25 -0
  219. package/dist/project/CompatProjectService.d.ts +19 -0
  220. package/dist/project/CompatProjectService.js +188 -0
  221. package/dist/project/FileMapService.d.ts +6 -0
  222. package/dist/project/FileMapService.js +14 -0
  223. package/dist/project/NativeMappedDiagnostic.d.ts +14 -0
  224. package/dist/project/NativeMappedDiagnostic.js +29 -0
  225. package/dist/project/NativeProjectService.d.ts +21 -0
  226. package/dist/project/NativeProjectService.js +216 -0
  227. package/dist/project/ProjectConfigService.d.ts +8 -0
  228. package/dist/project/ProjectConfigService.js +73 -0
  229. package/dist/project/index.d.ts +3 -0
  230. package/dist/project/index.js +2 -0
  231. package/dist/project/types.d.ts +7 -0
  232. package/dist/project/types.js +1 -0
  233. package/dist/reject/Reject.d.ts +9 -0
  234. package/dist/reject/Reject.js +43 -0
  235. package/dist/reject/RejectDiagnosticText.d.ts +5 -0
  236. package/dist/reject/RejectDiagnosticText.js +16 -0
  237. package/dist/reject/helpers.d.ts +1 -0
  238. package/dist/reject/helpers.js +3 -0
  239. package/dist/reject/index.d.ts +1 -0
  240. package/dist/reject/index.js +1 -0
  241. package/dist/reporters/BaseReporter.d.ts +7 -0
  242. package/dist/reporters/BaseReporter.js +6 -0
  243. package/dist/reporters/DotReporter.d.ts +6 -0
  244. package/dist/reporters/DotReporter.js +51 -0
  245. package/dist/reporters/FileView.d.ts +13 -0
  246. package/dist/reporters/FileView.js +33 -0
  247. package/dist/reporters/ListReporter.d.ts +6 -0
  248. package/dist/reporters/ListReporter.js +125 -0
  249. package/dist/reporters/SetupReporter.d.ts +4 -0
  250. package/dist/reporters/SetupReporter.js +21 -0
  251. package/dist/reporters/SummaryReporter.d.ts +5 -0
  252. package/dist/reporters/SummaryReporter.js +19 -0
  253. package/dist/reporters/WatchReporter.d.ts +5 -0
  254. package/dist/reporters/WatchReporter.js +21 -0
  255. package/dist/reporters/index.d.ts +7 -0
  256. package/dist/reporters/index.js +6 -0
  257. package/dist/reporters/types.d.ts +5 -0
  258. package/dist/reporters/types.js +1 -0
  259. package/dist/result/DescribeResult.d.ts +9 -0
  260. package/dist/result/DescribeResult.js +11 -0
  261. package/dist/result/ExpectResult.d.ts +10 -0
  262. package/dist/result/ExpectResult.js +11 -0
  263. package/dist/result/FileResult.d.ts +15 -0
  264. package/dist/result/FileResult.js +13 -0
  265. package/dist/result/ProjectConfigKind.enum.d.ts +6 -0
  266. package/dist/result/ProjectConfigKind.enum.js +7 -0
  267. package/dist/result/ProjectResult.d.ts +8 -0
  268. package/dist/result/ProjectResult.js +9 -0
  269. package/dist/result/Result.d.ts +13 -0
  270. package/dist/result/Result.js +14 -0
  271. package/dist/result/ResultStatus.enum.d.ts +10 -0
  272. package/dist/result/ResultStatus.enum.js +11 -0
  273. package/dist/result/SuppressedResult.d.ts +5 -0
  274. package/dist/result/SuppressedResult.js +6 -0
  275. package/dist/result/TargetResult.d.ts +11 -0
  276. package/dist/result/TargetResult.js +12 -0
  277. package/dist/result/TestResult.d.ts +13 -0
  278. package/dist/result/TestResult.js +13 -0
  279. package/dist/result/helpers.d.ts +7 -0
  280. package/dist/result/helpers.js +21 -0
  281. package/dist/result/index.d.ts +11 -0
  282. package/dist/result/index.js +10 -0
  283. package/dist/result/types.d.ts +31 -0
  284. package/dist/result/types.js +1 -0
  285. package/dist/runner/FileRunner.d.ts +10 -0
  286. package/dist/runner/FileRunner.js +93 -0
  287. package/dist/runner/FixmeDiagnosticText.d.ts +4 -0
  288. package/dist/runner/FixmeDiagnosticText.js +8 -0
  289. package/dist/runner/FixmeService.d.ts +9 -0
  290. package/dist/runner/FixmeService.js +51 -0
  291. package/dist/runner/RunModeFlags.enum.d.ts +7 -0
  292. package/dist/runner/RunModeFlags.enum.js +8 -0
  293. package/dist/runner/Runner.d.ts +9 -0
  294. package/dist/runner/Runner.js +101 -0
  295. package/dist/runner/TestTreeWalker.d.ts +19 -0
  296. package/dist/runner/TestTreeWalker.js +169 -0
  297. package/dist/runner/index.d.ts +1 -0
  298. package/dist/runner/index.js +1 -0
  299. package/dist/scribbler/Color.enum.d.ts +10 -0
  300. package/dist/scribbler/Color.enum.js +11 -0
  301. package/dist/scribbler/Line.d.ts +9 -0
  302. package/dist/scribbler/Line.js +5 -0
  303. package/dist/scribbler/Scribbler.d.ts +10 -0
  304. package/dist/scribbler/Scribbler.js +53 -0
  305. package/dist/scribbler/Text.d.ts +9 -0
  306. package/dist/scribbler/Text.js +8 -0
  307. package/dist/scribbler/index.d.ts +5 -0
  308. package/dist/scribbler/index.js +4 -0
  309. package/dist/scribbler/jsxRuntime.d.ts +4 -0
  310. package/dist/scribbler/jsxRuntime.js +4 -0
  311. package/dist/scribbler/types.d.ts +19 -0
  312. package/dist/scribbler/types.js +1 -0
  313. package/dist/select/Select.d.ts +7 -0
  314. package/dist/select/Select.js +91 -0
  315. package/dist/select/SelectDiagnosticText.d.ts +6 -0
  316. package/dist/select/SelectDiagnosticText.js +24 -0
  317. package/dist/select/index.d.ts +2 -0
  318. package/dist/select/index.js +2 -0
  319. package/dist/store/Fetcher.d.ts +8 -0
  320. package/dist/store/Fetcher.js +52 -0
  321. package/dist/store/Lock.d.ts +5 -0
  322. package/dist/store/Lock.js +17 -0
  323. package/dist/store/LockService.d.ts +8 -0
  324. package/dist/store/LockService.js +36 -0
  325. package/dist/store/Manifest.d.ts +35 -0
  326. package/dist/store/Manifest.js +58 -0
  327. package/dist/store/ManifestService.d.ts +10 -0
  328. package/dist/store/ManifestService.js +129 -0
  329. package/dist/store/PackageService.d.ts +8 -0
  330. package/dist/store/PackageService.js +69 -0
  331. package/dist/store/Store.d.ts +12 -0
  332. package/dist/store/Store.js +103 -0
  333. package/dist/store/StoreDiagnosticText.d.ts +12 -0
  334. package/dist/store/StoreDiagnosticText.js +36 -0
  335. package/dist/store/TarReader.d.ts +9 -0
  336. package/dist/store/TarReader.js +56 -0
  337. package/dist/store/helpers.d.ts +1 -0
  338. package/dist/store/helpers.js +3 -0
  339. package/dist/store/index.d.ts +1 -0
  340. package/dist/store/index.js +1 -0
  341. package/dist/structure/ComparisonResult.enum.d.ts +5 -0
  342. package/dist/structure/ComparisonResult.enum.js +6 -0
  343. package/dist/structure/Structure.d.ts +24 -0
  344. package/dist/structure/Structure.js +481 -0
  345. package/dist/structure/index.d.ts +1 -0
  346. package/dist/structure/index.js +1 -0
  347. package/dist/suppressed/SuppressedDiagnosticText.d.ts +6 -0
  348. package/dist/suppressed/SuppressedDiagnosticText.js +18 -0
  349. package/dist/suppressed/SuppressedService.d.ts +5 -0
  350. package/dist/suppressed/SuppressedService.js +61 -0
  351. package/dist/suppressed/index.d.ts +1 -0
  352. package/dist/suppressed/index.js +1 -0
  353. package/dist/tag.d.ts +1 -3
  354. package/dist/tag.js +2 -5
  355. package/dist/text/TextFile.d.ts +11 -0
  356. package/dist/text/TextFile.js +41 -0
  357. package/dist/text/TextFileService.d.ts +10 -0
  358. package/dist/text/TextFileService.js +31 -0
  359. package/dist/text/index.d.ts +3 -0
  360. package/dist/text/index.js +2 -0
  361. package/dist/text/types.d.ts +5 -0
  362. package/dist/text/types.js +1 -0
  363. package/dist/token/CancellationReason.enum.d.ts +6 -0
  364. package/dist/token/CancellationReason.enum.js +7 -0
  365. package/dist/token/CancellationToken.d.ts +8 -0
  366. package/dist/token/CancellationToken.js +22 -0
  367. package/dist/token/index.d.ts +2 -0
  368. package/dist/token/index.js +2 -0
  369. package/dist/typescript/BaseAdapter.d.ts +36 -0
  370. package/dist/typescript/BaseAdapter.js +83 -0
  371. package/dist/typescript/CompatTypeScript.d.ts +21 -0
  372. package/dist/typescript/CompatTypeScript.js +37 -0
  373. package/dist/typescript/NativeTypeScript.d.ts +24 -0
  374. package/dist/typescript/NativeTypeScript.js +44 -0
  375. package/dist/typescript/index.d.ts +3 -0
  376. package/dist/typescript/index.js +2 -0
  377. package/dist/typescript/types.d.ts +69 -0
  378. package/dist/typescript/types.js +1 -0
  379. package/dist/version/Version.d.ts +6 -0
  380. package/dist/version/Version.js +30 -0
  381. package/dist/version/index.d.ts +1 -0
  382. package/dist/version/index.js +1 -0
  383. package/dist/watch/Debounce.d.ts +9 -0
  384. package/dist/watch/Debounce.js +27 -0
  385. package/dist/watch/FileWatcher.d.ts +5 -0
  386. package/dist/watch/FileWatcher.js +12 -0
  387. package/dist/watch/WatchService.d.ts +8 -0
  388. package/dist/watch/WatchService.js +96 -0
  389. package/dist/watch/Watcher.d.ts +10 -0
  390. package/dist/watch/Watcher.js +31 -0
  391. package/dist/watch/index.d.ts +3 -0
  392. package/dist/watch/index.js +3 -0
  393. package/package.json +9 -1
@@ -0,0 +1,3 @@
1
+ export function sleep(delay) {
2
+ return new Promise((resolve) => setTimeout(resolve, delay));
3
+ }
@@ -0,0 +1 @@
1
+ export { Store } from "./Store.js";
@@ -0,0 +1 @@
1
+ export { Store } from "./Store.js";
@@ -0,0 +1,5 @@
1
+ export declare enum ComparisonResult {
2
+ Pending = 0,
3
+ Identical = 1,
4
+ Different = 2
5
+ }
@@ -0,0 +1,6 @@
1
+ export var ComparisonResult;
2
+ (function (ComparisonResult) {
3
+ ComparisonResult[ComparisonResult["Pending"] = 0] = "Pending";
4
+ ComparisonResult[ComparisonResult["Identical"] = 1] = "Identical";
5
+ ComparisonResult[ComparisonResult["Different"] = 2] = "Different";
6
+ })(ComparisonResult || (ComparisonResult = {}));
@@ -0,0 +1,24 @@
1
+ import type { Checker } from "#checker";
2
+ import type * as ts from "#typescript";
3
+ export declare class Structure {
4
+ #private;
5
+ constructor(ts: ts.TypeScript, program: ts.Program, checker: Checker);
6
+ compare(a: ts.Type, b: ts.Type): boolean;
7
+ compareStructured(a: ts.StructuredType, b: ts.StructuredType): boolean;
8
+ compareInstantiable(a: ts.Type, b: ts.Type): boolean;
9
+ compareIntersections(a: ts.IntersectionType, b: ts.IntersectionType): boolean;
10
+ compareUnions(a: ts.UnionType, b: ts.UnionType): boolean;
11
+ compareObjects(a: ts.ObjectType, b: ts.ObjectType): boolean;
12
+ compareTypeReferences(a: ts.TypeReference, b: ts.TypeReference): boolean;
13
+ compareTuples(a: ts.TupleTypeReference, b: ts.TupleTypeReference): boolean;
14
+ compareStructures(a: ts.Type, b: ts.Type): boolean;
15
+ compareProperties(a: ts.Type, b: ts.Type): boolean;
16
+ compareSignatures(a: ts.Type, b: ts.Type, kind: ts.SignatureKind): boolean;
17
+ compareIndexSignatures(a: ts.Type, b: ts.Type): boolean;
18
+ compareTypeParameters(a: ts.TypeParameter, b: ts.TypeParameter): boolean;
19
+ compareIndexedAccessTypes(a: ts.IndexedAccessType, b: ts.IndexedAccessType): boolean;
20
+ compareConditionalTypes(a: ts.ConditionalType, b: ts.ConditionalType): boolean;
21
+ compareSubstitutionTypes(a: ts.SubstitutionType, b: ts.SubstitutionType): boolean;
22
+ compareTemplateLiteralTypes(a: ts.TemplateLiteralType, b: ts.TemplateLiteralType): boolean;
23
+ compareStringMappingTypes(a: ts.StringMappingType, b: ts.StringMappingType): boolean;
24
+ }
@@ -0,0 +1,481 @@
1
+ export class Structure {
2
+ #checker;
3
+ #compilerOptions;
4
+ #ts;
5
+ #deduplicateCache = new WeakMap();
6
+ #memoizeCache = new Map();
7
+ #recursionStack = [];
8
+ #unusedTypeParametersLookup = new WeakMap();
9
+ constructor(ts, program, checker) {
10
+ this.#ts = ts;
11
+ this.#checker = checker;
12
+ this.#compilerOptions = program.getCompilerOptions();
13
+ }
14
+ #compareMaybeNullish(a, b) {
15
+ if (a != null && b != null) {
16
+ return this.compare(a, b);
17
+ }
18
+ return !a && !b;
19
+ }
20
+ compare(a, b) {
21
+ a = this.#normalize(a);
22
+ b = this.#normalize(b);
23
+ if (a === b) {
24
+ return true;
25
+ }
26
+ if (a.flags & this.#ts.TypeFlags.Any) {
27
+ return !!(b.flags & this.#ts.TypeFlags.Any);
28
+ }
29
+ if (a.flags & this.#ts.TypeFlags.Never) {
30
+ return !!(b.flags & this.#ts.TypeFlags.Never);
31
+ }
32
+ if (a.flags & this.#ts.TypeFlags.Undefined) {
33
+ return !!(b.flags & this.#ts.TypeFlags.Undefined);
34
+ }
35
+ if ((a.flags | b.flags) & this.#ts.TypeFlags.StructuredType) {
36
+ if (a.flags & this.#ts.TypeFlags.StructuredType && b.flags & this.#ts.TypeFlags.StructuredType) {
37
+ return this.#memoize(a, b, () => this.compareStructured(a, b));
38
+ }
39
+ return false;
40
+ }
41
+ if ((a.flags | b.flags) & this.#ts.TypeFlags.Instantiable) {
42
+ if (a.flags & this.#ts.TypeFlags.Instantiable && b.flags & this.#ts.TypeFlags.Instantiable) {
43
+ return this.#memoize(a, b, () => this.compareInstantiable(a, b));
44
+ }
45
+ return false;
46
+ }
47
+ return false;
48
+ }
49
+ compareStructured(a, b) {
50
+ if (this.#checker.isTupleType(a) || this.#checker.isTupleType(b)) {
51
+ if (this.#checker.isTupleType(a) && this.#checker.isTupleType(b)) {
52
+ return this.compareTuples(a, b);
53
+ }
54
+ return false;
55
+ }
56
+ if ((a.flags | b.flags) & this.#ts.TypeFlags.Union) {
57
+ if (a.flags & b.flags & this.#ts.TypeFlags.Union) {
58
+ return this.compareUnions(a, b);
59
+ }
60
+ return false;
61
+ }
62
+ if ((a.flags | b.flags) & this.#ts.TypeFlags.Intersection) {
63
+ if (a.flags & b.flags & this.#ts.TypeFlags.Intersection) {
64
+ if (this.compareIntersections(a, b)) {
65
+ return true;
66
+ }
67
+ }
68
+ if (this.#checker.containsInstantiable(a) || this.#checker.containsInstantiable(b)) {
69
+ return false;
70
+ }
71
+ }
72
+ if ((a.flags | b.flags) & this.#ts.TypeFlags.Object) {
73
+ if (a.flags & b.flags & this.#ts.TypeFlags.Object) {
74
+ return this.compareObjects(a, b);
75
+ }
76
+ }
77
+ return this.compareStructures(a, b);
78
+ }
79
+ compareInstantiable(a, b) {
80
+ if ((a.flags | b.flags) & this.#ts.TypeFlags.TypeParameter) {
81
+ if (a.flags & b.flags & this.#ts.TypeFlags.TypeParameter) {
82
+ return this.compareTypeParameters(a, b);
83
+ }
84
+ return false;
85
+ }
86
+ if ((a.flags | b.flags) & this.#ts.TypeFlags.IndexedAccess) {
87
+ if (a.flags & b.flags & this.#ts.TypeFlags.IndexedAccess) {
88
+ return this.compareIndexedAccessTypes(a, b);
89
+ }
90
+ return false;
91
+ }
92
+ if ((a.flags | b.flags) & this.#ts.TypeFlags.Conditional) {
93
+ if (a.flags & b.flags & this.#ts.TypeFlags.Conditional) {
94
+ return this.compareConditionalTypes(a, b);
95
+ }
96
+ return false;
97
+ }
98
+ if ((a.flags | b.flags) & this.#ts.TypeFlags.Substitution) {
99
+ if (a.flags & b.flags & this.#ts.TypeFlags.Substitution) {
100
+ return this.compareSubstitutionTypes(a, b);
101
+ }
102
+ return false;
103
+ }
104
+ if ((a.flags | b.flags) & this.#ts.TypeFlags.Index) {
105
+ if (a.flags & b.flags & this.#ts.TypeFlags.Index) {
106
+ return this.compare(this.#checker.indexType.getTarget(a), this.#checker.indexType.getTarget(b));
107
+ }
108
+ return false;
109
+ }
110
+ if ((a.flags | b.flags) & this.#ts.TypeFlags.TemplateLiteral) {
111
+ if (a.flags & b.flags & this.#ts.TypeFlags.TemplateLiteral) {
112
+ return this.compareTemplateLiteralTypes(a, b);
113
+ }
114
+ return false;
115
+ }
116
+ if ((a.flags | b.flags) & this.#ts.TypeFlags.StringMapping) {
117
+ if (a.flags & b.flags & this.#ts.TypeFlags.StringMapping) {
118
+ return this.compareStringMappingTypes(a, b);
119
+ }
120
+ }
121
+ return false;
122
+ }
123
+ compareIntersections(a, b) {
124
+ const aTypes = this.#deduplicate(a);
125
+ const bTypes = this.#deduplicate(b);
126
+ if (aTypes.length !== bTypes.length) {
127
+ return false;
128
+ }
129
+ return aTypes.every((aType, i) => this.compare(aType, bTypes[i]));
130
+ }
131
+ compareUnions(a, b) {
132
+ const aTypes = this.#deduplicate(a);
133
+ const bTypes = this.#deduplicate(b);
134
+ if (aTypes.length !== bTypes.length) {
135
+ return false;
136
+ }
137
+ return aTypes.every((aType) => bTypes.some((bType) => this.compare(aType, bType)));
138
+ }
139
+ compareObjects(a, b) {
140
+ if (a.objectFlags & b.objectFlags & this.#ts.ObjectFlags.Reference) {
141
+ if (!((a.objectFlags | b.objectFlags) & this.#ts.ObjectFlags.ClassOrInterface)) {
142
+ return this.compareTypeReferences(a, b);
143
+ }
144
+ }
145
+ return this.compareStructures(a, b);
146
+ }
147
+ compareTypeReferences(a, b) {
148
+ if (this.compare(this.#checker.typeReference.getTarget(a), this.#checker.typeReference.getTarget(b))) {
149
+ const aTypeArguments = this.#checker.getTypeArguments(a);
150
+ const bTypeArguments = this.#checker.getTypeArguments(b);
151
+ const unusedTypeParameters = this.#getUnusedTypeParameterIndexes(this.#checker.typeReference.getTarget(a));
152
+ for (let i = 0; i < aTypeArguments.length; i++) {
153
+ if (unusedTypeParameters.has(i)) {
154
+ continue;
155
+ }
156
+ if (!this.compare(aTypeArguments[i], bTypeArguments[i])) {
157
+ return false;
158
+ }
159
+ }
160
+ return true;
161
+ }
162
+ return this.compareStructures(a, b);
163
+ }
164
+ #getUnusedTypeParameterIndexes(type) {
165
+ const result = new Set();
166
+ const symbol = this.#checker.getSymbol(type);
167
+ const typeParameters = this.#checker.genericType.getTypeParameters(type);
168
+ if (symbol != null) {
169
+ const declarations = this.#checker.getDeclarations(symbol);
170
+ if (declarations != null) {
171
+ const cached = this.#unusedTypeParametersLookup.get(symbol);
172
+ if (cached != null) {
173
+ return cached;
174
+ }
175
+ for (let i = 0; i < typeParameters.length; i++) {
176
+ const symbol = this.#checker.getSymbol(typeParameters[i]);
177
+ const identifier = symbol.declarations[0].name;
178
+ const isUsed = declarations.some((declaration) => this.#isSymbolUsedIn(declaration, symbol, identifier));
179
+ if (!isUsed) {
180
+ result.add(i);
181
+ }
182
+ }
183
+ this.#unusedTypeParametersLookup.set(symbol, result);
184
+ }
185
+ }
186
+ return result;
187
+ }
188
+ #isSymbolUsedIn(node, symbol, identifier, enclosingNode = node) {
189
+ if (node === identifier || (this.#ts.isTypeParameterDeclaration(node) && node.parent === enclosingNode)) {
190
+ return false;
191
+ }
192
+ if (this.#ts.isIdentifier(node) && this.#checker.getSymbolAtLocation(node) === symbol) {
193
+ return true;
194
+ }
195
+ return node.forEachChild((child) => this.#isSymbolUsedIn(child, symbol, identifier, enclosingNode)) ?? false;
196
+ }
197
+ compareTuples(a, b) {
198
+ const aTarget = this.#checker.typeReference.getTarget(a);
199
+ const bTarget = this.#checker.typeReference.getTarget(b);
200
+ if (aTarget.readonly !== bTarget.readonly) {
201
+ return false;
202
+ }
203
+ const aTypeArguments = this.#checker.getTypeArguments(a);
204
+ const bTypeArguments = this.#checker.getTypeArguments(b);
205
+ if (aTypeArguments.length !== bTypeArguments.length) {
206
+ return false;
207
+ }
208
+ for (let i = 0; i < aTypeArguments.length; i++) {
209
+ if (aTarget.elementFlags[i] !== bTarget.elementFlags[i]) {
210
+ return false;
211
+ }
212
+ if (!this.compare(aTypeArguments[i], bTypeArguments[i])) {
213
+ return false;
214
+ }
215
+ }
216
+ return true;
217
+ }
218
+ compareStructures(a, b) {
219
+ if (!this.compareProperties(a, b)) {
220
+ return false;
221
+ }
222
+ if (!this.compareSignatures(a, b, this.#ts.SignatureKind.Call)) {
223
+ return false;
224
+ }
225
+ if (!this.compareSignatures(a, b, this.#ts.SignatureKind.Construct)) {
226
+ return false;
227
+ }
228
+ if (!this.compareIndexSignatures(a, b)) {
229
+ return false;
230
+ }
231
+ return true;
232
+ }
233
+ compareProperties(a, b) {
234
+ const aProperties = this.#checker.getProperties(a);
235
+ const bProperties = this.#checker.getProperties(b);
236
+ if (aProperties.length !== bProperties.length) {
237
+ return false;
238
+ }
239
+ for (const aProperty of aProperties) {
240
+ const bProperty = bProperties.find((bProperty) => bProperty.escapedName === aProperty.escapedName);
241
+ if (!bProperty) {
242
+ return false;
243
+ }
244
+ if (aProperty === bProperty) {
245
+ continue;
246
+ }
247
+ const aAccessibility = this.#checker.getDeclarationModifierFlags(aProperty) & this.#ts.ModifierFlags.NonPublicAccessibilityModifier;
248
+ const bAccessibility = this.#checker.getDeclarationModifierFlags(bProperty) & this.#ts.ModifierFlags.NonPublicAccessibilityModifier;
249
+ if (aAccessibility !== bAccessibility) {
250
+ return false;
251
+ }
252
+ if (aAccessibility) {
253
+ if (this.#checker.getTargetSymbol(aProperty) !== this.#checker.getTargetSymbol(bProperty)) {
254
+ return false;
255
+ }
256
+ }
257
+ if (this.#checker.isOptionalProperty(aProperty) !== this.#checker.isOptionalProperty(bProperty)) {
258
+ return false;
259
+ }
260
+ if (this.#checker.isReadonlyProperty(aProperty) !== this.#checker.isReadonlyProperty(bProperty)) {
261
+ return false;
262
+ }
263
+ const aType = this.#checker.getPropertyType(aProperty, this.#compilerOptions);
264
+ const bType = this.#checker.getPropertyType(bProperty, this.#compilerOptions);
265
+ if (!this.compare(aType, bType)) {
266
+ return false;
267
+ }
268
+ }
269
+ return true;
270
+ }
271
+ compareSignatures(a, b, kind) {
272
+ const aSignatures = this.#checker.getSignatures(a, kind);
273
+ const bSignatures = this.#checker.getSignatures(b, kind);
274
+ if (aSignatures.length !== bSignatures.length) {
275
+ return false;
276
+ }
277
+ for (let i = 0; i < aSignatures.length; i++) {
278
+ const aThisType = this.#checker.signature.getThisParameterType(aSignatures[i]);
279
+ const bThisType = this.#checker.signature.getThisParameterType(bSignatures[i]);
280
+ if (!this.#compareMaybeNullish(aThisType, bThisType)) {
281
+ return false;
282
+ }
283
+ const aParametersCount = this.#checker.getParameterCount(aSignatures[i]);
284
+ const bParametersCount = this.#checker.getParameterCount(bSignatures[i]);
285
+ if (aParametersCount !== bParametersCount) {
286
+ return false;
287
+ }
288
+ for (let j = 0; j < aParametersCount; j++) {
289
+ const aParameter = this.#checker.getParameterFacts(aSignatures[i], j);
290
+ const bParameter = this.#checker.getParameterFacts(bSignatures[i], j);
291
+ if (aParameter.isOptional !== bParameter.isOptional) {
292
+ return false;
293
+ }
294
+ if (aParameter.isRest !== bParameter.isRest) {
295
+ return false;
296
+ }
297
+ if (!this.compare(aParameter.getType(), bParameter.getType())) {
298
+ return false;
299
+ }
300
+ }
301
+ const aReturnType = this.#checker.signature.getReturnType(aSignatures[i]);
302
+ const bReturnType = this.#checker.signature.getReturnType(bSignatures[i]);
303
+ if (!this.compare(aReturnType, bReturnType)) {
304
+ return false;
305
+ }
306
+ const aTypePredicate = this.#checker.signature.getTypePredicate(aSignatures[i]);
307
+ const bTypePredicate = this.#checker.signature.getTypePredicate(bSignatures[i]);
308
+ if (aTypePredicate?.parameterIndex !== bTypePredicate?.parameterIndex) {
309
+ return false;
310
+ }
311
+ if (aTypePredicate?.kind !== bTypePredicate?.kind ||
312
+ !this.#compareMaybeNullish(aTypePredicate?.type, bTypePredicate?.type)) {
313
+ return false;
314
+ }
315
+ }
316
+ return true;
317
+ }
318
+ compareIndexSignatures(a, b) {
319
+ const aSignatures = this.#checker.getIndexSignatures(a);
320
+ const bSignatures = this.#checker.getIndexSignatures(b);
321
+ if (aSignatures.length !== bSignatures.length) {
322
+ return false;
323
+ }
324
+ return aSignatures.every((aSignature) => {
325
+ return bSignatures.some((bSignature) => {
326
+ if (aSignature.isReadonly !== bSignature.isReadonly) {
327
+ return false;
328
+ }
329
+ if (!this.compare(aSignature.keyType, bSignature.keyType)) {
330
+ return false;
331
+ }
332
+ if (!this.compare("valueType" in aSignature ? aSignature.valueType : aSignature.type, "valueType" in bSignature ? bSignature.valueType : bSignature.type)) {
333
+ return false;
334
+ }
335
+ return true;
336
+ });
337
+ });
338
+ }
339
+ compareTypeParameters(a, b) {
340
+ if (this.#checker.getTypeParameterModifiers(a) !== this.#checker.getTypeParameterModifiers(b)) {
341
+ return false;
342
+ }
343
+ if (!this.#compareMaybeNullish(this.#checker.typeParameter.getConstraint(a), this.#checker.typeParameter.getConstraint(b))) {
344
+ return false;
345
+ }
346
+ if (!this.#compareMaybeNullish(this.#checker.typeParameter.getDefault(a), this.#checker.typeParameter.getDefault(b))) {
347
+ return false;
348
+ }
349
+ return true;
350
+ }
351
+ compareIndexedAccessTypes(a, b) {
352
+ if (!this.compare(this.#checker.indexedAccessType.getObjectType(a), this.#checker.indexedAccessType.getObjectType(b))) {
353
+ return false;
354
+ }
355
+ if (!this.compare(this.#checker.indexedAccessType.getIndexType(a), this.#checker.indexedAccessType.getIndexType(b))) {
356
+ return false;
357
+ }
358
+ return true;
359
+ }
360
+ compareConditionalTypes(a, b) {
361
+ if (!this.compare(this.#checker.conditionalType.getCheckType(a), this.#checker.conditionalType.getCheckType(b))) {
362
+ return false;
363
+ }
364
+ if (!this.compare(this.#checker.conditionalType.getExtendsType(a), this.#checker.conditionalType.getExtendsType(b))) {
365
+ return false;
366
+ }
367
+ if (!this.compare(this.#checker.conditionalType.getTrueType(a), this.#checker.conditionalType.getTrueType(b))) {
368
+ return false;
369
+ }
370
+ if (!this.compare(this.#checker.conditionalType.getFalseType(a), this.#checker.conditionalType.getFalseType(b))) {
371
+ return false;
372
+ }
373
+ return true;
374
+ }
375
+ compareSubstitutionTypes(a, b) {
376
+ if (!this.compare(this.#checker.substitutionType.getBaseType(a), this.#checker.substitutionType.getBaseType(b))) {
377
+ return false;
378
+ }
379
+ if (!this.compare(this.#checker.substitutionType.getConstraint(a), this.#checker.substitutionType.getConstraint(b))) {
380
+ return false;
381
+ }
382
+ return true;
383
+ }
384
+ compareTemplateLiteralTypes(a, b) {
385
+ if (a.texts.length !== b.texts.length) {
386
+ return false;
387
+ }
388
+ const aTypes = this.#checker.templateLiteralType.getTypes(a);
389
+ const bTypes = this.#checker.templateLiteralType.getTypes(b);
390
+ for (let i = 0; i < a.texts.length; i++) {
391
+ if (a.texts[i] !== b.texts[i]) {
392
+ return false;
393
+ }
394
+ if (!this.#compareMaybeNullish(aTypes[i], bTypes[i])) {
395
+ return false;
396
+ }
397
+ }
398
+ return true;
399
+ }
400
+ compareStringMappingTypes(a, b) {
401
+ if (this.#checker.getSymbol(a) !== this.#checker.getSymbol(b)) {
402
+ return false;
403
+ }
404
+ if (!this.compare(this.#checker.stringMappingType.getTarget(a), this.#checker.stringMappingType.getTarget(b))) {
405
+ return false;
406
+ }
407
+ return true;
408
+ }
409
+ #deduplicate(target) {
410
+ let result = this.#deduplicateCache.get(target);
411
+ if (result) {
412
+ return result;
413
+ }
414
+ const types = this.#checker.unionOrIntersection.getTypes(target);
415
+ result = types.slice(0, 1);
416
+ for (let i = 1; i < types.length; i++) {
417
+ if (!result.some((existing) => this.compare(existing, types[i]))) {
418
+ result.push(types[i]);
419
+ }
420
+ }
421
+ this.#deduplicateCache.set(target, result);
422
+ return result;
423
+ }
424
+ #getRecursionIdentity(type) {
425
+ return this.#checker.getAliasSymbol(type) ?? this.#checker.getSymbol(type);
426
+ }
427
+ #isInfiniteRecursion(a, b) {
428
+ const aIdentity = this.#getRecursionIdentity(a);
429
+ const bIdentity = this.#getRecursionIdentity(b);
430
+ if (!aIdentity || !bIdentity) {
431
+ return false;
432
+ }
433
+ let matches = 0;
434
+ for (const frame of this.#recursionStack) {
435
+ if (frame.aIdentity === aIdentity && frame.bIdentity === bIdentity && a.id > frame.aId && b.id > frame.bId) {
436
+ matches++;
437
+ if (matches >= 2) {
438
+ return true;
439
+ }
440
+ }
441
+ }
442
+ return false;
443
+ }
444
+ #memoize(a, b, compare) {
445
+ const key = [a.id, b.id].sort((a, b) => a - b).join(":");
446
+ const result = this.#memoizeCache.get(key);
447
+ if (result !== undefined) {
448
+ return result !== 2;
449
+ }
450
+ if (this.#isInfiniteRecursion(a, b)) {
451
+ this.#memoizeCache.set(key, 1);
452
+ return true;
453
+ }
454
+ this.#memoizeCache.set(key, 0);
455
+ const aIdentity = this.#getRecursionIdentity(a);
456
+ const bIdentity = this.#getRecursionIdentity(b);
457
+ if (aIdentity != null && bIdentity != null) {
458
+ this.#recursionStack.push({ aId: a.id, bId: b.id, aIdentity, bIdentity });
459
+ }
460
+ const isSame = compare();
461
+ if (aIdentity != null && bIdentity != null) {
462
+ this.#recursionStack.pop();
463
+ }
464
+ this.#memoizeCache.set(key, isSame ? 1 : 2);
465
+ return isSame;
466
+ }
467
+ #normalize(type) {
468
+ type = this.#checker.getReducedType(type);
469
+ if (type.flags & this.#ts.TypeFlags.Freshable &&
470
+ this.#checker.freshableType.getFreshType(type) === type) {
471
+ return this.#checker.freshableType.getRegularType(type);
472
+ }
473
+ if (type.flags & this.#ts.TypeFlags.UnionOrIntersection) {
474
+ const parts = this.#deduplicate(type);
475
+ if (parts.length === 1) {
476
+ return parts.at(0);
477
+ }
478
+ }
479
+ return type;
480
+ }
481
+ }
@@ -0,0 +1 @@
1
+ export { Structure } from "./Structure.js";
@@ -0,0 +1 @@
1
+ export { Structure } from "./Structure.js";
@@ -0,0 +1,6 @@
1
+ export declare class SuppressedDiagnosticText {
2
+ static directiveRequires(): Array<string>;
3
+ static messageDidNotMatch(): string;
4
+ static onlySingleError(): string;
5
+ static suppressedError(count?: number): string;
6
+ }
@@ -0,0 +1,18 @@
1
+ export class SuppressedDiagnosticText {
2
+ static directiveRequires() {
3
+ return [
4
+ "Directive requires an argument.",
5
+ "Add a fragment of the expected error message after the directive.",
6
+ "To ignore the directive, append the '!' character after it.",
7
+ ];
8
+ }
9
+ static messageDidNotMatch() {
10
+ return "The diagnostic message did not match.";
11
+ }
12
+ static onlySingleError() {
13
+ return "Only a single error can be suppressed.";
14
+ }
15
+ static suppressedError(count = 1) {
16
+ return `The suppressed error${count === 1 ? "" : "s"}:`;
17
+ }
18
+ }
@@ -0,0 +1,5 @@
1
+ import type { TestTree } from "#collect";
2
+ export declare class SuppressedService {
3
+ #private;
4
+ match(testTree: TestTree): void;
5
+ }
@@ -0,0 +1,61 @@
1
+ import { Diagnostic, DiagnosticOrigin, getDiagnosticMessageText } from "#diagnostic";
2
+ import { EventEmitter } from "#events";
3
+ import { SuppressedResult } from "#result";
4
+ import { TextFileService } from "#text";
5
+ import { SuppressedDiagnosticText } from "./SuppressedDiagnosticText.js";
6
+ export class SuppressedService {
7
+ match(testTree) {
8
+ if (!testTree.suppressedErrors) {
9
+ return;
10
+ }
11
+ for (const suppressedError of testTree.suppressedErrors) {
12
+ const suppressedResult = new SuppressedResult(suppressedError);
13
+ if (suppressedError.diagnostics.length === 0) {
14
+ continue;
15
+ }
16
+ if (suppressedError.ignore) {
17
+ EventEmitter.dispatch(["suppressed:ignore", { result: suppressedResult }]);
18
+ continue;
19
+ }
20
+ const related = [
21
+ Diagnostic.error(SuppressedDiagnosticText.suppressedError(suppressedError.diagnostics.length)),
22
+ ...Diagnostic.fromDiagnostics(suppressedError.diagnostics),
23
+ ];
24
+ const origin = new DiagnosticOrigin(suppressedError.directive.start, suppressedError.directive.end, TextFileService.get(testTree.sourceFile));
25
+ if (!suppressedError.argument?.text) {
26
+ const text = SuppressedDiagnosticText.directiveRequires();
27
+ this.#onDiagnostics(Diagnostic.error(text, origin).add({ related }), suppressedResult);
28
+ continue;
29
+ }
30
+ if (suppressedError.diagnostics.length > 1) {
31
+ const text = SuppressedDiagnosticText.onlySingleError();
32
+ this.#onDiagnostics(Diagnostic.error(text, origin).add({ related }), suppressedResult);
33
+ continue;
34
+ }
35
+ const messageText = getDiagnosticMessageText(suppressedError.diagnostics[0]).join("\n");
36
+ if (!this.#matchMessage(messageText, suppressedError.argument.text)) {
37
+ const text = SuppressedDiagnosticText.messageDidNotMatch();
38
+ const origin = new DiagnosticOrigin(suppressedError.argument.start, suppressedError.argument.end, TextFileService.get(testTree.sourceFile));
39
+ this.#onDiagnostics(Diagnostic.error(text, origin).add({ related }), suppressedResult);
40
+ continue;
41
+ }
42
+ EventEmitter.dispatch(["suppressed:match", { result: suppressedResult }]);
43
+ }
44
+ }
45
+ #matchMessage(source, target) {
46
+ if (target.includes("...")) {
47
+ let position = 0;
48
+ for (const segment of target.split("...")) {
49
+ position = source.indexOf(segment, position);
50
+ if (position === -1) {
51
+ break;
52
+ }
53
+ }
54
+ return position > 0;
55
+ }
56
+ return source.includes(target);
57
+ }
58
+ #onDiagnostics(diagnostic, result) {
59
+ EventEmitter.dispatch(["suppressed:error", { diagnostics: [diagnostic], result }]);
60
+ }
61
+ }
@@ -0,0 +1 @@
1
+ export { SuppressedService } from "./SuppressedService.js";
@@ -0,0 +1 @@
1
+ export { SuppressedService } from "./SuppressedService.js";
package/dist/tag.d.ts CHANGED
@@ -3,6 +3,4 @@
3
3
  *
4
4
  * @returns A promise that resolves if the test run is successful and rejects if it fails.
5
5
  */
6
- declare function tstyche(template: TemplateStringsArray, ...substitutions: Array<string>): Promise<void>;
7
-
8
- export { tstyche as default };
6
+ export default function tstyche(template: TemplateStringsArray, ...substitutions: Array<string>): Promise<void>;
package/dist/tag.js CHANGED
@@ -1,6 +1,5 @@
1
- import { Cli } from './api.js';
2
-
3
- async function tstyche(template, ...substitutions) {
1
+ import { Cli } from "./api.js";
2
+ export default async function tstyche(template, ...substitutions) {
4
3
  const cli = new Cli();
5
4
  const commandLine = String.raw(template, ...substitutions).split(/\s+/);
6
5
  const exitCode = await cli.run(commandLine);
@@ -8,5 +7,3 @@ async function tstyche(template, ...substitutions) {
8
7
  throw new Error("TSTyche test run failed. Check the output above for details.");
9
8
  }
10
9
  }
11
-
12
- export { tstyche as default };
@@ -0,0 +1,11 @@
1
+ export declare class TextFile {
2
+ #private;
3
+ path: string;
4
+ text: string;
5
+ constructor(path: string, text: string);
6
+ getLineMap(): Array<number>;
7
+ getLocation(position: number): {
8
+ line: number;
9
+ character: number;
10
+ };
11
+ }