fix: resolve alias-imported and computed constants in Zod check arguments - #183
Merged
tazo90 merged 2 commits intoSep 16, 2026
Merged
Conversation
thelgason
marked this pull request as draft
September 14, 2026 13:29
thelgason
force-pushed
the
fix/resolve-imported-zod-constants
branch
from
September 14, 2026 13:46
9a36147 to
055ca53
Compare
…l resolver Only relative imports were followed, so a constant imported as `@/constants/limits` was unreachable and every check built from it silently lost its value. Non-relative imports now go through TypeScript module resolution, the same path the schema and drizzle processors already use, so `paths` aliases follow the project's own config; anything landing in node_modules stays unresolved. `const` initializers that are arithmetic, template literals, or aliases of another constant are evaluated as well. The path guard now covers a single resolution path rather than a whole file, so sibling expressions naming the same constant both resolve.
… stay unknown `.max(IMPORTED_LIMIT)`, `.min()`, `.length()` and friends only understood numeric literals and same-file constants, and `.describe()` only understood a plain string, so an imported limit or a template-literal description vanished from the emitted schema without a word. Every check argument now goes through the shared static evaluator, and anything that cannot be reduced to a value reports `unresolved-zod-argument` with the method, the symbol it names, and the line.
thelgason
force-pushed
the
fix/resolve-imported-zod-constants
branch
from
September 14, 2026 13:55
055ca53 to
d47091d
Compare
thelgason
marked this pull request as ready for review
September 14, 2026 14:05
tazo90
approved these changes
Sep 16, 2026
tazo90
left a comment
Owner
There was a problem hiding this comment.
Thanks for this fix @thelgason, LGTM 👍
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Zod check arguments that are not plain literals were silently dropped from the output. The Zod symbol resolver only followed relative imports, so any
@/*-aliased constant stopped at the import boundary; constants with computed initializers (1024 * 1024 * 2, template literals) were never indexed; andmin/max/describe/… discarded an unresolved argument without a diagnostic, unlikez.enum.This routes non-relative imports through the existing
resolveTypeScriptModule(sopathsaliases follow the project's own tsconfig), indexes computedconstinitializers, adds a small static evaluator (literals,+ - * /, template literals,as const, identifiers chased through imports and re-exports, depth- and cycle-guarded), and emits a newunresolved-zod-argumentwarning wherever an argument still cannot be reduced. Output for literal arguments is unchanged; all sample-app specs are identical tomain.Two side effects worth knowing: resolutions landing in
node_modulesare discarded, so a package entry point is never parsed as a schema source; and relative resolution now prefersfoo.tsover a siblingfoo/directory (the oldexistsSync(base)check matched the directory first). The new diagnostic is awarning, likeunresolved-zod-enum, so projects running--fail-on warningwith genuinely dynamic check arguments will start failing there.Type of Change
!after type, e.g.,feat!:)Checklist
pnpm checkpassespnpm testandpnpm buildwhen relevant)