@esportsplus/typescript 0.31.1 → 0.32.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.
package/README.md CHANGED
@@ -104,9 +104,14 @@ Add an `analyze` entry to `compilerOptions.plugins`. Analysis covers every file
104
104
  "channels": {
105
105
  "exceptions": {
106
106
  "enabled": true,
107
- // "consumers" (default): uncaught calls only.
108
- // "cross-module": only when the throwing callee is in another package.
109
- // "all": throws AND uncaught calls.
107
+ // "consumers" (default): uncaught calls only, and only when
108
+ // the throwing callee is in another PACKAGE — a throw within
109
+ // this package is its own contract, seen only where an
110
+ // external consumer calls in.
111
+ // "cross-module": like "consumers" but the boundary is the
112
+ // FILE — a callee thrown from the caller's own file stays
113
+ // silent; a call from another file reports.
114
+ // "all": throws AND every uncaught call.
110
115
  "report": "consumers",
111
116
  // Flag `throw`s inside `catch` that drop the caught error's cause.
112
117
  "errorCause": true
@@ -1,4 +1,4 @@
1
- import * as ts from '../../probe/adapter.js';
1
+ import * as ts from '../adapter.js';
2
2
  import { bodyOf, calleeSelectors, unwrap } from '../kernel/ast.js';
3
3
  import { isFunctionLike, locationOf } from '../kernel/ids.js';
4
4
  import { bottom, equals, promise, widen } from './value.js';
@@ -1,5 +1,5 @@
1
1
  import * as NodeFS from 'node:fs';
2
- import * as ts from '../../probe/adapter.js';
2
+ import * as ts from '../adapter.js';
3
3
  import { bodyOf, calleeSelectors, paramSymbols } from '../kernel/ast.js';
4
4
  import { isFunctionLike, locationOf } from '../kernel/ids.js';
5
5
  import { declaredExceptions } from './jsdoc.js';
@@ -50,13 +50,13 @@ function createExceptionsChannel() {
50
50
  diagnose(ctx) {
51
51
  const out = [];
52
52
  const base = makeEnv(ctx.checker, ctx.dispatch, ctx.sinks, ctx.fn, ctx.summaryOf, ctx.resolveCall, typeAt);
53
- const env = reportMode(ctx) === 'cross-module'
54
- ? {
53
+ const env = reportMode(ctx) === 'all'
54
+ ? { ...base, escapeCache: new Map() }
55
+ : {
55
56
  ...base,
56
57
  escapeCache: new Map(),
57
58
  unhandled: computeUnhandled(ctx),
58
- }
59
- : { ...base, escapeCache: new Map() };
59
+ };
60
60
  const body = bodyOf(ctx.fn.node);
61
61
  const decl = declaredExceptions(ctx.fn.node, ctx.checker);
62
62
  if (decl.declared && body) {
@@ -482,13 +482,20 @@ function packageRootOf(fileName) {
482
482
  }
483
483
  return root;
484
484
  }
485
- function crossesModuleBoundary(env, ctx, call) {
485
+ function crossesPackageBoundary(env, ctx, call) {
486
486
  const res = env.resolveCall(call);
487
487
  if (res.targets.length === 0)
488
488
  return true;
489
489
  const home = packageRootOf(ctx.fn.fileName);
490
490
  return res.targets.some((t) => packageRootOf(t.fileName) !== home);
491
491
  }
492
+ function crossesFileBoundary(env, ctx, call) {
493
+ const res = env.resolveCall(call);
494
+ if (res.targets.length === 0)
495
+ return true;
496
+ const home = ctx.fn.fileName.replace(/\\/g, '/');
497
+ return res.targets.some((t) => t.fileName.replace(/\\/g, '/') !== home);
498
+ }
492
499
  function reachesTop(env, rem) {
493
500
  const u = env.unhandled;
494
501
  if (!u || !u.active)
@@ -525,8 +532,13 @@ function walkDiagnostics(env, ctx, node, binding, remainder, out) {
525
532
  }
526
533
  if (ts.isCallExpression(n) || ts.isNewExpression(n)) {
527
534
  const rem = callEscape(env, n);
528
- const report = reportMode(ctx) !== 'cross-module' ||
529
- (crossesModuleBoundary(env, ctx, n) && reachesTop(env, rem));
535
+ const mode = reportMode(ctx);
536
+ const report = mode === 'all'
537
+ ? true
538
+ : mode === 'cross-module'
539
+ ? crossesFileBoundary(env, ctx, n) && reachesTop(env, rem)
540
+ : crossesPackageBoundary(env, ctx, n) &&
541
+ reachesTop(env, rem);
530
542
  if (!isEmpty(rem) && report)
531
543
  out.push(callDiagnostic(env, ctx, n, rem));
532
544
  ts.forEachChild(n, visit);
@@ -1,4 +1,4 @@
1
- import * as ts from '../../probe/adapter.js';
1
+ import * as ts from '../adapter.js';
2
2
  import type { FunctionLike } from '../kernel/types.js';
3
3
  import { type ExceptionsValue } from './value.js';
4
4
  declare function declaredExceptions(node: FunctionLike, checker: ts.TypeChecker): {
@@ -1,4 +1,4 @@
1
- import * as ts from '../../probe/adapter.js';
1
+ import * as ts from '../adapter.js';
2
2
  import { bottom, join, single, top, TOP_KEY, typeRef, } from './value.js';
3
3
  function declaredExceptions(node, checker) {
4
4
  let value = bottom();
@@ -1,4 +1,4 @@
1
- import * as ts from '../../probe/adapter.js';
1
+ import * as ts from '../adapter.js';
2
2
  type ExceptionOrigin = {
3
3
  readonly fileName: string;
4
4
  readonly pos: number;
@@ -1,4 +1,4 @@
1
- import * as ts from '../../probe/adapter.js';
1
+ import * as ts from '../adapter.js';
2
2
  const TOP_KEY = '\u0000top';
3
3
  const TOP_DISPLAY = 'an unknown error';
4
4
  const WIDEN_CAP = 8;
@@ -1,4 +1,4 @@
1
- import * as ts from '../../probe/adapter.js';
1
+ import * as ts from '../adapter.js';
2
2
  import type { Diagnostic, AnalyzeConfig } from './types.js';
3
3
  type AnalyzeResult = {
4
4
  readonly diagnostics: ReadonlyArray<Diagnostic>;
@@ -1,4 +1,4 @@
1
- import * as ts from '../../probe/adapter.js';
1
+ import * as ts from '../adapter.js';
2
2
  import type { FunctionLike } from './types.js';
3
3
  type UnwrapOptions = {
4
4
  assertions?: boolean;
@@ -1,4 +1,4 @@
1
- import * as ts from '../../probe/adapter.js';
1
+ import * as ts from '../adapter.js';
2
2
  function shouldUnwrap(expr, options) {
3
3
  return (ts.isParenthesizedExpression(expr) ||
4
4
  (options.assertions === true &&
@@ -1,4 +1,4 @@
1
- import * as ts from '../../probe/adapter.js';
1
+ import * as ts from '../adapter.js';
2
2
  import type { CallGraph, OverlaySet, AnalyzeConfig } from './types.js';
3
3
  declare function buildCallGraph(program: ts.Program, checker: ts.TypeChecker, config: AnalyzeConfig, overlays: OverlaySet): CallGraph;
4
4
  export { buildCallGraph };
@@ -1,4 +1,4 @@
1
- import * as ts from '../../probe/adapter.js';
1
+ import * as ts from '../adapter.js';
2
2
  import { isFunctionLike, makeFunctionInfo } from './ids.js';
3
3
  function buildCallGraph(program, checker, config, overlays) {
4
4
  const sourceFiles = ts.getSourceFiles(program);
@@ -1,4 +1,4 @@
1
- import * as ts from '../../probe/adapter.js';
1
+ import * as ts from '../adapter.js';
2
2
  import type { FunctionInfo, FunctionLike, SourceLocation } from './types.js';
3
3
  declare function isFunctionLike(node: ts.Node): node is FunctionLike;
4
4
  declare function functionName(node: FunctionLike): string;
@@ -1,4 +1,4 @@
1
- import * as ts from '../../probe/adapter.js';
1
+ import * as ts from '../adapter.js';
2
2
  const FUNCTION_LIKE_KINDS = new Set([
3
3
  ts.SyntaxKind.FunctionDeclaration,
4
4
  ts.SyntaxKind.FunctionExpression,
@@ -1,4 +1,4 @@
1
- import * as ts from '../../probe/adapter.js';
1
+ import * as ts from '../adapter.js';
2
2
  export type BuiltProgram = {
3
3
  program: ts.Program;
4
4
  checker: ts.Checker;
@@ -1,4 +1,4 @@
1
- import type * as ts from '../../probe/adapter.js';
1
+ import type * as ts from '../adapter.js';
2
2
  export type FunctionLike = ts.FunctionDeclaration | ts.FunctionExpression | ts.ArrowFunction | ts.MethodDeclaration | ts.GetAccessorDeclaration | ts.SetAccessorDeclaration | ts.ConstructorDeclaration;
3
3
  type FunctionInfo = {
4
4
  readonly id: string;
@@ -1,7 +1,7 @@
1
1
  import * as NodeFS from 'node:fs';
2
2
  import * as NodePath from 'node:path';
3
3
  import * as NodeURL from 'node:url';
4
- import * as ts from '../../probe/adapter.js';
4
+ import * as ts from '../adapter.js';
5
5
  import { stripJsonc } from '../../jsonc.js';
6
6
  const KNOWN_NAMESPACES = new Set([
7
7
  'JSON',
@@ -1,4 +1,4 @@
1
- import * as ts from '../../probe/adapter.js';
1
+ import * as ts from '../adapter.js';
2
2
  import { overlayThrows } from '../exceptions/channel.js';
3
3
  import { bodyOf, calleeSelectors, paramSymbols, unwrap } from '../kernel/ast.js';
4
4
  import { isEmpty } from '../exceptions/value.js';
package/package.json CHANGED
@@ -10,15 +10,15 @@
10
10
  "dependencies": {
11
11
  "@esportsplus/cli-passthrough": "^0.0.15",
12
12
  "@esportsplus/utilities": "^0.28.0",
13
- "@types/node": "^26.1.1",
14
- "tsc-alias": "^1.9.1",
13
+ "@types/node": "^26.4.1",
14
+ "tsc-alias": "^1.9.4",
15
15
  "typescript": "7.0.2",
16
- "vscode-languageserver": "^10.1.0",
17
- "vscode-languageserver-textdocument": "^1.0.12"
16
+ "vscode-languageserver": "^10.1.1",
17
+ "vscode-languageserver-textdocument": "^1.0.14"
18
18
  },
19
19
  "devDependencies": {
20
- "vite": "^8.1.5",
21
- "vitest": "^4.1.10"
20
+ "vite": "^8.2.2",
21
+ "vitest": "^4.1.11"
22
22
  },
23
23
  "exports": {
24
24
  "./package.json": "./package.json",
@@ -60,7 +60,7 @@
60
60
  },
61
61
  "type": "module",
62
62
  "types": "build/index.d.ts",
63
- "version": "0.31.1",
63
+ "version": "0.32.0",
64
64
  "scripts": {
65
65
  "agent:bench": "pnpm bench:run",
66
66
  "agent:build": "pnpm build",
@@ -33,7 +33,7 @@
33
33
  "channels": {
34
34
  "exceptions": {
35
35
  "enabled": true,
36
- "report": "consumers",
36
+ "report": "cross-module",
37
37
  // Flag `throw`s inside `catch` that drop the caught error's cause.
38
38
  "errorCause": true
39
39
  }