@stateward/plugin-errors 1.2.2 → 1.3.1

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 (54) hide show
  1. package/README.md +9 -8
  2. package/dist/catch-hides-unexpected.d.ts +4 -1
  3. package/dist/catch-hides-unexpected.js +12 -5
  4. package/dist/catch-misses-error.d.ts +1 -1
  5. package/dist/catch-misses-error.js +7 -4
  6. package/dist/finally-can-throw.js +3 -3
  7. package/dist/hover.js +6 -9
  8. package/dist/index.d.ts +3 -1
  9. package/dist/index.js +1 -0
  10. package/dist/inference/analysis.d.ts +109 -0
  11. package/dist/inference/analysis.js +170 -0
  12. package/dist/inference/builtins.d.ts +0 -2
  13. package/dist/inference/builtins.js +0 -33
  14. package/dist/inference/deps.d.ts +13 -2
  15. package/dist/inference/deps.js +24 -13
  16. package/dist/inference/needs.d.ts +16 -0
  17. package/dist/inference/needs.js +27 -0
  18. package/dist/inference/packages.d.ts +24 -32
  19. package/dist/inference/packages.js +156 -680
  20. package/dist/inference/project.d.ts +4 -4
  21. package/dist/inference/project.js +6 -17
  22. package/dist/inference/solve.d.ts +29 -4
  23. package/dist/inference/solve.js +42 -12
  24. package/dist/inference/summarize.d.ts +27 -15
  25. package/dist/inference/summarize.js +247 -130
  26. package/dist/inference/summary.d.ts +41 -5
  27. package/dist/inference/summary.js +84 -12
  28. package/dist/inference/unreachable.d.ts +5 -0
  29. package/dist/inference/unreachable.js +160 -0
  30. package/dist/inlay.d.ts +1 -5
  31. package/dist/inlay.js +1 -12
  32. package/dist/must-handle-error.d.ts +4 -3
  33. package/dist/must-handle-error.js +10 -13
  34. package/dist/plugin.d.ts +12 -2
  35. package/dist/plugin.js +4 -2
  36. package/dist/react/boundaries.d.ts +9 -7
  37. package/dist/react/boundaries.js +16 -24
  38. package/dist/react/tree.js +8 -4
  39. package/dist/refactors.js +1 -1
  40. package/dist/render-throw-without-boundary.d.ts +13 -4
  41. package/dist/render-throw-without-boundary.js +4 -2
  42. package/dist/result-ignored.d.ts +4 -1
  43. package/dist/result-type.js +2 -2
  44. package/dist/result-unchecked.d.ts +4 -1
  45. package/dist/result-unchecked.js +139 -61
  46. package/dist/rules.meta.d.ts +26 -14
  47. package/dist/rules.meta.js +18 -14
  48. package/dist/syntax.d.ts +0 -13
  49. package/dist/syntax.js +0 -79
  50. package/dist/text.d.ts +5 -2
  51. package/dist/text.js +11 -5
  52. package/dist/throws-doc-mismatch.d.ts +2 -2
  53. package/dist/throws-doc-mismatch.js +13 -5
  54. package/package.json +2 -2
