hinmil 0.0.0-stage → 0.2.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 (301) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +2306 -2
  3. package/dist/cli.d.ts +15 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +338 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/commentParser.d.ts +384 -0
  8. package/dist/commentParser.d.ts.map +1 -0
  9. package/dist/commentParser.js +2487 -0
  10. package/dist/commentParser.js.map +1 -0
  11. package/dist/config.d.ts +203 -0
  12. package/dist/config.d.ts.map +1 -0
  13. package/dist/config.js +375 -0
  14. package/dist/config.js.map +1 -0
  15. package/dist/debugLog.d.ts +13 -0
  16. package/dist/debugLog.d.ts.map +1 -0
  17. package/dist/debugLog.js +44 -0
  18. package/dist/debugLog.js.map +1 -0
  19. package/dist/estree.d.ts +100 -0
  20. package/dist/estree.d.ts.map +1 -0
  21. package/dist/estree.js +34 -0
  22. package/dist/estree.js.map +1 -0
  23. package/dist/hm/env.d.ts +134 -0
  24. package/dist/hm/env.d.ts.map +1 -0
  25. package/dist/hm/env.js +939 -0
  26. package/dist/hm/env.js.map +1 -0
  27. package/dist/hm/index.d.ts +7 -0
  28. package/dist/hm/index.d.ts.map +1 -0
  29. package/dist/hm/index.js +26 -0
  30. package/dist/hm/index.js.map +1 -0
  31. package/dist/hm/substitution.d.ts +57 -0
  32. package/dist/hm/substitution.d.ts.map +1 -0
  33. package/dist/hm/substitution.js +546 -0
  34. package/dist/hm/substitution.js.map +1 -0
  35. package/dist/hm/typeParser.d.ts +39 -0
  36. package/dist/hm/typeParser.d.ts.map +1 -0
  37. package/dist/hm/typeParser.js +1285 -0
  38. package/dist/hm/typeParser.js.map +1 -0
  39. package/dist/hm/typeUtils.d.ts +248 -0
  40. package/dist/hm/typeUtils.d.ts.map +1 -0
  41. package/dist/hm/typeUtils.js +905 -0
  42. package/dist/hm/typeUtils.js.map +1 -0
  43. package/dist/hm/types.d.ts +738 -0
  44. package/dist/hm/types.d.ts.map +1 -0
  45. package/dist/hm/types.js +1853 -0
  46. package/dist/hm/types.js.map +1 -0
  47. package/dist/hm/unify.d.ts +59 -0
  48. package/dist/hm/unify.d.ts.map +1 -0
  49. package/dist/hm/unify.js +1700 -0
  50. package/dist/hm/unify.js.map +1 -0
  51. package/dist/index.d.ts +20 -0
  52. package/dist/index.d.ts.map +1 -0
  53. package/dist/index.js +196 -0
  54. package/dist/index.js.map +1 -0
  55. package/dist/infer/annotation-rigid.d.ts +76 -0
  56. package/dist/infer/annotation-rigid.d.ts.map +1 -0
  57. package/dist/infer/annotation-rigid.js +542 -0
  58. package/dist/infer/annotation-rigid.js.map +1 -0
  59. package/dist/infer/annotation-validation.d.ts +109 -0
  60. package/dist/infer/annotation-validation.d.ts.map +1 -0
  61. package/dist/infer/annotation-validation.js +1078 -0
  62. package/dist/infer/annotation-validation.js.map +1 -0
  63. package/dist/infer/annotations.d.ts +277 -0
  64. package/dist/infer/annotations.d.ts.map +1 -0
  65. package/dist/infer/annotations.js +1343 -0
  66. package/dist/infer/annotations.js.map +1 -0
  67. package/dist/infer/call-overloads.d.ts +24 -0
  68. package/dist/infer/call-overloads.d.ts.map +1 -0
  69. package/dist/infer/call-overloads.js +900 -0
  70. package/dist/infer/call-overloads.js.map +1 -0
  71. package/dist/infer/call-rows.d.ts +154 -0
  72. package/dist/infer/call-rows.d.ts.map +1 -0
  73. package/dist/infer/call-rows.js +2162 -0
  74. package/dist/infer/call-rows.js.map +1 -0
  75. package/dist/infer/calls.d.ts +20 -0
  76. package/dist/infer/calls.d.ts.map +1 -0
  77. package/dist/infer/calls.js +1468 -0
  78. package/dist/infer/calls.js.map +1 -0
  79. package/dist/infer/constraints.d.ts +99 -0
  80. package/dist/infer/constraints.d.ts.map +1 -0
  81. package/dist/infer/constraints.js +1208 -0
  82. package/dist/infer/constraints.js.map +1 -0
  83. package/dist/infer/expr-assignment.d.ts +20 -0
  84. package/dist/infer/expr-assignment.d.ts.map +1 -0
  85. package/dist/infer/expr-assignment.js +620 -0
  86. package/dist/infer/expr-assignment.js.map +1 -0
  87. package/dist/infer/expr-constraint-lookup.d.ts +44 -0
  88. package/dist/infer/expr-constraint-lookup.d.ts.map +1 -0
  89. package/dist/infer/expr-constraint-lookup.js +207 -0
  90. package/dist/infer/expr-constraint-lookup.js.map +1 -0
  91. package/dist/infer/expr-functions.d.ts +20 -0
  92. package/dist/infer/expr-functions.d.ts.map +1 -0
  93. package/dist/infer/expr-functions.js +1359 -0
  94. package/dist/infer/expr-functions.js.map +1 -0
  95. package/dist/infer/expr-jsx.d.ts +19 -0
  96. package/dist/infer/expr-jsx.d.ts.map +1 -0
  97. package/dist/infer/expr-jsx.js +310 -0
  98. package/dist/infer/expr-jsx.js.map +1 -0
  99. package/dist/infer/expr-member.d.ts +40 -0
  100. package/dist/infer/expr-member.d.ts.map +1 -0
  101. package/dist/infer/expr-member.js +1154 -0
  102. package/dist/infer/expr-member.js.map +1 -0
  103. package/dist/infer/expr-prototype.d.ts +11 -0
  104. package/dist/infer/expr-prototype.d.ts.map +1 -0
  105. package/dist/infer/expr-prototype.js +202 -0
  106. package/dist/infer/expr-prototype.js.map +1 -0
  107. package/dist/infer/expressions.d.ts +40 -0
  108. package/dist/infer/expressions.d.ts.map +1 -0
  109. package/dist/infer/expressions.js +1497 -0
  110. package/dist/infer/expressions.js.map +1 -0
  111. package/dist/infer/functionPatterns.d.ts +229 -0
  112. package/dist/infer/functionPatterns.d.ts.map +1 -0
  113. package/dist/infer/functionPatterns.js +1035 -0
  114. package/dist/infer/functionPatterns.js.map +1 -0
  115. package/dist/infer/helpers.d.ts +73 -0
  116. package/dist/infer/helpers.d.ts.map +1 -0
  117. package/dist/infer/helpers.js +187 -0
  118. package/dist/infer/helpers.js.map +1 -0
  119. package/dist/infer/index.d.ts +551 -0
  120. package/dist/infer/index.d.ts.map +1 -0
  121. package/dist/infer/index.js +1127 -0
  122. package/dist/infer/index.js.map +1 -0
  123. package/dist/infer/jsx-dom.d.ts +26 -0
  124. package/dist/infer/jsx-dom.d.ts.map +1 -0
  125. package/dist/infer/jsx-dom.js +303 -0
  126. package/dist/infer/jsx-dom.js.map +1 -0
  127. package/dist/infer/moduleReps.d.ts +7 -0
  128. package/dist/infer/moduleReps.d.ts.map +1 -0
  129. package/dist/infer/moduleReps.js +48 -0
  130. package/dist/infer/moduleReps.js.map +1 -0
  131. package/dist/infer/modules.d.ts +10 -0
  132. package/dist/infer/modules.d.ts.map +1 -0
  133. package/dist/infer/modules.js +775 -0
  134. package/dist/infer/modules.js.map +1 -0
  135. package/dist/infer/narrowing.d.ts +199 -0
  136. package/dist/infer/narrowing.d.ts.map +1 -0
  137. package/dist/infer/narrowing.js +1428 -0
  138. package/dist/infer/narrowing.js.map +1 -0
  139. package/dist/infer/results.d.ts +24 -0
  140. package/dist/infer/results.d.ts.map +1 -0
  141. package/dist/infer/results.js +611 -0
  142. package/dist/infer/results.js.map +1 -0
  143. package/dist/infer/setupPass.d.ts +11 -0
  144. package/dist/infer/setupPass.d.ts.map +1 -0
  145. package/dist/infer/setupPass.js +524 -0
  146. package/dist/infer/setupPass.js.map +1 -0
  147. package/dist/infer/statements.d.ts +26 -0
  148. package/dist/infer/statements.d.ts.map +1 -0
  149. package/dist/infer/statements.js +750 -0
  150. package/dist/infer/statements.js.map +1 -0
  151. package/dist/infer/stmt-bindings.d.ts +22 -0
  152. package/dist/infer/stmt-bindings.d.ts.map +1 -0
  153. package/dist/infer/stmt-bindings.js +1482 -0
  154. package/dist/infer/stmt-bindings.js.map +1 -0
  155. package/dist/infer/stmt-destructure.d.ts +29 -0
  156. package/dist/infer/stmt-destructure.d.ts.map +1 -0
  157. package/dist/infer/stmt-destructure.js +490 -0
  158. package/dist/infer/stmt-destructure.js.map +1 -0
  159. package/dist/infer/types.d.ts +220 -0
  160. package/dist/infer/types.d.ts.map +1 -0
  161. package/dist/infer/types.js +46 -0
  162. package/dist/infer/types.js.map +1 -0
  163. package/dist/infer/unifyDiag.d.ts +46 -0
  164. package/dist/infer/unifyDiag.d.ts.map +1 -0
  165. package/dist/infer/unifyDiag.js +642 -0
  166. package/dist/infer/unifyDiag.js.map +1 -0
  167. package/dist/parsing-babel.d.ts +3 -0
  168. package/dist/parsing-babel.d.ts.map +1 -0
  169. package/dist/parsing-babel.js +353 -0
  170. package/dist/parsing-babel.js.map +1 -0
  171. package/dist/parsing.d.ts +69 -0
  172. package/dist/parsing.d.ts.map +1 -0
  173. package/dist/parsing.js +288 -0
  174. package/dist/parsing.js.map +1 -0
  175. package/dist/registries/constraintRegistry.d.ts +233 -0
  176. package/dist/registries/constraintRegistry.d.ts.map +1 -0
  177. package/dist/registries/constraintRegistry.js +803 -0
  178. package/dist/registries/constraintRegistry.js.map +1 -0
  179. package/dist/registries/dataTypeRegistry.d.ts +63 -0
  180. package/dist/registries/dataTypeRegistry.d.ts.map +1 -0
  181. package/dist/registries/dataTypeRegistry.js +180 -0
  182. package/dist/registries/dataTypeRegistry.js.map +1 -0
  183. package/dist/registries/domGlobals.d.ts +33 -0
  184. package/dist/registries/domGlobals.d.ts.map +1 -0
  185. package/dist/registries/domGlobals.js +309 -0
  186. package/dist/registries/domGlobals.js.map +1 -0
  187. package/dist/registries/methodRegistry.d.ts +277 -0
  188. package/dist/registries/methodRegistry.d.ts.map +1 -0
  189. package/dist/registries/methodRegistry.js +2074 -0
  190. package/dist/registries/methodRegistry.js.map +1 -0
  191. package/dist/registries/session.d.ts +38 -0
  192. package/dist/registries/session.d.ts.map +1 -0
  193. package/dist/registries/session.js +75 -0
  194. package/dist/registries/session.js.map +1 -0
  195. package/dist/server.d.ts +2 -0
  196. package/dist/server.d.ts.map +1 -0
  197. package/dist/server.js +1896 -0
  198. package/dist/server.js.map +1 -0
  199. package/dist/services/codeActions.d.ts +22 -0
  200. package/dist/services/codeActions.d.ts.map +1 -0
  201. package/dist/services/codeActions.js +465 -0
  202. package/dist/services/codeActions.js.map +1 -0
  203. package/dist/services/completion.d.ts +259 -0
  204. package/dist/services/completion.d.ts.map +1 -0
  205. package/dist/services/completion.js +2794 -0
  206. package/dist/services/completion.js.map +1 -0
  207. package/dist/services/definitions.d.ts +37 -0
  208. package/dist/services/definitions.d.ts.map +1 -0
  209. package/dist/services/definitions.js +605 -0
  210. package/dist/services/definitions.js.map +1 -0
  211. package/dist/services/diagnosticCodes.d.ts +70 -0
  212. package/dist/services/diagnosticCodes.d.ts.map +1 -0
  213. package/dist/services/diagnosticCodes.js +239 -0
  214. package/dist/services/diagnosticCodes.js.map +1 -0
  215. package/dist/services/diagnostics.d.ts +86 -0
  216. package/dist/services/diagnostics.d.ts.map +1 -0
  217. package/dist/services/diagnostics.js +665 -0
  218. package/dist/services/diagnostics.js.map +1 -0
  219. package/dist/services/documentCache.d.ts +88 -0
  220. package/dist/services/documentCache.d.ts.map +1 -0
  221. package/dist/services/documentCache.js +108 -0
  222. package/dist/services/documentCache.js.map +1 -0
  223. package/dist/services/documentSymbols.d.ts +20 -0
  224. package/dist/services/documentSymbols.d.ts.map +1 -0
  225. package/dist/services/documentSymbols.js +381 -0
  226. package/dist/services/documentSymbols.js.map +1 -0
  227. package/dist/services/fileSelection.d.ts +24 -0
  228. package/dist/services/fileSelection.d.ts.map +1 -0
  229. package/dist/services/fileSelection.js +154 -0
  230. package/dist/services/fileSelection.js.map +1 -0
  231. package/dist/services/fileSelectionRefresh.d.ts +26 -0
  232. package/dist/services/fileSelectionRefresh.d.ts.map +1 -0
  233. package/dist/services/fileSelectionRefresh.js +77 -0
  234. package/dist/services/fileSelectionRefresh.js.map +1 -0
  235. package/dist/services/files.d.ts +342 -0
  236. package/dist/services/files.d.ts.map +1 -0
  237. package/dist/services/files.js +1712 -0
  238. package/dist/services/files.js.map +1 -0
  239. package/dist/services/fsProbe.d.ts +14 -0
  240. package/dist/services/fsProbe.d.ts.map +1 -0
  241. package/dist/services/fsProbe.js +112 -0
  242. package/dist/services/fsProbe.js.map +1 -0
  243. package/dist/services/globalsLoader.d.ts +20 -0
  244. package/dist/services/globalsLoader.d.ts.map +1 -0
  245. package/dist/services/globalsLoader.js +122 -0
  246. package/dist/services/globalsLoader.js.map +1 -0
  247. package/dist/services/hmFileServices.d.ts +113 -0
  248. package/dist/services/hmFileServices.d.ts.map +1 -0
  249. package/dist/services/hmFileServices.js +686 -0
  250. package/dist/services/hmFileServices.js.map +1 -0
  251. package/dist/services/hover.d.ts +280 -0
  252. package/dist/services/hover.d.ts.map +1 -0
  253. package/dist/services/hover.js +1687 -0
  254. package/dist/services/hover.js.map +1 -0
  255. package/dist/services/importContext.d.ts +396 -0
  256. package/dist/services/importContext.d.ts.map +1 -0
  257. package/dist/services/importContext.js +1999 -0
  258. package/dist/services/importContext.js.map +1 -0
  259. package/dist/services/projectChecker.d.ts +50 -0
  260. package/dist/services/projectChecker.d.ts.map +1 -0
  261. package/dist/services/projectChecker.js +228 -0
  262. package/dist/services/projectChecker.js.map +1 -0
  263. package/dist/services/references.d.ts +41 -0
  264. package/dist/services/references.d.ts.map +1 -0
  265. package/dist/services/references.js +757 -0
  266. package/dist/services/references.js.map +1 -0
  267. package/dist/services/rename.d.ts +22 -0
  268. package/dist/services/rename.d.ts.map +1 -0
  269. package/dist/services/rename.js +101 -0
  270. package/dist/services/rename.js.map +1 -0
  271. package/dist/services/shortCircuit.d.ts +27 -0
  272. package/dist/services/shortCircuit.d.ts.map +1 -0
  273. package/dist/services/shortCircuit.js +28 -0
  274. package/dist/services/shortCircuit.js.map +1 -0
  275. package/dist/services/sidecarPerf.d.ts +19 -0
  276. package/dist/services/sidecarPerf.d.ts.map +1 -0
  277. package/dist/services/sidecarPerf.js +59 -0
  278. package/dist/services/sidecarPerf.js.map +1 -0
  279. package/dist/services/signatureHelp.d.ts +27 -0
  280. package/dist/services/signatureHelp.d.ts.map +1 -0
  281. package/dist/services/signatureHelp.js +984 -0
  282. package/dist/services/signatureHelp.js.map +1 -0
  283. package/dist/walking.d.ts +25 -0
  284. package/dist/walking.d.ts.map +1 -0
  285. package/dist/walking.js +107 -0
  286. package/dist/walking.js.map +1 -0
  287. package/hm-types-builtin/assert.hm +20 -0
  288. package/hm-types-builtin/buffer.hm +8 -0
  289. package/hm-types-builtin/child_process.hm +16 -0
  290. package/hm-types-builtin/crypto.hm +17 -0
  291. package/hm-types-builtin/fs.hm +15 -0
  292. package/hm-types-builtin/http.hm +14 -0
  293. package/hm-types-builtin/os.hm +19 -0
  294. package/hm-types-builtin/path.hm +18 -0
  295. package/hm-types-builtin/react-dom.hm +27 -0
  296. package/hm-types-builtin/react.hm +113 -0
  297. package/hm-types-builtin/url.hm +7 -0
  298. package/hm-types-builtin/zlib.hm +12 -0
  299. package/package.json +53 -4
  300. package/schemas/hinmil.config.schema.json +261 -0
  301. package/schemas/package-hinmil.schema.json +59 -0
