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
I'll start by exploring the repository structure and the relevant model.rs file to understand how defineModel type arguments are currently handled.
- Assistant
Let me find the model.rs file and explore the compile_script structure more carefully.
- Assistant
Let me look at the model.rs file and the define-model fixtures.
- Assistant
Let me read the rest of the model.rs file and the define-model fixtures.
- Assistant
Let me continue reading the rest of model.rs and find how type_arg is currently handled.
- Assistant
Let me use grep instead and continue reading the rest of the file.
- Assistant
Let me examine type resolution, define_model, and Vue reference behavior, plus existing snapshots with type args.
- Assistant
Let me look at how props type resolution works and find Vue reference for defineModel type args.
- Assistant
Let me look at how props with runtime types are resolved from TypeScript types, and how Vue's genModelProps works. Also check git log for #762 related changes.
- Assistant
Let me look at Vue's defineModel generation logic and any TODOs related to type_arg resolution.
- Assistant
Let me check git history related to defineModel and how
resolve_prop_js_type/ TypeScript types map to runtime. - Assistant
Let me inspect the #762 changes and any Vue reference for defineModel type resolution.
- Assistant
Let me look at Vue's expected defineModel type-arg behavior and our type-output path.
- Assistant
Let me inspect how types for models are emitted and pull Vue's defineModel expected output.
- Assistant
Let me fetch Vue's genModelProps and remaining defineModel type tests.
- Assistant
Let me check useModel emission, isProd handling, and ts_type_to_js_type details.
- Assistant
Let me check how defineModel macros are rewritten in the setup body, then how is_prod flows into compilation.
- Assistant
Let me look at how defineModel is transformed in the setup code path.
- Assistant
Let me check how the coverage oracle compares outputs, and what the current define-model tests produce.
- Assistant
Let me check how compile options flow and whether is_prod affects script compilation.
- Assistant
Let me check ts_type_to_js_type for
any/unknownand how fixtures should be structured. Also run a quick compile test. - Assistant
Let me look at generate-expected.ts and also see how to make ts_type_to_js_type handle any, and whether it's public.
- Assistant
Let me check if skipCheck is handled anywhere and how Vue's inferRuntimeType works.
- Assistant
Let me check whether SFC fixtures use inline or function mode, and review function mode model handling.
- Assistant
Let me verify type_args are correctly extracted for defineModel and check MacroCall structure.
- Assistant
There's already a type-args test — let me inspect it and the current compile output.
- Assistant
Let me look at that test's snapshot and compile a type-arg example now.
- Assistant
Let me look at the type_args snapshot to see current output.
- Assistant
I have a clear picture. Implementing type-arg resolution in model.rs and related call sites.
- Assistant
I'll add a public runtime-type inference helper and update model collection/build logic.
- Assistant
Adding the runtime type inference helper after
resolve_prop_js_type. - Assistant
Checking whether the strip_readonly function header is still intact:
- Assistant
Removing the duplicate docstring line.
- Assistant
Now rewriting model.rs to include type_arg resolution.
- Assistant
I accidentally overwrote props.rs — restoring it and writing to model.rs instead.
- Assistant
Re-adding the helper to props.rs and rewriting model.rs with explicit file paths.
- Assistant
The replace tool needs the content on-screen first.
- Assistant
Now I can use edit to insert between lines 533 and 535.
- Assistant
Writing the full model.rs update.
- Assistant
Updating body.rs and setup_emit.rs for the ModelInfo struct.
- Assistant
Update body.rs type annotation and setup_emit.
- Assistant
Need to update setup_emit to use ModelInfo and emit type args on useModel.
- Assistant
Checking how SFC compile sets is_ts for lang="ts" scripts:
- Assistant
Using
source_is_tsfor prop-decl format to match Vue. Updating the call chain. - Assistant
Letme navigate and update properly.
- Assistant
Adding
source_is_tsas a separate parameter for prop-decl format. - Assistant
Updating the body.rs call.
- Assistant
Checking how interfaces are collected and compiling to verify.
- Assistant
There's a brace mismatch in model.rs from the partial edit — fixing it.
- Assistant
Removing the duplicated lines.
- Assistant
Looks good. Compiling again.
- Assistant
Type resolution works. Adding the fixtures next and generating expected outputs.
- Assistant
Now generate expected with the tooling.
- Assistant
Need to find where @vue/compiler-sfc is installed.
- Assistant
pnpm not found. Letme try npm or corepack.
- Assistant
Interesting - no node? The which returned nothing? Let me check node more carefully.
- Assistant
No node available - installing it, or generating Vue-equivalent expected snaps manually.
- Assistant
Let me try fnm
- Assistant
Node is available. Installing deps and generating expected outputs.
- Assistant
Now run generate-expected
- Assistant
Expected snaps generated. Running the coverage oracle for define-model.
- Assistant
Checking how other lang=ts SFC fixtures handle defineComponent:
- Assistant
Checking how the test runner sets is_ts for SFC fixtures:
- Assistant
Checking preamble for when defineComponent is imported:
- Assistant
Writing a quick debug of one fixture to inspect compile output:
- Assistant
Checking how regenerate and install imports normalize for quote order:
- Assistant
Combining
useModelanddefineComponentinto one import to match Vue. - Assistant
Re-running the coverage oracle.
- Assistant
All define-model fixtures pass. Updating the minimum pass counts in coverage.rs.
- Assistant
Cleaning up leftover snapshot files and verifying final coverage.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.