fix: hoist grantedMs/grantedMin declarations to avoid ReferenceError in ncc bundles (#545)
The `grantedMs` and `grantedMin` variables were declared with `const`
inside the `if (decision.extend && decision.minutes > 0)` block but
referenced in the `return` statement outside that block. While the
conditional spread `...(decision.extend ? { granted_ms: grantedMs } : {})`
logically only evaluates when `decision.extend` is true, bundlers like
ncc can hoist or restructure code in ways that cause a ReferenceError
at runtime because the block-scoped `const` is not visible outside the
`if` block.
Fix: declare both variables with `let` (initialized to 0) before the
`if` block so they are in scope for the return statement.
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> L
Leonid Bugaev committed
5df01c7eb35efbe05ffc93ae63c55bc4eaa157b5
Parent: a29158a
Committed by GitHub <noreply@github.com>
on 3/20/2026, 8:10:55 PM