@@ -0,0 +1,16 @@
1
+ import type { FactNeed, UnnamedFact } from "@stateward/core";
2
+ import type { UnknownFact } from "./solve.js";
3
+ /** What a "not checked" finding carries for the places it depends on (`Finding.needs`, `unnamed`). */
4
+ export type DecidingFacts = {
5
+ needs?: readonly FactNeed[];
6
+ unnamed?: readonly UnnamedFact[];
7
+ };
8
+ /**
9
+ * The `facts` lines that decide a finding, one per call, from every unknown it depends on whose
10
+ * call no line states: a call met on both sides needs the one side `neededSides` picks. The
11
+ * package calls no key can name are listed apart, once each, with why.
12
+ */
13
+ export declare function decidingFacts(unknowns: Iterable<{
14
+ readonly fact?: UnknownFact | undefined;
15
+ }>): DecidingFacts;
16
+ //# sourceMappingURL=needs.d.ts.map
@@ -0,0 +1,27 @@
1
+ import { neededSides } from "@stateward/core";
2
+ /**
3
+ * The `facts` lines that decide a finding, one per call, from every unknown it depends on whose
4
+ * call no line states: a call met on both sides needs the one side `neededSides` picks. The
5
+ * package calls no key can name are listed apart, once each, with why.
6
+ */
7
+ export function decidingFacts(unknowns) {
8
+ const needs = new Map();
9
+ const unnamed = new Map();
10
+ for (const { fact } of unknowns) {
11
+ if (fact?.kind === "unstated") {
12
+ const { need } = fact;
13
+ const key = `${need.module}\u0000${need.name}`;
14
+ const known = needs.get(key);
15
+ const states = neededSides([...(known?.states ?? []), ...need.states]);
16
+ needs.set(key, { ...(known ?? need), states });
17
+ }
18
+ else if (fact?.kind === "unnamed") {
19
+ unnamed.set(`${fact.unnamed.name}\u0000${fact.unnamed.reason}`, fact.unnamed);
20
+ }
21
+ }
22
+ return {
23
+ ...(needs.size === 0 ? {} : { needs: [...needs.values()] }),
24
+ ...(unnamed.size === 0 ? {} : { unnamed: [...unnamed.values()] }),
25
+ };
26
+ }
27
+ //# sourceMappingURL=needs.js.map
@@ -1,40 +1,32 @@
1
- import ts from "@stateward/core/typescript";
2
- import type { FileContext } from "@stateward/core";
3
- import type { PackageResolver } from "./summarize.js";
1
+ import type { FileContext, TypeQueries } from "@stateward/core";
2
+ import type { PackageResolver, QuietCall } from "./summarize.js";
3
+ import { UNKNOWN_REASONS } from "./summary.js";
4
+ import type { UnknownReason } from "./summary.js";
4
5
  /**
5
- * Library facts for the Errors pack: what a call into a
6
- * package throws, from the first source that answers:
6
+ * Library facts for the Errors pack: what a call into a package throws, from its contract only
7
+ * (0041), from the first source that answers:
7
8
  *
8
9
  * 1. the project's config (`facts`);
9
- * 2. curated fact files shipped with stateward (`curatedFacts` answers nothing yet);
10
- * 3. `@throws {X}` on the called declaration in the package's `.d.ts`;
11
- * 4. inferred from the package's JavaScript, with the summarizer of the project's own code, from
12
- * the called function to what it calls in the package (bounded), cached globally;
13
- * 5. unknown, with one of the reasons below.
14
- */
15
- /** Why a package's function is not (fully) known: fixed strings, shown as they are. */
16
- export declare const UNKNOWN_REASONS: readonly ["no readable source", "not found in its source", "native addon", "minified", "eval", "dynamic require", "too large to follow", "untyped @throws", "calls a callback", "calls code it cannot see", "dynamic call", "throws a value of unknown class", "awaits a promise it cannot follow"];
17
- export type UnknownReason = (typeof UNKNOWN_REASONS)[number];
18
- /**
19
- * At most this many functions are read per package function asked for.
20
- * The bounds count, never time: a verdict by time would differ between machines.
10
+ * 2. the facts the loaded packs ship (`Plugin.facts`);
11
+ * 3. else unknown: "its errors are not stated", with a hint that gives the `facts` line.
12
+ *
13
+ * A line names the call when its key resolves to the called declaration (`factLineOf`). The
14
+ * package's code and the doc comments of its declarations are never read.
21
15
  */
22
- export declare const MAX_FUNCTIONS = 200;
23
- /** The declaration's path in the package's types: `["Client", "get"]`. */
24
- export declare function pathOf(node: ts.Node): string[];
16
+ export { UNKNOWN_REASONS };
17
+ export type { UnknownReason };
18
+ /** The calls the facts say throw nothing (`QuietCall`). */
19
+ export type Quiet = {
20
+ readonly test: QuietCall;
21
+ };
25
22
  /**
26
- * Curated fact files shipped with stateward: none ship yet, so nothing answers between the config
27
- * and the declarations. Reading `facts/<package>@<major>.json` here would add the `curated`
28
- * source, and the resolver would ask it after the config.
23
+ * The calls into packages that the facts the packs ship say throw and reject with nothing
24
+ * (`throws: []`, as the React pack says of React's hooks), unless the config's own `facts` has a
25
+ * line for the function: that line is read instead, as the resolver reads it.
29
26
  */
30
- export declare function curatedFacts(): undefined;
31
- /** What this process computed and read back, for tests: inference runs and global-cache hits. */
32
- export declare function packageFactsStats(): {
33
- inferences: number;
34
- cacheHits: number;
35
- };
36
- /** Forgets what this process knows about packages (tests: the next run reads the global cache). */
37
- export declare function forgetPackageFacts(): void;
27
+ export declare function quietCalls(ctx: Pick<FileContext, "facts" | "shippedFacts"> & {
28
+ readonly types: Pick<TypeQueries, "factTarget" | "isOrExtends">;
29
+ }): Quiet;
38
30
  /** Finds the facts of the calls into packages of the file `ctx` summarizes. */
39
- export declare function packageResolver(ctx: Pick<FileContext, "file" | "facts">): PackageResolver;
31
+ export declare function packageResolver(ctx: Pick<FileContext, "file" | "facts" | "shippedFacts" | "withheldFacts" | "types">): PackageResolver;
40
32
  //# sourceMappingURL=packages.d.ts.map