@noego/trust 0.5.0-dev.1 → 0.5.0-dev.3

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.
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/guard.ts","../src/eslint/policy.ts","../src/core/dropped-results.ts","../src/core/rules.ts","../src/core/promise-rules.ts","../src/core/accept.ts","../src/core/redundant-guards.ts","../src/core/type-text.ts","../src/core/type-claims.ts","../src/core/untrusted-values.ts","../src/core/check-file.ts"],"sourcesContent":["// \"Is this node guarded?\" A node is guarded when, within the same function, it sits in the `try`\n// block of a TryStatement whose `catch` returns Result.err(...) on every path, or when the function\n// it sits in is the callback passed directly to Trust.try / Trust.tryAsync.\n//\n// Works on TypeScript nodes. The ESLint adapter maps its ESTree nodes onto these, so the shapes\n// ESTree hides are handled here: parentheses are transparent, and an optional chain's top node\n// counts as wrapped (ESTree's ChainExpression), exactly as the rules have always seen them.\nimport type * as TS from 'typescript';\nimport type { CatchProblem } from './messages.js';\nimport type { TypeScript } from '../eslint/typescript.js';\n\nexport type Guard =\n | { readonly status: 'unguarded' }\n | { readonly status: 'guarded'; readonly via: 'try' | 'sync-callback' | 'async-callback' }\n | { readonly status: 'badCatch'; readonly problem: CatchProblem };\n\nexport interface GuardContext {\n readonly ts: TypeScript;\n /** The returned expression is an `Err` (typed: by declaration; untyped: `Result.err(...)`/`err(...)` by name). */\n isResultErr(expression: TS.Expression): boolean;\n /** The call is `Result.err(...)` / `err(...)` itself (for the raw-caught-value check). */\n isErrCall(call: TS.CallExpression): boolean;\n /** 'sync' for Trust.try, 'async' for Trust.tryAsync, else null. */\n trustTryKind(call: TS.CallExpression): 'sync' | 'async' | null;\n}\n\n/** `node` without surrounding parentheses (ESTree has no parenthesized-expression node). */\nexport function unparen(ts: TypeScript, node: TS.Node): TS.Node {\n let current = node;\n while (ts.isParenthesizedExpression(current)) current = current.expression;\n return current;\n}\n\n/** The parent ESTree would report: parentheses skipped. */\nexport function esParent(ts: TypeScript, node: TS.Node): TS.Node | undefined {\n let parent = node.parent;\n while (parent && ts.isParenthesizedExpression(parent)) parent = parent.parent;\n return parent;\n}\n\n/** Part of an optional chain: in ESTree the chain's top node sits inside a ChainExpression. */\nexport function inOptionalChain(ts: TypeScript, node: TS.Node): boolean {\n return (node.flags & ts.NodeFlags.OptionalChain) !== 0;\n}\n\n/** A plain (non-optional-chain) call, as ESTree's `type === 'CallExpression'` check sees it. */\nexport function asPlainCall(ts: TypeScript, node: TS.Node): TS.CallExpression | null {\n const inner = unparen(ts, node);\n return ts.isCallExpression(inner) && !inOptionalChain(ts, inner) ? inner : null;\n}\n\n/** Function boundaries (ESTree: FunctionDeclaration / FunctionExpression / ArrowFunctionExpression). */\nexport function isFunctionBoundary(ts: TypeScript, node: TS.Node): boolean {\n return (\n ts.isFunctionDeclaration(node) ||\n ts.isFunctionExpression(node) ||\n ts.isArrowFunction(node) ||\n ts.isMethodDeclaration(node) ||\n ts.isConstructorDeclaration(node) ||\n ts.isGetAccessorDeclaration(node) ||\n ts.isSetAccessorDeclaration(node)\n );\n}\n\nfunction isLoopOrSwitch(ts: TypeScript, node: TS.Node): boolean {\n return (\n ts.isForStatement(node) ||\n ts.isForInStatement(node) ||\n ts.isForOfStatement(node) ||\n ts.isWhileStatement(node) ||\n ts.isDoStatement(node) ||\n ts.isSwitchStatement(node)\n );\n}\n\nfunction collectExits(ts: TypeScript, node: TS.Node, exits: Array<TS.ReturnStatement | TS.ThrowStatement>): void {\n if (isFunctionBoundary(ts, node)) return;\n if (ts.isReturnStatement(node) || ts.isThrowStatement(node)) exits.push(node);\n ts.forEachChild(node, (child) => collectExits(ts, child, exits));\n}\n\nfunction containsBreakFor(ts: TypeScript, node: TS.Node, isRoot = true): boolean {\n if (isFunctionBoundary(ts, node)) return false;\n if (!isRoot && isLoopOrSwitch(ts, node)) return false;\n if (ts.isBreakStatement(node) && !node.label) return true;\n return ts.forEachChild(node, (child) => containsBreakFor(ts, child, false) || undefined) ?? false;\n}\n\n/** Every path through `statement` ends in return (or throw). */\nexport function alwaysExits(ts: TypeScript, statement: TS.Statement | undefined): boolean {\n if (!statement) return false;\n if (ts.isReturnStatement(statement) || ts.isThrowStatement(statement)) return true;\n if (ts.isBlock(statement)) return statement.statements.some((child) => alwaysExits(ts, child));\n if (ts.isIfStatement(statement)) return alwaysExits(ts, statement.thenStatement) && alwaysExits(ts, statement.elseStatement);\n if (ts.isSwitchStatement(statement)) {\n const clauses = statement.caseBlock.clauses;\n if (!clauses.some((clause) => ts.isDefaultClause(clause))) return false;\n if (containsBreakFor(ts, statement)) return false;\n return clauses[clauses.length - 1].statements.some((child) => alwaysExits(ts, child));\n }\n if (ts.isTryStatement(statement)) {\n if (alwaysExits(ts, statement.finallyBlock)) return true;\n const handler = statement.catchClause;\n return alwaysExits(ts, statement.tryBlock) && (!handler || alwaysExits(ts, handler.block));\n }\n if (ts.isLabeledStatement(statement)) return alwaysExits(ts, statement.statement);\n return false;\n}\n\n/** Null when the catch clause returns Result.err(...) on every path, else the problem. */\nexport function catchProblem(handler: TS.CatchClause, context: GuardContext): CatchProblem | null {\n const ts = context.ts;\n const exits: Array<TS.ReturnStatement | TS.ThrowStatement> = [];\n collectExits(ts, handler.block, exits);\n const param = handler.variableDeclaration?.name;\n const paramName = param && ts.isIdentifier(param) ? param.text : null;\n for (const exit of exits) {\n if (ts.isThrowStatement(exit)) return 'rethrow';\n const argument = exit.expression ? (unparen(ts, exit.expression) as TS.Expression) : undefined;\n if (!argument || !context.isResultErr(argument)) return 'notResultErr';\n const call = paramName ? asPlainCall(ts, argument) : null;\n if (call && context.isErrCall(call)) {\n const first = call.arguments[0];\n const value = first ? unparen(ts, first) : undefined;\n if (value && ts.isIdentifier(value) && value.text === paramName) return 'rawCatchValue';\n }\n }\n return alwaysExits(ts, handler.block) ? null : 'notAllPaths';\n}\n\n/** Innermost guard of `node` within its own function. */\nexport function guardOf(node: TS.Node, context: GuardContext): Guard {\n const ts = context.ts;\n let child: TS.Node = node;\n let current = node.parent;\n while (current) {\n if (isFunctionBoundary(ts, current)) {\n const call = esParent(ts, current);\n if (call && ts.isCallExpression(call) && call.arguments[0] && unparen(ts, call.arguments[0]) === current) {\n const kind = context.trustTryKind(call);\n if (kind) return { status: 'guarded', via: kind === 'sync' ? 'sync-callback' : 'async-callback' };\n }\n return { status: 'unguarded' };\n }\n if (ts.isTryStatement(current) && current.tryBlock === child) {\n const handler = current.catchClause;\n if (handler) {\n const problem = catchProblem(handler, context);\n return problem ? { status: 'badCatch', problem } : { status: 'guarded', via: 'try' };\n }\n }\n child = current;\n current = current.parent;\n }\n return { status: 'unguarded' };\n}\n","// Decides whether one call/new expression is trusted, and whether the types an origin declares are\n// trusted. Shared by the rules and `trust explain`.\nimport { svelteFor } from '../core/svelte.js';\nimport type * as TS from 'typescript';\nimport type { TrustConfig, TrustLevel, TrustRuleSettings } from './config.js';\nimport { isTrustPackageFile, OriginResolver, type OriginInfo } from './origin.js';\nimport type { TypeScript } from './typescript.js';\nimport { Zones } from './zones.js';\n\nexport interface MatchedEntry {\n readonly source: string;\n readonly entry: string;\n}\n\nexport type Verdict =\n | { readonly kind: 'unresolved' }\n | { readonly kind: 'first-party'; readonly origin: OriginInfo }\n | { readonly kind: 'returns-result'; readonly origin: OriginInfo }\n | { readonly kind: 'trusted'; readonly origin: OriginInfo; readonly by: MatchedEntry }\n | { readonly kind: 'untrusted'; readonly origin: OriginInfo; readonly distrustedBy?: MatchedEntry }\n | { readonly kind: 'calls-ignored'; readonly origin: OriginInfo };\n\n/**\n * Are the types a declaration states true at runtime? Type trust is separate from throw trust (`Verdict`):\n * it is decided by the `trust_type` / `distrust_type` lists only.\n * first-party declared in a checked file: its types are checked themselves\n * trust-package declared by @noego/trust: Result, Trust and friends are this tool's own contract\n * type-trusted a `trust_type` entry covers the origin\n * type-untrusted nothing does, or a `distrust_type` entry removed it\n */\nexport type TypeVerdict =\n | { readonly kind: 'first-party'; readonly origin: OriginInfo }\n | { readonly kind: 'trust-package'; readonly origin: OriginInfo }\n | { readonly kind: 'type-trusted'; readonly origin: OriginInfo; readonly by: MatchedEntry }\n | { readonly kind: 'type-untrusted'; readonly origin: OriginInfo; readonly distrustedBy?: MatchedEntry };\n\ntype Decision = { trusted: true; by: MatchedEntry } | { trusted: false; distrustedBy?: MatchedEntry };\n\n/** A level of the chain that is a built-in preset (`preset:<name>`), not a config file of the project. */\nexport function isPresetSource(source: string): boolean {\n return source.startsWith('preset:');\n}\n\n/**\n * `entry` covers `origin` itself, its subpaths (`fs` → `fs/promises`) and members (`js:JSON` →\n * `js:JSON.parse`). When the origin's `base` (package/module part) is known, an entry that stops\n * inside the base may only continue with `/`, so `lodash` does not cover the package `lodash.merge`.\n */\nexport function entryMatches(entry: string, origin: string, base?: string): boolean {\n if (origin === entry) return true;\n if (!origin.startsWith(entry)) return false;\n const next = origin[entry.length];\n if (base !== undefined && entry.length < base.length) return next === '/';\n return next === '/' || next === '.' || next === '#';\n}\n\n/** The most specific (longest) entry covering `origin`. */\nfunction bestMatch(entries: readonly string[], origin: string, base?: string): string | undefined {\n let best: string | undefined;\n for (const entry of entries) {\n if (entryMatches(entry, origin, base) && (best === undefined || entry.length > best.length)) best = entry;\n }\n return best;\n}\n\n/**\n * Walks leaf → root; the first level with a matching entry decides. Within a level the most specific\n * entry wins (`distrust @noego/wood` + `trust @noego/wood.TraceProvider` trusts only the tracer);\n * on equal specificity distrust wins.\n */\nexport function decide(\n levels: readonly TrustLevel[],\n lists: (level: TrustLevel) => { readonly trust: readonly string[]; readonly distrust: readonly string[] },\n origin: string,\n base?: string,\n): Decision {\n for (const level of levels) {\n const { trust, distrust } = lists(level);\n const distrusted = bestMatch(distrust, origin, base);\n const trusted = bestMatch(trust, origin, base);\n if (trusted && (!distrusted || trusted.length > distrusted.length)) {\n return { trusted: true, by: { source: level.source, entry: trusted } };\n }\n if (distrusted) return { trusted: false, distrustedBy: { source: level.source, entry: distrusted } };\n }\n return { trusted: false };\n}\n\nexport class TrustPolicy {\n readonly zones: Zones;\n readonly origins: OriginResolver;\n /** The config's per-rule settings (`rules`): which opt-in rules run and which callbacks are sources. */\n readonly rules: TrustRuleSettings;\n private readonly levels: readonly TrustLevel[];\n\n constructor(\n private readonly ts: TypeScript,\n private readonly checker: TS.TypeChecker,\n config: TrustConfig,\n extraTrust: readonly string[] = [],\n ) {\n this.zones = new Zones(config.rootDir, config.passthrough, config.ignore, svelteFor(checker)?.paths);\n this.origins = new OriginResolver(ts, this.zones);\n this.rules = config.rules;\n const fromOptions: TrustLevel = { source: 'rule options', trust: extraTrust, distrust: [], typeTrust: [], typeDistrust: [] };\n this.levels = extraTrust.length > 0 ? [fromOptions, ...config.levels] : config.levels;\n }\n\n /** Throw trust of an origin: the `trust` / `distrust` lists of the chain (see `decide`). */\n lookup(origin: string, base?: string): Decision {\n return decide(this.levels, (level) => level, origin, base);\n }\n\n /** Type trust of an origin: the `trust_type` / `distrust_type` lists of the chain, resolved the same way. */\n lookupType(origin: string, base?: string): Decision {\n return decide(this.levels, (level) => ({ trust: level.typeTrust, distrust: level.typeDistrust }), origin, base);\n }\n\n /**\n * The `trust_type` entry of the project's own config files that type-trusts `declaration` (member or\n * package level), else null. Entries of built-in presets (`preset:<name>` levels: js, node, web,\n * web_strict, svelte) never count, and a `distrust_type` that wins along the chain takes it back. Only\n * this unlocks a caller-chosen generic return (`container.get<Foo>('x')`, type-claims.ts): a broad preset\n * entry such as `js:Array` must not silently bless a cast. Checked code is looked up too, so a user entry\n * naming a first-party origin (`local:ui/scope.ts#resolveSyncInScope`) unlocks its generic returns.\n */\n userTypeTrustOf(declaration: TS.Node): MatchedEntry | null {\n if (isTrustPackageFile(declaration.getSourceFile().fileName)) return null;\n const origin = this.origins.originOf(declaration);\n const decision = this.lookupType(origin.origin, origin.kind === 'external' ? origin.base : undefined);\n return decision.trusted && !isPresetSource(decision.by.source) ? decision.by : null;\n }\n\n /** Whether the types `declaration` states are trusted (see TypeVerdict). */\n typeVerdictOf(declaration: TS.Node): TypeVerdict {\n const origin = this.origins.originOf(declaration);\n if (origin.kind === 'local' && origin.zone === 'checked') return { kind: 'first-party', origin };\n if (isTrustPackageFile(declaration.getSourceFile().fileName)) return { kind: 'trust-package', origin };\n const decision = this.lookupType(origin.origin, origin.kind === 'external' ? origin.base : undefined);\n if (decision.trusted) return { kind: 'type-trusted', origin, by: decision.by };\n return decision.distrustedBy ? { kind: 'type-untrusted', origin, distrustedBy: decision.distrustedBy } : { kind: 'type-untrusted', origin };\n }\n\n classify(node: TS.CallExpression | TS.NewExpression): Verdict {\n const resolved = this.calleeDeclaration(node);\n if (!resolved) return { kind: 'unresolved' };\n const origin = this.origins.originOf(resolved.declaration);\n if (origin.kind === 'local' && origin.zone === 'checked') return { kind: 'first-party', origin };\n if (origin.kind === 'local' && origin.zone === 'ignore') return { kind: 'calls-ignored', origin };\n const decision = this.lookup(origin.origin, origin.kind === 'external' ? origin.base : undefined);\n if (!decision.trusted && decision.distrustedBy) return { kind: 'untrusted', origin, distrustedBy: decision.distrustedBy };\n if (resolved.signature && this.returnsResult(resolved.signature)) return { kind: 'returns-result', origin };\n if (decision.trusted) return { kind: 'trusted', origin, by: decision.by };\n return { kind: 'untrusted', origin };\n }\n\n /** Pick by origin, never compiler-internal union order (JavaScript compares UTF-16 units). */\n choose_origin_declaration(candidates: readonly TS.Declaration[]): TS.Declaration | undefined {\n let best: TS.Declaration | undefined;\n let bestOrigin: string | undefined;\n for (const declaration of candidates) {\n const origin = this.origins.originOf(declaration).origin;\n if (bestOrigin === undefined || origin < bestOrigin) {\n best = declaration;\n bestOrigin = origin;\n }\n }\n return best;\n }\n\n /** Equal-origin overloads keep the existing declaration; distinct origins select the minimum. */\n symbol_declaration(symbol: TS.Symbol | undefined, fallback = symbol?.valueDeclaration ?? symbol?.declarations?.[0]): TS.Declaration | undefined {\n const candidates = symbol?.declarations ?? [];\n if (candidates.length > 1) {\n const firstOrigin = this.origins.originOf(candidates[0]!).origin;\n if (candidates.some((declaration) => this.origins.originOf(declaration).origin !== firstOrigin)) {\n return this.choose_origin_declaration(candidates);\n }\n }\n return fallback;\n }\n\n calleeDeclaration(node: TS.CallExpression | TS.NewExpression): { declaration: TS.Node; signature?: TS.Signature } | null {\n const ts = this.ts;\n const signature = this.checker.getResolvedSignature(node);\n const fromSignature = signature?.declaration && !ts.isJSDocSignature(signature.declaration) ? signature.declaration : undefined;\n const callee = node.expression;\n if (ts.isPropertyAccessExpression(callee)) {\n const receiver = this.checker.getApparentType(this.checker.getTypeAtLocation(callee.expression));\n if (receiver.isUnion()) {\n const candidates = receiver.types.flatMap((member) => this.checker.getPropertyOfType(member, callee.name.text)?.declarations ?? []);\n const declaration = this.choose_origin_declaration(candidates);\n if (declaration) {\n // Keep the resolved overload when it already has the winning origin.\n const chosen = fromSignature && this.origins.originOf(fromSignature).origin === this.origins.originOf(declaration).origin ? fromSignature : declaration;\n return { declaration: chosen, signature };\n }\n }\n }\n // A union callee can synthesize a signature from either constituent.\n const calleeType = this.checker.getApparentType(this.checker.getTypeAtLocation(callee));\n if (calleeType.isUnion()) {\n const kind = ts.isNewExpression(node) ? ts.SignatureKind.Construct : ts.SignatureKind.Call;\n const candidates = calleeType.types.flatMap((member) => this.checker.getSignaturesOfType(member, kind)\n .flatMap((candidate) => candidate.declaration && !ts.isJSDocSignature(candidate.declaration) ? [candidate.declaration] : []));\n const declaration = this.choose_origin_declaration(candidates);\n if (declaration) {\n const chosen = fromSignature && this.origins.originOf(fromSignature).origin === this.origins.originOf(declaration).origin ? fromSignature : declaration;\n return { declaration: chosen, signature };\n }\n }\n // An unnamed call/construct signature (`const statSync: StatSyncFn`, `declare var URL: { new(): URL }`)\n // names its interface, not the callee; prefer the callee's own declaration (`fs.statSync`).\n const anonymous =\n !fromSignature || ts.isCallSignatureDeclaration(fromSignature) || ts.isConstructSignatureDeclaration(fromSignature) || ts.isFunctionTypeNode(fromSignature);\n if (fromSignature && !anonymous) return { declaration: fromSignature, signature };\n let symbol = this.checker.getSymbolAtLocation(node.expression);\n if (symbol && symbol.flags & ts.SymbolFlags.Alias) symbol = this.checker.getAliasedSymbol(symbol);\n const fromSymbol = this.symbol_declaration(symbol, symbol?.declarations?.[0]);\n // Only rename within the declaring file: a first-party parameter typed by a package's function\n // interface keeps the package origin.\n const sameFile = fromSymbol && fromSignature && fromSymbol.getSourceFile() === fromSignature.getSourceFile();\n const declaration = !fromSignature || sameFile ? fromSymbol : fromSignature;\n return declaration ? { declaration, signature } : null;\n }\n\n /** Declared return type is Result / Promise<Result> from @noego/trust (every union member is Ok or Err). */\n returnsResult(signature: TS.Signature): boolean {\n const returnType = this.checker.getReturnTypeOfSignature(signature);\n const awaited = this.checker.getAwaitedType(returnType) ?? returnType;\n return this.isResultType(awaited);\n }\n\n isResultType(type: TS.Type): boolean {\n const members = type.isUnion() ? type.types : [type];\n return members.length > 0 && members.every((member) => this.resultVariant(member) !== null);\n }\n\n /** True when every member of the type is an `Err` from @noego/trust. */\n isErrType(type: TS.Type): boolean {\n const members = type.isUnion() ? type.types : [type];\n return members.length > 0 && members.every((member) => this.resultVariant(member) === 'err');\n }\n\n /** 'ok' | 'err' when the type is @noego/trust's Ok/Err (by the declaration of its `ok` property). */\n resultVariant(type: TS.Type): 'ok' | 'err' | null {\n const property = type.getProperty('ok');\n const declaration = this.symbol_declaration(property);\n if (!property || !declaration || !isTrustPackageFile(declaration.getSourceFile().fileName)) return null;\n const discriminant = this.checker.typeToString(this.checker.getTypeOfSymbol(property));\n if (discriminant === 'true') return 'ok';\n if (discriminant === 'false') return 'err';\n return null;\n }\n\n /** Name of the @noego/trust function a call resolves to (`err`, `tryResult`, …), else null. */\n trustFunctionName(node: TS.CallExpression): string | null {\n const resolved = this.calleeDeclaration(node);\n if (!resolved || !isTrustPackageFile(resolved.declaration.getSourceFile().fileName)) return null;\n const name = (resolved.declaration as TS.NamedDeclaration).name;\n return name && this.ts.isIdentifier(name) ? name.text : null;\n }\n}\n","// dropped-result: a Result that can still fail is either passed up or handled, never dropped.\n//\n// A value \"can fail\" when its type (awaited, and one level into an array or tuple) has an `Err` member from\n// @noego/trust. Every such value is followed through the function that holds it, path by path:\n//\n// passed up returned (also an arrow function's expression body, `yield`), or flowing into a call whose\n// own value can fail (`Promise.all([...])`, `retry(r)`), or, on a path where a followed value\n// is known to be an `Err` (`if (!r.ok)`), returning any value that can fail (`Result.err(...)`):\n// the first failure goes up, and covers the values not checked yet on that path\n// carried out the returned value takes the failure along, whatever its type (`return this.failed(r.error)`,\n// `return reply(r)`, a call's Result inside the returned response): `r.ok` / `r.value` do not\n// handled passed to Trust.decide / Trust.translate (what they leave is a new value, followed the same\n// way), a branch that names the kind (`r.error.kind === 'NotFound'`, `case 'NotFound':`), or\n// handed to a parameter whose declared type is a Result (that function is checked in turn)\n// read compared for identity with a value that can fail and is already held (`map.get(k) === pending`):\n// it is that same value, followed where it is held\n//\n// Everything else drops the failure and is reported, with the kinds still possible there (the origin is\n// the baseline key):\n//\n// discarded a call's Result nobody keeps: an expression statement, `void`, `f().ok`\n// argument a call's Result passed where no Result is expected (`console.log(f())`)\n// stored a call's Result put where failures are not followed (an object property, a field)\n// callback a function returning a Result handed to a callee that does not take a Result back\n// return a `return` that neither passes a variable up nor follows a check that handled it\n// end a variable that can still fail when it goes out of scope: the end of its function or\n// block, a `break` / `continue` out of it\n// overwritten a variable assigned again while it can still fail\n//\n// Variables are followed in the function that declares them (parameters included); a module-level\n// variable is not followed. A closure reading a variable of an outer function does not handle it.\n// Control flow is followed through if / else, switch, loops (one pass), try / catch / finally, labels,\n// break and continue. Conditions narrow on `r.ok` (with `!`, `&&`, `||`, `=== true/false`) and on\n// `r.error.kind` compared with a string literal.\nimport type * as TS from 'typescript';\nimport type { TrustPolicy } from '../eslint/policy.js';\nimport type { TypeScript } from '../eslint/typescript.js';\nimport { isFunctionBoundary, unparen } from './guard.js';\nimport { DROPPED_RESULT_MESSAGES, fillMessage, formatFailureKinds, type DroppedResultOrigin } from './messages.js';\n\n/** A kind that is not a string literal (`{ kind: string }`, a type parameter): no branch can name it. */\nexport const ANY_KIND = '*';\n\n/** One dropped failure, at the position it is reported at. */\nexport interface DroppedResult {\n readonly origin: DroppedResultOrigin;\n /** Offset of the report position in the source file. */\n readonly start: number;\n /** The variable's name, the expression's text, or (callback) the callee's text. */\n readonly subject: string;\n /** The kinds still possible where the failure is dropped, sorted; ANY_KIND for a kind no branch can name. */\n readonly kinds: readonly string[];\n}\n\nexport interface DroppedResultContext {\n readonly ts: TypeScript;\n readonly checker: TS.TypeChecker;\n readonly policy: TrustPolicy;\n /** Failure kinds per type (null: the type cannot fail). */\n readonly kindCache: WeakMap<TS.Type, ReadonlySet<string> | null>;\n}\n\nexport function droppedResultContext(ts: TypeScript, checker: TS.TypeChecker, policy: TrustPolicy): DroppedResultContext {\n return { ts, checker, policy, kindCache: new WeakMap() };\n}\n\n/** The data `DROPPED_RESULT_MESSAGES[origin]` is filled with. */\nexport function droppedResultData(dropped: DroppedResult): Record<string, string> {\n return { subject: dropped.subject, kinds: formatFailureKinds(dropped.kinds, ANY_KIND) };\n}\n\nexport function droppedResultMessage(dropped: DroppedResult): string {\n return fillMessage(DROPPED_RESULT_MESSAGES[dropped.origin], droppedResultData(dropped));\n}\n\ntype FunctionOwner = TS.SignatureDeclaration & { readonly body?: TS.ConciseBody } | TS.ClassStaticBlockDeclaration;\ntype Owner = TS.SourceFile | FunctionOwner;\n\ninterface VarState {\n /** Kinds that may still be an unhandled failure here. Empty: nothing left to drop. */\n readonly kinds: ReadonlySet<string>;\n /** Known to be an `Err` on this path (inside `if (!r.ok)`). */\n readonly err: boolean;\n}\n\ntype State = Map<TS.Symbol, VarState>;\n\ninterface Tracked {\n readonly name: string;\n /** The block (or loop, case block, function body) the variable lives in. */\n readonly scope: TS.Node;\n}\n\ninterface JumpTarget {\n readonly node: TS.Node;\n readonly label: string | undefined;\n /** Loops take `continue`; loops and switches take an unlabeled `break`. */\n readonly kind: 'loop' | 'switch' | 'labeled';\n readonly breaks: State[];\n readonly continues: State[];\n}\n\n/** What happens to a value at the top of its flow (see DropWalk.fate). */\ntype Fate = 'discarded' | 'argument' | 'stored' | 'track' | 'consume' | 'return' | 'read';\n\nconst NOTHING: ReadonlySet<string> = new Set();\n/** Array methods whose value holds only elements of the receiver. */\nconst ELEMENT_METHODS: ReadonlySet<string> = new Set([\n 'filter', 'slice', 'concat', 'reverse', 'sort', 'toSorted', 'toReversed', 'toSpliced', 'flat', 'find', 'findLast', 'at',\n]);\n/** Array methods whose callback only looks at the elements (they stay in the receiver). */\nconst PREDICATE_METHODS: ReadonlySet<string> = new Set([\n 'filter', 'find', 'findLast', 'findIndex', 'findLastIndex', 'some', 'every', 'sort', 'toSorted',\n]);\nconst SUBJECT_LIMIT = 60;\n\nfunction members(type: TS.Type): readonly TS.Type[] {\n return type.isUnion() ? type.types : [type];\n}\n\nfunction union(a: ReadonlySet<string>, b: ReadonlySet<string>): ReadonlySet<string> {\n if (a.size === 0) return b;\n if (b.size === 0) return a;\n return new Set([...a, ...b]);\n}\n\nfunction merge(a: State | null, b: State | null): State | null {\n if (!a) return b ? new Map(b) : null;\n const merged = new Map(a);\n if (!b) return merged;\n for (const [symbol, right] of b) {\n const left = merged.get(symbol);\n merged.set(symbol, left ? { kinds: union(left.kinds, right.kinds), err: left.err && right.err } : right);\n }\n return merged;\n}\n\nfunction mergeAll(states: ReadonlyArray<State | null>): State | null {\n return states.reduce<State | null>((merged, state) => merge(merged, state), null);\n}\n\nfunction argumentsOf(call: TS.CallExpression | TS.NewExpression): readonly TS.Node[] {\n return call.arguments ?? [];\n}\n\nfunction within(node: TS.Node, container: TS.Node): boolean {\n return node.pos >= container.pos && node.end <= container.end;\n}\n\n/** Records the failure kinds of an `Err` member of `type`; true when it has one. */\nfunction errKinds(context: DroppedResultContext, type: TS.Type, kinds: Set<string>): boolean {\n const { ts, checker, policy } = context;\n let fallible = false;\n for (const member of members(checker.getAwaitedType(type) ?? type)) {\n if (policy.resultVariant(member) !== 'err') continue;\n const error = member.getProperty('error');\n const errorType = error ? checker.getTypeOfSymbol(error) : undefined;\n if (errorType && errorType.flags & ts.TypeFlags.Never) continue;\n fallible = true;\n if (!errorType) {\n kinds.add(ANY_KIND);\n continue;\n }\n for (const failure of members(errorType)) {\n const kind = failure.getProperty('kind');\n const kindType = kind ? checker.getTypeOfSymbol(kind) : undefined;\n if (!kindType) {\n kinds.add(ANY_KIND);\n continue;\n }\n for (const literal of members(kindType)) kinds.add(literal.isStringLiteral() ? literal.value : ANY_KIND);\n }\n }\n return fallible;\n}\n\n/** The failure kinds a value of `type` can carry (awaited, and one level into arrays and tuples); null when it cannot fail. */\nexport function failureKinds(context: DroppedResultContext, type: TS.Type): ReadonlySet<string> | null {\n const cached = context.kindCache.get(type);\n if (cached !== undefined) return cached;\n const { ts, checker, policy } = context;\n let result: ReadonlySet<string> | null = null;\n if (!(type.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown | ts.TypeFlags.Never))) {\n const kinds = new Set<string>();\n let fallible = errKinds(context, type, kinds);\n for (const member of members(checker.getAwaitedType(type) ?? type)) {\n if (member.flags & (ts.TypeFlags.StringLike | ts.TypeFlags.Any) || policy.resultVariant(member) !== null) continue;\n const element = checker.getIndexTypeOfType(member, ts.IndexKind.Number);\n if (element && errKinds(context, element, kinds)) fallible = true;\n }\n result = fallible ? kinds : null;\n }\n context.kindCache.set(type, result);\n return result;\n}\n\nfunction subjectOf(node: TS.Node, sourceFile: TS.SourceFile): string {\n const text = node.getText(sourceFile).replace(/\\s+/g, ' ').trim();\n return text.length > SUBJECT_LIMIT ? `${text.slice(0, SUBJECT_LIMIT - 1)}…` : text;\n}\n\nfunction isOwner(ts: TypeScript, node: TS.Node): node is FunctionOwner {\n return isFunctionBoundary(ts, node) || ts.isClassStaticBlockDeclaration(node);\n}\n\nfunction stringLiteral(ts: TypeScript, node: TS.Node): string | undefined {\n const inner = unparen(ts, node);\n return ts.isStringLiteral(inner) || ts.isNoSubstitutionTemplateLiteral(inner) ? inner.text : undefined;\n}\n\n/** `=`, `??=`, `||=`, `&&=`: the right side is kept in the left side. */\nfunction isPlainOrLogicalAssignment(ts: TypeScript, operator: TS.SyntaxKind): boolean {\n return (\n operator === ts.SyntaxKind.EqualsToken ||\n operator === ts.SyntaxKind.QuestionQuestionEqualsToken ||\n operator === ts.SyntaxKind.BarBarEqualsToken ||\n operator === ts.SyntaxKind.AmpersandAmpersandEqualsToken\n );\n}\n\n/** `===`, `!==`, `==`, `!=`. */\nfunction isEquality(ts: TypeScript, operator: TS.SyntaxKind): boolean {\n return (\n operator === ts.SyntaxKind.EqualsEqualsEqualsToken ||\n operator === ts.SyntaxKind.ExclamationEqualsEqualsToken ||\n operator === ts.SyntaxKind.EqualsEqualsToken ||\n operator === ts.SyntaxKind.ExclamationEqualsToken\n );\n}\n\n/** `null` or `undefined`. */\nfunction isNullish(ts: TypeScript, node: TS.Node): boolean {\n const inner = unparen(ts, node);\n return inner.kind === ts.SyntaxKind.NullKeyword || (ts.isIdentifier(inner) && inner.text === 'undefined');\n}\n\nfunction booleanLiteral(ts: TypeScript, node: TS.Node): boolean | undefined {\n const inner = unparen(ts, node);\n if (inner.kind === ts.SyntaxKind.TrueKeyword) return true;\n if (inner.kind === ts.SyntaxKind.FalseKeyword) return false;\n return undefined;\n}\n\n/** The dropped failures of one function (or, for the source file, of its top-level statements). */\nclass DropWalk {\n private readonly ts: TypeScript;\n private readonly checker: TS.TypeChecker;\n private readonly sourceFile: TS.SourceFile;\n private readonly tracked = new Map<TS.Symbol, Tracked>();\n /** `const failure = r.error`: alias symbol → r. */\n private readonly errorAliases = new Map<TS.Symbol, TS.Symbol>();\n /** A variable whose value takes failures along (`const failed = { error: r.error }`) → those variables. */\n private readonly failureCarriers = new Map<TS.Symbol, ReadonlySet<TS.Symbol>>();\n private readonly targets: JumpTarget[] = [];\n private readonly reported = new Set<TS.Node>();\n /** Where `var` declarations live. */\n private readonly functionScope: TS.Node;\n\n constructor(\n private readonly context: DroppedResultContext,\n private readonly owner: Owner,\n private readonly found: DroppedResult[],\n ) {\n this.ts = context.ts;\n this.checker = context.checker;\n this.sourceFile = owner.getSourceFile();\n this.functionScope = context.ts.isSourceFile(owner) ? owner : (owner.body ?? owner);\n }\n\n run(): void {\n const ts = this.ts;\n const owner = this.owner;\n if (ts.isSourceFile(owner)) {\n this.statements(owner.statements, new Map(), owner);\n return;\n }\n const body = owner.body;\n if (!body) return;\n const state: State = new Map();\n if (!ts.isClassStaticBlockDeclaration(owner) && !this.isPredicateCallback(owner)) {\n for (const parameter of owner.parameters) this.declare(parameter.name, body, state, true);\n }\n if (ts.isBlock(body)) {\n this.block(body, state);\n return;\n }\n this.visit(body, state);\n this.checkReturn(body, body, state);\n }\n\n /** The function is the predicate of `xs.filter(…)` / `find` / `some` / …: it looks at elements its receiver keeps. */\n private isPredicateCallback(owner: FunctionOwner): boolean {\n const ts = this.ts;\n if (!ts.isArrowFunction(owner) && !ts.isFunctionExpression(owner)) return false;\n const call = owner.parent;\n if (!ts.isCallExpression(call) || !call.arguments.includes(owner)) return false;\n const callee = unparen(ts, call.expression);\n return ts.isPropertyAccessExpression(callee) && PREDICATE_METHODS.has(callee.name.text);\n }\n\n // ---- reporting ----\n\n private report(origin: DroppedResultOrigin, at: TS.Node | number, subject: string, kinds: ReadonlySet<string>): void {\n const start = typeof at === 'number' ? at : at.getStart(this.sourceFile);\n this.found.push({ origin, start, subject, kinds: [...kinds].sort() });\n }\n\n private reportVariable(origin: DroppedResultOrigin, at: TS.Node | number, symbol: TS.Symbol, kinds: ReadonlySet<string>): void {\n this.report(origin, at, this.tracked.get(symbol)?.name ?? symbol.name, kinds);\n }\n\n /** Reports and forgets the variables living in `scope` (or, with `inside`, anywhere inside it) that can still fail. */\n private leaveScope(scope: TS.Node, state: State | null, at: TS.Node | number, inside = false, keep?: (info: Tracked) => boolean): State | null {\n if (!state) return null;\n const left = new Map(state);\n for (const [symbol, info] of this.tracked) {\n const leaving = inside ? within(info.scope, scope) : info.scope === scope;\n if (!leaving || keep?.(info)) continue;\n const value = left.get(symbol);\n if (value && value.kinds.size > 0) this.reportVariable('end', at, symbol, value.kinds);\n left.delete(symbol);\n }\n return left;\n }\n\n // ---- types ----\n\n private kindsOf(node: TS.Node): ReadonlySet<string> | null {\n return failureKinds(this.context, this.checker.getTypeAtLocation(node));\n }\n\n private typeKinds(type: TS.Type | undefined): ReadonlySet<string> | null {\n return type ? failureKinds(this.context, type) : null;\n }\n\n private trackedSymbol(node: TS.Node, state: State): TS.Symbol | null {\n const inner = unparen(this.ts, node);\n if (!this.ts.isIdentifier(inner)) return null;\n const symbol = this.checker.getSymbolAtLocation(inner);\n return symbol && state.has(symbol) ? symbol : null;\n }\n\n private isDecideOrTranslate(call: TS.Node): boolean {\n if (!this.ts.isCallExpression(call)) return false;\n const name = this.context.policy.trustFunctionName(call);\n return name === 'decide' || name === 'translate';\n }\n\n /** The declared (not instantiated) type of the parameter that receives argument `index`. */\n private declaredParameterType(call: TS.CallExpression | TS.NewExpression, index: number): TS.Type | undefined {\n const ts = this.ts;\n const declaration = this.checker.getResolvedSignature(call)?.getDeclaration();\n if (!declaration || ts.isJSDocSignature(declaration)) return undefined;\n const parameters = declaration.parameters;\n const last = parameters[parameters.length - 1];\n if (last?.dotDotDotToken && index >= parameters.length - 1) {\n const restType = this.checker.getTypeAtLocation(last);\n return this.checker.getIndexTypeOfType(restType, ts.IndexKind.Number);\n }\n const parameter = parameters[index];\n return parameter ? this.checker.getTypeAtLocation(parameter) : undefined;\n }\n\n /**\n * The type of the parameter that receives argument `index` at this call: type parameters filled in, so\n * `resolve` of a `new Promise<Result<…>>`, `map.set(id, pending)` on a `Map<string, Promise<Result<…>>>` or\n * `Result.ok(() => …)` take a Result here.\n */\n private instantiatedParameterType(call: TS.CallExpression | TS.NewExpression, index: number): TS.Type | undefined {\n const ts = this.ts;\n const signature = this.checker.getResolvedSignature(call);\n if (!signature) return undefined;\n const parameters = signature.getParameters();\n const last = parameters[parameters.length - 1];\n const lastDeclaration = last?.valueDeclaration;\n const isRest = lastDeclaration !== undefined && ts.isParameter(lastDeclaration) && lastDeclaration.dotDotDotToken !== undefined;\n if (isRest && index >= parameters.length - 1) {\n return this.checker.getIndexTypeOfType(this.checker.getTypeOfSymbolAtLocation(last, call), ts.IndexKind.Number);\n }\n const parameter = parameters[index];\n return parameter ? this.checker.getTypeOfSymbolAtLocation(parameter, call) : undefined;\n }\n\n /** A Result, or a function returning one. */\n private takesResult(type: TS.Type | undefined): boolean {\n if (!type) return false;\n if (this.typeKinds(type)) return true;\n return members(type).some((member) => member.getCallSignatures().some((signature) => this.typeKinds(signature.getReturnType()) !== null));\n }\n\n /**\n * The callee takes the failure over: its parameter is a Result (or a function returning one), as declared or as\n * this call fills in its type parameters. `console.log(…)` (`any`) and `String(…)` (`unknown`) take nothing.\n */\n private acceptsArgument(call: TS.CallExpression | TS.NewExpression, argument: TS.Node): boolean {\n const index = argumentsOf(call).indexOf(argument);\n if (index < 0) return false;\n return this.takesResult(this.declaredParameterType(call, index)) || this.takesResult(this.instantiatedParameterType(call, index));\n }\n\n /** `results.push(f())`: the receiver is itself a collection of Results, so the value is kept in it. */\n private receiverKeeps(call: TS.CallExpression | TS.NewExpression): boolean {\n const callee = this.ts.isCallExpression(call) ? unparen(this.ts, call.expression) : undefined;\n return callee !== undefined && this.ts.isPropertyAccessExpression(callee) && this.kindsOf(callee.expression) !== null;\n }\n\n // ---- flow of a value to the place its fate is decided ----\n\n /** The expression `child`'s value flows into unchanged (wrappers, branches, collections, calls returning it), else null. */\n private flowsInto(child: TS.Node): TS.Node | null {\n const ts = this.ts;\n const parent = child.parent;\n if (!parent) return null;\n if (\n ts.isParenthesizedExpression(parent) ||\n ts.isAwaitExpression(parent) ||\n ts.isAsExpression(parent) ||\n ts.isNonNullExpression(parent) ||\n ts.isSatisfiesExpression(parent) ||\n ts.isTypeAssertionExpression(parent)\n ) {\n return parent;\n }\n if (ts.isConditionalExpression(parent)) return child === parent.condition ? null : parent;\n if (ts.isBinaryExpression(parent)) {\n const operator = parent.operatorToken.kind;\n if (operator === ts.SyntaxKind.QuestionQuestionToken || operator === ts.SyntaxKind.BarBarToken) return parent;\n if (operator === ts.SyntaxKind.AmpersandAmpersandToken || operator === ts.SyntaxKind.CommaToken) return child === parent.right ? parent : null;\n return null;\n }\n if (ts.isArrayLiteralExpression(parent)) return parent;\n if (ts.isSpreadElement(parent) && ts.isArrayLiteralExpression(parent.parent)) return parent;\n if ((ts.isCallExpression(parent) || ts.isNewExpression(parent)) && argumentsOf(parent).includes(child)) {\n if (this.isDecideOrTranslate(parent)) return null;\n return this.kindsOf(parent) !== null ? parent : null;\n }\n return null;\n }\n\n /**\n * A value that can fail and is already held somewhere (a variable, a field, an element; awaited or not): one no\n * call, `new` or `await` of a call makes here, whose failure is followed (or dropped) where it is held.\n */\n private isHeldFallible(node: TS.Node): boolean {\n const ts = this.ts;\n let inner = unparen(ts, node);\n while (\n ts.isAwaitExpression(inner) ||\n ts.isAsExpression(inner) ||\n ts.isNonNullExpression(inner) ||\n ts.isSatisfiesExpression(inner) ||\n ts.isTypeAssertionExpression(inner)\n ) {\n inner = unparen(ts, inner.expression);\n }\n if (!ts.isIdentifier(inner) && !ts.isPropertyAccessExpression(inner) && !ts.isElementAccessExpression(inner)) return false;\n return this.kindsOf(node) !== null;\n }\n\n private carrier(node: TS.Node): TS.Node {\n let current = node;\n for (let next = this.flowsInto(current); next; next = this.flowsInto(current)) current = next;\n return current;\n }\n\n /** What happens to the value of `carrier` (the top of its flow) where it ends up. */\n private fate(carrier: TS.Node): Fate {\n const ts = this.ts;\n const parent = carrier.parent;\n if (!parent) return 'discarded';\n if (ts.isExpressionStatement(parent) || ts.isVoidExpression(parent)) return 'discarded';\n if (ts.isVariableDeclaration(parent)) {\n if (parent.initializer !== carrier) return 'read';\n return ts.isObjectBindingPattern(parent.name) ? 'discarded' : 'track';\n }\n // `export default f()` is a module-level value, like a module-level variable: not followed.\n if (ts.isExportAssignment(parent)) return 'track';\n if (ts.isReturnStatement(parent) || ts.isYieldExpression(parent)) return 'return';\n if (ts.isArrowFunction(parent) && parent.body === carrier) return 'return';\n if (ts.isBinaryExpression(parent) && isPlainOrLogicalAssignment(ts, parent.operatorToken.kind)) {\n if (parent.right !== carrier) return 'read';\n const target = unparen(ts, parent.left);\n if (ts.isIdentifier(target) || ts.isArrayLiteralExpression(target)) return 'track';\n // `this.pending = f()` into a field typed as a Result: the field keeps it, and every read of it is a Result.\n return this.kindsOf(target) !== null ? 'track' : 'stored';\n }\n // `pending.get(key) === existing`: compared for identity with a value that can fail and is already held\n // elsewhere, the value is only looked at; it is that same value, not a new failure. Compared with another\n // call's value (`find() === find()`) or with something that cannot fail (`find() === undefined`), it is dropped.\n if (ts.isBinaryExpression(parent) && isEquality(ts, parent.operatorToken.kind)) {\n const other = parent.left === carrier ? parent.right : parent.left;\n if (this.isHeldFallible(other)) return 'read';\n }\n if ((ts.isCallExpression(parent) || ts.isNewExpression(parent)) && argumentsOf(parent).includes(carrier)) {\n if (this.isDecideOrTranslate(parent)) return parent.arguments?.[0] === carrier ? 'consume' : 'argument';\n if (this.acceptsArgument(parent, carrier) || this.receiverKeeps(parent)) return 'consume';\n return 'argument';\n }\n if ((ts.isPropertyAccessExpression(parent) || ts.isElementAccessExpression(parent)) && parent.expression === carrier) {\n // `results.map((r) => …)`: the elements are handed to a function that is checked on its own. A predicate\n // (`results.filter((r) => !r.ok)`) only looks at them: the receiver keeps them, so it is just read.\n const call = parent.parent;\n const predicate = ts.isPropertyAccessExpression(parent) && PREDICATE_METHODS.has(parent.name.text);\n const handsOver =\n !predicate && ts.isCallExpression(call) && call.expression === parent && call.arguments.some((argument) => isOwner(ts, unparen(ts, argument)));\n return handsOver ? 'consume' : 'discarded';\n }\n if ((ts.isForOfStatement(parent) || ts.isForInStatement(parent)) && parent.expression === carrier) return 'consume';\n // `private readonly catalog = this.loadCatalog();`: a field whose type is the Result keeps it; every read of the\n // field is a Result again, checked where it is used.\n if (ts.isPropertyDeclaration(parent) && parent.initializer === carrier) return 'track';\n // `{ result: f() }` where the object is declared to hold a Result there.\n if (ts.isPropertyAssignment(parent) && parent.initializer === carrier && ts.isExpression(carrier)) {\n if (this.typeKinds(this.checker.getContextualType(carrier)) !== null) return 'track';\n }\n if (\n ts.isPropertyAssignment(parent) ||\n ts.isShorthandPropertyAssignment(parent) ||\n ts.isSpreadAssignment(parent) ||\n ts.isSpreadElement(parent) ||\n ts.isJsxExpression(parent) ||\n ts.isParameter(parent)\n ) {\n return 'stored';\n }\n return 'discarded';\n }\n\n // ---- expressions ----\n\n /** Visits the expressions under `node` (not into nested functions) in source order, deciding the fate of each value that can fail. */\n private visit(node: TS.Node, state: State): void {\n const ts = this.ts;\n if (ts.isTypeNode(node)) return;\n if (node !== this.owner && isOwner(ts, node)) {\n this.handedFunction(node);\n return;\n }\n if (ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.EqualsToken) {\n this.visit(node.right, state);\n this.visit(node.left, state);\n this.assign(node, state);\n return;\n }\n ts.forEachChild(node, (child) => this.visit(child, state));\n if (ts.isCallExpression(node) || ts.isNewExpression(node) || ts.isTaggedTemplateExpression(node)) this.temporary(node);\n else if (ts.isIdentifier(node)) this.reference(node, state);\n }\n\n /**\n * `results.filter(…)`, `[...map.values()].slice(1)`: a method that only hands back elements its receiver\n * already holds. The failures belong to the receiver (followed, or not, where it lives); the derived\n * collection is not a new one.\n */\n private derivedFromReceiver(node: TS.Expression): boolean {\n const ts = this.ts;\n if (!ts.isCallExpression(node)) return false;\n const callee = unparen(ts, node.expression);\n if (!ts.isPropertyAccessExpression(callee) || !ELEMENT_METHODS.has(callee.name.text)) return false;\n return this.kindsOf(callee.expression) !== null;\n }\n\n /** A call's value: reported where it is dropped; followed when it is kept in a variable. */\n private temporary(node: TS.Expression): void {\n if (!this.kindsOf(node) || this.derivedFromReceiver(node)) return;\n const carrier = this.carrier(node);\n const fate = this.fate(carrier);\n if (fate !== 'discarded' && fate !== 'argument' && fate !== 'stored') return;\n if (fate !== 'discarded' && this.returnedWithin(carrier)) return;\n if (this.reported.has(carrier)) return;\n this.reported.add(carrier);\n this.report(fate, carrier, subjectOf(carrier, this.sourceFile), this.kindsOf(carrier) ?? this.kindsOf(node) ?? NOTHING);\n }\n\n /**\n * `return this.reply('status', await svc.status())`, `return { result: f() }`: the value sits inside the\n * returned value (an argument of a call, or a property, that is itself returned), so its failure goes out with\n * it. A call that returns nothing (`return log(f())`) carries nothing.\n */\n private returnedWithin(node: TS.Node): boolean {\n const ts = this.ts;\n let current = node;\n for (let parent = current.parent; parent; current = parent, parent = parent.parent) {\n if (ts.isReturnStatement(parent)) return true;\n if (ts.isArrowFunction(parent)) return parent.body === current;\n if (ts.isStatement(parent) || isOwner(ts, parent)) return false;\n if ((ts.isCallExpression(parent) || ts.isNewExpression(parent)) && argumentsOf(parent).includes(current)) {\n const returned = this.checker.getTypeAtLocation(parent);\n if (returned.flags & (ts.TypeFlags.Void | ts.TypeFlags.Undefined)) return false;\n }\n }\n return false;\n }\n\n /** A followed variable read: handed over (alias, return, decide, a Result parameter) or just read. */\n private reference(node: TS.Identifier, state: State): void {\n const symbol = this.trackedSymbol(node, state);\n if (!symbol) return;\n const fate = this.fate(this.carrier(node));\n // Handed over: nothing is left to drop, but the path still knows whether it is a failure path.\n if (fate === 'track' || fate === 'consume' || fate === 'return') state.set(symbol, { kinds: NOTHING, err: state.get(symbol)?.err ?? false });\n }\n\n /** A function written inline as an argument: its failure is dropped when the callee takes no Result back. */\n private handedFunction(node: FunctionOwner): void {\n const ts = this.ts;\n if (!ts.isArrowFunction(node) && !ts.isFunctionExpression(node)) return;\n const call = node.parent;\n if (!(ts.isCallExpression(call) || ts.isNewExpression(call)) || !argumentsOf(call).includes(node)) return;\n if (this.isDecideOrTranslate(call)) return;\n const signature = this.checker.getSignatureFromDeclaration(node);\n const kinds = signature ? this.typeKinds(this.checker.getReturnTypeOfSignature(signature)) : null;\n if (!kinds || this.kindsOf(call) !== null || this.acceptsArgument(call, node)) return;\n this.report('callback', node, subjectOf(call.expression, this.sourceFile), kinds);\n }\n\n private assign(node: TS.BinaryExpression, state: State): void {\n const ts = this.ts;\n const target = unparen(ts, node.left);\n const names = ts.isIdentifier(target) ? [target] : ts.isArrayLiteralExpression(target) ? target.elements.filter(ts.isIdentifier) : [];\n for (const name of names) {\n const symbol = this.checker.getSymbolAtLocation(name);\n if (!symbol || !this.tracked.has(symbol)) continue;\n const current = state.get(symbol);\n if (current && current.kinds.size > 0) this.reportVariable('overwritten', node, symbol, current.kinds);\n const kinds = ts.isIdentifier(target) ? this.kindsOf(node.right) : this.kindsOf(name);\n state.set(symbol, { kinds: kinds ?? NOTHING, err: false });\n }\n }\n\n /**\n * Starts following the variables `name` binds that can fail (a module-level variable is never followed). With an\n * `initializer`, what can fail is what the initializer holds (`let scope: Result<…> | null = null` holds nothing yet).\n */\n private declare(name: TS.BindingName, scope: TS.Node, state: State, assigned: boolean, initializer?: TS.Expression): void {\n const ts = this.ts;\n if (ts.isSourceFile(this.owner)) return;\n if (ts.isIdentifier(name)) {\n const symbol = this.checker.getSymbolAtLocation(name);\n const kinds = symbol ? this.kindsOf(name) : null;\n if (!symbol || !kinds) return;\n this.tracked.set(symbol, { name: name.text, scope });\n if (assigned) state.set(symbol, { kinds: initializer ? (this.kindsOf(initializer) ?? NOTHING) : kinds, err: false });\n return;\n }\n for (const element of name.elements) {\n if (!ts.isOmittedExpression(element)) this.declare(element.name, scope, state, assigned);\n }\n }\n\n private declarations(list: TS.VariableDeclarationList, scope: TS.Node, state: State): void {\n const ts = this.ts;\n const blockScoped = (list.flags & (ts.NodeFlags.Let | ts.NodeFlags.Const | ts.NodeFlags.Using | ts.NodeFlags.AwaitUsing)) !== 0;\n for (const declaration of list.declarations) {\n if (declaration.initializer) {\n this.visit(declaration.initializer, state);\n this.recordErrorAlias(declaration, state);\n }\n const initializer = ts.isIdentifier(declaration.name) ? declaration.initializer : undefined;\n this.declare(declaration.name, blockScoped ? scope : this.functionScope, state, declaration.initializer !== undefined, initializer);\n }\n }\n\n /**\n * `const failure = r.error`: `failure.kind` names r's kinds. Any variable whose initializer takes a failure along\n * (`const failed = { message: r.error.message }`) carries it: returning that variable carries r's failure out.\n */\n private recordErrorAlias(declaration: TS.VariableDeclaration, state: State): void {\n const ts = this.ts;\n const initializer = declaration.initializer ? unparen(ts, declaration.initializer) : undefined;\n if (!initializer || !ts.isIdentifier(declaration.name)) return;\n const alias = this.checker.getSymbolAtLocation(declaration.name);\n if (!alias) return;\n if (ts.isPropertyAccessExpression(initializer) && initializer.name.text === 'error') {\n const owner = this.trackedSymbol(initializer.expression, state);\n if (owner) this.errorAliases.set(alias, owner);\n }\n const owners = new Set<TS.Symbol>();\n const collect = (node: TS.Node): void => {\n if (isOwner(ts, node)) return;\n if (ts.isIdentifier(node) && this.carriesFailure(node)) {\n const owner = this.trackedSymbol(node, state);\n if (owner) owners.add(owner);\n const viaAlias = this.checker.getSymbolAtLocation(node);\n for (const carried of (viaAlias && this.failureCarriers.get(viaAlias)) || []) owners.add(carried);\n }\n ts.forEachChild(node, collect);\n };\n collect(initializer);\n if (owners.size > 0) this.failureCarriers.set(alias, owners);\n }\n\n // ---- narrowing ----\n\n /** `r.ok` on a followed variable. */\n private okCheck(node: TS.Node, state: State): TS.Symbol | null {\n const inner = unparen(this.ts, node);\n if (!this.ts.isPropertyAccessExpression(inner) || inner.name.text !== 'ok') return null;\n return this.trackedSymbol(inner.expression, state);\n }\n\n /** `r.error.kind` on a followed variable, or `failure.kind` on an alias of its `error`. */\n private kindCheck(node: TS.Node, state: State): TS.Symbol | null {\n const ts = this.ts;\n const inner = unparen(ts, node);\n if (!ts.isPropertyAccessExpression(inner) || inner.name.text !== 'kind') return null;\n const error = unparen(ts, inner.expression);\n if (ts.isIdentifier(error)) {\n const alias = this.checker.getSymbolAtLocation(error);\n const owner = alias ? this.errorAliases.get(alias) : undefined;\n return owner && state.has(owner) ? owner : null;\n }\n if (!ts.isPropertyAccessExpression(error) || error.name.text !== 'error') return null;\n return this.trackedSymbol(error.expression, state);\n }\n\n private withOk(state: State, symbol: TS.Symbol, isOk: boolean): State {\n const narrowed = new Map(state);\n const current = state.get(symbol);\n if (current) narrowed.set(symbol, isOk ? { kinds: NOTHING, err: false } : { kinds: current.kinds, err: true });\n return narrowed;\n }\n\n /** A branch that names `kind` handles it; the other branch keeps the kinds that are not `kind`. */\n private withKind(state: State, symbol: TS.Symbol, kind: string, isKind: boolean): State {\n const narrowed = new Map(state);\n const current = state.get(symbol);\n if (current) {\n const rest = new Set(current.kinds);\n rest.delete(kind);\n narrowed.set(symbol, isKind ? { kinds: NOTHING, err: true } : { kinds: rest, err: true });\n }\n return narrowed;\n }\n\n /** The state a branch starts with: narrowed by its condition, and its own copy (a branch's declarations stay in it). */\n private branch(condition: TS.Node, state: State, outcome: boolean): State {\n return new Map(this.narrow(condition, state, outcome));\n }\n\n private narrow(condition: TS.Node, state: State, outcome: boolean): State {\n const ts = this.ts;\n const node = unparen(ts, condition);\n if (ts.isPrefixUnaryExpression(node) && node.operator === ts.SyntaxKind.ExclamationToken) return this.narrow(node.operand, state, !outcome);\n if (ts.isBinaryExpression(node)) {\n const operator = node.operatorToken.kind;\n if (operator === ts.SyntaxKind.AmpersandAmpersandToken) {\n const left = this.narrow(node.left, state, true);\n if (outcome) return this.narrow(node.right, left, true);\n return merge(this.narrow(node.left, state, false), this.narrow(node.right, left, false)) ?? state;\n }\n if (operator === ts.SyntaxKind.BarBarToken) {\n const left = this.narrow(node.left, state, false);\n if (!outcome) return this.narrow(node.right, left, false);\n return merge(this.narrow(node.left, state, true), this.narrow(node.right, left, true)) ?? state;\n }\n // `'ok' in r`: where it is false, `r` is some other shape than a Result, so nothing to drop.\n if (operator === ts.SyntaxKind.InKeyword && stringLiteral(ts, node.left) !== undefined) {\n const shape = this.trackedSymbol(node.right, state);\n const key = stringLiteral(ts, node.left);\n if (shape && (key === 'ok' || key === 'error' || key === 'value')) {\n if (key === 'ok') return outcome ? state : this.withNothing(state, shape);\n return key === 'error' ? this.withOk(state, shape, !outcome) : this.withOk(state, shape, outcome);\n }\n return state;\n }\n const equal = operator === ts.SyntaxKind.EqualsEqualsEqualsToken || operator === ts.SyntaxKind.EqualsEqualsToken;\n const unequal = operator === ts.SyntaxKind.ExclamationEqualsEqualsToken || operator === ts.SyntaxKind.ExclamationEqualsToken;\n if (equal || unequal) {\n const holds = equal ? outcome : !outcome;\n for (const [side, other] of [\n [node.left, node.right],\n [node.right, node.left],\n ] as const) {\n const ok = this.okCheck(side, state);\n const value = booleanLiteral(ts, other);\n if (ok && value !== undefined) return this.withOk(state, ok, value === holds);\n const kindOf = this.kindCheck(side, state);\n const kind = stringLiteral(ts, other);\n if (kindOf && kind !== undefined) return this.withKind(state, kindOf, kind, holds);\n // `r === null` / `r == undefined`: where it holds there is no Result, so nothing to drop.\n const nullable = this.trackedSymbol(side, state);\n if (nullable && isNullish(ts, other)) return holds ? this.withNothing(state, nullable) : state;\n }\n }\n return state;\n }\n const ok = this.okCheck(node, state);\n if (ok) return this.withOk(state, ok, outcome);\n // `if (r)`: a Result is an object, always truthy, so where `r` is falsy it is null or undefined.\n const truthy = this.trackedSymbol(node, state);\n return truthy && !outcome ? this.withNothing(state, truthy) : state;\n }\n\n private withNothing(state: State, symbol: TS.Symbol): State {\n const narrowed = new Map(state);\n if (narrowed.has(symbol)) narrowed.set(symbol, { kinds: NOTHING, err: false });\n return narrowed;\n }\n\n // ---- statements ----\n\n private block(block: TS.Block, state: State): State | null {\n const out = this.statements(block.statements, state, block);\n return this.leaveScope(block, out, block.end - 1);\n }\n\n private statements(list: readonly TS.Statement[], state: State, scope: TS.Node): State | null {\n let current: State | null = state;\n for (const statement of list) {\n if (!current) break;\n current = this.statement(statement, current, scope);\n }\n return current;\n }\n\n private statement(node: TS.Statement, state: State, scope: TS.Node, label?: string): State | null {\n const ts = this.ts;\n if (ts.isBlock(node)) return this.block(node, state);\n if (ts.isVariableStatement(node)) {\n this.declarations(node.declarationList, scope, state);\n return state;\n }\n if (ts.isExpressionStatement(node)) {\n this.visit(node.expression, state);\n return state;\n }\n if (ts.isIfStatement(node)) {\n this.visit(node.expression, state);\n const whenTrue = this.statement(node.thenStatement, this.branch(node.expression, state, true), scope);\n const otherwise = this.branch(node.expression, state, false);\n const whenFalse = node.elseStatement ? this.statement(node.elseStatement, otherwise, scope) : otherwise;\n return merge(whenTrue, whenFalse);\n }\n if (ts.isReturnStatement(node)) {\n if (node.expression) this.visit(node.expression, state);\n this.checkReturn(node, node.expression, state);\n return null;\n }\n if (ts.isThrowStatement(node)) {\n this.visit(node.expression, state);\n return null;\n }\n if (ts.isBreakStatement(node) || ts.isContinueStatement(node)) return this.jump(node, state);\n if (ts.isSwitchStatement(node)) return this.switchStatement(node, state, label);\n if (ts.isTryStatement(node)) return this.tryStatement(node, state);\n if (ts.isLabeledStatement(node)) return this.labeled(node, state, scope);\n if (\n ts.isForStatement(node) ||\n ts.isForOfStatement(node) ||\n ts.isForInStatement(node) ||\n ts.isWhileStatement(node) ||\n ts.isDoStatement(node)\n ) {\n return this.loop(node, state, label);\n }\n this.visit(node, state);\n return state;\n }\n\n /**\n * Every variable that can still fail is dropped unless the return passes it up or carries it out:\n * - the returned value can fail and names the variable (`return r`, `return r.ok ? x : r`);\n * - the returned value carries the failure itself, whatever its type (`return this.failed(r.error)`,\n * `return reply(r)`): the error goes out with the response (`r.ok` / `r.value` alone do not carry it);\n * - the return passes a failure up on a path where a followed value is known to be an `Err`\n * (`if (!a.ok) return a;` also covers a `b` not checked yet: the first failure goes up).\n */\n private checkReturn(at: TS.Node, expression: TS.Expression | undefined, state: State): void {\n const ts = this.ts;\n const passes = expression !== undefined && this.kindsOf(expression) !== null;\n const referenced = new Set<TS.Symbol>();\n const carried = new Set<TS.Symbol>();\n const collect = (node: TS.Node): void => {\n if (isOwner(ts, node)) return;\n if (ts.isIdentifier(node)) {\n const symbol = this.checker.getSymbolAtLocation(node);\n if (symbol) {\n referenced.add(symbol);\n if (this.carriesFailure(node)) carried.add(symbol);\n const owner = this.errorAliases.get(symbol);\n if (owner) carried.add(owner);\n for (const carrier of this.failureCarriers.get(symbol) ?? []) carried.add(carrier);\n }\n }\n ts.forEachChild(node, collect);\n };\n if (expression) collect(expression);\n // A failure path: a followed value is known to be an `Err` here, or the returned value is one by its own\n // narrowed type (`if (!loaded.value.ok) return loaded.value;`, `return Result.err(…)`).\n const returnsErr = passes && expression !== undefined && this.isErrOnly(expression);\n const failing = returnsErr || [...state].some(([symbol, value]) => value.err && (passes || carried.has(symbol)));\n for (const [symbol, value] of state) {\n if (value.kinds.size === 0) continue;\n if ((passes && referenced.has(symbol)) || carried.has(symbol) || failing) continue;\n this.reportVariable('return', at, symbol, value.kinds);\n }\n }\n\n /** The expression's type (awaited) is only `Err` members: TypeScript has narrowed it to a failure. */\n private isErrOnly(expression: TS.Expression): boolean {\n const type = this.checker.getTypeAtLocation(expression);\n return this.context.policy.isErrType(this.checker.getAwaitedType(type) ?? type);\n }\n\n /** A read of a variable that takes its failure along: the variable itself, or its `error` (not `.ok` / `.value`). */\n private carriesFailure(node: TS.Identifier): boolean {\n const ts = this.ts;\n let current: TS.Node = node;\n while (ts.isParenthesizedExpression(current.parent) || ts.isNonNullExpression(current.parent) || ts.isAsExpression(current.parent)) current = current.parent;\n const parent = current.parent;\n if (ts.isPropertyAccessExpression(parent) && parent.expression === current) return parent.name.text === 'error';\n if (ts.isElementAccessExpression(parent) && parent.expression === current) return false;\n return true;\n }\n\n private jump(node: TS.BreakStatement | TS.ContinueStatement, state: State): null {\n const ts = this.ts;\n const label = node.label?.text;\n const isBreak = ts.isBreakStatement(node);\n let target: JumpTarget | undefined;\n for (let index = this.targets.length - 1; index >= 0 && !target; index -= 1) {\n const candidate = this.targets[index];\n if (label !== undefined ? candidate.label === label : isBreak ? candidate.kind !== 'labeled' : candidate.kind === 'loop') target = candidate;\n }\n if (!target) return null;\n const to = target;\n // A classic `for` keeps its own variables across a `continue`.\n const keeps = (info: Tracked) => !isBreak && ts.isForStatement(to.node) && info.scope === to.node;\n const left = this.leaveScope(to.node, state, node, true, keeps) ?? state;\n (isBreak ? to.breaks : to.continues).push(left);\n return null;\n }\n\n private labeled(node: TS.LabeledStatement, state: State, scope: TS.Node): State | null {\n const ts = this.ts;\n const inner = node.statement;\n const isLoop =\n ts.isForStatement(inner) || ts.isForOfStatement(inner) || ts.isForInStatement(inner) || ts.isWhileStatement(inner) || ts.isDoStatement(inner);\n if (isLoop || ts.isSwitchStatement(inner)) return this.statement(inner, state, scope, node.label.text);\n const target: JumpTarget = { node, label: node.label.text, kind: 'labeled', breaks: [], continues: [] };\n this.targets.push(target);\n const out = this.statement(inner, state, scope);\n this.targets.pop();\n return mergeAll([out, ...target.breaks]);\n }\n\n private switchStatement(node: TS.SwitchStatement, state: State, label: string | undefined): State | null {\n const ts = this.ts;\n this.visit(node.expression, state);\n const kindOf = this.kindCheck(node.expression, state);\n const labels = node.caseBlock.clauses.flatMap((clause) => {\n const kind = ts.isCaseClause(clause) ? stringLiteral(ts, clause.expression) : undefined;\n return kind === undefined ? [] : [kind];\n });\n const rest = (): State => {\n if (!kindOf) return new Map(state);\n let narrowed = state;\n for (const kind of labels) narrowed = this.withKind(narrowed, kindOf, kind, false);\n return narrowed;\n };\n const target: JumpTarget = { node, label, kind: 'switch', breaks: [], continues: [] };\n this.targets.push(target);\n let fallthrough: State | null = null;\n let hasDefault = false;\n for (const clause of node.caseBlock.clauses) {\n let entry: State;\n if (ts.isCaseClause(clause)) {\n this.visit(clause.expression, state);\n const kind = stringLiteral(ts, clause.expression);\n entry = kindOf && kind !== undefined ? this.withKind(state, kindOf, kind, true) : new Map(state);\n } else {\n hasDefault = true;\n entry = rest();\n }\n fallthrough = this.statements(clause.statements, merge(entry, fallthrough) ?? entry, node.caseBlock);\n }\n this.targets.pop();\n const out = mergeAll([fallthrough, ...target.breaks, hasDefault ? null : rest()]);\n return this.leaveScope(node.caseBlock, out, node.end - 1);\n }\n\n private loop(\n node: TS.ForStatement | TS.ForOfStatement | TS.ForInStatement | TS.WhileStatement | TS.DoStatement,\n state: State,\n label: string | undefined,\n ): State | null {\n const ts = this.ts;\n let entry: State = new Map(state);\n let skip: State | null = entry;\n if (ts.isForStatement(node)) {\n if (node.initializer && ts.isVariableDeclarationList(node.initializer)) this.declarations(node.initializer, node, entry);\n else if (node.initializer) this.visit(node.initializer, entry);\n if (node.condition) {\n this.visit(node.condition, entry);\n skip = this.branch(node.condition, entry, false);\n entry = this.branch(node.condition, entry, true);\n } else {\n skip = null;\n }\n } else if (ts.isForOfStatement(node) || ts.isForInStatement(node)) {\n this.visit(node.expression, entry);\n skip = new Map(entry);\n if (ts.isVariableDeclarationList(node.initializer)) {\n for (const declaration of node.initializer.declarations) this.declare(declaration.name, node, entry, true);\n } else {\n this.visit(node.initializer, entry);\n }\n } else if (ts.isWhileStatement(node)) {\n this.visit(node.expression, entry);\n skip = this.branch(node.expression, entry, false);\n entry = this.branch(node.expression, entry, true);\n } else {\n skip = null;\n }\n const target: JumpTarget = { node, label, kind: 'loop', breaks: [], continues: [] };\n this.targets.push(target);\n let out = this.statement(node.statement, entry, node);\n this.targets.pop();\n const repeat = mergeAll([out, ...target.continues]);\n if (ts.isForStatement(node) && node.incrementor && repeat) this.visit(node.incrementor, repeat);\n if (ts.isDoStatement(node) && repeat) this.visit(node.expression, repeat);\n // One iteration of a for-of / for-in ends here: its loop variable goes out of scope.\n if (ts.isForOfStatement(node) || ts.isForInStatement(node)) out = this.leaveScope(node, out, node.statement.end - 1);\n const exit = mergeAll([skip, out, ...target.continues, ...target.breaks]);\n return ts.isForStatement(node) ? this.leaveScope(node, exit, node.end - 1) : exit;\n }\n\n private tryStatement(node: TS.TryStatement, state: State): State | null {\n const tried = this.block(node.tryBlock, new Map(state));\n let caught: State | null = null;\n // The catch runs when the try threw, so it starts from the state before the try: a value the try was about to\n // assign (`try { x = await work(); } catch { x = fallback; }`) was never there.\n if (node.catchClause) caught = this.block(node.catchClause.block, new Map(state));\n const out = node.catchClause ? merge(tried, caught) : tried;\n if (!node.finallyBlock) return out;\n const finished = this.block(node.finallyBlock, out ?? new Map(state));\n return out ? finished : null;\n }\n}\n\n/** Every dropped failure in `sourceFile`: its top-level statements, then each function, in source order. */\nexport function droppedResultsIn(sourceFile: TS.SourceFile, context: DroppedResultContext): DroppedResult[] {\n const ts = context.ts;\n const found: DroppedResult[] = [];\n new DropWalk(context, sourceFile, found).run();\n const visit = (node: TS.Node): void => {\n if (isOwner(ts, node)) new DropWalk(context, node, found).run();\n ts.forEachChild(node, visit);\n };\n ts.forEachChild(sourceFile, visit);\n return found.sort((a, b) => a.start - b.start);\n}\n","// The two trust rules as decisions on TypeScript nodes — the one implementation shared by the\n// standalone checker (check-file.ts) and the ESLint adapter (src/eslint/rules/*).\n// throw-must-return-result: every `throw` in checked code must be guarded.\n// untrusted-call-must-return-result: every call/`new` whose callee is untrusted must be guarded,\n// and an async one must settle inside the guard.\nimport type * as TS from 'typescript';\nimport type { TrustPolicy } from '../eslint/policy.js';\nimport type { TypeScript } from '../eslint/typescript.js';\nimport { asPlainCall, esParent, guardOf, inOptionalChain, unparen, type Guard, type GuardContext } from './guard.js';\nimport type { ThrowMessageId, UntrustedCallMessageId } from './messages.js';\n\nconst PROMISE_COMBINATORS = new Set(['all', 'allSettled', 'race', 'any']);\n\n/** Typed guard context: Result.err and Trust.try* recognised by declaration. */\nexport function typedGuardContext(ts: TypeScript, checker: TS.TypeChecker, policy: TrustPolicy): GuardContext {\n return {\n ts,\n isResultErr: (expression) => policy.isErrType(checker.getTypeAtLocation(expression)),\n isErrCall: (call) => policy.trustFunctionName(call) === 'err',\n trustTryKind: (call) => {\n const name = policy.trustFunctionName(call);\n if (name === 'tryResult') return 'sync';\n if (name === 'tryResultAsync') return 'async';\n return null;\n },\n };\n}\n\nfunction isIdentifierNamed(ts: TypeScript, node: TS.Node, name: string): boolean {\n return ts.isIdentifier(node) && node.text === name;\n}\n\nfunction isNamedErrCall(ts: TypeScript, node: TS.Node): boolean {\n const call = asPlainCall(ts, node);\n if (!call) return false;\n const callee = unparen(ts, call.expression);\n if (ts.isIdentifier(callee)) return callee.text === 'err';\n if (!ts.isPropertyAccessExpression(callee)) return false;\n return isIdentifierNamed(ts, unparen(ts, callee.expression), 'Result') && isIdentifierNamed(ts, callee.name, 'err');\n}\n\nfunction namedTryKind(ts: TypeScript, call: TS.CallExpression): 'sync' | 'async' | null {\n const callee = unparen(ts, call.expression);\n if (ts.isIdentifier(callee)) {\n if (callee.text === 'tryResult') return 'sync';\n if (callee.text === 'tryResultAsync') return 'async';\n return null;\n }\n if (!ts.isPropertyAccessExpression(callee)) return null;\n const object = unparen(ts, callee.expression);\n // `Trust.try` / `Trust.tryAsync` is the current spelling; `Result.try` / `Result.tryAsync` is pre-0.4.\n if (!ts.isIdentifier(object) || (object.text !== 'Trust' && object.text !== 'Result') || !ts.isIdentifier(callee.name)) return null;\n if (callee.name.text === 'try') return 'sync';\n if (callee.name.text === 'tryAsync') return 'async';\n return null;\n}\n\n/** Name-based fallback for untyped linting (ESLint without type information). */\nexport function nameBasedGuardContext(ts: TypeScript): GuardContext {\n return {\n ts,\n isResultErr: (expression) => isNamedErrCall(ts, expression),\n isErrCall: (call) => isNamedErrCall(ts, call),\n trustTryKind: (call) => namedTryKind(ts, call),\n };\n}\n\n/** Message id for an unguarded / badly guarded `throw`, else null. */\nexport function throwProblem(node: TS.ThrowStatement, context: GuardContext): ThrowMessageId | null {\n const guard = guardOf(node, context);\n if (guard.status === 'unguarded') return 'escapes';\n if (guard.status === 'badCatch') return guard.problem;\n return null;\n}\n\n/** Outermost expression of a `.then()/.catch()` chain started by `node`. */\nfunction chainTop(ts: TypeScript, node: TS.Node): TS.Node {\n let current = node;\n for (;;) {\n const member = esParent(ts, current);\n const call = member && esParent(ts, member);\n const isMember = member && (ts.isPropertyAccessExpression(member) || ts.isElementAccessExpression(member));\n if (isMember && unparen(ts, member.expression) === current && call && ts.isCallExpression(call) && unparen(ts, call.expression) === member) {\n current = call;\n } else {\n return current;\n }\n }\n}\n\nfunction isPromiseCombinator(ts: TypeScript, call: TS.Node | undefined): call is TS.CallExpression {\n if (!call || !ts.isCallExpression(call)) return false;\n const callee = unparen(ts, call.expression);\n if (!ts.isPropertyAccessExpression(callee)) return false;\n return isIdentifierNamed(ts, unparen(ts, callee.expression), 'Promise') && ts.isIdentifier(callee.name) && PROMISE_COMBINATORS.has(callee.name.text);\n}\n\n/** The promise produced by `expression` settles inside the guard (awaited, or returned to Trust.tryAsync). */\nfunction isConsumed(ts: TypeScript, expression: TS.Node, guard: Guard): boolean {\n const top = chainTop(ts, expression);\n // The top of an optional chain sits inside an ESTree ChainExpression, which none of the checks accept.\n if (inOptionalChain(ts, top)) return false;\n const parent = esParent(ts, top);\n if (!parent) return false;\n if (ts.isAwaitExpression(parent)) return true;\n if (ts.isArrayLiteralExpression(parent)) {\n const combinator = esParent(ts, parent);\n return isPromiseCombinator(ts, combinator) && isConsumed(ts, combinator, guard);\n }\n if (guard.status === 'guarded' && guard.via === 'async-callback') {\n if (ts.isReturnStatement(parent)) return true;\n if (ts.isArrowFunction(parent) && unparen(ts, parent.body) === top) return true;\n }\n return false;\n}\n\nexport interface CallProblem {\n readonly messageId: UntrustedCallMessageId;\n readonly origin: string;\n}\n\n/** Problem with one call/`new` (untrusted and unguarded, badly guarded, not awaited, or into an ignored file), else null. */\nexport function untrustedCallProblem(\n node: TS.CallExpression | TS.NewExpression,\n policy: TrustPolicy,\n checker: TS.TypeChecker,\n context: GuardContext,\n): CallProblem | null {\n const ts = context.ts;\n const verdict = policy.classify(node);\n if (verdict.kind === 'calls-ignored') return { messageId: 'callsIgnored', origin: verdict.origin.origin };\n if (verdict.kind !== 'untrusted') return null;\n const origin = verdict.origin.origin;\n const guard = guardOf(node, context);\n if (guard.status === 'unguarded') return { messageId: 'unguarded', origin };\n if (guard.status === 'badCatch') return { messageId: guard.problem, origin };\n if (checker.getTypeAtLocation(node).getProperty('then') && !isConsumed(ts, node, guard)) return { messageId: 'notAwaited', origin };\n return null;\n}\n","// The two promise rules as decisions on TypeScript nodes (type-aware, run in the same walk as the\n// trust rules by check-file.ts):\n// floating-promise: an expression statement whose value is thenable must be awaited, `void`-ed,\n// assigned, yielded, or handled with `.catch(...)` / `.then(onFulfilled, onRejected)`.\n// misused-promise: a promise used as a condition (`condition`), or an async callback passed where a\n// void-returning function is expected (`void-callback`).\nimport type * as TS from 'typescript';\nimport type { TypeScript } from '../eslint/typescript.js';\nimport { esParent, unparen } from './guard.js';\n\nfunction unionParts(type: TS.Type): readonly TS.Type[] {\n return type.isUnion() ? type.types : [type];\n}\n\n/** One non-union type with a callable `then` member. */\nfunction hasCallableThen(checker: TS.TypeChecker, type: TS.Type, node: TS.Node): boolean {\n const then = checker.getApparentType(type).getProperty('then');\n if (!then) return false;\n return checker.getTypeOfSymbolAtLocation(then, node).getCallSignatures().length > 0;\n}\n\n/** Thenable, or a union with at least one thenable member. */\nexport function isSometimesThenable(checker: TS.TypeChecker, type: TS.Type, node: TS.Node): boolean {\n return unionParts(type).some((part) => hasCallableThen(checker, part, node));\n}\n\n/** Thenable in every union member: such a value is always truthy and never nullish. */\nexport function isAlwaysThenable(checker: TS.TypeChecker, type: TS.Type, node: TS.Node): boolean {\n return unionParts(type).every((part) => hasCallableThen(checker, part, node));\n}\n\nfunction isAssignment(ts: TypeScript, node: TS.Node): boolean {\n return (\n ts.isBinaryExpression(node) &&\n node.operatorToken.kind >= ts.SyntaxKind.FirstAssignment &&\n node.operatorToken.kind <= ts.SyntaxKind.LastAssignment\n );\n}\n\n/**\n * `x.catch(...)` (any arguments) or `x.then(onFulfilled, onRejected)`: the rejection is handled.\n * `.finally(...)` neither handles nor loses a rejection, so `x.finally(f)` is judged by `x`\n * (`work().then(a, b).finally(f)` is handled; `work().finally(f)` is not).\n */\nfunction isHandledChain(ts: TypeScript, node: TS.Node): boolean {\n if (!ts.isCallExpression(node)) return false;\n const callee = unparen(ts, node.expression);\n if (!ts.isPropertyAccessExpression(callee) || !ts.isIdentifier(callee.name)) return false;\n if (callee.name.text === 'finally') return isHandledChain(ts, unparen(ts, callee.expression));\n if (callee.name.text === 'catch') return true;\n return callee.name.text === 'then' && node.arguments.length >= 2;\n}\n\n/** True when the statement's value is a promise nobody awaits or handles. */\nexport function isFloatingPromise(ts: TypeScript, checker: TS.TypeChecker, statement: TS.ExpressionStatement): boolean {\n const expression = unparen(ts, statement.expression);\n if (\n ts.isAwaitExpression(expression) ||\n ts.isVoidExpression(expression) ||\n ts.isYieldExpression(expression) ||\n isAssignment(ts, expression) ||\n isHandledChain(ts, expression)\n ) {\n return false;\n }\n return isSometimesThenable(checker, checker.getTypeAtLocation(expression), expression);\n}\n\nfunction isLogical(ts: TypeScript, node: TS.Node): node is TS.BinaryExpression {\n if (!ts.isBinaryExpression(node)) return false;\n const kind = node.operatorToken.kind;\n return kind === ts.SyntaxKind.AmpersandAmpersandToken || kind === ts.SyntaxKind.BarBarToken || kind === ts.SyntaxKind.QuestionQuestionToken;\n}\n\n/** `node` (parentheses skipped) is read for its truthiness: a statement/ternary test, `!x`, or a logical operand that decides. */\nfunction isConditionPosition(ts: TypeScript, node: TS.Node): boolean {\n const parent = esParent(ts, node);\n if (!parent) return false;\n const self = (candidate: TS.Node | undefined): boolean => candidate !== undefined && unparen(ts, candidate) === node;\n if (ts.isIfStatement(parent) || ts.isWhileStatement(parent) || ts.isDoStatement(parent)) return self(parent.expression);\n if (ts.isForStatement(parent)) return self(parent.condition);\n if (ts.isConditionalExpression(parent)) return self(parent.condition);\n if (ts.isPrefixUnaryExpression(parent)) return parent.operator === ts.SyntaxKind.ExclamationToken;\n if (isLogical(ts, parent)) return self(parent.left) || isConditionPosition(ts, parent);\n return false;\n}\n\n/**\n * Expressions `node` reads as conditions. A logical expression is not itself returned: its operands\n * are (the left one always, the right one only when the whole expression is a condition), so\n * `if (p() || q())` reports `p()` and `q()` once each.\n */\nexport function conditionOperands(ts: TypeScript, node: TS.Node): TS.Expression[] {\n let operands: Array<TS.Expression | undefined> = [];\n if (ts.isIfStatement(node) || ts.isWhileStatement(node) || ts.isDoStatement(node)) operands = [node.expression];\n else if (ts.isForStatement(node)) operands = [node.condition];\n else if (ts.isConditionalExpression(node)) operands = [node.condition];\n else if (ts.isPrefixUnaryExpression(node) && node.operator === ts.SyntaxKind.ExclamationToken) operands = [node.operand];\n else if (isLogical(ts, node)) operands = isConditionPosition(ts, node) ? [node.left, node.right] : [node.left];\n return operands.filter((operand): operand is TS.Expression => operand !== undefined && !isLogical(ts, unparen(ts, operand)));\n}\n\n/** A promise used as a condition (always truthy, never nullish). */\nexport function isPromiseCondition(checker: TS.TypeChecker, operand: TS.Expression): boolean {\n return isAlwaysThenable(checker, checker.getTypeAtLocation(operand), operand);\n}\n\nfunction returnsThenable(checker: TS.TypeChecker, type: TS.Type, node: TS.Node): boolean {\n return unionParts(type).some((part) =>\n part.getCallSignatures().some((signature) => isSometimesThenable(checker, signature.getReturnType(), node)),\n );\n}\n\nfunction returnsVoid(ts: TypeScript, type: TS.Type): boolean {\n return unionParts(type).some((part) =>\n part.getCallSignatures().some((signature) => (signature.getReturnType().flags & ts.TypeFlags.Void) !== 0),\n );\n}\n\n/** Type of the parameter receiving argument `index` (the element type for a rest parameter). */\nfunction parameterType(ts: TypeScript, checker: TS.TypeChecker, signature: TS.Signature, index: number, node: TS.Node): TS.Type | undefined {\n const parameters = signature.getParameters();\n const last = parameters[parameters.length - 1];\n const lastDeclaration = last?.valueDeclaration;\n const isRest = lastDeclaration !== undefined && ts.isParameter(lastDeclaration) && lastDeclaration.dotDotDotToken !== undefined;\n if (isRest && index >= parameters.length - 1) {\n const restType = checker.getTypeOfSymbolAtLocation(last, node);\n return checker.getIndexTypeOfType(restType, ts.IndexKind.Number);\n }\n const parameter = parameters[index];\n return parameter ? checker.getTypeOfSymbolAtLocation(parameter, node) : undefined;\n}\n\n/** Arguments of `call` that return a promise into a parameter typed as a void-returning function. */\nexport function asyncVoidCallbacks(ts: TypeScript, checker: TS.TypeChecker, call: TS.CallExpression | TS.NewExpression): TS.Expression[] {\n const args = call.arguments ?? [];\n if (args.length === 0) return [];\n const signature = checker.getResolvedSignature(call);\n if (!signature) return [];\n return args.filter((argument, index) => {\n if (ts.isSpreadElement(argument)) return false;\n if (!returnsThenable(checker, checker.getTypeAtLocation(argument), argument)) return false;\n const expected = parameterType(ts, checker, signature, index, call);\n return expected !== undefined && returnsVoid(ts, expected);\n });\n}\n","// Accepted failure paths: the one place a throw, an untrusted call or a promise may stay unhandled. A\n// statement is accepted when the line directly above it is the directive\n//\n// //trust:accept public API contract: callers get exceptions from this edge\n// throw toError(failure);\n//\n// It accepts the findings of the failure-path rules (throw-must-return-result,\n// untrusted-call-must-return-result, floating-promise, misused-promise) that belong to that statement,\n// and nothing else: never a type claim (validators are the way out there), never the enclosing\n// function, never a sibling. A finding belongs to the innermost statement around it in the same\n// function (statementOf): a statement nested in a block of the accepted one (an `if` or loop body) is a\n// statement of its own, and so is everything inside a function or class written in it. So the directive\n// goes above the `throw` itself or the statement holding the call, never above the function. The reason\n// is required: like a trust-list entry, it is the human decision, and nothing here checks it.\n//\n// An accept directive that accepts nothing is a finding (origin `directive`, reported by\n// throw-must-return-result, which is always on): a block comment, one with no reason, one not directly\n// above a statement it can accept (a declaration is not one), and one whose statement has no finding to\n// accept (stale), so a leftover cannot linger. A misspelling (`//trust:acept`) is no accept directive:\n// type-claim reports it like any unknown `//trust:` comment, and the finding it meant to accept stays.\n// `trust check`, `trust baseline`, `trust explain` and the ESLint rules all go through here.\nimport type * as TS from 'typescript';\nimport type { TrustPolicy } from '../eslint/policy.js';\nimport type { TypeScript } from '../eslint/typescript.js';\nimport { isFunctionBoundary, type GuardContext } from './guard.js';\nimport {\n FLOATING_PROMISE_MESSAGE,\n FLOATING_PROMISE_ORIGIN,\n FLOATING_PROMISE_RULE,\n formatMessage,\n MISUSED_PROMISE_MESSAGES,\n MISUSED_PROMISE_RULE,\n THROW_MESSAGES,\n THROW_ORIGIN,\n THROW_RULE,\n UNTRUSTED_CALL_MESSAGES,\n UNTRUSTED_CALL_RULE,\n type AcceptDirectiveMessageId,\n} from './messages.js';\nimport { asyncVoidCallbacks, conditionOperands, isFloatingPromise, isPromiseCondition } from './promise-rules.js';\nimport { throwProblem, untrustedCallProblem } from './rules.js';\nimport { ACCEPT_DIRECTIVE, directiveDirectlyAbove, isAcceptDirective, nodeBelow, trustDirectivesIn, type TrustDirective } from './validator.js';\n\n/** The rules whose findings an accept directive accepts. */\nexport const ACCEPTED_RULES: readonly string[] = [THROW_RULE, UNTRUSTED_CALL_RULE, FLOATING_PROMISE_RULE, MISUSED_PROMISE_RULE];\n\n/** Why an accept directive accepts nothing. */\nexport type AcceptProblem = 'block' | 'reason' | 'misplaced' | 'stale';\n\nconst ACCEPT_PROBLEMS: Readonly<Record<AcceptProblem, string>> = {\n block: 'is a block comment, not a `//` line comment',\n reason: 'gives no reason',\n misplaced: 'is not directly above a statement it can accept (a declaration is not one)',\n stale: `has no ${ACCEPTED_RULES.slice(0, -1).join(', ')} or ${ACCEPTED_RULES[ACCEPTED_RULES.length - 1]} finding in the statement below it`,\n};\n\n/** What the failure-path rules need to decide a node: the same context `trust check` and the ESLint rules build. */\nexport interface FailurePathContext {\n readonly ts: TypeScript;\n readonly checker: TS.TypeChecker;\n readonly policy: TrustPolicy;\n readonly guardContext: GuardContext;\n}\n\n/** One finding of a failure-path rule, at the node it is reported at. */\nexport interface FailurePathFinding {\n readonly node: TS.Node;\n readonly rule: string;\n readonly origin: string;\n readonly message: string;\n}\n\n/** A finding's statement, accepted by the directive above it with this reason. */\nexport interface Acceptance {\n readonly statement: TS.Statement;\n readonly directive: TrustDirective;\n readonly reason: string;\n}\n\n/** The text after `trust:accept`, trimmed: empty when there is no reason. */\nexport function acceptReason(directive: TrustDirective): string {\n return directive.body.slice(ACCEPT_DIRECTIVE.length).trim();\n}\n\n/**\n * The failure-path findings decided at `node`, in the order `trust check` reports them: floating-promise,\n * misused-promise, then the throw or untrusted-call finding.\n */\nexport function failurePathFindingsAt(node: TS.Node, context: FailurePathContext): FailurePathFinding[] {\n const { ts, checker, policy, guardContext } = context;\n const found: FailurePathFinding[] = [];\n if (ts.isExpressionStatement(node) && isFloatingPromise(ts, checker, node)) {\n found.push({ node, rule: FLOATING_PROMISE_RULE, origin: FLOATING_PROMISE_ORIGIN, message: FLOATING_PROMISE_MESSAGE });\n }\n for (const operand of conditionOperands(ts, node)) {\n if (isPromiseCondition(checker, operand)) found.push({ node: operand, rule: MISUSED_PROMISE_RULE, origin: 'condition', message: MISUSED_PROMISE_MESSAGES.condition });\n }\n if (ts.isCallExpression(node) || ts.isNewExpression(node)) {\n for (const argument of asyncVoidCallbacks(ts, checker, node)) {\n found.push({ node: argument, rule: MISUSED_PROMISE_RULE, origin: 'void-callback', message: MISUSED_PROMISE_MESSAGES['void-callback'] });\n }\n }\n if (ts.isThrowStatement(node)) {\n const messageId = throwProblem(node, guardContext);\n if (messageId) found.push({ node, rule: THROW_RULE, origin: THROW_ORIGIN, message: THROW_MESSAGES[messageId] });\n } else if ((ts.isCallExpression(node) && node.expression.kind !== ts.SyntaxKind.ImportKeyword) || ts.isNewExpression(node)) {\n // `import(...)` is an ImportExpression in ESTree, not a call, so the rule never sees it.\n const problem = untrustedCallProblem(node, policy, checker, guardContext);\n if (problem) found.push({ node, rule: UNTRUSTED_CALL_RULE, origin: problem.origin, message: formatMessage(UNTRUSTED_CALL_MESSAGES[problem.messageId], problem.origin) });\n }\n return found;\n}\n\n/** A statement an accept directive may sit above: one that holds expressions of its own. Declarations, blocks and `try` are not. */\nfunction isAcceptable(ts: TypeScript, node: TS.Node): node is TS.Statement {\n return (\n ts.isExpressionStatement(node) ||\n ts.isVariableStatement(node) ||\n ts.isReturnStatement(node) ||\n ts.isThrowStatement(node) ||\n ts.isIfStatement(node) ||\n ts.isDoStatement(node) ||\n ts.isWhileStatement(node) ||\n ts.isForStatement(node) ||\n ts.isForInStatement(node) ||\n ts.isForOfStatement(node) ||\n ts.isSwitchStatement(node) ||\n ts.isExportAssignment(node)\n );\n}\n\n/** A function or class: what is written inside runs at another time, so it belongs to none of the statements around it. */\nfunction isBoundary(ts: TypeScript, node: TS.Node): boolean {\n return isFunctionBoundary(ts, node) || ts.isClassLike(node) || ts.isClassStaticBlockDeclaration(node);\n}\n\n/**\n * The statement a finding at `node` belongs to: the innermost statement around it (`node` itself when it\n * is one) in the same function. Null when a function or class comes first (a class field initializer,\n * the expression body of an arrow) or there is none.\n */\nexport function statementOf(ts: TypeScript, node: TS.Node): TS.Statement | null {\n for (let current: TS.Node | undefined = node; current && !ts.isSourceFile(current); current = current.parent) {\n if (current !== node && isBoundary(ts, current)) return null;\n if (ts.isStatement(current)) return current;\n }\n return null;\n}\n\n/** The accept directive with a reason directly above `statement` (an acceptable one), else null. */\nfunction acceptingDirective(ts: TypeScript, statement: TS.Node): TrustDirective | null {\n if (!isAcceptable(ts, statement)) return null;\n const directive = directiveDirectlyAbove(ts, statement);\n if (!directive || directive.kind !== 'line' || !isAcceptDirective(directive) || !acceptReason(directive)) return null;\n return directive;\n}\n\n/** How the finding reported at `node` is accepted, or null when it is not: its statement has no valid accept directive directly above it. */\nexport function acceptanceOf(ts: TypeScript, node: TS.Node): Acceptance | null {\n const statement = statementOf(ts, node);\n const directive = statement && acceptingDirective(ts, statement);\n return statement && directive ? { statement, directive, reason: acceptReason(directive) } : null;\n}\n\n/** Every failure-path finding that belongs to `statement` (what an accept directive above it accepts). */\nexport function findingsOfStatement(statement: TS.Statement, context: FailurePathContext): FailurePathFinding[] {\n const { ts } = context;\n const found: FailurePathFinding[] = [];\n const visit = (node: TS.Node): void => {\n for (const finding of failurePathFindingsAt(node, context)) {\n if (statementOf(ts, finding.node) === statement) found.push(finding);\n }\n ts.forEachChild(node, visit);\n };\n visit(statement);\n return found;\n}\n\n/**\n * Why the accept directive `directive` accepts nothing, else null. `context` null (ESLint without type\n * information) leaves out `stale`: untrusted calls and promises cannot be decided there.\n */\nexport function acceptProblem(ts: TypeScript, sourceFile: TS.SourceFile, directive: TrustDirective, context: FailurePathContext | null): AcceptProblem | null {\n if (directive.kind !== 'line') return 'block';\n if (!acceptReason(directive)) return 'reason';\n const below = nodeBelow(ts, sourceFile, directive);\n if (!below || !isAcceptable(ts, below) || directiveDirectlyAbove(ts, below)?.pos !== directive.pos) return 'misplaced';\n if (!context) return null;\n return findingsOfStatement(below, context).length > 0 ? null : 'stale';\n}\n\n/** One `directive` finding of throw-must-return-result, reported at the comment. */\nexport interface DirectiveFinding {\n readonly directive: TrustDirective;\n readonly messageId: AcceptDirectiveMessageId;\n readonly data: Readonly<Record<string, string>>;\n}\n\nfunction clip(text: string, max: number): string {\n const flat = text.replace(/\\s+/g, ' ');\n return flat.length > max ? `${flat.slice(0, max - 3)}...` : flat;\n}\n\n/**\n * The `directive` findings throw-must-return-result reports in `sourceFile`, in source order: every accept\n * directive that accepts nothing. A `//trust:` comment that is no known directive (`//trust:acept`) is\n * type-claim's, as before; it cannot hide anything, since what it meant to accept is still reported.\n */\nexport function acceptDirectiveFindings(ts: TypeScript, sourceFile: TS.SourceFile, context: FailurePathContext | null): DirectiveFinding[] {\n const found: DirectiveFinding[] = [];\n for (const directive of trustDirectivesIn(ts, sourceFile)) {\n if (!isAcceptDirective(directive)) continue;\n const problem = acceptProblem(ts, sourceFile, directive, context);\n if (problem) found.push({ directive, messageId: 'directive', data: { text: clip(directive.text, 40), problem: ACCEPT_PROBLEMS[problem] } });\n }\n return found;\n}\n","// redundant-guard: a guard around code that cannot fail.\n//\n// A guard (Trust.try / Trust.tryAsync, or a `try` whose `catch` returns Result.err) turns a throw into a named\n// failure. Wrapped around code that cannot throw, it invents a failure path: callers receive a Result whose\n// `Err` never happens, and must unwrap or pass it up for nothing. The typical case is a trusted origin:\n//\n// // @noego/ioc is trusted (\"resolution failures are programmer errors at boot\")\n// return Trust.tryAsync(() => scope.instance(token), (cause) => ({ kind: 'resolution_failed', cause }));\n//\n// trust.config.json already decided that call cannot fail; the guard contradicts it. Call it directly and\n// return the value.\n//\n// The guarded code can fail when it holds (outside nested functions, except the Trust.try callback itself):\n// - a call or `new` whose verdict is untrusted, unresolved, or into an ignored file;\n// - a `throw`;\n// - an `await` (or `for await`) of something that is not a call: a promise from elsewhere can reject;\n// - a dynamic `import()`.\n// - a call into first-party code that is not declared to return a Result: it may still throw.\n// - a promise (or other thenable) from elsewhere that the guarded work reads: `() => pending`,\n// `Promise.resolve(pending)`, `pending.finally(…)` settle the way `pending` does, and it can reject;\n// - (Trust.try callbacks) a returned value that is not a call and may be a thenable: a type parameter,\n// `unknown` or `any` is taken to be one.\n// - a value adopted by `Promise.resolve(value)` that is not a call and may be a thenable, under the same\n// reading: `Promise.resolve(stored)` with `stored: unknown` settles the way `stored` does if it is one.\n// `Promise.resolve('x')`, `Promise.resolve(text)` with `text: string`, `Promise.resolve(safe())` stay safe.\n// Calls into trusted origins and to functions declared to return a Result (first-party or not) cannot fail,\n// whatever they return: `() => scope.instance(token)` on a trusted container stays redundant.\n// Nothing else is a failure (property reads, getters, coercions are not, as for the trust rules).\nimport type * as TS from 'typescript';\nimport type { TrustPolicy } from '../eslint/policy.js';\nimport type { TypeScript } from '../eslint/typescript.js';\nimport { catchProblem, isFunctionBoundary, unparen, type GuardContext } from './guard.js';\nimport { fillMessage, REDUNDANT_GUARD_MESSAGES } from './messages.js';\n\nexport interface RedundantGuard {\n /** Offset the finding is reported at: the Trust.try call, or the `try` keyword. */\n readonly start: number;\n /** `Trust.try`, `Trust.tryAsync` or `try`. */\n readonly guard: string;\n /** The trusted origins called inside (at most three), for the message. */\n readonly origins: readonly string[];\n}\n\nexport interface RedundantGuardContext {\n readonly ts: TypeScript;\n readonly checker: TS.TypeChecker;\n readonly policy: TrustPolicy;\n readonly guardContext: GuardContext;\n}\n\nconst ORIGIN_LIMIT = 3;\n\n/** The data `REDUNDANT_GUARD_MESSAGES.redundant` is filled with. */\nexport function redundantGuardData(guard: RedundantGuard): Record<string, string> {\n const calls =\n guard.origins.length === 0\n ? 'nothing inside can throw (no call, or only calls declared to return a Result)'\n : `every call inside is trusted (${guard.origins.map((origin) => `\"${origin}\"`).join(', ')})`;\n return { guard: guard.guard, calls };\n}\n\nexport function redundantGuardMessage(guard: RedundantGuard): string {\n return fillMessage(REDUNDANT_GUARD_MESSAGES.redundant, redundantGuardData(guard));\n}\n\nfunction isInlineArgument(ts: TypeScript, node: TS.Node): boolean {\n if (!ts.isArrowFunction(node) && !ts.isFunctionExpression(node)) return false;\n let current: TS.Node = node;\n while (ts.isParenthesizedExpression(current.parent)) current = current.parent;\n const parent = current.parent;\n return (ts.isCallExpression(parent) || ts.isNewExpression(parent)) && (parent.arguments ?? []).some((argument) => argument === current);\n}\n\n/**\n * A type parameter bounded by `constraint` can be instantiated with a type that adds a callable `then`: true unless\n * every member of the constraint is a primitive (`T extends string` cannot be a thenable, `T extends { id: string }`\n * can).\n */\nfunction openToThen(constraint: TS.Type, context: RedundantGuardContext): boolean {\n const { ts } = context;\n if (constraint.isUnion()) return constraint.types.some((member) => openToThen(member, context));\n const open = ts.TypeFlags.Object | ts.TypeFlags.NonPrimitive | ts.TypeFlags.Intersection | ts.TypeFlags.Instantiable | ts.TypeFlags.Any | ts.TypeFlags.Unknown;\n return (constraint.flags & open) !== 0;\n}\n\n/**\n * Values of `type` may be a thenable (a callable `then`): a promise from elsewhere, which can reject. With\n * `opaque`, a type that says nothing about it (`any`, `unknown`, a type parameter without a constraint, or one whose\n * constraint an instantiation could extend with `then`) counts.\n */\nfunction thenable(type: TS.Type, context: RedundantGuardContext, opaque: boolean, seen: Set<TS.Type> = new Set()): boolean {\n const { ts, checker } = context;\n if (seen.has(type)) return false;\n seen.add(type);\n if (type.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)) return opaque;\n if (type.isUnionOrIntersection()) return type.types.some((member) => thenable(member, context, opaque, seen));\n if (type.flags & ts.TypeFlags.Instantiable) {\n const constraint = checker.getBaseConstraintOfType(type);\n if (!constraint || constraint === type) return opaque;\n return thenable(constraint, context, opaque, seen) || (opaque && openToThen(constraint, context));\n }\n const then = checker.getPropertyOfType(checker.getApparentType(type), 'then');\n return then !== undefined && checker.getTypeOfSymbol(then).getCallSignatures().length > 0;\n}\n\n/** `node` reads a value: not a name being declared, a property name, a callee, or the target of `=`. */\nfunction isValueRead(ts: TypeScript, node: TS.Node): boolean {\n if (!ts.isIdentifier(node) && !ts.isPropertyAccessExpression(node) && !ts.isElementAccessExpression(node)) return false;\n if (ts.isShorthandPropertyAssignment(node.parent)) return true;\n if ((node.parent as TS.NamedDeclaration).name === node) return false;\n let current: TS.Node = node;\n while (ts.isParenthesizedExpression(current.parent)) current = current.parent;\n const parent = current.parent;\n if ((ts.isCallExpression(parent) || ts.isNewExpression(parent)) && parent.expression === current) return false;\n return !(ts.isBinaryExpression(parent) && parent.operatorToken.kind === ts.SyntaxKind.EqualsToken && parent.left === current);\n}\n\n/** The values `fn` returns: its expression body, or the operands of its own `return` statements. */\nfunction returnedValues(ts: TypeScript, fn: TS.ArrowFunction | TS.FunctionExpression): TS.Node[] {\n if (!ts.isBlock(fn.body)) return [fn.body];\n const values: TS.Node[] = [];\n const visit = (node: TS.Node): void => {\n if (isFunctionBoundary(ts, node) || ts.isClassLike(node)) return;\n if (ts.isReturnStatement(node) && node.expression) values.push(node.expression);\n ts.forEachChild(node, visit);\n };\n ts.forEachChild(fn.body, visit);\n return values;\n}\n\n/**\n * A returned value that is not the value of a call may be a thenable that rejects, and the guard settles with it.\n * A call's value is covered by its own verdict (a trusted container's `scope.instance(token)` cannot fail), and an\n * `await` of anything but a call already fails.\n */\nfunction mayReturnThenable(node: TS.Node, context: RedundantGuardContext): boolean {\n const { ts, checker } = context;\n const inner = unparen(ts, node);\n if (ts.isConditionalExpression(inner)) return mayReturnThenable(inner.whenTrue, context) || mayReturnThenable(inner.whenFalse, context);\n if (ts.isBinaryExpression(inner)) {\n const operator = inner.operatorToken.kind;\n if (operator === ts.SyntaxKind.CommaToken) return mayReturnThenable(inner.right, context);\n if (operator === ts.SyntaxKind.QuestionQuestionToken || operator === ts.SyntaxKind.BarBarToken || operator === ts.SyntaxKind.AmpersandAmpersandToken) {\n return mayReturnThenable(inner.left, context) || mayReturnThenable(inner.right, context);\n }\n }\n if (ts.isCallExpression(inner) || ts.isNewExpression(inner) || ts.isAwaitExpression(inner)) return false;\n return thenable(checker.getTypeAtLocation(inner), context, true);\n}\n\n/**\n * `node` is `Promise.resolve(…)` (the lib's `PromiseConstructor.resolve`): it adopts a thenable argument and settles\n * the way it does.\n */\nfunction isPromiseAdoption(node: TS.CallExpression, context: RedundantGuardContext): boolean {\n const { ts, checker } = context;\n const callee = unparen(ts, node.expression);\n if (!ts.isPropertyAccessExpression(callee) || callee.name.text !== 'resolve') return false;\n const owner = checker.getResolvedSignature(node)?.declaration?.parent;\n return owner !== undefined && ts.isInterfaceDeclaration(owner) && owner.name.text === 'PromiseConstructor';\n}\n\n/** The calls inside `body` that cannot fail, or null as soon as something inside can fail. */\nfunction cannotFail(body: TS.Node, context: RedundantGuardContext): Set<string> | null {\n const { ts, policy } = context;\n const origins = new Set<string>();\n let fails = false;\n const visit = (node: TS.Node): void => {\n if (fails) return;\n // Types do not run.\n if (ts.isTypeNode(node) && !ts.isExpressionWithTypeArguments(node)) return;\n // A function written inline as an argument runs as part of the guarded work: `items.map((x) => risky(x))`\n // throws through it, and `promise.then(() => risky())` rejects what the guard awaits. Other nested functions\n // (declared, stored) are not run here.\n if (node !== body && isFunctionBoundary(ts, node) && !isInlineArgument(ts, node)) return;\n // A promise from elsewhere, read: returned (`() => pending`), adopted (`Promise.resolve(pending)`) or chained\n // (`pending.finally(…)`), it settles the way it does, and it can reject.\n if (isValueRead(ts, node) && thenable(context.checker.getTypeAtLocation(node), context, false)) {\n fails = true;\n return;\n }\n // A value adopted by `Promise.resolve` that says nothing about being a thenable (`unknown`, `any`, an open\n // type parameter) may be one, and the adopted promise rejects with it. Only the adoption argument is read this\n // way: other reads of opaque values stay safe.\n if (ts.isCallExpression(node) && isPromiseAdoption(node, context) && node.arguments.some((argument) => mayReturnThenable(argument, context))) {\n fails = true;\n return;\n }\n if (ts.isThrowStatement(node)) {\n fails = true;\n return;\n }\n if (ts.isAwaitExpression(node)) {\n const awaited = unparen(ts, node.expression);\n if (!ts.isCallExpression(awaited) && !ts.isNewExpression(awaited)) {\n fails = true;\n return;\n }\n }\n if (ts.isForOfStatement(node) && node.awaitModifier) {\n fails = true;\n return;\n }\n if ((ts.isCallExpression(node) && node.expression.kind !== ts.SyntaxKind.ImportKeyword) || ts.isNewExpression(node)) {\n const verdict = policy.classify(node);\n if (verdict.kind === 'untrusted' || verdict.kind === 'unresolved' || verdict.kind === 'calls-ignored') {\n fails = true;\n return;\n }\n // First-party code can still throw (a provider over a native API, a function value, unfinished code);\n // only its declared Result contract says it cannot.\n if (verdict.kind === 'first-party') {\n const signature = context.checker.getResolvedSignature(node);\n if (!signature || !policy.returnsResult(signature)) {\n fails = true;\n return;\n }\n }\n if (verdict.kind === 'trusted') origins.add(verdict.origin.origin);\n }\n if (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword) {\n fails = true;\n return;\n }\n ts.forEachChild(node, visit);\n };\n visit(body);\n if (!fails && (ts.isArrowFunction(body) || ts.isFunctionExpression(body))) {\n fails = returnedValues(ts, body).some((value) => mayReturnThenable(value, context));\n }\n return fails ? null : origins;\n}\n\n/** Every guard in `sourceFile` around code that cannot fail, in source order. */\nexport function redundantGuardsIn(sourceFile: TS.SourceFile, context: RedundantGuardContext): RedundantGuard[] {\n const { ts, guardContext } = context;\n const found: RedundantGuard[] = [];\n const visit = (node: TS.Node): void => {\n if (ts.isCallExpression(node)) {\n const kind = guardContext.trustTryKind(node);\n const callback = node.arguments[0] ? unparen(ts, node.arguments[0]) : undefined;\n if (kind && callback && (ts.isArrowFunction(callback) || ts.isFunctionExpression(callback))) {\n const origins = cannotFail(callback, context);\n if (origins) {\n found.push({ start: node.getStart(sourceFile), guard: kind === 'sync' ? 'Trust.try' : 'Trust.tryAsync', origins: [...origins].sort().slice(0, ORIGIN_LIMIT) });\n }\n }\n }\n if (ts.isTryStatement(node) && node.catchClause && catchProblem(node.catchClause, guardContext) === null) {\n const origins = cannotFail(node.tryBlock, context);\n if (origins) found.push({ start: node.getStart(sourceFile), guard: 'try', origins: [...origins].sort().slice(0, ORIGIN_LIMIT) });\n }\n ts.forEachChild(node, visit);\n };\n visit(sourceFile);\n return found;\n}\n","// Canonical rendering of a type's printed text for messages. The TypeScript checker prints union and\n// intersection members, and the properties of inferred object types, in the order it created them, and\n// that order differs between TypeScript and the TypeScript 7 port the CLI engine runs on. Sorting those\n// members at every nesting level makes the same type print the same way everywhere (ESLint, CLI), so a\n// finding's message is independent of the compiler. The native engine (native/src/type_text.rs) keeps an\n// identical copy of this algorithm; change both together.\n//\n// Only member ORDER changes: generic arguments, tuple elements and parameter lists keep their order and\n// are canonicalised inside. Separators are re-emitted as the checker prints them (` | `, ` & `, `; `, `, `).\n\nconst OPEN = new Set(['(', '[', '{', '<']);\nconst CLOSE: Record<string, string> = { ')': '(', ']': '[', '}': '{', '>': '<' };\n\n/** Canonical text of a one-line (whitespace-flattened) type as `checker.typeToString` prints it. */\nexport function canonicalTypeText(text: string): string {\n return canonical(text.trim());\n}\n\nfunction canonical(text: string): string {\n // A named piece (`b?: B | A`, a parameter, an index signature, a method signature): the name and the\n // colon stay verbatim, the type after the colon is canonicalised on its own.\n const colon = memberTypeStart(text);\n if (colon >= 0) return `${text.slice(0, colon + 1)} ${canonical(text.slice(colon + 1).trim())}`;\n const union = splitTop(text, ' | ');\n if (union.length > 1) return union.map(canonical).sort(compare).join(' | ');\n const intersection = splitTop(text, ' & ');\n if (intersection.length > 1) return intersection.map(canonical).sort(compare).join(' & ');\n return canonicalGroups(text);\n}\n\n/** Canonicalises the inside of every bracket group at the top level of `text`, keeping the rest verbatim. */\nfunction canonicalGroups(text: string): string {\n let out = '';\n let i = 0;\n while (i < text.length) {\n const ch = text[i];\n if (ch === '\"' || ch === \"'\" || ch === '`') {\n const end = stringEnd(text, i);\n out += text.slice(i, end);\n i = end;\n continue;\n }\n if (ch === '=' && text[i + 1] === '>') {\n out += '=>';\n i += 2;\n continue;\n }\n if (OPEN.has(ch)) {\n const end = groupEnd(text, i);\n if (end < 0) {\n out += text.slice(i);\n break;\n }\n const inner = text.slice(i + 1, end);\n out += ch + (ch === '{' ? canonicalMembers(inner) : splitTop(inner, ', ').map(canonical).join(', ')) + text[end];\n i = end + 1;\n continue;\n }\n out += ch;\n i += 1;\n }\n return out;\n}\n\n/** The members of an object type `{ a: A; b?: B; }`, each canonicalised, sorted. */\nfunction canonicalMembers(inner: string): string {\n const body = inner.trim();\n if (body === '') return inner;\n const members = splitTop(body, ';').map((member) => member.trim()).filter((member) => member !== '');\n const canonicalised = members.map(canonical);\n canonicalised.sort(compare);\n return ` ${canonicalised.join('; ')}; `;\n}\n\n/** Index of the `:` that separates a member's name (or signature) from its type, at depth 0; -1 when none. */\nfunction memberTypeStart(member: string): number {\n let depth = 0;\n let i = 0;\n while (i < member.length) {\n const ch = member[i];\n if (ch === '\"' || ch === \"'\" || ch === '`') {\n i = stringEnd(member, i);\n continue;\n }\n if (ch === '=' && member[i + 1] === '>') {\n i += 2;\n continue;\n }\n if (OPEN.has(ch)) depth += 1;\n else if (CLOSE[ch] !== undefined) depth -= 1;\n else if (ch === ':' && depth === 0) return i;\n i += 1;\n }\n return -1;\n}\n\n/** Splits `text` on `separator` occurrences at bracket depth 0 and outside string literals. */\nfunction splitTop(text: string, separator: string): string[] {\n const parts: string[] = [];\n let depth = 0;\n let start = 0;\n let i = 0;\n while (i < text.length) {\n const ch = text[i];\n if (ch === '\"' || ch === \"'\" || ch === '`') {\n i = stringEnd(text, i);\n continue;\n }\n if (ch === '=' && text[i + 1] === '>') {\n i += 2;\n continue;\n }\n if (OPEN.has(ch)) depth += 1;\n else if (CLOSE[ch] !== undefined) depth -= 1;\n else if (depth === 0 && text.startsWith(separator, i)) {\n parts.push(text.slice(start, i));\n i += separator.length;\n start = i;\n continue;\n }\n i += 1;\n }\n parts.push(text.slice(start));\n return parts;\n}\n\n/** Index just past the string literal that starts at `start` (its closing quote included); escapes are skipped. */\nfunction stringEnd(text: string, start: number): number {\n const quote = text[start];\n let i = start + 1;\n while (i < text.length) {\n if (text[i] === '\\\\') i += 2;\n else if (text[i] === quote) return i + 1;\n else i += 1;\n }\n return text.length;\n}\n\n/** Index of the bracket that closes the group opened at `start`; -1 when unbalanced. */\nfunction groupEnd(text: string, start: number): number {\n const open = text[start];\n let depth = 0;\n let i = start;\n while (i < text.length) {\n const ch = text[i];\n if (ch === '\"' || ch === \"'\" || ch === '`') {\n i = stringEnd(text, i);\n continue;\n }\n if (ch === '=' && text[i + 1] === '>') {\n i += 2;\n continue;\n }\n if (OPEN.has(ch)) depth += 1;\n else if (CLOSE[ch] !== undefined) {\n depth -= 1;\n if (depth === 0) return CLOSE[ch] === open ? i : -1;\n }\n i += 1;\n }\n return -1;\n}\n\n/** Code-unit order, as JavaScript's `<` on strings; the Rust twin compares UTF-16 units the same way. */\nfunction compare(a: string, b: string): number {\n return a < b ? -1 : a > b ? 1 : 0;\n}\n","// The type-claim rule as decisions on TypeScript nodes: every place a type is claimed instead of\n// proven. One implementation, shared by the standalone checker (check-file.ts), the ESLint adapter\n// (src/eslint/rules/type-claim.ts) and `trust explain`.\n//\n// claim:as `x as T` / `<T>x` whose source type is not assignable to `T` (a widening\n// assertion and `as const` are not claims)\n// claim:non-null `x!`\n// claim:any an explicit `any`, or a value of type `any` that is assigned, passed or\n// returned where a type is expected, or whose member is used\n// claim:predicate a written type predicate / assertion signature (`x is T`, `asserts x is T`,\n// `asserts x`): the compiler does not check the body against it\n// claim:generic-return a call whose return type depends on a type parameter found only in the\n// return position (`parse<T>(): T`), so the caller picks the type; not a\n// claim when the callee's own body proves the type for every choice, or when a\n// `trust_type` entry of the project's own config files (not a built-in preset)\n// covers the callee (`container.get<Foo>('x')` with `trust_type: [\"lib.Client.get\"]`)\n// unanalyzable a written type or a value whose type does not resolve, wherever it appears\n// (also a re-export or dynamic import of a module that does not resolve, and a\n// node the checker fails on): reported, never passed\n//\n// A claim inside a validator (a function marked `//trust:validator_function`, validator.ts) is allowed;\n// a `//trust:` comment that marks nothing is itself reported (`directive`).\nimport type * as TS from 'typescript';\nimport type { TrustPolicy } from '../eslint/policy.js';\nimport type { TypeScript } from '../eslint/typescript.js';\nimport { unparen } from './guard.js';\nimport { fillMessage, TYPE_CLAIM_MESSAGES, type TypeClaimOrigin } from './messages.js';\nimport { canonicalTypeText } from './type-text.js';\nimport { directiveProblem, isAcceptDirective, isInsideValidator, trustDirectivesIn, type DirectiveProblem, type InsideValidator } from './validator.js';\n\n/** One claim: the node it is decided at, its kind (the finding's origin), the message data, and (a directive) the comment it is reported at. */\nexport interface TypeClaim {\n readonly node: TS.Node;\n readonly origin: TypeClaimOrigin;\n readonly data: Readonly<Record<string, string>>;\n /** Where it is reported when that is not `node`'s own span: a `//trust:` comment. */\n readonly at?: ClaimSpan;\n}\n\n/** Offsets into the source text: start inclusive, end exclusive. */\nexport interface ClaimSpan {\n readonly start: number;\n readonly end: number;\n}\n\n/** The span a claim is reported at: its comment, else from its node's first token to its end. */\nexport function claimSpan(claim: TypeClaim, sourceFile: TS.SourceFile): ClaimSpan {\n return claim.at ?? { start: claim.node.getStart(sourceFile), end: claim.node.getEnd() };\n}\n\nexport interface TypeClaimContext {\n readonly ts: TypeScript;\n readonly checker: TS.TypeChecker;\n /** Claims inside an approved validator are allowed (not reported). */\n readonly isInsideValidator: InsideValidator;\n /** Per generic declaration: does its body prove its return type (see bodyProvesReturn)? */\n readonly provenBodies: WeakMap<TS.Node, 'checking' | 'proven' | 'claimed'>;\n /**\n * The trust config's say on a caller-chosen generic return: true when a `trust_type` entry of the\n * project's own config files covers the callee (TrustPolicy.userTypeTrustOf). Absent: every such return is\n * a claim.\n */\n readonly trustsChosenReturn?: (node: TS.CallExpression) => boolean;\n}\n\nconst contexts = new WeakMap<TS.TypeChecker, TypeClaimContext>();\nconst policyContexts = new WeakMap<TrustPolicy, TypeClaimContext>();\n\n/**\n * The context every caller uses: one per checker (or, given the trust policy, one per policy), validators\n * recognised by validator.ts. With `policy`, a caller-chosen generic return whose callee a user\n * `trust_type` entry covers is not a claim. Pass `insideValidator` only to replace the validator\n * recogniser (the result is then a context of its own).\n */\nexport function typeClaimContext(ts: TypeScript, checker: TS.TypeChecker, insideValidator?: InsideValidator, policy?: TrustPolicy): TypeClaimContext {\n const trustsChosenReturn = policy ? (node: TS.CallExpression) => calleeIsUserTypeTrusted(node, policy) : undefined;\n if (insideValidator) return { ts, checker, isInsideValidator: insideValidator, provenBodies: new WeakMap(), trustsChosenReturn };\n const known = policy ? policyContexts.get(policy) : contexts.get(checker);\n if (known) return known;\n const context: TypeClaimContext = { ts, checker, isInsideValidator: (node) => isInsideValidator(ts, node), provenBodies: new WeakMap(), trustsChosenReturn };\n if (policy) policyContexts.set(policy, context);\n else contexts.set(checker, context);\n return context;\n}\n\n/** The callee of `node`, resolved as the untrusted-value rule resolves it, is type-trusted by a user `trust_type` entry. */\nfunction calleeIsUserTypeTrusted(node: TS.CallExpression, policy: TrustPolicy): boolean {\n const resolved = policy.calleeDeclaration(node);\n return resolved !== null && policy.userTypeTrustOf(resolved.declaration) !== null;\n}\n\n/** The finding message of a claim (the ESLint rule fills the same template with the same data). */\nexport function typeClaimMessage(claim: TypeClaim): string {\n return fillMessage(TYPE_CLAIM_MESSAGES[claim.origin], claim.data);\n}\n\nconst MAX_TEXT = 80;\nconst MAX_TYPE_DEPTH = 4;\n\nfunction clip(text: string, max = MAX_TEXT): string {\n const flat = text.replace(/\\s+/g, ' ');\n return flat.length > max ? `${flat.slice(0, max - 3)}...` : flat;\n}\n\nfunction typeText(context: TypeClaimContext, type: TS.Type): string {\n // The full text (the checker's own `...` truncation would keep different members on different compilers),\n // in canonical member order, then the clip.\n return clip(canonicalTypeText(context.checker.typeToString(type, undefined, typeTextFlags(context.ts))));\n}\n\n/** `typeToString`'s default flags plus no truncation (native/src/type_claims.rs passes the same). */\nexport function typeTextFlags(ts: TypeScript): TS.TypeFormatFlags {\n return ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.AllowUniqueESSymbolType | ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope;\n}\n\nfunction claim(node: TS.Node, origin: TypeClaimOrigin, data: Readonly<Record<string, string>>): TypeClaim {\n return { node, origin, data };\n}\n\nfunction isAny(ts: TypeScript, type: TS.Type): boolean {\n return (type.flags & ts.TypeFlags.Any) !== 0;\n}\n\nfunction isAnyOrUnknown(ts: TypeScript, type: TS.Type): boolean {\n return (type.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)) !== 0;\n}\n\n/**\n * The checker's stand-in for a type it could not resolve (an unresolved import or type name). It is\n * an `any` named \"error\"/\"unresolved\"; the name is the only thing that tells it from a real `any`.\n */\nfunction isUnresolved(ts: TypeScript, type: TS.Type): boolean {\n if (!isAny(ts, type)) return false;\n const name = (type as TS.Type & { readonly intrinsicName?: string }).intrinsicName;\n return name === 'error' || name === 'unresolved';\n}\n\n/**\n * The type of an object literal is \"fresh\": assigning it is also checked for excess properties, so\n * `{ name, extra } as User` would look narrowing. Its widened type is the value's real type.\n */\nfunction withoutFreshness(context: TypeClaimContext, type: TS.Type): TS.Type {\n const { ts, checker } = context;\n const fresh = (type.flags & ts.TypeFlags.Object) !== 0 && ((type as TS.ObjectType).objectFlags & ts.ObjectFlags.FreshLiteral) !== 0;\n return fresh ? checker.getWidenedType(type) : type;\n}\n\n/** `node` without parentheses and `!`: neither changes what value it is. */\nfunction unwrap(ts: TypeScript, node: TS.Node): TS.Node {\n let current = unparen(ts, node);\n while (ts.isNonNullExpression(current)) current = unparen(ts, current.expression);\n return current;\n}\n\n/** What a member access / call / `new` / tagged template is applied to, else null. */\nfunction accessTarget(ts: TypeScript, node: TS.Node): TS.Expression | null {\n if (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node) || ts.isNewExpression(node)) return node.expression;\n if (ts.isCallExpression(node)) return node.expression.kind === ts.SyntaxKind.ImportKeyword ? null : node.expression;\n if (ts.isTaggedTemplateExpression(node)) return node.tag;\n return null;\n}\n\nfunction isCallLike(ts: TypeScript, node: TS.Node): boolean {\n return ts.isCallExpression(node) || ts.isNewExpression(node) || ts.isTaggedTemplateExpression(node);\n}\n\n/** A member access or call on a value of type `any`: its own result is `any` because of that value. */\nfunction isAnyAccess(node: TS.Node, context: TypeClaimContext): boolean {\n const target = accessTarget(context.ts, node);\n return target !== null && isAny(context.ts, context.checker.getTypeAtLocation(target));\n}\n\n/** `x as any` / `<any>x`: the written `any` is the claim, reported once at the keyword. */\nfunction isExplicitAnyCast(ts: TypeScript, node: TS.Node): boolean {\n return ts.isAssertionExpression(node) && node.type.kind === ts.SyntaxKind.AnyKeyword;\n}\n\n/** The value was already reported where its `any` came from: a member access on `any`, or `as any`. */\nfunction isReportedAtItsSource(node: TS.Node, context: TypeClaimContext): boolean {\n const inner = unwrap(context.ts, node);\n return isAnyAccess(inner, context) || isExplicitAnyCast(context.ts, inner);\n}\n\nfunction isPlainAssignment(ts: TypeScript, node: TS.Node): node is TS.BinaryExpression {\n if (!ts.isBinaryExpression(node)) return false;\n const kind = node.operatorToken.kind;\n return (\n kind === ts.SyntaxKind.EqualsToken ||\n kind === ts.SyntaxKind.BarBarEqualsToken ||\n kind === ts.SyntaxKind.AmpersandAmpersandEqualsToken ||\n kind === ts.SyntaxKind.QuestionQuestionEqualsToken\n );\n}\n\n/**\n * The expressions `node` puts in a position that may expect a type: an initializer, the right side\n * of an assignment, an argument, a returned or yielded value, an object/array literal member, and\n * the operand of an assertion or `satisfies`. Whether a type is expected there is the checker's call\n * (the contextual type).\n */\nfunction typedOperands(ts: TypeScript, node: TS.Node): TS.Expression[] {\n if (\n ts.isVariableDeclaration(node) ||\n ts.isParameter(node) ||\n ts.isPropertyDeclaration(node) ||\n ts.isBindingElement(node) ||\n ts.isPropertyAssignment(node)\n ) {\n return node.initializer ? [node.initializer] : [];\n }\n if (ts.isShorthandPropertyAssignment(node)) return [node.name];\n if (ts.isSpreadAssignment(node)) return [node.expression];\n if (isPlainAssignment(ts, node)) return [node.right];\n if (ts.isCallExpression(node) || ts.isNewExpression(node)) {\n return (node.arguments ?? []).map((argument) => (ts.isSpreadElement(argument) ? argument.expression : argument));\n }\n if (ts.isReturnStatement(node) || ts.isYieldExpression(node) || ts.isJsxExpression(node)) return node.expression ? [node.expression] : [];\n if (ts.isArrowFunction(node)) return ts.isBlock(node.body) ? [] : [node.body];\n if (ts.isArrayLiteralExpression(node)) {\n return node.elements.filter((element) => !ts.isOmittedExpression(element)).map((element) => (ts.isSpreadElement(element) ? element.expression : element));\n }\n if (ts.isAssertionExpression(node)) return ts.isConstTypeReference(node.type) ? [] : [node.expression];\n if (ts.isSatisfiesExpression(node)) return [node.expression];\n return [];\n}\n\n/** An intrinsic JSX tag (`<div>`): a name the JSX typings look up, not a value that is read. */\nfunction isIntrinsicTagName(name: string): boolean {\n return /^[a-z]/.test(name) || name.includes('-');\n}\n\n/**\n * The identifier is read as a value here: an operand, an initializer, an argument, a returned or\n * exported value. Not a declared name, a member name, a label or a name inside a type.\n */\nexport function isValueUse(ts: TypeScript, node: TS.Identifier): boolean {\n const parent = node.parent;\n if (\n ts.isVariableDeclaration(parent) ||\n ts.isParameter(parent) ||\n ts.isPropertyDeclaration(parent) ||\n ts.isBindingElement(parent) ||\n ts.isPropertyAssignment(parent) ||\n ts.isEnumMember(parent)\n ) {\n return parent.initializer === node;\n }\n if (ts.isShorthandPropertyAssignment(parent)) return true;\n if (ts.isJsxOpeningElement(parent) || ts.isJsxSelfClosingElement(parent)) return parent.tagName === node && !isIntrinsicTagName(node.text);\n switch (parent.kind) {\n case ts.SyntaxKind.ExpressionStatement:\n case ts.SyntaxKind.IfStatement:\n case ts.SyntaxKind.DoStatement:\n case ts.SyntaxKind.WhileStatement:\n case ts.SyntaxKind.ForStatement:\n case ts.SyntaxKind.ForInStatement:\n case ts.SyntaxKind.ForOfStatement:\n case ts.SyntaxKind.ReturnStatement:\n case ts.SyntaxKind.WithStatement:\n case ts.SyntaxKind.SwitchStatement:\n case ts.SyntaxKind.CaseClause:\n case ts.SyntaxKind.ThrowStatement:\n case ts.SyntaxKind.ExportAssignment:\n case ts.SyntaxKind.TemplateSpan:\n case ts.SyntaxKind.ComputedPropertyName:\n case ts.SyntaxKind.Decorator:\n case ts.SyntaxKind.JsxExpression:\n case ts.SyntaxKind.JsxSpreadAttribute:\n case ts.SyntaxKind.SpreadAssignment:\n return true;\n default:\n // An operand of an expression, except the name the expression declares or selects (`a.name`, `function name() {}`).\n return ts.isExpression(parent) && (parent as { readonly name?: TS.Node }).name !== node && !ts.isPartOfTypeNode(node);\n }\n}\n\n/**\n * An expression that is evaluated, so its type is the type of a value. Keywords and literals (tokens)\n * always have a type of their own; a literal inside a type and `implements ns.Shape` are not evaluated.\n */\nfunction isValueExpression(ts: TypeScript, node: TS.Node): boolean {\n if (ts.isIdentifier(node)) return isValueUse(ts, node);\n if (!ts.isExpression(node) || node.kind <= ts.SyntaxKind.LastToken) return false;\n if (ts.isOmittedExpression(node) || ts.isExpressionWithTypeArguments(node) || ts.isLiteralTypeNode(node.parent)) return false;\n return !ts.isPartOfTypeNode(node);\n}\n\n/** `node` is a written type, or an expression that is evaluated, and its type does not resolve. */\nfunction doesNotResolve(node: TS.Node, context: TypeClaimContext): boolean {\n const { ts, checker } = context;\n if (ts.isTypeNode(node)) {\n // `extends Base` of a class is a type node in syntax only: `Base` is a value there, checked as one.\n if (ts.isExpressionWithTypeArguments(node) && !ts.isPartOfTypeNode(node)) return false;\n return isUnresolved(ts, checker.getTypeFromTypeNode(node));\n }\n return isValueExpression(ts, node) && isUnresolved(ts, checker.getTypeAtLocation(node));\n}\n\n/** `node`, or something inside it, does not resolve: unresolvedClaim reports it (at the innermost such node). */\nfunction containsUnresolved(node: TS.Node, context: TypeClaimContext): boolean {\n return doesNotResolve(node, context) || (context.ts.forEachChild(node, (child) => containsUnresolved(child, context) || undefined) ?? false);\n}\n\n/**\n * A written type or a value whose type does not resolve (a missing import, an unknown name, a member\n * that does not exist), wherever it appears: an annotation, a heritage clause, a condition, an\n * initializer with no declared type. Reported once, at the innermost node: `missing` in `missing.a.b`,\n * `Missing` in `Missing | undefined`.\n */\nfunction unresolvedClaim(node: TS.Node, context: TypeClaimContext): TypeClaim | null {\n const { ts } = context;\n if (!doesNotResolve(node, context)) return null;\n if (ts.forEachChild(node, (child) => containsUnresolved(child, context) || undefined)) return null;\n const text = clip(node.getText(), 40);\n if (ts.isTypeNode(node)) return claim(node, 'unanalyzable', { what: 'this type', reason: `\"${text}\" does not resolve` });\n return claim(node, 'unanalyzable', { what: 'this value', reason: `the type of \"${text}\" does not resolve` });\n}\n\n/**\n * A module that does not resolve, where no value or type would show it: a re-export (the names leave\n * this file untyped, with no use here to report) and a dynamic `import()` (its type is `Promise<any>`).\n * What a static import brings in is reported at each use (unresolvedClaim).\n */\nfunction unresolvedModuleClaim(node: TS.Node, context: TypeClaimContext): TypeClaim | null {\n const { ts, checker } = context;\n const unresolvedModule = (specifier: TS.Expression | undefined, what: string): TypeClaim | null => {\n if (!specifier || !ts.isStringLiteralLike(specifier) || checker.getSymbolAtLocation(specifier)) return null;\n return claim(node, 'unanalyzable', { what, reason: `the module ${clip(specifier.getText(), 40)} does not resolve` });\n };\n if (ts.isExportDeclaration(node)) return unresolvedModule(node.moduleSpecifier, 'this re-export');\n if (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword) return unresolvedModule(node.arguments[0], 'this dynamic import');\n if (ts.isExportSpecifier(node) && !node.parent.parent.moduleSpecifier) {\n const local = checker.getExportSpecifierLocalTargetSymbol(node);\n const target = local && local.flags & ts.SymbolFlags.Alias ? checker.getAliasedSymbol(local) : local;\n if (!target || checker.isUnknownSymbol(target)) {\n return claim(node, 'unanalyzable', { what: 'this export', reason: `\"${clip(node.getText(), 40)}\" does not resolve` });\n }\n }\n return null;\n}\n\n/** A value of type `any` in a position that expects a type (not `any`, not `unknown`). */\nfunction anyFlowClaim(operand: TS.Expression, context: TypeClaimContext): TypeClaim | null {\n const { ts, checker } = context;\n const node = unparen(ts, operand) as TS.Expression;\n const type = checker.getTypeAtLocation(node);\n if (!isAny(ts, type)) return null;\n const expected = checker.getContextualType(node);\n if (!expected || isAnyOrUnknown(ts, expected)) return null;\n if (isReportedAtItsSource(node, context)) return null;\n const position = `where \"${typeText(context, expected)}\" is expected`;\n if (isUnresolved(ts, type)) {\n // The value is reported where its type stops resolving (unresolvedClaim), once.\n if (containsUnresolved(node, context)) return null;\n return claim(node, 'unanalyzable', { what: 'this value', reason: `its type does not resolve, and it is used ${position}` });\n }\n return claim(node, 'claim:any', { detail: `A value of type \\`any\\` is used ${position}` });\n}\n\n/** A member access, call, `new` or tagged template on a value of type `any`, reported once per chain (at its first link). */\nfunction anyAccessClaim(node: TS.Node, context: TypeClaimContext): TypeClaim | null {\n const { ts, checker } = context;\n const target = accessTarget(ts, node);\n // `implements types.Shape` is a property access only in syntax: it names a type, no value is read.\n if (!target || ts.isPartOfTypeNode(node)) return null;\n const type = checker.getTypeAtLocation(target);\n if (!isAny(ts, type) || isReportedAtItsSource(target, context)) return null;\n const called = isCallLike(ts, node);\n if (isUnresolved(ts, type)) {\n // The target is reported where its type stops resolving (unresolvedClaim), once.\n if (containsUnresolved(target, context)) return null;\n return claim(node, 'unanalyzable', {\n what: called ? 'this call' : 'this member access',\n reason: `the type of \"${clip(target.getText(), 40)}\" does not resolve`,\n });\n }\n return claim(node, 'claim:any', { detail: called ? 'A value of type `any` is called' : 'A member of a value of type `any` is used' });\n}\n\n/** `x as T` / `<T>x` whose source type is not assignable to `T`. */\nfunction assertionClaim(node: TS.AssertionExpression, context: TypeClaimContext): TypeClaim | null {\n const { ts, checker } = context;\n if (ts.isConstTypeReference(node.type)) return null;\n const what = 'this type assertion';\n const target = checker.getTypeFromTypeNode(node.type);\n if (isUnresolved(ts, target)) {\n // The target type is reported where it stops resolving (unresolvedClaim), once.\n if (containsUnresolved(node.type, context)) return null;\n return claim(node, 'unanalyzable', { what, reason: `its target type \"${clip(node.type.getText(), 40)}\" does not resolve` });\n }\n // Widening to `unknown` is always allowed; a written `any` is reported at the keyword.\n if (isAnyOrUnknown(ts, target)) return null;\n const source = checker.getTypeAtLocation(node.expression);\n // An `any` source is assignable to everything: it is reported as `any` flowing into the asserted type (anyFlowClaim).\n if (isAny(ts, source)) return null;\n if (typeof checker.isTypeAssignableTo !== 'function') {\n return claim(node, 'unanalyzable', { what, reason: 'this TypeScript has no isTypeAssignableTo (5.4 or newer is needed)' });\n }\n if (checker.isTypeAssignableTo(withoutFreshness(context, source), target)) return null;\n return claim(node, 'claim:as', { from: typeText(context, source), to: typeText(context, target) });\n}\n\n/** `type` is, or is built from, the type parameter `parameter` (unions, type arguments, object members; bounded depth). */\nfunction typeMentions(context: TypeClaimContext, type: TS.Type, parameter: TS.Type, depth = 0): boolean {\n const { ts, checker } = context;\n if (type === parameter) return true;\n if (depth >= MAX_TYPE_DEPTH) return false;\n const next = (inner: TS.Type): boolean => typeMentions(context, inner, parameter, depth + 1);\n if (type.aliasTypeArguments?.some(next)) return true;\n if (type.isUnionOrIntersection()) return type.types.some(next);\n if (type.flags & ts.TypeFlags.IndexedAccess) {\n const access = type as TS.IndexedAccessType;\n return next(access.objectType) || next(access.indexType);\n }\n if (!(type.flags & ts.TypeFlags.Object)) return false;\n const objectFlags = (type as TS.ObjectType).objectFlags;\n if (objectFlags & ts.ObjectFlags.Reference) return checker.getTypeArguments(type as TS.TypeReference).some(next);\n if (!(objectFlags & ts.ObjectFlags.Anonymous)) return false;\n if (type.getCallSignatures().some((signature) => next(signature.getReturnType()))) return true;\n return type.getProperties().some((property) => next(checker.getTypeOfSymbol(property)));\n}\n\n/** `root` (a type node) names the type parameter `declaration`. */\nfunction nodeMentions(context: TypeClaimContext, root: TS.Node | undefined, declaration: TS.TypeParameterDeclaration): boolean {\n if (!root) return false;\n const { ts, checker } = context;\n const symbol = checker.getSymbolAtLocation(declaration.name);\n const visit = (node: TS.Node): boolean => {\n if (ts.isIdentifier(node) && node.text === declaration.name.text && (!symbol || checker.getSymbolAtLocation(node) === symbol)) return true;\n return ts.forEachChild(node, (child) => visit(child) || undefined) ?? false;\n };\n return visit(root);\n}\n\nconst returnOnlyCache = new WeakMap<TS.Node, readonly number[]>();\n\n/** Indexes of the declaration's type parameters that no parameter type names but the return type does. */\nfunction returnOnlyTypeParameters(declaration: TS.SignatureDeclaration, context: TypeClaimContext): readonly number[] {\n const cached = returnOnlyCache.get(declaration);\n if (cached) return cached;\n const { checker } = context;\n const parameters = declaration.typeParameters ?? [];\n // With no written return type the inferred one decides (a body returning `value as T`).\n const inferred = declaration.type ? undefined : checker.getSignatureFromDeclaration(declaration)?.getReturnType();\n const indexes: number[] = [];\n parameters.forEach((parameter, index) => {\n if (declaration.parameters.some((argument) => nodeMentions(context, argument.type, parameter))) return;\n const inReturn = declaration.type\n ? nodeMentions(context, declaration.type, parameter)\n : inferred !== undefined && typeMentions(context, inferred, checker.getTypeAtLocation(parameter));\n if (inReturn) indexes.push(index);\n });\n returnOnlyCache.set(declaration, indexes);\n return indexes;\n}\n\nfunction sameType(checker: TS.TypeChecker, a: TS.Type, b: TS.Type): boolean {\n if (a === b) return true;\n if (typeof checker.isTypeAssignableTo !== 'function') return false;\n return checker.isTypeAssignableTo(a, b) && checker.isTypeAssignableTo(b, a);\n}\n\n/** The type arguments the call resolved to: undefined when the signature is not generic, null when they cannot be read. */\nfunction resolvedTypeArguments(\n node: TS.CallExpression,\n signature: TS.Signature,\n expected: number,\n checker: TS.TypeChecker,\n): readonly TS.Type[] | undefined | null {\n if (typeof checker.getTypeArgumentsForResolvedSignature === 'function') return checker.getTypeArgumentsForResolvedSignature(signature);\n // Older TypeScript: only written type arguments can be read; inferred ones stay unknown to us.\n if (expected === 0) return undefined;\n const written = node.typeArguments ?? [];\n return written.length === expected ? written.map((argument) => checker.getTypeFromTypeNode(argument)) : null;\n}\n\n/**\n * The callee's own body proves its return type for every type argument: the compiler checked the\n * body against the return type, and nothing in the declaration is a claim (`function none<T>(): T[]\n * { return []; }`, a failure constructor returning `Result<T, E>`). The caller's choice then asserts\n * nothing. A declaration with no body (a `.d.ts`, `declare`, an overload or interface signature)\n * proves nothing, and neither does one that is still being decided (it calls itself).\n */\nfunction bodyProvesReturn(declaration: TS.SignatureDeclaration, context: TypeClaimContext): boolean {\n if (!('body' in declaration) || !declaration.body) return false;\n const known = context.provenBodies.get(declaration);\n if (known) return known === 'proven';\n context.provenBodies.set(declaration, 'checking');\n const hasClaim = (node: TS.Node): boolean =>\n typeClaimsAt(node, context).length > 0 || (context.ts.forEachChild(node, (child) => hasClaim(child) || undefined) ?? false);\n const proven = !hasClaim(declaration);\n context.provenBodies.set(declaration, proven ? 'proven' : 'claimed');\n return proven;\n}\n\n/**\n * A call whose return type depends on a type parameter the caller chose: it appears only in the\n * return position, the callee's body does not prove the return type for every choice, and no user\n * `trust_type` entry covers the callee (the project vouches for what it returns, whatever is chosen).\n */\nfunction genericReturnClaim(node: TS.CallExpression, context: TypeClaimContext): TypeClaim | null {\n const found = chosenReturnClaim(node, context);\n if (found?.origin === 'claim:generic-return' && context.trustsChosenReturn?.(node)) return null;\n return found;\n}\n\nfunction chosenReturnClaim(node: TS.CallExpression, context: TypeClaimContext): TypeClaim | null {\n const { ts, checker } = context;\n if (node.expression.kind === ts.SyntaxKind.ImportKeyword || node.expression.kind === ts.SyntaxKind.SuperKeyword) return null;\n const what = 'this generic call';\n const callee = clip(node.expression.getText(), 40);\n const signature = checker.getResolvedSignature(node);\n if (!signature) return claim(node, 'unanalyzable', { what: 'this call', reason: `no signature resolves for \"${callee}\"` });\n const declared = signature.getDeclaration() as TS.SignatureDeclaration | TS.JSDocSignature | undefined;\n const declaration = declared && !ts.isJSDocSignature(declared) ? declared : undefined;\n const parameters = declaration?.typeParameters ?? [];\n const chosen = resolvedTypeArguments(node, signature, parameters.length, checker);\n if (chosen === undefined || (chosen !== null && chosen.length === 0)) return null;\n if (!declaration || (chosen !== null && chosen.length !== parameters.length)) {\n return claim(node, 'unanalyzable', { what, reason: `the declaration of the signature of \"${callee}\" is not available` });\n }\n const returnOnly = returnOnlyTypeParameters(declaration, context);\n if (returnOnly.length === 0 || bodyProvesReturn(declaration, context)) return null;\n for (const index of returnOnly) {\n const parameter = parameters[index];\n const name = parameter.name.text;\n if (chosen === null) return claim(node, 'claim:generic-return', { parameter: name, callee, chosen: 'the inferred type' });\n const type = chosen[index];\n if (isUnresolved(ts, type)) {\n // A written type argument that does not resolve is reported at the type argument (unresolvedClaim).\n if (containsUnresolved(node, context)) return null;\n return claim(node, 'unanalyzable', { what, reason: `its type argument for \"${name}\" does not resolve` });\n }\n // `unknown` and `never` claim nothing; a written `any` is reported at the keyword.\n if (type.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown | ts.TypeFlags.Never)) continue;\n // The declaration's own default or constraint is its promise, not the caller's choice.\n const fallback = parameter.default ?? parameter.constraint;\n if (fallback && sameType(checker, type, checker.getTypeFromTypeNode(fallback))) continue;\n return claim(node, 'claim:generic-return', { parameter: name, callee, chosen: typeText(context, type) });\n }\n return null;\n}\n\n/**\n * True when the call picked its own return type (what `claim:generic-return` reports), wherever it is\n * written. The untrusted-value rule asks this: such a return is unproven even from a type-trusted origin,\n * unless a user `trust_type` entry covers the callee (a preset entry does not).\n */\nexport function picksOwnReturnType(node: TS.CallExpression, context: TypeClaimContext): boolean {\n try {\n return genericReturnClaim(node, context)?.origin === 'claim:generic-return';\n } catch {\n // The call is reported as `unanalyzable` by typeClaimsAt.\n return false;\n }\n}\n\nfunction decide(node: TS.Node, context: TypeClaimContext): TypeClaim[] {\n const { ts, checker } = context;\n const claims: TypeClaim[] = [];\n const add = (found: TypeClaim | null): void => {\n if (found) claims.push(found);\n };\n add(unresolvedClaim(node, context));\n add(unresolvedModuleClaim(node, context));\n for (const operand of typedOperands(ts, node)) add(anyFlowClaim(operand, context));\n if (node.kind === ts.SyntaxKind.AnyKeyword) add(claim(node, 'claim:any', { detail: 'Explicit `any`' }));\n else if (ts.isAssertionExpression(node)) add(assertionClaim(node, context));\n else if (ts.isNonNullExpression(node)) add(claim(node, 'claim:non-null', { from: typeText(context, checker.getTypeAtLocation(node.expression)) }));\n else if (ts.isTypePredicateNode(node)) add(claim(node, 'claim:predicate', { predicate: clip(node.getText()) }));\n add(anyAccessClaim(node, context));\n if (ts.isCallExpression(node)) add(genericReturnClaim(node, context));\n return claims;\n}\n\n/**\n * The claims decided at `node` (its own, and `any` values it puts in typed positions), minus the ones\n * inside an approved validator. A node the type checker fails on is itself a claim (`unanalyzable`).\n */\nexport function typeClaimsAt(node: TS.Node, context: TypeClaimContext): TypeClaim[] {\n let claims: TypeClaim[];\n try {\n claims = decide(node, context);\n } catch (error) {\n const reason = `the type checker failed on it (${clip(error instanceof Error ? error.message : String(error))})`;\n claims = [claim(node, 'unanalyzable', { what: 'this node', reason })];\n }\n return claims.filter((found) => !context.isInsideValidator(found.node));\n}\n\nconst DIRECTIVE_PROBLEMS: Readonly<Record<DirectiveProblem, string>> = {\n unknown: 'is not a known directive',\n block: 'is a block comment, not a `//` line comment',\n misplaced: 'is not directly above a function',\n};\n\n/**\n * Every `//trust:` comment within `root` that marks nothing (origin `directive`), in source order, reported\n * at the comment. Never allowed by a validator: a typo inside one is still a typo. A `//trust:accept` is\n * not one of them: throw-must-return-result decides it (accept.ts).\n */\nexport function directiveClaims(ts: TypeScript, root: TS.Node): TypeClaim[] {\n const sourceFile = root.getSourceFile();\n const claims: TypeClaim[] = [];\n for (const directive of trustDirectivesIn(ts, sourceFile)) {\n if (directive.pos < root.pos || directive.end > root.end || isAcceptDirective(directive)) continue;\n const problem = directiveProblem(ts, sourceFile, directive);\n if (!problem) continue;\n const data = { text: clip(directive.text, 40), problem: DIRECTIVE_PROBLEMS[problem] };\n claims.push({ node: sourceFile, origin: 'directive', data, at: { start: directive.pos, end: directive.end } });\n }\n return claims;\n}\n\n/** Every claim in `root` (a source file, usually): its directive findings, then the claims in walk order. */\nexport function typeClaimsIn(root: TS.Node, context: TypeClaimContext): TypeClaim[] {\n const claims: TypeClaim[] = directiveClaims(context.ts, root);\n const visit = (node: TS.Node): void => {\n claims.push(...typeClaimsAt(node, context));\n context.ts.forEachChild(node, visit);\n };\n visit(root);\n return claims;\n}\n","// The untrusted-value rule as decisions on TypeScript nodes: type trust is opt-in. One implementation,\n// shared by the standalone checker (check-file.ts), the ESLint adapter\n// (src/eslint/rules/untrusted-value.ts) and `trust explain`.\n//\n// A value is untrusted when the type it has was declared by an origin that is not on the type-trust\n// list (`trust_type` / `distrust_type` in trust.config.json, policy.ts). It enters checked code as\n//\n// return the result of a call / `new` into such an origin readFileSync(path)\n// generic-return the result of a call that picked its own return type, even db.query<User>(sql)\n// from a type-trusted or first-party origin, unless a `trust_type` entry of the\n// project's own config files (not a built-in preset) covers the callee\n// parameter a parameter of a callback whose signature such an origin ws.on('message', (data) => …)\n// declares: the outside calls it, the annotation is a claim ipcMain.handle((event, payload: Foo) => …)\n// (`rules.untrustedCallbacks` in trust.config.json: \"inline\", the default, is a function\n// written inline at the call; \"off\" makes no callback parameter a source; \"all\" adds the\n// hand-offs below)\n// read a property or global such an origin declares process.env.PORT, event.data, location.hash\n// catch a `catch` variable catch (error)\n// guard a value narrowed by a type guard or assertion function if (validateUser(input)) input.name\n// (`x is T`, `asserts x is T`, `asserts x`) whose signature assertUser(input); input.name\n// such an origin declares: the narrowed type is its claim, even of a value declared `unknown`.\n// The origin is the declaration of the signature the call resolves to (AJV's\n// `ValidateFunction<T>` for `const validateUser = ajv.compile(schema)`), not the name it is\n// called through. Where the guard holds is read from the code around the value: the branch\n// of an `if`/`?:`/`&&`/`||`/loop its result decides, the code after an `if` whose other branch\n// exits, the code after an assertion's statement. Not a source: a guard checked code declares\n// (its written predicate is a type claim), a validator, `Array.isArray`, a type-trusted origin.\n//\n// and stays untrusted through `await`, `!`, parentheses, an assertion, `?:`, `??`/`||`/`&&`, and a\n// `const`/`let` with no written type. Each occurrence of an untrusted value is then judged by where it\n// stands. It may\n//\n// - be passed to a validator (a function marked `//trust:validator_function`, validator.ts),\n// - be kept as `unknown` (or `any`, which type-claim reports): stored, assigned, passed or returned\n// where `unknown` is expected,\n// - be tested by a built-in check: `typeof`, `in`, `instanceof`, `Array.isArray`, `===`/`!==`, truthiness,\n// - be thrown, discarded, or be the initializer of a variable with no written type (it stays untrusted).\n//\n// Any other use is a finding that names the origin: reading a member, passing or storing it where a type\n// is expected, returning it from a function that does not return `unknown`, computing with it, iterating\n// or spreading it.\n//\n// Members. Who declares the member decides what reading it is:\n// - a member declared by an origin that is not type-trusted (`event.data`, `row.name` of a package's own\n// `Row`), or by nothing (an index signature: `process.env.PORT`), is a read: no finding, and the member\n// is the untrusted value, judged where it stands in turn;\n// - a member declared by checked code or by a type-trusted origin (`payload.x` of a first-party `Foo`,\n// `text.length`) would come out looking trusted, so reading it from an untrusted value is the finding.\n// A global or an imported constant (`process`, `JSON`, `location`) is a name rather than a value that was\n// handed over: what is read from it is judged by the member's own declaration.\n//\n// Narrowing happens on `unknown`: the compiler narrows a typed value against its declared type, and that\n// type is the unproven claim, so a `typeof` on the typed value is allowed but unlocks nothing. A built-in\n// check proves what it narrows to; a guard proves only what the origin declaring it is trusted for (`guard`).\n//\n// Nothing is reported for a value whose type claims nothing: `unknown`, `any` (type-claim reports its\n// uses), `void`/`undefined`/`null`/`never`, and functions (a function is judged where it is called). A\n// `catch` variable is `unknown` (or `any`), so the compiler and type-claim already hold it.\n// Uses inside a validator are not reported.\n//\n// A value its declaration fixes is never a finding, with no config (issue #8): an enum member\n// (`LoadAs.Singleton`, regular or const enum) or a constant whose declared type is one value (`declare const\n// MODE: 'prod'`, `unique symbol`) is not an untrusted value at all, and a class or function used as a value\n// claims nothing (above).\n// What a declaration only describes stays untrusted: a return (`scopeOf(): LoadAs`), a callback parameter,\n// a property of an object (`settings().mode` typed `'prod'`), a `let`.\n//\n// Hand-offs (`untrustedCallbacks: \"all\"`). A function checked code hands to an origin that is not\n// type-trusted is called by that origin with whatever it has, however the function is written: a named\n// function, a `const` function, `this.method`, `fn.bind(...)`, the methods and properties of an object\n// literal, the methods of a class instance. Each such function is judged where it is handed over, never\n// tainted itself (first-party code may call it too): a parameter the origin fills whose type claims\n// something (not `unknown`/`any`) is a finding at the hand-off, naming the origin. The hand-off is\n// - an argument of a call / `new` into an origin that is not type-trusted, whose expected type has call\n// signatures (a callback) or methods (a handler object, a class instance): the origin is the callee,\n// so a `trust_type` entry for it (`evil-lib.on`) clears every pattern;\n// - an `implements` clause naming an interface such an origin declares: each implementing method is\n// judged against the interface member, which is the origin (`evil-lib.Handler.onData`).\n// A function written inline where an untrusted signature is declared is not judged here: its parameters\n// are untrusted values, judged where they are used (as with \"inline\"). Nothing is reported inside a\n// validator, and a validator handed over is not questioned.\nimport type * as TS from 'typescript';\nimport type { OriginInfo } from '../eslint/origin.js';\nimport type { TrustPolicy, TypeVerdict } from '../eslint/policy.js';\nimport type { TypeScript } from '../eslint/typescript.js';\nimport {\n CATCH_ORIGIN,\n fillMessage,\n UNTRUSTED_ENTRY_LABELS,\n UNTRUSTED_VALUE_MESSAGES,\n type UntrustedEntry,\n type UntrustedValueMessageId,\n} from './messages.js';\nimport { isValueUse, picksOwnReturnType, typeClaimContext, typeTextFlags, type TypeClaimContext } from './type-claims.js';\nimport { canonicalTypeText } from './type-text.js';\nimport { isInsideValidator, isMarkedValidator } from './validator.js';\n\n/** Where an untrusted value came from: how it entered, and the origin that declared its type. */\nexport interface UntrustedSource {\n readonly entry: UntrustedEntry;\n readonly origin: string;\n}\n\n/**\n * What became of one occurrence of an untrusted value:\n * finding it is used in a way that relies on its declared type (`use` says how)\n * allowed it stands where an untrusted value may stand\n * no-claim its type claims nothing (`unknown`, `any`, empty, a function)\n * validator it is inside a validator, which is not questioned\n */\nexport type UntrustedOutcome = 'finding' | 'allowed' | 'no-claim' | 'validator';\n\n/** One occurrence of an untrusted value in checked code. */\nexport interface UntrustedValue extends UntrustedSource {\n /** The expression that is the untrusted value: a call, a name, a member read. */\n readonly node: TS.Expression;\n /** The type the value is declared to have where it is used (after `await`, `!`, an assertion). */\n readonly type: string;\n readonly outcome: UntrustedOutcome;\n /** What the code does with it, when that is a finding (`passed where \"User\" is expected`). */\n readonly use: string | null;\n}\n\n/** Type trust of the callee of one call / `new`: the policy's verdict, a validator, or a caller-chosen return type. */\nexport type CallTypeVerdict =\n | { readonly kind: 'unresolved' }\n | { readonly kind: 'validator'; readonly origin: OriginInfo }\n /** The origin's types are trusted, but this call picked its own return type: the result is untrusted. */\n | { readonly kind: 'caller-chosen-generic'; readonly origin: OriginInfo }\n | TypeVerdict;\n\n/**\n * A cached decision: a source, 'none', 'deciding' (being decided further up: a cycle such as `x = y; y = x`),\n * or 'tentative' (found nothing while something it depends on was still being decided; settled when the\n * outermost decision ends, see `remember`).\n */\nexport type SourceDecision = UntrustedSource | 'none' | 'deciding' | 'tentative';\n\n/** The state of the decision being made: how deep it is, and what was found while a cycle was open. */\ninterface DecisionState {\n depth: number;\n /** The current decision met a cycle (or a tentative answer), so finding nothing is not final yet. */\n provisional: boolean;\n /** Undoes or confirms each tentative answer when the outermost decision ends. */\n readonly tentative: Array<(confirmed: boolean) => void>;\n}\n\nexport interface UntrustedValueContext {\n readonly ts: TypeScript;\n readonly checker: TS.TypeChecker;\n readonly policy: TrustPolicy;\n readonly claims: TypeClaimContext;\n readonly sources: WeakMap<TS.Node, SourceDecision>;\n /** Per variable with no written type: the source of a value assigned to it after its declaration. */\n readonly assignedSources: WeakMap<TS.Symbol, SourceDecision>;\n /** Per file, scanned once: the values assigned to each name (`=`, `||=`, `&&=`, `??=`, destructuring). */\n readonly assignments: WeakMap<TS.SourceFile, Map<TS.Symbol, TS.Expression[]>>;\n /** Per file, scanned once: the calls to a type guard or assertion function, by the reference each narrows. */\n readonly guards: WeakMap<TS.SourceFile, Map<string, GuardCall[]>>;\n readonly decision: DecisionState;\n}\n\nconst contexts = new WeakMap<TrustPolicy, UntrustedValueContext>();\n\n/** One context per policy (a policy belongs to one checker and one config). */\nexport function untrustedValueContext(ts: TypeScript, checker: TS.TypeChecker, policy: TrustPolicy): UntrustedValueContext {\n let context = contexts.get(policy);\n if (!context) {\n context = {\n ts,\n checker,\n policy,\n claims: typeClaimContext(ts, checker, undefined, policy),\n sources: new WeakMap(),\n assignedSources: new WeakMap(),\n assignments: new WeakMap(),\n guards: new WeakMap(),\n decision: { depth: 0, provisional: false, tentative: [] },\n };\n contexts.set(policy, context);\n }\n return context;\n}\n\n/**\n * Decide `key` once and cache the answer in `cache`. A source found is final (a source is never taken\n * back). Finding nothing while a cycle was open (`x = y; y = x`: deciding `y` meets `x`, still being decided)\n * is tentative: it is confirmed when the outermost decision also finds nothing (then nothing in the cycle\n * carries a source), and forgotten otherwise, to be decided again.\n */\nfunction remember<K extends object>(cache: WeakMap<K, SourceDecision>, key: K, context: UntrustedValueContext, decide: () => UntrustedSource | null): UntrustedSource | null {\n const state = context.decision;\n const known = cache.get(key);\n if (known === 'deciding' || known === 'tentative') {\n state.provisional = true;\n return null;\n }\n if (known !== undefined) return known === 'none' ? null : known;\n const outer = state.provisional;\n state.provisional = false;\n state.depth += 1;\n cache.set(key, 'deciding');\n let source: UntrustedSource | null;\n try {\n source = decide();\n } catch (error) {\n cache.delete(key);\n state.depth = 0;\n state.provisional = false;\n state.tentative.length = 0;\n throw error;\n }\n state.depth -= 1;\n const tentative = source === null && state.provisional;\n if (tentative) {\n cache.set(key, 'tentative');\n state.tentative.push((confirmed) => (confirmed ? cache.set(key, 'none') : cache.delete(key)));\n } else {\n cache.set(key, source ?? 'none');\n }\n state.provisional = outer || tentative;\n if (state.depth === 0) {\n for (const settle of state.tentative) settle(source === null);\n state.tentative.length = 0;\n state.provisional = false;\n }\n return source;\n}\n\nconst MAX_TEXT = 80;\n\nfunction clip(text: string, max = MAX_TEXT): string {\n const flat = text.replace(/\\s+/g, ' ');\n return flat.length > max ? `${flat.slice(0, max - 3)}...` : flat;\n}\n\nfunction typeText(context: UntrustedValueContext, type: TS.Type): string {\n // The full text (the checker's own `...` truncation would keep different members on different compilers),\n // in canonical member order, then the clip.\n return clip(canonicalTypeText(context.checker.typeToString(type, undefined, typeTextFlags(context.ts))));\n}\n\nfunction isOpaque(ts: TypeScript, type: TS.Type): boolean {\n return (type.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)) !== 0;\n}\n\n/** The type says nothing a use could rely on: `unknown`, `any`, an empty type, or a function. */\nfunction claimsNothing(ts: TypeScript, type: TS.Type): boolean {\n const empty = ts.TypeFlags.Any | ts.TypeFlags.Unknown | ts.TypeFlags.Never | ts.TypeFlags.Void | ts.TypeFlags.Undefined | ts.TypeFlags.Null;\n const members = type.isUnion() ? type.types : [type];\n return members.every((member) => (member.flags & empty) !== 0 || member.getCallSignatures().length > 0 || member.getConstructSignatures().length > 0);\n}\n\n/** One value and no other: a single string, number, bigint or boolean literal, an enum member, a `unique symbol`. */\nfunction isUnitType(ts: TypeScript, type: TS.Type): boolean {\n if (type.isUnion()) return false;\n const unit = ts.TypeFlags.StringLiteral | ts.TypeFlags.NumberLiteral | ts.TypeFlags.BigIntLiteral | ts.TypeFlags.BooleanLiteral | ts.TypeFlags.EnumLiteral | ts.TypeFlags.UniqueESSymbol;\n return (type.flags & unit) !== 0;\n}\n\n/**\n * A name or member whose value its declaration fixes (issue #8): an enum member (of a regular or a const\n * enum: `LoadAs.Singleton`) or the enum itself (`lib.LoadAs`), or a constant whose declared type is one value\n * (`declare const MODE: 'prod'`, `declare const TOKEN: unique symbol`). It cannot hold anything its\n * declaration does not say, so it claims nothing and is not an untrusted value. What a declaration only\n * describes (a return, a callback parameter, a property of an object, a `let`) is not fixed by it.\n */\nfunction isFixedByDeclaration(declaration: TS.Node, context: UntrustedValueContext): boolean {\n const { ts, checker } = context;\n if (ts.isEnumMember(declaration) || ts.isEnumDeclaration(declaration)) return true;\n if (!ts.isVariableDeclaration(declaration) || !ts.isIdentifier(declaration.name)) return false;\n if (!(ts.getCombinedNodeFlags(declaration) & ts.NodeFlags.Const)) return false;\n const symbol = checker.getSymbolAtLocation(declaration.name);\n return symbol !== undefined && isUnitType(ts, checker.getTypeOfSymbol(symbol));\n}\n\n/** A callback's return value is dropped: `void`, or a union with `void` (`void | Promise<void>`). */\nfunction isDiscarded(ts: TypeScript, type: TS.Type): boolean {\n const members = type.isUnion() ? type.types : [type];\n return members.some((member) => (member.flags & ts.TypeFlags.Void) !== 0);\n}\n\nfunction declarationOf(ts: TypeScript, checker: TS.TypeChecker, symbol: TS.Symbol | undefined, policy: TrustPolicy): TS.Declaration | undefined {\n const target = symbol && symbol.flags & ts.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;\n return policy.symbol_declaration(target);\n}\n\n/** Type trust of the callee of `node` (see CallTypeVerdict). */\nexport function callTypeVerdict(node: TS.CallExpression | TS.NewExpression, context: UntrustedValueContext): CallTypeVerdict {\n const { ts, policy } = context;\n const resolved = policy.calleeDeclaration(node);\n if (!resolved) return { kind: 'unresolved' };\n const verdict = policy.typeVerdictOf(resolved.declaration);\n if (isMarkedValidator(ts, resolved.declaration)) return { kind: 'validator', origin: verdict.origin };\n if (verdict.kind === 'type-untrusted') return verdict;\n if (ts.isCallExpression(node) && picksOwnReturnType(node, context.claims)) return { kind: 'caller-chosen-generic', origin: verdict.origin };\n return verdict;\n}\n\nfunction callSource(node: TS.CallExpression | TS.NewExpression, context: UntrustedValueContext): UntrustedSource | null {\n const { ts } = context;\n if (node.expression.kind === ts.SyntaxKind.ImportKeyword || node.expression.kind === ts.SyntaxKind.SuperKeyword) return null;\n const verdict = callTypeVerdict(node, context);\n if (verdict.kind === 'type-untrusted') return { entry: 'return', origin: verdict.origin.origin };\n if (verdict.kind === 'caller-chosen-generic') return { entry: 'generic-return', origin: verdict.origin.origin };\n return null;\n}\n\n/** The declaration of the signature a callback is called through (its contextual signature), else null. */\nfunction contextualSignatureDeclaration(fn: TS.ArrowFunction | TS.FunctionExpression, context: UntrustedValueContext): TS.Node | null {\n const { ts, checker } = context;\n const expected = checker.getContextualType(fn);\n if (!expected) return null;\n const members = expected.isUnion() ? expected.types : [expected];\n for (const member of members) {\n for (const signature of member.getCallSignatures()) {\n const declaration = signature.getDeclaration() as TS.SignatureDeclaration | TS.JSDocSignature | undefined;\n if (declaration && !ts.isJSDocSignature(declaration)) return declaration;\n }\n }\n return null;\n}\n\n/** The parameter or variable a name is bound by: itself, or the one whose binding pattern holds it. */\nfunction bindingRoot(ts: TypeScript, declaration: TS.Node): TS.Node {\n let current = declaration;\n while (ts.isBindingElement(current)) current = current.parent.parent;\n return current;\n}\n\nfunction declaredNameSource(declaration: TS.Node, context: UntrustedValueContext): UntrustedSource | null {\n const { ts, policy } = context;\n const root = bindingRoot(ts, declaration);\n if (ts.isParameter(root)) {\n // `untrustedCallbacks: \"off\"`: no callback parameter is a source. \"inline\" and \"all\": a parameter of a\n // function written inline where its signature is declared (\"all\" also judges hand-offs, see below).\n if (policy.rules.untrustedCallbacks === 'off') return null;\n const fn = root.parent;\n if (!ts.isArrowFunction(fn) && !ts.isFunctionExpression(fn)) return null;\n const signature = contextualSignatureDeclaration(fn, context);\n if (!signature) return null;\n const verdict = policy.typeVerdictOf(signature);\n return verdict.kind === 'type-untrusted' ? { entry: 'parameter', origin: verdict.origin.origin } : null;\n }\n if (!ts.isVariableDeclaration(root)) return null;\n if (ts.isCatchClause(root.parent)) return { entry: 'catch', origin: CATCH_ORIGIN };\n if (policy.zones.zoneOf(root.getSourceFile().fileName) === 'checked') {\n // A written type was judged where each value was stored. With none, the variable is whatever is put in\n // it: its initializer, or any value assigned to it later (see assignedSource).\n if (root.type) return null;\n return (root.initializer ? carriedSource(root.initializer, context) : null) ?? assignedSource(declaration, root, context);\n }\n if (isFixedByDeclaration(declaration, context)) return null;\n const verdict = policy.typeVerdictOf(root);\n return verdict.kind === 'type-untrusted' ? { entry: 'read', origin: verdict.origin.origin } : null;\n}\n\n/**\n * The source of any value assigned to a variable of checked code with no written type, after its\n * declaration: `=`, `||=`, `&&=`, `??=`, or a destructuring assignment (`[x] = …`, `({ a: x } = …)`, which,\n * like a binding pattern's initializer, gives each name the whole value; a default is a value too). Flow-\n * insensitive and conservative: one untrusted value assigned anywhere in its scope (a closure included), in\n * any order, makes every use of the variable untrusted. Decided once per variable.\n */\nfunction assignedSource(declaration: TS.Node, root: TS.VariableDeclaration, context: UntrustedValueContext): UntrustedSource | null {\n const { ts, checker } = context;\n if (ts.getCombinedNodeFlags(root) & ts.NodeFlags.Const) return null;\n const name = ts.isVariableDeclaration(declaration) || ts.isBindingElement(declaration) ? declaration.name : undefined;\n const symbol = name && ts.isIdentifier(name) ? checker.getSymbolAtLocation(name) : undefined;\n if (!symbol) return null;\n return remember(context.assignedSources, symbol, context, () => {\n for (const value of assignmentsIn(root.getSourceFile(), context).get(symbol) ?? []) {\n const source = carriedSource(value, context);\n if (source) return source;\n }\n return null;\n });\n}\n\n/**\n * The values assigned to each name in a file, by the name's symbol. A file holds every scope a variable\n * can be assigned in, so it is scanned once, whatever number of its variables are asked about.\n */\nfunction assignmentsIn(file: TS.SourceFile, context: UntrustedValueContext): Map<TS.Symbol, TS.Expression[]> {\n const { ts, checker } = context;\n const known = context.assignments.get(file);\n if (known) return known;\n const assigned = new Map<TS.Symbol, TS.Expression[]>();\n const add = (symbol: TS.Symbol | undefined, value: TS.Expression): void => {\n if (!symbol) return;\n const values = assigned.get(symbol);\n if (values) values.push(value);\n else assigned.set(symbol, [value]);\n };\n // The names a target writes, each given `value`. A default (`[x = d]`, `{ a: x = d }`) is an assignment\n // the walk meets on its own; a shorthand default (`{ x = d }`) is not, so it is added here.\n const targets = (target: TS.Expression, value: TS.Expression): void => {\n let inner = target;\n while (ts.isParenthesizedExpression(inner) || ts.isNonNullExpression(inner)) inner = inner.expression;\n if (ts.isIdentifier(inner)) {\n add(checker.getSymbolAtLocation(inner), value);\n } else if (ts.isBinaryExpression(inner) && inner.operatorToken.kind === ts.SyntaxKind.EqualsToken) {\n targets(inner.left, value);\n } else if (ts.isSpreadElement(inner)) {\n targets(inner.expression, value);\n } else if (ts.isArrayLiteralExpression(inner)) {\n for (const element of inner.elements) if (!ts.isOmittedExpression(element)) targets(element, value);\n } else if (ts.isObjectLiteralExpression(inner)) {\n for (const property of inner.properties) {\n if (ts.isPropertyAssignment(property)) targets(property.initializer, value);\n else if (ts.isSpreadAssignment(property)) targets(property.expression, value);\n else if (ts.isShorthandPropertyAssignment(property)) {\n const symbol = checker.getShorthandAssignmentValueSymbol(property);\n add(symbol, value);\n if (property.objectAssignmentInitializer) add(symbol, property.objectAssignmentInitializer);\n }\n }\n }\n };\n const { assignment } = operatorSets(ts);\n const visit = (node: TS.Node): void => {\n if (ts.isBinaryExpression(node) && assignment.has(node.operatorToken.kind)) targets(node.left, node.right);\n ts.forEachChild(node, visit);\n };\n visit(file);\n context.assignments.set(file, assigned);\n return assigned;\n}\n\nfunction identifierSource(node: TS.Identifier, context: UntrustedValueContext): UntrustedSource | null {\n const { ts, checker, policy } = context;\n const symbol = ts.isShorthandPropertyAssignment(node.parent) ? checker.getShorthandAssignmentValueSymbol(node.parent) : checker.getSymbolAtLocation(node);\n const declaration = declarationOf(ts, checker, symbol, policy);\n return declaration ? declaredNameSource(declaration, context) : null;\n}\n\n/**\n * A member read. A member an origin that is not type-trusted declares is untrusted, whatever it is read\n * from. A member nothing declares (an index signature, a tuple element) is what its object is. A member\n * checked code or a type-trusted origin declares is trusted here: reading it from an untrusted value is\n * the finding, reported at that value.\n */\nfunction accessSource(node: TS.PropertyAccessExpression | TS.ElementAccessExpression, context: UntrustedValueContext): UntrustedSource | null {\n const { ts, checker, policy } = context;\n const name = ts.isPropertyAccessExpression(node) ? node.name : node.argumentExpression;\n const named = ts.isPropertyAccessExpression(node) || ts.isStringLiteralLike(name) || ts.isNumericLiteral(name);\n const declaration = named ? declarationOf(ts, checker, checker.getSymbolAtLocation(name), policy) : undefined;\n if (!declaration) return carriedSource(node.expression, context);\n if (isFixedByDeclaration(declaration, context)) return null;\n const verdict = policy.typeVerdictOf(declaration);\n return verdict.kind === 'type-untrusted' ? { entry: 'read', origin: verdict.origin.origin } : null;\n}\n\n/**\n * Who vouches for what a type guard or assertion function narrows: the policy's verdict on the origin that\n * declares its signature, a validator (`//trust:validator_function`), or a built-in check (`Array.isArray`).\n */\nexport type GuardVerdict =\n | { readonly kind: 'validator'; readonly origin: OriginInfo }\n | { readonly kind: 'built-in'; readonly origin: OriginInfo }\n | TypeVerdict;\n\n/** One call to a type guard (`x is T`) or an assertion function (`asserts x is T`, `asserts x`). */\nexport interface GuardCall {\n readonly call: TS.CallExpression;\n /** The value it narrows: the argument at the predicate's parameter, or the object of a `this` guard. */\n readonly argument: TS.Expression;\n /** An assertion narrows the code after its statement; a type guard, the branch its result decides. */\n readonly asserts: boolean;\n /** The signature's predicate, as the call instantiates it (`data is User`, `asserts value`). */\n readonly predicate: string;\n readonly verdict: GuardVerdict;\n}\n\n/** The built-in checks a guard may be: they narrow, but claim nothing (see the header). */\nconst BUILT_IN_GUARDS = new Set(['js:Array.isArray']);\n\n/**\n * The guard `call` is, else null. Its origin is the declaration of the signature the call resolves to, not\n * of the name it is called through: `const validateUser = ajv.compile(schema)` is checked code's name for\n * AJV's `ValidateFunction<User>`, whose call signature AJV declares.\n */\nexport function guardCallOf(call: TS.CallExpression, context: UntrustedValueContext): GuardCall | null {\n const { ts, checker, policy } = context;\n if (call.expression.kind === ts.SyntaxKind.ImportKeyword || call.expression.kind === ts.SyntaxKind.SuperKeyword) return null;\n const signature = checker.getResolvedSignature(call);\n const predicate = signature ? checker.getTypePredicateOfSignature(signature) : undefined;\n const declaration = signature?.getDeclaration() as TS.SignatureDeclaration | TS.JSDocSignature | undefined;\n if (!predicate || !declaration) return null;\n let argument: TS.Expression | undefined;\n if (predicate.kind === ts.TypePredicateKind.Identifier || predicate.kind === ts.TypePredicateKind.AssertsIdentifier) {\n argument = call.arguments[predicate.parameterIndex];\n } else {\n let callee: TS.Expression = call.expression;\n while (ts.isParenthesizedExpression(callee) || ts.isNonNullExpression(callee)) callee = callee.expression;\n argument = ts.isPropertyAccessExpression(callee) || ts.isElementAccessExpression(callee) ? callee.expression : undefined;\n }\n if (!argument || ts.isSpreadElement(argument)) return null;\n const typeVerdict = policy.typeVerdictOf(declaration);\n const verdict: GuardVerdict = isMarkedValidator(ts, declaration)\n ? { kind: 'validator', origin: typeVerdict.origin }\n : BUILT_IN_GUARDS.has(typeVerdict.origin.origin)\n ? { kind: 'built-in', origin: typeVerdict.origin }\n : typeVerdict;\n const asserts = predicate.kind === ts.TypePredicateKind.AssertsIdentifier || predicate.kind === ts.TypePredicateKind.AssertsThis;\n return { call, argument, asserts, predicate: clip(checker.typePredicateToString(predicate)), verdict };\n}\n\n/** A name, `this`, or a member chain of them (`input`, `event.data`, `this.body['raw']`) as text; else null. */\nfunction referenceKey(ts: TypeScript, node: TS.Node): string | null {\n let inner = node;\n while (ts.isParenthesizedExpression(inner) || ts.isNonNullExpression(inner)) inner = inner.expression;\n if (ts.isIdentifier(inner)) return inner.text;\n if (inner.kind === ts.SyntaxKind.ThisKeyword) return 'this';\n if (ts.isPropertyAccessExpression(inner)) {\n const object = referenceKey(ts, inner.expression);\n return object === null ? null : `${object}.${inner.name.text}`;\n }\n if (ts.isElementAccessExpression(inner) && (ts.isStringLiteralLike(inner.argumentExpression) || ts.isNumericLiteral(inner.argumentExpression))) {\n const object = referenceKey(ts, inner.expression);\n return object === null ? null : `${object}.${inner.argumentExpression.text}`;\n }\n return null;\n}\n\n/** The symbol of the name a reference starts from (`input` in `input.body.raw`); `this` has none. */\nfunction referenceRoot(node: TS.Node, context: UntrustedValueContext): TS.Symbol | undefined {\n const { ts, checker } = context;\n let inner = node;\n for (;;) {\n if (ts.isParenthesizedExpression(inner) || ts.isNonNullExpression(inner) || ts.isPropertyAccessExpression(inner) || ts.isElementAccessExpression(inner)) {\n inner = inner.expression;\n } else {\n break;\n }\n }\n if (!ts.isIdentifier(inner)) return undefined;\n return ts.isShorthandPropertyAssignment(inner.parent) ? checker.getShorthandAssignmentValueSymbol(inner.parent) : checker.getSymbolAtLocation(inner);\n}\n\n/** Per file, scanned once: every guard call, by the text of the reference it narrows. */\nfunction guardsIn(file: TS.SourceFile, context: UntrustedValueContext): Map<string, GuardCall[]> {\n const { ts } = context;\n const known = context.guards.get(file);\n if (known) return known;\n const guards = new Map<string, GuardCall[]>();\n const visit = (node: TS.Node): void => {\n if (ts.isCallExpression(node)) {\n const guard = guardCallOf(node, context);\n const key = guard ? referenceKey(ts, guard.argument) : null;\n if (guard && key !== null) {\n const list = guards.get(key);\n if (list) list.push(guard);\n else guards.set(key, [guard]);\n }\n }\n ts.forEachChild(node, visit);\n };\n visit(file);\n context.guards.set(file, guards);\n return guards;\n}\n\n/** `call` holds when `condition` is `outcome`: it is the condition, or a part of it `!`, `&&` and `||` decide. */\nfunction holdsWhen(condition: TS.Expression, outcome: boolean, call: TS.CallExpression, ts: TypeScript): boolean {\n let inner = condition;\n while (ts.isParenthesizedExpression(inner)) inner = inner.expression;\n if (inner === call) return outcome;\n if (ts.isPrefixUnaryExpression(inner) && inner.operator === ts.SyntaxKind.ExclamationToken) return holdsWhen(inner.operand, !outcome, call, ts);\n if (ts.isBinaryExpression(inner)) {\n const kind = inner.operatorToken.kind;\n if (kind === ts.SyntaxKind.AmpersandAmpersandToken && outcome) return holdsWhen(inner.left, true, call, ts) || holdsWhen(inner.right, true, call, ts);\n if (kind === ts.SyntaxKind.BarBarToken && !outcome) return holdsWhen(inner.left, false, call, ts) || holdsWhen(inner.right, false, call, ts);\n }\n return false;\n}\n\n/** The statement never completes normally: `return`, `throw`, `break`, `continue`, or a block ending in one. */\nfunction exits(statement: TS.Statement, ts: TypeScript): boolean {\n if (ts.isReturnStatement(statement) || ts.isThrowStatement(statement) || ts.isBreakStatement(statement) || ts.isContinueStatement(statement)) return true;\n if (ts.isBlock(statement)) return statement.statements.length > 0 && exits(statement.statements[statement.statements.length - 1], ts);\n if (ts.isIfStatement(statement)) return statement.elseStatement !== undefined && exits(statement.thenStatement, ts) && exits(statement.elseStatement, ts);\n return false;\n}\n\n/** The statements of a statement list that run before `child` (a block, a file, a module, a `case`). */\nfunction statementsBefore(parent: TS.Node, child: TS.Node, ts: TypeScript): readonly TS.Statement[] {\n const list = ts.isBlock(parent) || ts.isSourceFile(parent) || ts.isModuleBlock(parent) || ts.isCaseClause(parent) || ts.isDefaultClause(parent) ? parent.statements : undefined;\n if (!list) return [];\n const index = list.indexOf(child as TS.Statement);\n return index > 0 ? list.slice(0, index) : [];\n}\n\n/**\n * The guard call holds where `node` is evaluated, by the shape of the code around it: `node` is in the\n * branch its result decides (`if`, `?:`, `&&`, `||`, a loop condition), or after an `if` whose other branch\n * exits (`if (!isUser(input)) return;`), or, for an assertion, after the statement that calls it.\n */\nfunction guardHolds(guard: GuardCall, node: TS.Node, ts: TypeScript): boolean {\n const { call } = guard;\n for (let child = node, parent = node.parent; parent; child = parent, parent = parent.parent) {\n if (!guard.asserts) {\n if (ts.isIfStatement(parent) && child !== parent.expression && holdsWhen(parent.expression, child === parent.thenStatement, call, ts)) return true;\n if (ts.isConditionalExpression(parent) && child !== parent.condition && holdsWhen(parent.condition, child === parent.whenTrue, call, ts)) return true;\n if (ts.isBinaryExpression(parent) && child === parent.right) {\n const kind = parent.operatorToken.kind;\n if (kind === ts.SyntaxKind.AmpersandAmpersandToken && holdsWhen(parent.left, true, call, ts)) return true;\n if (kind === ts.SyntaxKind.BarBarToken && holdsWhen(parent.left, false, call, ts)) return true;\n }\n if (ts.isWhileStatement(parent) && child === parent.statement && holdsWhen(parent.expression, true, call, ts)) return true;\n if (ts.isForStatement(parent) && (child === parent.statement || child === parent.incrementor) && parent.condition && holdsWhen(parent.condition, true, call, ts)) {\n return true;\n }\n }\n for (const before of statementsBefore(parent, child, ts)) {\n if (guard.asserts) {\n let expression = ts.isExpressionStatement(before) ? before.expression : undefined;\n while (expression && (ts.isParenthesizedExpression(expression) || ts.isAwaitExpression(expression))) expression = expression.expression;\n if (expression === call) return true;\n } else if (ts.isIfStatement(before)) {\n const thenExits = exits(before.thenStatement, ts);\n const elseExits = before.elseStatement !== undefined && exits(before.elseStatement, ts);\n if (thenExits && !elseExits && holdsWhen(before.expression, false, call, ts)) return true;\n if (elseExits && !thenExits && holdsWhen(before.expression, true, call, ts)) return true;\n }\n }\n }\n return false;\n}\n\n/**\n * The guard that narrowed `node` (a name or a member read) when an origin that is not type-trusted declares\n * it: the narrowed type is that origin's claim, so the value is untrusted, entry `guard`. Only a reference\n * the compiler did narrow (its type here is not its declared type) is asked; a guard checked code declares\n * is type-claim's (`claim:predicate`), and a validator, a built-in check and a type-trusted origin vouch for\n * what they narrow.\n */\nfunction guardSource(node: TS.Expression, context: UntrustedValueContext): UntrustedSource | null {\n const { ts, checker } = context;\n const key = referenceKey(ts, node);\n if (key === null) return null;\n const candidates = guardsIn(node.getSourceFile(), context).get(key);\n if (!candidates) return null;\n if (checker.getTypeAtLocation(node) === declaredType(node, context)) return null;\n const root = referenceRoot(node, context);\n for (const guard of candidates) {\n if (guard.verdict.kind !== 'type-untrusted' || referenceRoot(guard.argument, context) !== root) continue;\n if (guard.argument === node || !guardHolds(guard, node, ts)) continue;\n return { entry: 'guard', origin: guard.verdict.origin.origin };\n }\n return null;\n}\n\n/**\n * `source`, or the guard that narrowed `node`: a value that is not untrusted, or whose declared type\n * claims nothing (an `unknown` parameter, a `catch` variable), is untrusted once such a guard narrows it.\n */\nfunction withGuard(node: TS.Expression, source: UntrustedSource | null, context: UntrustedValueContext): UntrustedSource | null {\n if (source && !claimsNothing(context.ts, declaredType(node, context))) return source;\n return guardSource(node, context) ?? source;\n}\n\nfunction decideSource(node: TS.Node, context: UntrustedValueContext): UntrustedSource | null {\n const { ts } = context;\n if (ts.isCallExpression(node) || ts.isNewExpression(node)) return callSource(node, context);\n if (ts.isIdentifier(node)) return isValueUse(ts, node) ? withGuard(node, identifierSource(node, context), context) : null;\n if (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) return ts.isPartOfTypeNode(node) ? null : withGuard(node, accessSource(node, context), context);\n return null;\n}\n\n/** The source `node` itself is (a call, a name, a member read), else null. A name that is its own initializer is not a source. */\nexport function untrustedSourceOf(node: TS.Node, context: UntrustedValueContext): UntrustedSource | null {\n return remember(context.sources, node, context, () => decideSource(node, context));\n}\n\n/** A wrapper that hands its operand's value on unchanged: parentheses, `!`, `await`, an assertion, `satisfies`. */\nfunction isTransparent(ts: TypeScript, node: TS.Node): node is TS.ParenthesizedExpression | TS.NonNullExpression | TS.AwaitExpression | TS.AssertionExpression | TS.SatisfiesExpression {\n return ts.isParenthesizedExpression(node) || ts.isNonNullExpression(node) || ts.isAwaitExpression(node) || ts.isAssertionExpression(node) || ts.isSatisfiesExpression(node);\n}\n\n/** `node` (under its wrappers) is a name bound outside checked code: a global or an imported constant (`process`, `JSON`, `location`). */\nfunction isOutsideBinding(node: TS.Node, context: UntrustedValueContext): boolean {\n const { ts, checker, policy } = context;\n let inner = node;\n while (isTransparent(ts, inner)) inner = inner.expression;\n if (!ts.isIdentifier(inner)) return false;\n const declaration = declarationOf(ts, checker, checker.getSymbolAtLocation(inner), policy);\n if (!declaration || !ts.isVariableDeclaration(declaration) || ts.isCatchClause(declaration.parent)) return false;\n return policy.zones.zoneOf(declaration.getSourceFile().fileName) !== 'checked';\n}\n\n/** `??`, `||`, `&&`: the result is one of the operands. */\nfunction isValueLogical(ts: TypeScript, kind: TS.SyntaxKind): boolean {\n return kind === ts.SyntaxKind.BarBarToken || kind === ts.SyntaxKind.QuestionQuestionToken || kind === ts.SyntaxKind.AmpersandAmpersandToken;\n}\n\n/**\n * The source whose value `expression` hands on: through wrappers, either branch of `?:`, either side of\n * `??`/`||`/`&&` (and of `??=`/`||=`/`&&=`), the right of `,` and `=`.\n */\nfunction carriedSource(expression: TS.Node, context: UntrustedValueContext): UntrustedSource | null {\n const { ts } = context;\n if (isTransparent(ts, expression)) return carriedSource(expression.expression, context);\n if (ts.isConditionalExpression(expression)) return carriedSource(expression.whenTrue, context) ?? carriedSource(expression.whenFalse, context);\n if (ts.isBinaryExpression(expression)) {\n const kind = expression.operatorToken.kind;\n if (isValueLogical(ts, kind)) return carriedSource(expression.left, context) ?? carriedSource(expression.right, context);\n if (kind === ts.SyntaxKind.CommaToken || kind === ts.SyntaxKind.EqualsToken) return carriedSource(expression.right, context);\n if (operatorSets(ts).assignment.has(kind)) return carriedSource(expression.left, context) ?? carriedSource(expression.right, context);\n }\n return untrustedSourceOf(expression, context);\n}\n\nconst EQUALITY = new Set<TS.SyntaxKind>();\nconst ASSIGNMENT = new Set<TS.SyntaxKind>();\n\nfunction operatorSets(ts: TypeScript): { equality: Set<TS.SyntaxKind>; assignment: Set<TS.SyntaxKind> } {\n if (EQUALITY.size === 0) {\n for (const kind of [\n ts.SyntaxKind.EqualsEqualsEqualsToken,\n ts.SyntaxKind.ExclamationEqualsEqualsToken,\n ts.SyntaxKind.EqualsEqualsToken,\n ts.SyntaxKind.ExclamationEqualsToken,\n ]) {\n EQUALITY.add(kind);\n }\n for (const kind of [\n ts.SyntaxKind.EqualsToken,\n ts.SyntaxKind.BarBarEqualsToken,\n ts.SyntaxKind.AmpersandAmpersandEqualsToken,\n ts.SyntaxKind.QuestionQuestionEqualsToken,\n ]) {\n ASSIGNMENT.add(kind);\n }\n }\n return { equality: EQUALITY, assignment: ASSIGNMENT };\n}\n\n/** `Array.isArray(value)`: the built-in check, by the declaration the callee resolves to. */\nfunction isArrayIsArray(call: TS.CallExpression | TS.NewExpression, context: UntrustedValueContext): boolean {\n const resolved = context.ts.isCallExpression(call) ? context.policy.calleeDeclaration(call) : null;\n return resolved !== null && context.policy.origins.originOf(resolved.declaration).origin === 'js:Array.isArray';\n}\n\nfunction isValidatorCall(call: TS.CallExpression | TS.NewExpression, context: UntrustedValueContext): boolean {\n const resolved = context.policy.calleeDeclaration(call);\n return resolved !== null && isMarkedValidator(context.ts, resolved.declaration);\n}\n\n/** `node` is a name a destructuring assignment writes (`[x] = …`, `({ a: x, y } = …)`, `for ([x] of …)`): written, not read. */\nfunction isDestructuringTarget(ts: TypeScript, node: TS.Node): boolean {\n let current = node;\n let inPattern = false;\n for (;;) {\n const parent = current.parent;\n if (ts.isParenthesizedExpression(parent) || ts.isSpreadElement(parent) || ts.isSpreadAssignment(parent)) {\n current = parent;\n } else if (ts.isArrayLiteralExpression(parent)) {\n current = parent;\n inPattern = true;\n } else if ((ts.isPropertyAssignment(parent) && parent.initializer === current) || (ts.isShorthandPropertyAssignment(parent) && parent.name === current)) {\n current = parent.parent;\n inPattern = true;\n } else if (inPattern && ts.isBinaryExpression(parent) && parent.operatorToken.kind === ts.SyntaxKind.EqualsToken && parent.left === current) {\n // The pattern is the target (`[x] = …`), or a nested pattern with a default (`[[x] = []] = …`).\n return true;\n } else {\n return inPattern && (ts.isForOfStatement(parent) || ts.isForInStatement(parent)) && parent.initializer === current;\n }\n }\n}\n\n/**\n * What the code does with the value `top` (an untrusted value with its wrappers), when that relies on its\n * declared type; null when `top` stands where an untrusted value may stand. `inLiteral`: `top` is an object\n * or array literal holding the value, so a variable with no written type would hide it.\n */\nfunction useOf(top: TS.Node, context: UntrustedValueContext, inLiteral: boolean): string | null {\n const { ts, checker } = context;\n const parent = top.parent;\n const { equality, assignment } = operatorSets(ts);\n const ownType = (): string => typeText(context, checker.getTypeAtLocation(top));\n\n if (isTransparent(ts, parent)) return useOf(parent, context, inLiteral);\n if (isDestructuringTarget(ts, top)) return null;\n if (ts.isExpressionStatement(parent) || ts.isVoidExpression(parent) || ts.isTypeOfExpression(parent) || ts.isDeleteExpression(parent)) return null;\n if (ts.isThrowStatement(parent) || ts.isSwitchStatement(parent) || ts.isCaseClause(parent)) return null;\n if (ts.isIfStatement(parent) || ts.isWhileStatement(parent) || ts.isDoStatement(parent)) return null;\n if (ts.isForStatement(parent)) return parent.condition === top ? null : 'used in a loop header';\n if (ts.isPrefixUnaryExpression(parent)) return parent.operator === ts.SyntaxKind.ExclamationToken ? null : 'used in an operation';\n if (ts.isConditionalExpression(parent)) return parent.condition === top ? null : useOf(parent, context, inLiteral);\n\n if (ts.isBinaryExpression(parent)) {\n const kind = parent.operatorToken.kind;\n if (equality.has(kind)) return null;\n if (kind === ts.SyntaxKind.InstanceOfKeyword) return parent.left === top ? null : 'used as a constructor';\n if (kind === ts.SyntaxKind.InKeyword) return parent.right === top ? null : 'used as a key';\n if (kind === ts.SyntaxKind.CommaToken) return parent.left === top ? null : useOf(parent, context, inLiteral);\n if (isValueLogical(ts, kind)) return useOf(parent, context, inLiteral);\n if (assignment.has(kind)) {\n // The target of an assignment is written, not read.\n if (parent.left === top) return null;\n const target = checker.getTypeAtLocation(parent.left);\n return isOpaque(ts, target) ? null : `assigned to \"${typeText(context, target)}\"`;\n }\n return 'used in an operation';\n }\n\n if (ts.isCallExpression(parent) || ts.isNewExpression(parent)) {\n if (parent.expression === top) return 'called';\n if (isValidatorCall(parent, context) || isArrayIsArray(parent, context)) return null;\n const expected = checker.getContextualType(top as TS.Expression);\n if (!expected) return 'passed as an argument';\n return isOpaque(ts, expected) ? null : `passed where \"${typeText(context, expected)}\" is expected`;\n }\n\n if (ts.isPropertyAccessExpression(parent) || ts.isElementAccessExpression(parent)) {\n if (parent.expression !== top) return 'used as a key';\n // A member the same kind of origin declares (or nothing declares) is a further read: the member is the untrusted value.\n if (untrustedSourceOf(parent, context)) return null;\n // A global or an imported constant is a name, not a value that was handed over: what is read from it is\n // judged by the origin that declares the member (`JSON.stringify` with only `js:JSON.stringify` type-trusted).\n if (isOutsideBinding(top, context)) return null;\n const member = ts.isPropertyAccessExpression(parent) ? parent.name.text : clip(parent.argumentExpression.getText(), 40);\n return `read through its member \"${member}\"`;\n }\n\n if (ts.isVariableDeclaration(parent) || ts.isParameter(parent) || ts.isPropertyDeclaration(parent) || ts.isBindingElement(parent)) {\n if (parent.initializer !== top) return `used as \"${ownType()}\"`;\n if (ts.isVariableDeclaration(parent) && !parent.type) return inLiteral ? 'stored in a value whose type is inferred' : null;\n const declared = checker.getTypeAtLocation(parent.name);\n return isOpaque(ts, declared) ? null : `stored as \"${typeText(context, declared)}\"`;\n }\n\n if (ts.isPropertyAssignment(parent) || ts.isShorthandPropertyAssignment(parent) || ts.isArrayLiteralExpression(parent)) {\n const expected = checker.getContextualType(top as TS.Expression);\n if (expected) return isOpaque(ts, expected) ? null : `stored where \"${typeText(context, expected)}\" is expected`;\n // Nothing is expected of the member itself: the literal holding it is judged in its place.\n const literal = ts.isArrayLiteralExpression(parent) ? parent : parent.parent;\n return useOf(literal, context, true);\n }\n\n if (ts.isReturnStatement(parent) || ts.isYieldExpression(parent) || (ts.isArrowFunction(parent) && parent.body === top)) {\n const expected = checker.getContextualType(top as TS.Expression);\n if (expected && (isOpaque(ts, expected) || isDiscarded(ts, expected))) return null;\n return `returned as \"${expected ? typeText(context, expected) : ownType()}\"`;\n }\n\n if (ts.isSpreadElement(parent) || ts.isSpreadAssignment(parent)) return 'spread';\n if (ts.isForOfStatement(parent) || ts.isForInStatement(parent)) return parent.expression === top ? 'iterated' : null;\n if (ts.isTemplateSpan(parent)) return 'used in a template';\n if (ts.isPostfixUnaryExpression(parent)) return 'used in an operation';\n return `used as \"${ownType()}\"`;\n}\n\n/** The outermost wrapper around `node`: where its value, unchanged, is used. */\nfunction withWrappers(ts: TypeScript, node: TS.Node): TS.Node {\n let top = node;\n while (isTransparent(ts, top.parent)) top = top.parent;\n return top;\n}\n\n/**\n * The type a name or member was declared with, before any narrowing. The compiler narrows `unknown`\n * soundly, so a value declared `unknown` and narrowed by `typeof` / `instanceof` is proven, not claimed:\n * what counts is whether the declaration claimed a type. (A member only an index signature declares has\n * no symbol of its own to ask: its type where it is read is the declared one.)\n */\nfunction declaredType(node: TS.Node, context: UntrustedValueContext): TS.Type {\n const { ts, checker } = context;\n let symbol: TS.Symbol | undefined;\n if (ts.isIdentifier(node)) {\n symbol = ts.isShorthandPropertyAssignment(node.parent) ? checker.getShorthandAssignmentValueSymbol(node.parent) : checker.getSymbolAtLocation(node);\n } else if (ts.isPropertyAccessExpression(node)) {\n symbol = checker.getSymbolAtLocation(node.name);\n }\n const named = ts.SymbolFlags.Variable | ts.SymbolFlags.Property | ts.SymbolFlags.Accessor | ts.SymbolFlags.Alias;\n if (!symbol || !(symbol.flags & named)) return checker.getTypeAtLocation(node);\n const declared = checker.getTypeOfSymbol(symbol);\n // `let x;` (or `= null`, `= undefined`) with no written type: the compiler gives `x` the type of what was\n // assigned to it (an evolving `any`), so the type where it is read is the one it was given.\n const declaration = symbol.valueDeclaration;\n if (declared.flags & ts.TypeFlags.Any && declaration && ts.isVariableDeclaration(declaration) && !declaration.type) return checker.getTypeAtLocation(node);\n return declared;\n}\n\nfunction decideValue(node: TS.Node, context: UntrustedValueContext): UntrustedValue | null {\n const { ts, checker } = context;\n const source = untrustedSourceOf(node, context);\n if (!source) return null;\n const top = withWrappers(ts, node);\n const type = checker.getTypeAtLocation(top);\n const value = { node: node as TS.Expression, entry: source.entry, origin: source.origin, type: typeText(context, type) };\n // A value a guard narrowed was declared as claiming nothing (`unknown`): the guard's narrowed type is the claim.\n const declaredNothing = source.entry !== 'guard' && claimsNothing(ts, declaredType(node, context));\n if (declaredNothing || claimsNothing(ts, type)) return { ...value, outcome: 'no-claim', use: null };\n if (isInsideValidator(ts, node)) return { ...value, outcome: 'validator', use: null };\n const use = useOf(node, context, false);\n return use === null ? { ...value, outcome: 'allowed', use: null } : { ...value, outcome: 'finding', use };\n}\n\n/**\n * The untrusted value `node` is, with what became of it; null when `node` is not one. Nothing is caught\n * here: a failure of the type checker stops the run (as it does for the call rule) rather than letting a\n * value pass unjudged.\n */\nexport function untrustedValueAt(node: TS.Node, context: UntrustedValueContext): UntrustedValue | null {\n return decideValue(node, context);\n}\n\n/** Every untrusted value in `root`, in walk order (findings and allowed uses alike). */\nexport function untrustedValuesIn(root: TS.Node, context: UntrustedValueContext): UntrustedValue[] {\n const values: UntrustedValue[] = [];\n const visit = (node: TS.Node): void => {\n const value = untrustedValueAt(node, context);\n if (value) values.push(value);\n context.ts.forEachChild(node, visit);\n };\n visit(root);\n return values;\n}\n\n/**\n * A function checked code hands to an origin that is not type-trusted, with a parameter that origin fills\n * whose type claims something (`untrustedCallbacks: \"all\"`). One per such parameter.\n */\nexport interface UntrustedHandoff {\n /** Where the function is handed over: the argument of the call / `new`, or the type in an `implements` clause. */\n readonly node: TS.Node;\n /** Who calls the function: the callee, or the member of the implemented interface (baseline key, and the `trust_type` entry that clears it). */\n readonly origin: string;\n /** The function handed over (`handle`, `MyHandler.onData`). */\n readonly callback: string;\n /** The parameter that claims a type, and that type. */\n readonly parameter: string;\n readonly type: string;\n}\n\n/** A function handed over, and how many of its leading parameters `bind` already filled. */\ninterface HandedFunction {\n readonly fn: TS.FunctionLikeDeclaration;\n readonly bound: number;\n}\n\n/** How far a name is followed to the function it holds (`const a = b; const b = handle.bind(this)`). */\nconst MAX_HOPS = 8;\n\nfunction isInChecked(node: TS.Node, context: UntrustedValueContext): boolean {\n return context.policy.zones.zoneOf(node.getSourceFile().fileName) === 'checked';\n}\n\n/** `fn.bind(...)`: the language's own `bind` (by the origin of the declaration the call resolves to). */\nfunction isBindCall(call: TS.CallExpression, context: UntrustedValueContext): call is TS.CallExpression & { expression: TS.PropertyAccessExpression } {\n const { ts, policy } = context;\n if (!ts.isPropertyAccessExpression(call.expression) || call.expression.name.text !== 'bind') return false;\n const resolved = policy.calleeDeclaration(call);\n return resolved !== null && /^js:(Callable|Newable)?Function\\.bind$/.test(policy.origins.originOf(resolved.declaration).origin);\n}\n\nfunction functionsOfSymbol(symbol: TS.Symbol | undefined, context: UntrustedValueContext, bound: number, hops: number): HandedFunction[] {\n const { ts, checker } = context;\n const target = symbol && symbol.flags & ts.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;\n return (target?.declarations ?? []).flatMap((declaration) => functionsOfDeclaration(declaration, context, bound, hops));\n}\n\n/**\n * The function a declaration of checked code gives: a function or method with a body (the implementation of\n * an overloaded one), or what a `const`, a class field or an object-literal property holds.\n */\nfunction functionsOfDeclaration(declaration: TS.Node, context: UntrustedValueContext, bound: number, hops: number): HandedFunction[] {\n const { ts, checker } = context;\n if (hops > MAX_HOPS || !isInChecked(declaration, context)) return [];\n if (ts.isFunctionDeclaration(declaration) || ts.isMethodDeclaration(declaration)) return declaration.body ? [{ fn: declaration, bound }] : [];\n if (ts.isVariableDeclaration(declaration)) {\n const isConst = (ts.getCombinedNodeFlags(declaration) & ts.NodeFlags.Const) !== 0;\n return isConst && declaration.initializer ? functionsOfExpression(declaration.initializer, context, bound, true, hops + 1) : [];\n }\n if (ts.isPropertyDeclaration(declaration) || ts.isPropertyAssignment(declaration)) {\n return declaration.initializer ? functionsOfExpression(declaration.initializer, context, bound, true, hops + 1) : [];\n }\n if (ts.isShorthandPropertyAssignment(declaration)) return functionsOfSymbol(checker.getShorthandAssignmentValueSymbol(declaration), context, bound, hops + 1);\n return [];\n}\n\n/**\n * The functions `expression` hands over: a name or member that holds one, or `fn.bind(...)`. A function\n * written right there counts only when `inline` (it is held by a name, not written at the hand-off).\n */\nfunction functionsOfExpression(expression: TS.Expression, context: UntrustedValueContext, bound: number, inline: boolean, hops: number): HandedFunction[] {\n const { ts, checker } = context;\n let inner: TS.Expression = expression;\n while (isTransparent(ts, inner)) inner = inner.expression;\n if (ts.isArrowFunction(inner) || ts.isFunctionExpression(inner)) return inline ? [{ fn: inner, bound }] : [];\n if (hops > MAX_HOPS) return [];\n if (ts.isIdentifier(inner)) return functionsOfSymbol(checker.getSymbolAtLocation(inner), context, bound, hops + 1);\n if (ts.isPropertyAccessExpression(inner)) return functionsOfSymbol(checker.getSymbolAtLocation(inner.name), context, bound, hops + 1);\n if (ts.isCallExpression(inner) && isBindCall(inner, context)) {\n // `fn.bind(thisArg, a, b)` fills the first two parameters: the caller fills the rest.\n return functionsOfExpression(inner.expression.expression, context, bound + Math.max(0, inner.arguments.length - 1), true, hops + 1);\n }\n return [];\n}\n\n/** The functions a member of a value holds: a method, or a property / field holding a function. */\nfunction functionsOfMember(member: TS.Symbol | undefined, context: UntrustedValueContext): HandedFunction[] {\n return (member?.declarations ?? []).flatMap((declaration) => functionsOfDeclaration(declaration, context, 0, 0));\n}\n\n/** How many arguments a caller passes through `signature` (all of them when it has a rest parameter). */\nfunction passedCount(ts: TypeScript, signature: TS.Signature): number {\n const declaration = signature.getDeclaration() as TS.SignatureDeclaration | TS.JSDocSignature | undefined;\n const rest = declaration !== undefined && !ts.isJSDocSignature(declaration) && declaration.parameters.some((parameter) => parameter.dotDotDotToken);\n return rest ? Number.POSITIVE_INFINITY : signature.getParameters().length;\n}\n\n/** The type a parameter is declared (or contextually given) to have; an unconstrained type parameter claims nothing. */\nfunction parameterType(parameter: TS.ParameterDeclaration, context: UntrustedValueContext): TS.Type | null {\n const { ts, checker } = context;\n const type = checker.getTypeAtLocation(parameter.name);\n if (!(type.flags & ts.TypeFlags.TypeParameter)) return type;\n return checker.getBaseConstraintOfType(type) ?? null;\n}\n\nfunction callbackName(fn: TS.FunctionLikeDeclaration, context: UntrustedValueContext): string {\n const { ts } = context;\n const holder = ts.isArrowFunction(fn) || (ts.isFunctionExpression(fn) && !fn.name) ? fn.parent : fn;\n const name = ts.isVariableDeclaration(holder) || ts.isPropertyDeclaration(holder) || ts.isPropertyAssignment(holder) || ts.isFunctionLike(holder) ? holder.name : undefined;\n if (!name) return 'callback';\n const text = clip(name.getText(), 40);\n const owner = holder.parent;\n return (ts.isMethodDeclaration(holder) || ts.isPropertyDeclaration(holder)) && ts.isClassLike(owner) && owner.name ? `${owner.name.text}.${text}` : text;\n}\n\n/** The parameters of `handed` that `expected`'s caller fills and whose type claims something. */\nfunction handoffsOf(handed: HandedFunction, expected: TS.Signature, origin: string, node: TS.Node, context: UntrustedValueContext): UntrustedHandoff[] {\n const { ts, policy } = context;\n const { fn, bound } = handed;\n if (isMarkedValidator(ts, fn)) return [];\n if (ts.isArrowFunction(fn) || ts.isFunctionExpression(fn)) {\n // Written where an untrusted signature is declared: its parameters are untrusted values, judged where used.\n const signature = contextualSignatureDeclaration(fn, context);\n if (signature && policy.typeVerdictOf(signature).kind === 'type-untrusted') return [];\n }\n const parameters = fn.parameters.filter((parameter) => !(ts.isIdentifier(parameter.name) && parameter.name.text === 'this')).slice(bound);\n const passed = passedCount(ts, expected);\n const found: UntrustedHandoff[] = [];\n parameters.forEach((parameter, index) => {\n if (index >= passed) return;\n const type = parameterType(parameter, context);\n if (!type || claimsNothing(ts, type)) return;\n found.push({ node, origin, callback: callbackName(fn, context), parameter: clip(parameter.name.getText(), 40), type: typeText(context, type) });\n });\n return found;\n}\n\n/** The first call signature of a member's type (an optional method included). */\nfunction memberSignature(property: TS.Symbol, at: TS.Node, context: UntrustedValueContext): TS.Signature | undefined {\n const { checker } = context;\n return checker.getNonNullableType(checker.getTypeOfSymbolAtLocation(property, at)).getCallSignatures()[0];\n}\n\nfunction isObjectLike(ts: TypeScript, type: TS.Type): boolean {\n const members = type.isUnion() ? type.types : [type];\n return members.some((member) => (member.flags & (ts.TypeFlags.Object | ts.TypeFlags.Intersection)) !== 0);\n}\n\n/** One argument handed to `origin`: a callback, or a value whose methods `origin` will call. */\nfunction argumentHandoffs(argument: TS.Expression, origin: string, context: UntrustedValueContext): UntrustedHandoff[] {\n const { ts, checker } = context;\n if (ts.isSpreadElement(argument)) return [];\n const contextual = checker.getContextualType(argument);\n if (!contextual || isOpaque(ts, contextual)) return [];\n const expected = checker.getNonNullableType(contextual);\n const signatures = (expected.isUnion() ? expected.types : [expected]).flatMap((member) => member.getCallSignatures());\n if (signatures.length > 0) {\n return functionsOfExpression(argument, context, 0, false, 0).flatMap((handed) => handoffsOf(handed, signatures[0], origin, argument, context));\n }\n if (!isObjectLike(ts, expected)) return [];\n const value = checker.getApparentType(checker.getTypeAtLocation(argument));\n return checker.getPropertiesOfType(expected).flatMap((property) => {\n const signature = memberSignature(property, argument, context);\n if (!signature) return [];\n return functionsOfMember(checker.getPropertyOfType(value, property.name), context).flatMap((handed) => handoffsOf(handed, signature, origin, argument, context));\n });\n}\n\nfunction callHandoffs(call: TS.CallExpression | TS.NewExpression, context: UntrustedValueContext): UntrustedHandoff[] {\n const { ts } = context;\n if (!call.arguments || call.arguments.length === 0 || call.expression.kind === ts.SyntaxKind.ImportKeyword) return [];\n if (isInsideValidator(ts, call)) return [];\n const verdict = callTypeVerdict(call, context);\n if (verdict.kind !== 'type-untrusted') return [];\n return call.arguments.flatMap((argument) => argumentHandoffs(argument, verdict.origin.origin, context));\n}\n\n/** A class that `implements` an interface an origin that is not type-trusted declares: each implementing method. */\nfunction implementsHandoffs(declaration: TS.ClassLikeDeclaration, context: UntrustedValueContext): UntrustedHandoff[] {\n const { ts, checker, policy } = context;\n const clauses = (declaration.heritageClauses ?? []).filter((clause) => clause.token === ts.SyntaxKind.ImplementsKeyword);\n if (clauses.length === 0 || isInsideValidator(ts, declaration)) return [];\n const own = checker.getTypeAtLocation(declaration);\n const instance = own.getConstructSignatures()[0]?.getReturnType() ?? own;\n return clauses.flatMap((clause) =>\n clause.types.flatMap((implemented) =>\n checker.getPropertiesOfType(checker.getTypeAtLocation(implemented)).flatMap((property) => {\n const member = policy.symbol_declaration(property);\n const signature = member ? memberSignature(property, implemented, context) : undefined;\n if (!member || !signature) return [];\n const verdict = policy.typeVerdictOf(member);\n if (verdict.kind !== 'type-untrusted') return [];\n return functionsOfMember(checker.getPropertyOfType(instance, property.name), context).flatMap((handed) =>\n handoffsOf(handed, signature, verdict.origin.origin, implemented, context),\n );\n }),\n ),\n );\n}\n\n/**\n * The hand-offs at `node`: a call / `new`, or a class with an `implements` clause. None unless\n * `untrustedCallbacks` is \"all\". Each is a finding.\n */\nexport function untrustedHandoffsAt(node: TS.Node, context: UntrustedValueContext): UntrustedHandoff[] {\n const { ts, policy } = context;\n if (policy.rules.untrustedCallbacks !== 'all') return [];\n if (ts.isCallExpression(node) || ts.isNewExpression(node)) return callHandoffs(node, context);\n if (ts.isClassDeclaration(node) || ts.isClassExpression(node)) return implementsHandoffs(node, context);\n return [];\n}\n\n/** Every hand-off in `root`, in walk order. */\nexport function untrustedHandoffsIn(root: TS.Node, context: UntrustedValueContext): UntrustedHandoff[] {\n const handoffs: UntrustedHandoff[] = [];\n const visit = (node: TS.Node): void => {\n handoffs.push(...untrustedHandoffsAt(node, context));\n context.ts.forEachChild(node, visit);\n };\n visit(root);\n return handoffs;\n}\n\n/** The message data of a hand-off (ESLint messageId `handoff`). */\nexport function untrustedHandoffData(handoff: UntrustedHandoff): Record<string, string> {\n return { callback: handoff.callback, origin: handoff.origin, parameter: handoff.parameter, type: handoff.type };\n}\n\n/** The finding message of a hand-off. */\nexport function untrustedHandoffMessage(handoff: UntrustedHandoff): string {\n return fillMessage(UNTRUSTED_VALUE_MESSAGES.handoff, untrustedHandoffData(handoff));\n}\n\n/** The message data of a finding (the ESLint rule fills the same template with the same data). */\nexport function untrustedValueData(value: UntrustedValue): Record<string, string> {\n return { entry: UNTRUSTED_ENTRY_LABELS[value.entry], origin: value.origin, use: value.use ?? 'used', type: value.type };\n}\n\n/** Which message a finding uses (the ESLint messageId): a caller-chosen return type has its own. */\nexport function untrustedValueMessageId(value: UntrustedValue): UntrustedValueMessageId {\n return value.entry === 'generic-return' ? 'callerChosen' : 'untrusted';\n}\n\n/** The finding message of an untrusted value that is used. */\nexport function untrustedValueMessage(value: UntrustedValue): string {\n return fillMessage(UNTRUSTED_VALUE_MESSAGES[untrustedValueMessageId(value)], untrustedValueData(value));\n}\n","// Standalone trust check of one source file: walks the TypeScript AST and reports what the ESLint\n// rules report (same ids, messages, origins and positions) with no ESLint involved: the two trust\n// rules (rules.ts), `type-claim` (type-claims.ts) and `untrusted-value` (untrusted-values.ts), plus the\n// core-only promise rules `floating-promise` and `misused-promise` (promise-rules.ts), and `dropped-result`\n// (dropped-results.ts). `type-claim`, `untrusted-value` and `dropped-result` run only when the config turns\n// them on (`rules` in trust.config.json). A finding of the failure-path rules in a statement marked\n// `//trust:accept <reason>` is accepted, not reported (accept.ts); a dropped-result finding is never accepted.\nimport { svelteFor } from './svelte.js';\nimport type * as TS from 'typescript';\nimport type { TypeClaim } from './type-claims.js';\nimport { DEFAULT_RULE_SETTINGS, isRuleEnabled, type TrustConfig } from '../eslint/config.js';\nimport { TrustPolicy } from '../eslint/policy.js';\nimport type { TypeScript } from '../eslint/typescript.js';\nimport { realpathOrSelf } from '../eslint/zones.js';\nimport { acceptanceOf, acceptDirectiveFindings, failurePathFindingsAt, type Acceptance, type FailurePathContext } from './accept.js';\nimport { droppedResultContext, droppedResultMessage, droppedResultsIn } from './dropped-results.js';\nimport { redundantGuardMessage, redundantGuardsIn } from './redundant-guards.js';\nimport {\n ACCEPT_DIRECTIVE_MESSAGES,\n DIRECTIVE_ORIGIN,\n DROPPED_RESULT_RULE,\n fillMessage,\n REDUNDANT_GUARD_ORIGIN,\n REDUNDANT_GUARD_RULE,\n THROW_RULE,\n TYPE_CLAIM_RULE,\n UNTRUSTED_VALUE_RULE,\n type Finding,\n} from './messages.js';\nimport { typedGuardContext } from './rules.js';\nimport { claimSpan, directiveClaims, typeClaimContext, typeClaimMessage, typeClaimsAt } from './type-claims.js';\nimport { untrustedHandoffMessage, untrustedHandoffsAt, untrustedValueAt, untrustedValueContext, untrustedValueMessage } from './untrusted-values.js';\n\nconst emptyConfigs = new Map<string, TrustConfig>();\n\n/** The config used when there is no trust.config.json: every file under `cwd` is checked, nothing is trusted. */\nexport function emptyTrustConfig(cwd: string): TrustConfig {\n let config = emptyConfigs.get(cwd);\n if (!config) {\n config = { file: '', rootDir: realpathOrSelf(cwd), levels: [], passthrough: [], ignore: [], strict: [], tsconfig: [], rules: DEFAULT_RULE_SETTINGS, unmatchedGlobs: [] };\n emptyConfigs.set(cwd, config);\n }\n return config;\n}\n\nconst policies = new WeakMap<TS.TypeChecker, Map<string, { config: TrustConfig; policy: TrustPolicy }>>();\n\n/** One policy per checker + config + extra trust, so zone/origin caches survive across files. */\nexport function policyFor(ts: TypeScript, checker: TS.TypeChecker, config: TrustConfig, extraTrust: readonly string[] = []): TrustPolicy {\n let byKey = policies.get(checker);\n if (!byKey) {\n byKey = new Map();\n policies.set(checker, byKey);\n }\n const key = `${config.file}\\u0000${extraTrust.join('\\u0000')}`;\n const hit = byKey.get(key);\n if (hit && hit.config === config) return hit.policy;\n const policy = new TrustPolicy(ts, checker, config, extraTrust);\n byKey.set(key, { config, policy });\n return policy;\n}\n\nexport interface CheckSourceFileOptions {\n readonly ts: TypeScript;\n readonly program: TS.Program;\n /** Defaults to `program.getTypeChecker()`. */\n readonly checker?: TS.TypeChecker;\n readonly config: TrustConfig;\n readonly sourceFile: TS.SourceFile;\n /** Extra trusted origins, applied before the config chain (the ESLint rules' `trust` option). */\n readonly extraTrust?: readonly string[];\n}\n\n/** 1-based line/column of an offset into the file: how findings report positions. */\nexport function positionAt(ts: TypeScript, sourceFile: TS.SourceFile, offset: number): { line: number; column: number } {\n const position = ts.getLineAndCharacterOfPosition(sourceFile, offset);\n return { line: position.line + 1, column: position.character + 1 };\n}\n\n/** 1-based line/column of the node's first token: where ESLint reports the node. */\nexport function startOf(ts: TypeScript, sourceFile: TS.SourceFile, node: TS.Node): { line: number; column: number } {\n return positionAt(ts, sourceFile, node.getStart(sourceFile));\n}\n\n/** A failure-path finding an accept directive accepted: not reported, but `trust explain` shows it. */\nexport interface AcceptedFinding {\n readonly finding: Finding;\n /** The source text of the node the finding is at. */\n readonly text: string;\n readonly acceptance: Acceptance;\n}\n\n/** What one file's check decided: its findings, and the findings accept directives accepted. */\nexport interface FileCheck {\n readonly findings: Finding[];\n readonly accepted: AcceptedFinding[];\n}\n\n/**\n * Findings of the trust, type-claim, untrusted-value and promise rules in one file: the directive findings\n * (comments belong to no node; type-claim's, then throw-must-return-result's for `//trust:accept`), then\n * everything else in walk order. Files outside the checked zone have none. type-claim and untrusted-value\n * report only when the config turns them on.\n */\nexport function checkSourceFile(options: CheckSourceFileOptions): Finding[] {\n return checkSourceFileWithAccepted(options).findings;\n}\n\n/** checkSourceFile, plus the failure-path findings an accept directive accepted (core/accept.ts). */\nexport function checkSourceFileWithAccepted(options: CheckSourceFileOptions): FileCheck {\n const { ts, sourceFile, config } = options;\n const checker = options.checker ?? options.program.getTypeChecker();\n const policy = policyFor(ts, checker, config, options.extraTrust);\n if (policy.zones.zoneOf(sourceFile.fileName) !== 'checked') return { findings: [], accepted: [] };\n const failureContext: FailurePathContext = { ts, checker, policy, guardContext: typedGuardContext(ts, checker, policy) };\n const claimContext = isRuleEnabled(config, TYPE_CLAIM_RULE) ? typeClaimContext(ts, checker, undefined, policy) : null;\n const valueContext = isRuleEnabled(config, UNTRUSTED_VALUE_RULE) ? untrustedValueContext(ts, checker, policy) : null;\n const file = policy.zones.relativePath(sourceFile.fileName);\n const findings: Finding[] = [];\n const accepted: AcceptedFinding[] = [];\n const findingAt = (start: number, rule: string, origin: string, message: string): Finding => ({ file, rule, origin, ...positionAt(ts, sourceFile, start), message });\n const reportAt = (start: number, rule: string, origin: string, message: string): void => {\n findings.push(findingAt(start, rule, origin, message));\n };\n const report = (node: TS.Node, rule: string, origin: string, message: string): void => reportAt(node.getStart(sourceFile), rule, origin, message);\n const reportClaim = (claim: TypeClaim): void => reportAt(claimSpan(claim, sourceFile).start, TYPE_CLAIM_RULE, claim.origin, typeClaimMessage(claim));\n\n if (claimContext) for (const claim of directiveClaims(ts, sourceFile)) reportClaim(claim);\n for (const found of acceptDirectiveFindings(ts, sourceFile, failureContext)) {\n reportAt(found.directive.pos, THROW_RULE, DIRECTIVE_ORIGIN, fillMessage(ACCEPT_DIRECTIVE_MESSAGES[found.messageId], found.data));\n }\n\n const visit = (node: TS.Node): void => {\n for (const found of failurePathFindingsAt(node, failureContext)) {\n const acceptance = acceptanceOf(ts, found.node);\n if (!acceptance) report(found.node, found.rule, found.origin, found.message);\n else accepted.push({ finding: findingAt(found.node.getStart(sourceFile), found.rule, found.origin, found.message), text: found.node.getText(sourceFile), acceptance });\n }\n if (claimContext) for (const claim of typeClaimsAt(node, claimContext)) reportClaim(claim);\n const value = valueContext ? untrustedValueAt(node, valueContext) : null;\n if (value?.outcome === 'finding') report(node, UNTRUSTED_VALUE_RULE, value.origin, untrustedValueMessage(value));\n if (valueContext) {\n for (const handoff of untrustedHandoffsAt(node, valueContext)) report(handoff.node, UNTRUSTED_VALUE_RULE, handoff.origin, untrustedHandoffMessage(handoff));\n }\n ts.forEachChild(node, visit);\n };\n visit(sourceFile);\n if (isRuleEnabled(config, DROPPED_RESULT_RULE)) {\n for (const dropped of droppedResultsIn(sourceFile, droppedResultContext(ts, checker, policy))) {\n reportAt(dropped.start, DROPPED_RESULT_RULE, dropped.origin, droppedResultMessage(dropped));\n }\n }\n if (isRuleEnabled(config, REDUNDANT_GUARD_RULE)) {\n for (const guard of redundantGuardsIn(sourceFile, failureContext)) {\n reportAt(guard.start, REDUNDANT_GUARD_RULE, REDUNDANT_GUARD_ORIGIN, redundantGuardMessage(guard));\n }\n }\n const svelte = svelteFor(checker);\n const snippetTrusted = policy.lookup('svelte.__renderSnippet', 'svelte').trusted && !('distrustedBy' in policy.lookup('svelte.Snippet', 'svelte'));\n return { findings: svelte ? findings.flatMap(finding => {\n const mapped = svelte.finding(sourceFile.fileName, finding, snippetTrusted);\n return mapped ? [mapped] : [];\n }) : findings, accepted };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BO,SAAS,QAAQ,IAAgB,MAAwB;AAC9D,MAAI,UAAU;AACd,SAAO,GAAG,0BAA0B,OAAO,EAAG,WAAU,QAAQ;AAChE,SAAO;AACT;AAGO,SAAS,SAAS,IAAgB,MAAoC;AAC3E,MAAI,SAAS,KAAK;AAClB,SAAO,UAAU,GAAG,0BAA0B,MAAM,EAAG,UAAS,OAAO;AACvE,SAAO;AACT;AAGO,SAAS,gBAAgB,IAAgB,MAAwB;AACtE,UAAQ,KAAK,QAAQ,GAAG,UAAU,mBAAmB;AACvD;AAGO,SAAS,YAAY,IAAgB,MAAyC;AACnF,QAAM,QAAQ,QAAQ,IAAI,IAAI;AAC9B,SAAO,GAAG,iBAAiB,KAAK,KAAK,C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;AACpE,QAAI,OAAO,YAAY,UAAW,QAAO,MAAM,sBAAsB,MAAM,QAAQ,sBAAsB,KAAK,CAAC;AAC/G,QAAI,cAAc;AAChB,iBAAW,WAAW,oBAAoB,MAAM,YAAY,EAAG,QAAO,QAAQ,MAAM,sBAAsB,QAAQ,QAAQ,wBAAwB,OAAO,CAAC;AAAA,IAC5J;AACA,OAAG,aAAa,MAAM,KAAK;AAAA,EAC7B;AACA,QAAM,UAAU;AAChB,MAAI,cAAc,QAAQ,mBAAmB,GAAG;AAC9C,eAAW,WAAW,iBAAiB,YAAY,qBAAqB,IAAI,SAAS,MAAM,CAAC,GAAG;AAC7F,eAAS,QAAQ,OAAO,qBAAqB,QAAQ,QAAQ,qBAAqB,OAAO,CAAC;AAAA,IAC5F;AAAA,EACF;AACA,MAAI,cAAc,QAAQ,oBAAoB,GAAG;AAC/C,eAAW,SAAS,kBAAkB,YAAY,cAAc,GAAG;AACjE,eAAS,MAAM,OAAO,sBAAsB,wBAAwB,sBAAsB,KAAK,CAAC;AAAA,IAClG;AAAA,EACF;AACA,QAAM,SAAS,UAAU,OAAO;AAChC,QAAM,iBAAiB,OAAO,OAAO,0BAA0B,QAAQ,EAAE,WAAW,EAAE,kBAAkB,OAAO,OAAO,kBAAkB,QAAQ;AAChJ,SAAO,EAAE,UAAU,SAAS,SAAS,QAAQ,aAAW;AACtD,UAAM,SAAS,OAAO,QAAQ,WAAW,UAAU,SAAS,cAAc;AAC1E,WAAO,SAAS,CAAC,MAAM,IAAI,CAAC;AAAA,EAC9B,CAAC,IAAI,UAAU,SAAS;AAC1B;","names":["exits","declaration","members","ok","union","members","claim","clip","decide","contexts","decide","MAX_TEXT","clip","typeText","members","verdict","parameterType","claim"]}