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
I’ll inspect the compile-script model path and existing fixture/oracle conventions, then implement the type resolution and run the focused SFC tests.
- Assistant
The repository layout differs slightly from the path in the request, so I’m locating the current module before making changes.
- Assistant
I found the missing behavior: model metadata currently discards the macro’s type argument, so prop generation only sees runtime options. I’m extending that metadata and reusing the existing script-context type resolver/runtime-type inference used by
defineProps. - Assistant
The implementation now preserves each model’s type argument, resolves local aliases/interfaces through the script context, handles modifier generic parameters separately, and merges inferred runtime types with options using compiler-SFC’s TS spread form. The focused Rust tests are compiling now.
- Assistant
The first oracle pass exposed that the new cases were recognized and runtime props matched. I’m tightening the TypeScript side too: compiler-SFC preserves
defineModel’s generic arguments on the rewritten_useModel<…>call, so the generated type output must retain them as well.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.