SFC: complete defineModel type-argument resolution in compileScript Follow-up to #762…
- User
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.
- Assistant
Now I have full ground truth. Let me implement. First, the runtime-type inference helper in
props.rs: - Assistant
Now rewrite
model.rswith theModelInfostruct and type-resolved prop codegen: - Assistant
Now update
collect_model_infos: - Assistant
Now update
body.rsandsetup_emit.rs: - Assistant
Now the preamble import merge for TS + defineModel (Vue emits one combined helper import line):
- Assistant
Builds clean. Now add the new fixture cases:
- Assistant
Output matches Vue's semantics exactly (verified against Vue's own spec snapshots). Now write the expected snap entries in Vue's emission style:
- Assistant
Now run the coverage oracle:
- Assistant
All snapshot diffs are intended. Now re-run the coverage oracle and the broader workspace tests:
- Assistant
Add unit tests for the inference helper:
- Assistant
Done. All 678 coverage-oracle cases pass (including the 5 new type-argument cases), and the full suite (408 tests) is green.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.