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 defineModel compile path and how type arguments are resolved elsewhere in compileScript, then wire that up and add fixtures.
- Assistant
Implementing type-arg resolution: checking current compile output and whether a helper already exists.
- Assistant
Implementing type-arg resolution and adding fixtures.
- Assistant
defineModeltype-argument resolution is now wired throughbuild_model_props_emits, matching@vue/compiler-sfc'sgenModelPropsbehavior.Implementation
model.rs- Introduced
ModelInfowithtype_argcollected from eachdefineModelmacro call. - Added
build_model_prop_decl()to infer runtime prop types from the type argument via script context (interfaces/type_aliases) and merge them with runtime options:- TS:
{ type: String, ...{ default: 0 } } - JS:
Object.assign({ type: Number }, { default: 0 })
- TS:
- Interface references (e.g.
Layer) resolve to{ type: Object }.
props.rs- Added
infer_runtime_type_from_ts()— shared helper that maps TS types to runtime constructors (String,Number,Object, etc.), including alias/interface lookup.
Fixtures & verification
Added 5 cases to :
- Introduced
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.