ISSUE DESCRIPTION SFC: complete defineModel type-argument resolution in compileScript…
- User
ISSUE DESCRIPTION
SFC: complete defineModel type-argument resolution in compileScript Follow-up to #762 (which merged
defineModelviamergeModels). Remaining: resolve the type argument ofdefineModel<T>()/defineModel<T>(options)into the generated runtime + type output so the model prop's resolved type matches@vue/compiler-sfc.Work
In
crates/vize_atelier_sfc/src/compile_script/.../model.rs(build_model_props_emits), compute the resolved type frominfo.type_argusing the script context instead of leaving it unresolved. Add fixtures undertests/fixtures/sfc/coveringdefineModel<string>(),defineModel<T>(options), nameddefineModel('foo'), multiple models, modifiers; regenerate expected viagenerate-expected.ts sfc/<file>and verify with the coverage oracle.Interface
No new interfaces are introduced.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Assistant
Now let's check if
@vue/compiler-sfcis available (node_modules) to actually run this generator.Assistant
Now let's try to install pnpm and the needed deps to run generate-expected.ts.
Assistant
Install succeeded. Let's check if @vue/compiler-sfc is available in tests/tooling directory context.
Assistant
Great, it's available. Let's try running generate-expected.ts on the existing define-model fixture first, to confirm the tool works and see if it matches existing expected output (sanity check).
Assistant
Now let's try running the generate-expected.ts script.
Assistant
It's run directly with
node. Let's try that.Assistant
It works. Let's confirm the output matches the existing checked-in expected (no diff means the current fixture already correct).
Assistant
No diff, great — the tool matches exactly. Now let's set up a convenient alias for tsx.
Assistant
Now let's find
inferRuntimeTypeandtoRuntimeTypeString, andUNKNOWN_TYPE.Assistant
Good —
compile_sfc(used by test runner for "sfc" mode fixtures) always uses inline mode. So function_mode is not exercised by these fixtures; scope is correctly confined toinline/compiler/model.rs.Assistant
Now let's update the
build_model_props_emitsfunction signature and the model_infos consumers.Assistant
Now let's replace the relevant section with a resolved-type-aware version.
Assistant
Now update
collect_model_infosto also return the type argument.Assistant
Now update body.rs type annotation for
model_infos.Assistant
Let's check line 123 context, probably another usage (maybe emit_setup_body or model bindings use model_infos for generating
useModelcalls).Assistant
Need to update
emit_setup_bodysignature too.Assistant
Now fix the remaining two spots:
setup_emit.rssignature/loop andmodel.rsmodel_emits loop.Assistant
Compiles cleanly. Now let's run the existing coverage binary and existing unit/insta tests to confirm nothing broke.
Assistant
All existing coverage tests still pass. Now let's add new fixture cases to
define-model.tomlcovering the scenarios from the issue.Assistant
Now let's add fixtures to
tests/fixtures/sfc/define-model.tomlcovering these cases, then regenerate expected snapshot and run the coverage binary.Assistant
Now let's run the coverage binary to check our Rust implementation against this newly generated expected output.
Assistant
Now rebuild and re-run coverage.
Assistant
All 679 tests pass at 100%, including the new fixtures. Let's now run the broader test suite (insta snapshots, other crates) to make sure nothing else broke.
Assistant
Good, cleanup done. Now let's run the full crate test suite.
Assistant
Now let's rewrite
resolve_model_type_optionin model.rs to implement proper union/Unknown handling.Assistant
Now update the import line to include
split_type_at_top_level.Assistant
Compiles. Now let's rerun the coverage binary and the crate test suite.
Assistant
Still 100%. Let's add a fixture case for this
string | undefinedscenario too, then rerun the crate's unit tests (with the two failing insta tests) to check and update snapshots.Assistant
Let's remove the extra
assertion_linefield to keep consistent format with the rest of the repo.Assistant
Good, those are clean already. Now let's rerun the full test suite for this crate to confirm everything passes.
Assistant
All tests pass now with updated snapshots. Let's clean any stray
assertion_linemetadata that INSTA_UPDATE=always may have introduced.Assistant
Clean diffs, no
assertion_linenoise (this insta version writes it in the.snap.newtemp file but strips it upon final overwrite... good). Now let's run the full workspace test suite to check for any other ripple effects.Assistant
Entire workspace builds cleanly. Now let's run the workspace-wide test suite for crates that might depend on
vize_atelier_sfc(like vize_canon, vize_maestro, vize_glyph, vize_patina, vize).Assistant
Confirmed pre-existing failure, unrelated to my changes (caused by the environment's node/npm setup, not by my code). Let's clean up the stray test file and continue the workspace test run past this unrelated failure.
Assistant
Let's check for any failures earlier in the output (before the doc-tests section).
Assistant
Only the pre-existing unrelated failure remains. Now let's clean up temp/example artifacts and double check final diff.
Assistant
Clean. Now let's add the "string | undefined" edge case fixture to
define-model.tomlas well (since it's a real quirk we now correctly match), and regenerate/verify.Assistant
All 13 defineModel fixture cases (including the tricky union+undefined and interface-reference cases) pass at 100%. Now let's update the coverage budget constants (
MIN_SFC_PASSED,MIN_TOTAL_PASSED) since we added new passing tests, to keep the regression floor meaningful.Assistant
Confirmed convention: bump the floor whenever coverage grows. Let's do the same for our change (147→155, 634→681).
Assistant
Now let's re-run the full crate test suite once more to make sure everything is still green after this last change.
Assistant
Let's also check clippy for the crate to ensure code quality is maintained.
Assistant
No clippy warnings. Let's run the crate tests one final time and re-run the coverage binary to confirm everything is consistent after the doc tidy-up.
Assistant
All green. Let's view the final full diff summary before submitting.
Assistant
This all looks focused and complete. Let's clean up any leftover build artifacts (uninstall of node/pnpm not needed to revert, they don't affect the repo diff). Let's double check no stray files remain in the repo.
Assistant
This looks good. Now let's review the final diff for
setup_emit.rs.Assistant
This all looks correct and consistent. Now let's finalize with a full re-run of everything one more time to be safe.
Assistant
Everything is green. Let's go through the checklist explicitly.
Checklist review:
-
If an error was reported in the issue description, I have successfully reproduced it. The issue wasn't a bug report with a stack trace, but a feature gap:
defineModel<T>()'s type argument was left unresolved in generated output. I reproduced this by inspectingbuild_model_props_emitsand confirming (before my fix) thattype_argwas never consulted, and by diffing against real@vue/compiler-sfcoutput (installed locally) which showed atype: Xfield my code was missing. -
If an error was reported in the issue description, I have confirmed that my fix resolves the error. I implemented
resolve_model_type_option/resolve_single_model_typeinmodel.rs, added the<T>propagation onto the generated_useModel<T>()call, fixed a latentvueimport-merging gap that this feature surfaced, added 8 new fixtures (, typed+options, named+typed, multiple typed models, unresolved generic, union-with-, interface-typed) to , regenerated via the real (), and verified 100% pass via the coverage oracle (, 13/13 for , 681/681 total).
-
Assistant
-
I have thought about edge cases and made sure my fix handles them as well. Handled: named vs. unnamed models, multiple models, type+options merge (TS
{ type, ...opts }vs JSObject.assign), unresolved generic type parameters (T→null, matching Vue), union types withBoolean/Function(kept per Vue's skip-check-adjacent logic), thestring | undefinedquirk whereundefinedpoisons the union tonullunlike explicitnull(verified byte-for-byte against real Vue via a throwaway node script), and interface/type-alias resolution via existingctx.interfaces/ctx.type_aliases. Also fixed a real (if unrelated-looking) gap where multiple single-quoted'vue'helper imports weren't merged into one statement, which is required for TS+defineModel fixtures to match Vue exactly.
-
Assistant
Everything looks complete, tested, and consistent. Let's submit.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.