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 locate the
defineModelcompile path and how type arguments are resolved elsewhere incompileScript, then implement resolution and add the SFC fixtures. - Assistant
Implementing type-argument resolution and adding fixtures. Starting with the inference logic in
props.rs, then updatingmodel.rs. - Assistant
Implemented
defineModeltype-argument resolution inbuild_model_props_emits, matching@vue/compiler-sfc'sgenModelPropsbehavior.Compiler changes
compile_script/props.rs- Added
codegen_model_type_from_type_arg()to resolve type references via script context (interfaces/type_aliases), map to runtime constructors (String,Number,[Boolean, String], etc.), and apply Vue'sskipCheckrules for unknown + boolean/function unions.
compile_script/inline/compiler/model.rs- Introduced
ModelInfo(includes from each call).
- Added
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.