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 other SFC script types resolve type arguments, then wire that intobuild_model_props_emitsand add fixtures. - Assistant
Implementing type resolution in
model.rs, then adding fixtures and generating expected output from Vue's compiler. - Assistant
Updating the modifiers fixture to avoid array destructuring (template
isRefis a separate gap) while still testing the modifier type parameter: - Assistant
Completed
defineModeltype-argument resolution incompileScript, aligned with@vue/compiler-sfc'sgenModelPropsbehavior.Implementation
compile_script/props.rs- Added
ModelRuntimeType,extract_first_type_param, andinfer_model_runtime_type. - Resolves type references via
resolve_type_args, maps TS types to runtime constructors (String,[Boolean, String], etc.), and applies Vue's unknown-type rules (skipCheckwhenanyis mixed withBoolean/Function).
compile_script/inline/compiler/model.rs- Added to merge inferred with runtime options:
- Added
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.