@@ -0,0 +1,384 @@
1
+ import type * as estree from './estree';
2
+ import { Type, Scheme } from './hm/types';
3
+ /** Sentinel comment inserted between sidecar/override parts in the merged
4
+ * source returned by `ImportInferenceContext.createTypeDirectiveResolver`.
5
+ * `processTypeDirectives` splits on it to apply override semantics for
6
+ * instance-callables (later parts win on `Name() :: ...` collisions).
7
+ * Comments survive the JS-parse pass that processes the merged source
8
+ * for annotations, so the sentinel itself is harmless to all other
9
+ * consumers. */
10
+ export declare const TYPE_DIRECTIVE_PART_BOUNDARY = "//__HM_TYPE_DIRECTIVE_BOUNDARY__";
11
+ /**
12
+ * Extract X.prototype.method pattern from a MemberExpression node.
13
+ * Returns { typeName, methodName } or null.
14
+ */
15
+ export declare function extractPrototypeMethod(memberExpr: estree.MemberExpression): {
16
+ typeName: string;
17
+ methodName: string;
18
+ } | null;
19
+ /**
20
+ * Provenance of a `TypeAnnotation` entry in `engine.annotationMap`.
21
+ *
22
+ * `annotationMap` is a junction point: file-local annotations live next
23
+ * to entries merged in from project globals (`engine.globalsSource`),
24
+ * `// ::types <pkg>` directive targets, and imported packages. Many
25
+ * features (export schemes, dotted-name constraint injection, prototype
26
+ * receiver inference, bare-binding annotation lookup …) must only honour
27
+ * file-local entries — otherwise a sidecar's `default :: ...` or a
28
+ * library's `field :: ...` silently hijacks unrelated user bindings.
29
+ *
30
+ * Consumers that need a strict file-local check should use the
31
+ * `isLocalAnnotation` helper (see `infer/annotations.ts`) rather than
32
+ * comparing this field directly; that helper is the single source of
33
+ * truth for "treat absent as 'local' for backwards-compat" and any
34
+ * future origin refinement.
35
+ */
36
+ export type AnnotationOrigin =
37
+ /** Parsed from the file currently being inferred. Trusted as authoritative. */
38
+ 'local'
39
+ /** Merged from `engine.globalsSource` (user globals file +
40
+ * project `::types` addendum + package globals concatenation). */
41
+ | 'globals'
42
+ /** Merged via a `// ::types <specifier>` directive resolution. */
43
+ | 'directive'
44
+ /** Sourced from an imported module's exports / sidecar. Reserved;
45
+ * no production path writes this today. */
46
+ | 'imported';
47
+ export interface TypeAnnotation {
48
+ /** The raw signature text after `::` */
49
+ raw: string;
50
+ /** Parsed scheme (null if parsing failed) */
51
+ scheme: Scheme | null;
52
+ /** Parse error message, if any */
53
+ error?: string;
54
+ /** Comment start offset in source */
55
+ commentStart: number;
56
+ /** Comment end offset in source */
57
+ commentEnd: number;
58
+ /** Name of the declaration this annotation is attached to (if found) */
59
+ name?: string;
60
+ /** Start offset of the declaration node */
61
+ nodeStart?: number;
62
+ /** Start offset of the declaration name identifier */
63
+ nameStart?: number;
64
+ /** End offset of the declaration name identifier */
65
+ nameEnd?: number;
66
+ /** Receiver type for method annotations (when ~> is used) */
67
+ receiver?: Type;
68
+ /** Method type for method annotations (right side of ~>) */
69
+ methodType?: Type;
70
+ /** When set, the annotation's method name didn't match the attached
71
+ * declaration's method name. Contains the ACTUAL declaration method name. */
72
+ methodNameMismatch?: string;
73
+ /** When set, the annotation's regular name didn't match the attached
74
+ * declaration's name. Contains the ACTUAL declaration name. */
75
+ nameMismatch?: string;
76
+ /** Start offset of the mismatched name identifier */
77
+ mismatchNameStart?: number;
78
+ /** End offset of the mismatched name identifier */
79
+ mismatchNameEnd?: number;
80
+ /** When ::narrow is used on a method annotation, the variant name to narrow to */
81
+ narrowVariant?: string;
82
+ /** Source span of the `::narrow` directive comment line (when present), used
83
+ * to anchor inference-time diagnostics about the directive (e.g. an
84
+ * unknown parameter name). */
85
+ narrowLoc?: {
86
+ start: number;
87
+ end: number;
88
+ };
89
+ /** When `::hidden` is used on the line above this annotation, this property/
90
+ * method should NOT be offered in completion lists. It remains fully
91
+ * usable when the user types it explicitly (hover, signature help and
92
+ * inference work as normal). Constructor properties are hidden
93
+ * implicitly without this flag. */
94
+ hidden?: boolean;
95
+ /** When `::private` is used on the line above this annotation, the
96
+ * member is private to the owning type: accessible via `this.x` inside
97
+ * the class / prototype methods, but NOT from outside. Outside access
98
+ * (`obj.x`) emits a diagnostic. Implies `hidden`. */
99
+ private?: boolean;
100
+ /** When set, a nameless annotation (`// :: ...`) was used above a named declaration */
101
+ namelessOnNamed?: string;
102
+ /**
103
+ * Set on the SECONDARY entry produced by chained-annotation syntax
104
+ * (`// A :: B :: T`). Such entries describe a binding annotation under
105
+ * the second name (typically a dotted `Obj.Field` for a member
106
+ * assignment, or a bare `Ident` alias) and must NOT be treated as a
107
+ * static/instance method on the type before the `.` — the chained
108
+ * form is the binding's own annotation, not a member declaration on
109
+ * an unrelated constructor.
110
+ */
111
+ chainedSecondary?: true;
112
+ /** Start offset of the annotation name within the comment (e.g. "TypedArray" in `// TypedArray :: ...`) */
113
+ signatureNameStart?: number;
114
+ /** End offset of the annotation name within the comment */
115
+ signatureNameEnd?: number;
116
+ /**
117
+ * Where this annotation came from. Absent means "local" for
118
+ * backwards compatibility with code paths that synthesise
119
+ * `TypeAnnotation` objects directly (always treat via the
120
+ * `isLocalAnnotation` helper rather than reading this field raw).
121
+ * See {@link AnnotationOrigin}.
122
+ */
123
+ origin?: AnnotationOrigin;
124
+ }
125
+ /**
126
+ * Single source of truth for "is this annotation file-local?".
127
+ *
128
+ * Inference-feeding consumers (export-scheme construction, dotted-name
129
+ * constraint injection, prototype receiver inference, bare-binding
130
+ * annotation lookup, …) must call this rather than naked
131
+ * `annotationMap.get(...)` so that sidecar / globals / `::types`
132
+ * entries with colliding names cannot silently hijack user bindings.
133
+ *
134
+ * Treats `undefined` origin as `'local'` so that any code path that
135
+ * still constructs `TypeAnnotation` objects without setting `origin`
136
+ * remains correct by default.
137
+ */
138
+ export declare function isLocalAnnotation(ann: TypeAnnotation | undefined | null): boolean;
139
+ /**
140
+ * Extract all HM type annotations from a JavaScript source string.
141
+ *
142
+ * The function:
143
+ * 1. Parses the source with Acorn to get comments + AST
144
+ * 2. For each comment containing `:: <signature>`, parses the type signature
145
+ * 3. Associates the annotation with the next declaration
146
+ */
147
+ export declare function extractAnnotations(source: string): TypeAnnotation[];
148
+ /**
149
+ * A standalone `// ::hidden` directive — one that is not immediately
150
+ * followed by an HM annotation comment. These are attached to the next
151
+ * AST member declaration (class method or prototype-object property)
152
+ * that we can identify the owning type for.
153
+ *
154
+ * Returned as `{ typeName, methodName }` pairs so the inference engine
155
+ * can mark them via `markMethodHidden`.
156
+ */
157
+ export interface StandaloneHiddenMarker {
158
+ typeName: string;
159
+ methodName: string;
160
+ /** Comment start offset (for diagnostics if needed) */
161
+ commentStart: number;
162
+ /** Comment end offset */
163
+ commentEnd: number;
164
+ /** Start offset of the AST node (Property / MethodDefinition) being hidden */
165
+ memberStart: number;
166
+ }
167
+ /** Extract `(typeName, methodName)` pairs for every standalone `::hidden`
168
+ * directive found in `source` whose owning type can be resolved. */
169
+ export declare function extractStandaloneHiddenMarkers(source: string): StandaloneHiddenMarker[];
170
+ /** Extract `(typeName, methodName)` pairs for every standalone `::private`
171
+ * directive found in `source` whose owning type can be resolved. */
172
+ export declare function extractStandalonePrivateMarkers(source: string): StandaloneHiddenMarker[];
173
+ /**
174
+ * Build a map from declaration name -> parsed Scheme for all valid annotations.
175
+ *
176
+ * When the same name appears more than once with non-method annotations
177
+ * (e.g. two `Table :: ...` lines in a `.hm` file) the schemes are merged
178
+ * into a single overloaded scheme using `mergeOverloadSchemes`. Call sites
179
+ * use the existing union-unification path to pick the matching branch.
180
+ */
181
+ export declare function buildAnnotationMap(source: string): Map<string, TypeAnnotation>;
182
+ /**
183
+ * Build a map from type name -> array of Schemes for all `Name() :: T`
184
+ * (instance-callable) annotations in the source. Multiple `Name()`
185
+ * declarations produce multiple overload entries, in declaration order.
186
+ *
187
+ * Used by the inference engine and hover/signature help to look up the
188
+ * callable signatures of an uppercase TCon-typed value (e.g. an
189
+ * `QueryTag {row}` instance is callable as `({}) -> RTask r e [b]`).
190
+ */
191
+ export declare function extractInstanceCallables(source: string): Map<string, Scheme[]>;
192
+ export declare function declarationStarts(annotations: TypeAnnotation[]): Map<TypeAnnotation, number | undefined>;
193
+ export declare function buildAnnotationsByDeclaration(source: string): Map<number, TypeAnnotation>;
194
+ /**
195
+ * Build a map from node start offset -> TypeAnnotation.
196
+ */
197
+ export declare function buildAnnotationByOffset(source: string): Map<number, TypeAnnotation>;
198
+ /**
199
+ * Extract all `// ::types <specifier>` directives from a JavaScript source string.
200
+ *
201
+ * These directives tell the type system to load type annotations from another
202
+ * file or package, without requiring a runtime import. Supports:
203
+ * - Relative paths: `// ::types ./demo`
204
+ * - Package names: `// ::types fantasy-box`
205
+ * - Scoped packages: `// ::types @scope/package`
206
+ */
207
+ export declare function extractTypeDirectives(source: string): string[];
208
+ /**
209
+ * Extract all `// ::types <specifier>` directives with their source locations.
210
+ * Returns an array of `{ specifier, start, end }` objects.
211
+ */
212
+ export declare function extractTypeDirectivesWithLocations(source: string): {
213
+ specifier: string;
214
+ start: number;
215
+ end: number;
216
+ }[];
217
+ /**
218
+ * Extract `// ::prefer <Name>(, <Name>)* from <specifier>` directives. Used
219
+ * to disambiguate when the same uppercase type/constructor name (e.g.
220
+ * `Prop`) is defined by multiple loaded sidecars/globals. Multiple names
221
+ * may share one directive, e.g. `// ::prefer Prop, Table from query-builder`.
222
+ * Returns a Map from each declared name to its preferred origin specifier
223
+ * (bare package name or relative path, exactly as written). When the
224
+ * same name appears in multiple directives, the last wins.
225
+ */
226
+ export declare function extractPreferDirectives(source: string): Map<string, string>;
227
+ /**
228
+ * Extract all `// ::extend <AliasName> <typeExpr>` directives from source.
229
+ *
230
+ * Each directive appends `typeExpr` to the named union-alias post-build
231
+ * (see `applyAliasExtensions` in src/infer/annotations.ts). Generic
232
+ * mechanism — independent of any particular library. When `typeExpr` is
233
+ * itself a `|`-union, its branches are flattened into the target.
234
+ *
235
+ * Returns an array of `{ name, raw, start, end }` where `raw` is the
236
+ * unparsed RHS to be fed into `parseTypeSignature` later.
237
+ */
238
+ export declare function extractAliasExtensions(source: string): {
239
+ name: string;
240
+ raw: string;
241
+ start: number;
242
+ end: number;
243
+ }[];
244
+ /**
245
+ * Extract all `// ::constraint ...` directive comment bodies from source.
246
+ * Returns the raw comment text for each ::constraint comment.
247
+ */
248
+ export declare function extractConstraintDirectives(source: string): {
249
+ text: string;
250
+ start: number;
251
+ end: number;
252
+ }[];
253
+ export interface RepDirective {
254
+ constraint: string;
255
+ typeName: string;
256
+ methodName: string;
257
+ /** True when the directive used `Type.method` (static); false for `Type#method` (instance). */
258
+ isStatic: boolean;
259
+ start: number;
260
+ end: number;
261
+ }
262
+ /**
263
+ * Extract all `// ::rep <Constraint> <Type#method>` directives.
264
+ *
265
+ * A `::rep` directive declares that the named container method (annotated
266
+ * locally in the same file) represents the constraint's like-named method
267
+ * when discharging that constraint — scoped to the function that carries it
268
+ * (see Fase 5). Returns one entry per well-formed directive; malformed
269
+ * directives are silently skipped (the caller emits no parser error).
270
+ */
271
+ /**
272
+ * Every `::curried` directive in the comments of a JavaScript source. The
273
+ * directive belongs in `.hm` files only; in JavaScript the curried behaviour
274
+ * of a function follows from its code (see `setupPass`).
275
+ */
276
+ export declare function extractCurriedDirectiveLocations(source: string): {
277
+ start: number;
278
+ end: number;
279
+ }[];
280
+ export declare function extractRepDirectives(source: string): RepDirective[];
281
+ /**
282
+ * Extract all `// ::global ...` directive comment bodies from source.
283
+ * Returns the raw comment text (without the leading `//`) for each ::global comment.
284
+ *
285
+ * Supports:
286
+ * - Instance methods: `// ::global Array#ap :: [a] ~> [a -> b] -> [b]`
287
+ * - Static methods: `// ::global Array.empty :: () -> [a]`
288
+ */
289
+ export declare function extractGlobalDirectives(source: string): {
290
+ text: string;
291
+ start: number;
292
+ end: number;
293
+ }[];
294
+ /**
295
+ * A parsed sum type declaration.
296
+ *
297
+ * Example: `// Maybe :: Just a | Nothing`
298
+ * → { name: 'Maybe', typeVars: ['a'], variants: [{ name: 'Just', fields: ['a'] }, { name: 'Nothing', fields: [] }] }
299
+ */
300
+ export interface DataTypeDecl {
301
+ /** The sum type name (e.g. 'Maybe', 'Either') */
302
+ name: string;
303
+ /** Type variable names (e.g. ['a'] for Maybe, ['e', 'a'] for Either) */
304
+ typeVars: string[];
305
+ /** Variant definitions */
306
+ variants: DataVariant[];
307
+ /** Comment start offset in source */
308
+ commentStart: number;
309
+ /** Comment end offset in source */
310
+ commentEnd: number;
311
+ /** Start offset of the type name within the comment */
312
+ signatureNameStart?: number;
313
+ /** End offset of the type name within the comment */
314
+ signatureNameEnd?: number;
315
+ }
316
+ export interface DataVariant {
317
+ /** Variant name (e.g. 'Just', 'Nothing', 'Left', 'Right') */
318
+ name: string;
319
+ /** Field types carried by this variant — type variable names (e.g. 'a') or concrete type names (e.g. 'Int') */
320
+ fields: string[];
321
+ }
322
+ /**
323
+ * Return the parent type variables a single field references, in order.
324
+ * Exposed so the sumtype identifier-union builder can map complex fields
325
+ * (records / parenthesized applications) back to their type parameters.
326
+ */
327
+ export declare function fieldTypeVars(field: string): string[];
328
+ /**
329
+ * Extract the labelled fields from a record-style variant field
330
+ * (`{ ext :: String, handler :: EngineFn }` -> [{name:'ext', type:'String'},
331
+ * {name:'handler', type:'EngineFn'}]). Returns [] when `field` is not a
332
+ * `{...}` record group (e.g. a positional word or parenthesized application).
333
+ */
334
+ export declare function recordFields(field: string): {
335
+ name: string;
336
+ type: string;
337
+ }[];
338
+ export declare function isDataShorthand(annotationName: string, raw: string): boolean;
339
+ /**
340
+ * Parse the shorthand data type syntax:
341
+ * `// TypeName :: Variant1 a | Variant2 b`
342
+ *
343
+ * Type variables are inferred from the variant fields in order of first
344
+ * appearance. Fields can be type variables (lowercase) or concrete types
345
+ * (uppercase), e.g. `// Result :: Ok Int | Err String`.
346
+ * Returns null if the body doesn't match.
347
+ */
348
+ export declare function parseDataShorthand(typeName: string, body: string, commentStart: number, commentEnd: number): DataTypeDecl | null;
349
+ /**
350
+ * Extract all sum type declarations from a JavaScript source string.
351
+ *
352
+ * Recognises the `// TypeName :: Variant1 a | Variant2 b` syntax, including
353
+ * multi-line forms (block comments whose variants span several lines, or
354
+ * consecutive `//` line comments joined by a trailing/leading `|`).
355
+ */
356
+ export declare function extractDataDirectives(source: string): DataTypeDecl[];
357
+ /**
358
+ * Check whether the source contains an `// ::ignore-file` directive.
359
+ * When present, all diagnostics for the file should be suppressed.
360
+ */
361
+ export declare function hasIgnoreFileDirective(source: string): boolean;
362
+ /**
363
+ * Extract 0-based line numbers that should be ignored due to `// ::ignore`
364
+ * directives. The directive suppresses diagnostics on the **next** line.
365
+ */
366
+ export declare function extractIgnoreLineDirectives(source: string): Set<number>;
367
+ /**
368
+ * Extract 0-based line numbers that should be ignored due to `// ::ignore-function`
369
+ * directives. The directive suppresses diagnostics on the entire function body
370
+ * following the comment.
371
+ */
372
+ export declare function extractIgnoreFunctionDirectives(source: string): Set<number>;
373
+ /**
374
+ * Extract uppercase-initial names from ES module import / require declarations
375
+ * in JS source. Used to recognise locally-imported type constructors so the
376
+ * type validator doesn't flag them as unknown.
377
+ */
378
+ export declare function extractImportedNames(source: string): string[];
379
+ /**
380
+ * Extract unique module specifier paths from import/require declarations.
381
+ * Returns paths like `'./Either2'`, `'./demo'`, etc.
382
+ */
383
+ export declare function extractImportModuleSpecifiers(source: string): string[];
384
+ //# sourceMappingURL=commentParser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commentParser.d.ts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