@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 +8 -3
- package/build/probe/async/channel.js +1 -1
- package/build/probe/exceptions/channel.js +20 -8
- package/build/probe/exceptions/jsdoc.d.ts +1 -1
- package/build/probe/exceptions/jsdoc.js +1 -1
- package/build/probe/exceptions/value.d.ts +1 -1
- package/build/probe/exceptions/value.js +1 -1
- package/build/probe/kernel/analyze.d.ts +1 -1
- package/build/probe/kernel/ast.d.ts +1 -1
- package/build/probe/kernel/ast.js +1 -1
- package/build/probe/kernel/graph.d.ts +1 -1
- package/build/probe/kernel/graph.js +1 -1
- package/build/probe/kernel/ids.d.ts +1 -1
- package/build/probe/kernel/ids.js +1 -1
- package/build/probe/kernel/program.d.ts +1 -1
- package/build/probe/kernel/types.d.ts +1 -1
- package/build/probe/overlay/load.js +1 -1
- package/build/probe/resources/channel.js +1 -1
- package/package.json +7 -7
- package/tsconfig.base.json +1 -1
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
|
-
//
|
|
109
|
-
//
|
|
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 '
|
|
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 '
|
|
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) === '
|
|
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
|
|
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
|
|
529
|
-
|
|
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 '
|
|
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 '
|
|
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 '
|
|
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 type * as ts from '
|
|
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 '
|
|
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 '
|
|
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.
|
|
14
|
-
"tsc-alias": "^1.9.
|
|
13
|
+
"@types/node": "^26.4.1",
|
|
14
|
+
"tsc-alias": "^1.9.4",
|
|
15
15
|
"typescript": "7.0.2",
|
|
16
|
-
"vscode-languageserver": "^10.1.
|
|
17
|
-
"vscode-languageserver-textdocument": "^1.0.
|
|
16
|
+
"vscode-languageserver": "^10.1.1",
|
|
17
|
+
"vscode-languageserver-textdocument": "^1.0.14"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"vite": "^8.
|
|
21
|
-
"vitest": "^4.1.
|
|
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.
|
|
63
|
+
"version": "0.32.0",
|
|
64
64
|
"scripts": {
|
|
65
65
|
"agent:bench": "pnpm bench:run",
|
|
66
66
|
"agent:build": "pnpm build",
|