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 retry running the generate-expected.ts script.
Assistant
Node 20 needs a loader for TS. Let's use tsx again but now with proper node version.
Assistant
It worked. Let's check the diff to ensure existing fixture output is unchanged (sanity check of setup) and clean up node_modules symlink concerns later.
Assistant
Good, ts lang already handled generally. Let's see the rest of the generated output (boolean, generic).
Assistant
Let's view the actual source for genModelProps and inferRuntimeType - great, I can just read the real dist code.
Assistant
Good, these fields exist. Now let's look at
collect_model_infosandbuild_model_props_emitsmore, and how they're called, to wire intype_args(currently the model_infos tuple doesn't carry type_args).Assistant
Now let's make these
pub(crate)so model.rs can use them.Assistant
Now let's check module path from model.rs to props.rs (compile_script::props) to get correct import path.
Assistant
super::super::super::propsiscrate::compile_script::props. Good, so I can importsplit_type_at_top_level,contains_top_level_arrow,strip_readonly_prefixfrom there.Assistant
Now let's add the type-inference helper functions right before
build_model_props_emits.Assistant
Now let's insert helper functions before line 165, and replace the props-building loop.
Assistant
Good, none left (grep exit 1 = no matches, expected). Now let's update the props-building loop to use these helpers.
Assistant
Now let's try building.
Assistant
Now let's rebuild.
Assistant
It compiles. Now let's run the coverage tool and existing tests.
Assistant
All 8 new cases still failing. Let's inspect diffs.
Assistant
Let's add the inverse extraction function right after
strip_runtime_accessors.Assistant
Now let's update
collect_model_infosto compute the runtime accessors and return a 4-tuple.Assistant
Now let's update
build_model_props_emitssignature and body to use the 4-tuple, and other usages within that function.Assistant
Good. Now let's fix line length/formatting concerns and update body.rs and setup_emit.rs.
Assistant
Now let's check where
model_infosis used at line 123 (likely passed toemit_setup_body) and update setup_emit.rs.Assistant
Now let's update setup_emit.rs to use the new tuple shape, emit
<T>type args and the third runtime-options argument.Assistant
Now let's build.
Assistant
Now let's tackle the import-merging issue: when
is_tsandhas_define_model, combine theuseModel/mergeModelsimport with thedefineComponentimport into one statement.Assistant
Builds fine. Now let's clean up the debug test and rerun the coverage tool.
Assistant
Good (grep exit 1 = no matches, debug test removed). Let's rebuild and run coverage.
Assistant
All 155 SFC fixtures pass (up from 147), 681/681 total. Now let's update
MIN_SFC_PASSEDandMIN_TOTAL_PASSEDconstants in coverage.rs to reflect the new totals.Assistant
All good. Now let's run the broader test suite for
vize_atelier_sfc(unit tests, insta snapshots) to make sure nothing else broke.Assistant
Just a leftover blank line. Let's clean that up.
Assistant
No diff now, meaning
lib.rsis back to original. Let's clean up the leftover.snap.newfiles and remove the tempnode_modulessymlink and other scratch artifacts.Assistant
Now let's re-run the full test suite (excluding the 3 known "stale snapshot" tests) to confirm nothing else broke.
Assistant
Now let's run the broader workspace test suite to check nothing else broke (other crates might depend on these preamble/model functions).
Assistant
Workspace builds cleanly. Let's run the full workspace test suite (may take a while) to check for regressions beyond vize_atelier_sfc.
Assistant
Confirmed: these
vize_cartonfailures (config/pkl loader) are pre-existing and unrelated to my change (likely environment-specific, e.g. missingpklbinary). Let's clean up leftover.snap.newartifacts and finalize.Assistant
No clippy warnings in the modified files. Let's view the full diff for a final review.
Assistant
Let's run
cargo fmtto ensure formatting matches project conventions.Assistant
Formatted cleanly. Let's rebuild and rerun coverage + full crate tests once more to confirm everything is still fine after formatting.
Assistant
All green. Let's also clean up the temporary node install artifacts to avoid leaving anything stray in the repo.
Assistant
Clean working tree with only intended changes. Let's do a final review of the complete diff.
Assistant
This all looks correct and minimal. Let's view the preamble.rs diff fully too for a final check.
Assistant
This looks good. Now let's do a final full check of the test fixture file added.
Assistant
This all looks solid. Let's do one last full workspace build + targeted test run to be safe before submitting.
Assistant
Excellent, everything builds and the full coverage oracle passes 681/681 (100%). Let's clean up any remaining leftover artifacts one more time.
Assistant
The working tree is clean with only intended changes. Let's go through the checklist:
Assistant
Assistant
The working tree is exactly as I left it, with all intended changes present and no stray artifacts. Everything is verified and ready. I'll now submit.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.