fix(dynamic): map unmappable function params/returns and type parameters to JSVAL - #221
Open
techfreaque wants to merge 1 commit into
Open
fix(dynamic): map unmappable function params/returns and type parameters to JSVAL#221techfreaque wants to merge 1 commit into
techfreaque wants to merge 1 commit into
Conversation
…ers to JSVAL In --dynamic mode, three categories of type-mapping failures now resolve to JSVAL rather than emitting SC errors: 1. Function params/returns that don't map to a static IR type (e.g. complex Zod schema types, React prop types): the param/return becomes JSVAL. The function remains callable from static code. 2. TypeParameters with no bound or an unmappable bound: falls back to the constraint type via checker.getBaseConstraintOfType. If the constraint maps (e.g. TSchema extends z.ZodTypeAny → JSVAL), the parameter maps to the same type. Previously this caused SC2008 on intersection types with heavily-generic npm packages. 3. Multi-signature function types (overloaded / intersection overloads) that lack a static lowering: return JSVAL unless every declaration comes from a stdlib file (spawnSync, readFileSync etc. have static lowerings via their overload selection path and must not regress). Also adds getBaseConstraintOfType to CheckerFacade and exports esOwnKeyOrder for downstream use.
Contributor
|
@techfreaque is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
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.
Problem
In
--dynamicmode, three categories of types could not be mapped to IR types, causing SC errors on valid programs that use heavily-generic npm packages (Drizzle, Zod, React):(schema: z.ZodTypeAny) => void): emitted SC2008 on the containing record type.TConfig extends z.AnyZodObject): fell through tonull, poisoning any intersection that contained it.Fix
types.ts:ptis null in--dynamicmode, useJSVAL. The param accepts any island value.retis null in--dynamicmode, returnfuncOf(params, JSVAL). The function is callable; the return value rides the island.checker.getBaseConstraintOfType(widened)and recursively map the constraint. If the constraint maps (e.g.TSchema extends z.ZodTypeAny→ JSVAL), the parameter maps to the same type.callSigs.length > 1in--dynamicreturns JSVAL, except when every declaration comes from a stdlib file (@types/nodeetc.) — those have static overload-selection lowerings that must not regress (e.g.spawnSync,readFileSync).ts7/checker.ts: addsgetBaseConstraintOfTypemethod toCheckerFacade.lowering/lowerer.ts: exportsesOwnKeyOrderfor downstream use.Verification
A program that imports Drizzle ORM with 30+ table joins, Zod schemas with
TSchema extends z.ZodTypeAny, and overloaded event callback types compiles without SC errors.spawnSync,readFileSync, and other stdlib overloads retain their static lowerings.packages/compilerbuilds clean.Non-goals
MIDI type support (
node-midi/@julusian/midi) is intentionally excluded from this PR — it belongs in a separate focused change.