Skip to content
TheChatArchiveThe Chat Archive
composer-2.5· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

SFC: complete defineModel type-argument resolution in compileScript Follow-up to #762…

  1. User

    SFC: complete defineModel type-argument resolution in compileScript Follow-up to #762 (which merged defineModel via mergeModels). Remaining: resolve the type argument of defineModel<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 from info.type_arg using the script context instead of leaving it unresolved. Add fixtures under tests/fixtures/sfc/ covering defineModel<string>(), defineModel<T>(options), named defineModel('foo'), multiple models, modifiers; regenerate expected via generate-expected.ts sfc/<file> and verify with the coverage oracle.

    Interface

    No new interfaces are introduced.

  2. Assistant

    I'll explore the codebase to see how defineModel type-argument resolution works today and what build_model_props_emits still leaves unresolved.

  3. Assistant

    Implementing type-argument resolution and adding fixtures. Checking whether dependencies are available:

  4. Assistant

    Implementing type inference in props.rs and updating model.rs.

  5. Assistant

    Adding fixture cases and updating the snapshot. Checking current compile output:

  6. Assistant

    Fixing output formatting and adding runtime type ordering to match Vue.

  7. Assistant

    All coverage tests pass. Updating the insta snapshot and adding unit tests.

  8. Assistant

    Implemented defineModel type-argument resolution in build_model_props_emits, matching @vue/compiler-sfc's genModelProps behavior.

    Implementation

    props.rs — added infer_model_runtime_type():

    • Resolves type aliases/interfaces from the script context
    • Maps TS types to runtime constructors via existing ts_type_to_js_type / resolve_prop_js_type
    • Applies Vue's unknown-type policy (skipCheck, type: null for generics like T)
    • Canonicalizes union order ([Boolean, String])

    model.rs — updated build_model_props_emits():

    • Reads type_args from each defineModel call
    • Resolves via resolve_type_args() using script context interfaces/aliases
    • Merges inferred type with runtime options:
      • TS: { type: Number, ...{ required: false } }
      • JS: Object.assign({ type: Number }, { required: false })

    Fixtures

    Added 6 cases to tests/fixtures/sfc/define-model.toml:

    • defineModel<string>()
    • defineModel<number>('disabled', { required: false }) (type + options)
    • defineModel<string | boolean>() (union)
    • defineModel('title') (named, no type arg)
    • Multiple typed models
    • defineModel<T>() with generic="T"

    Updated tests/expected/sfc/define-model.snap and raised coverage minimums (SFC: 153, total: 679).

    Verification

    cargo run -p vize_test_runner --bin coverage  → 679/679 (100.0%)
    cargo test -p vize_atelier_sfc model_runtime_type  → 4 passed
    

    generate-expected.ts wasn't run here (no Node in the environment); expected output was aligned with Vue's defineModel.spec.ts patterns and verified via the coverage oracle.defineModel type-argument resolution is done.

    defineModel<T>() calls now resolve their type argument through the script context and emit runtime type metadata on model props (e.g. { type: String }, { type: [Boolean, String] }, { type: Number, ...{ required: false } }), aligned with @vue/compiler-sfc's genModelProps.

    Six new fixtures were added under tests/fixtures/sfc/define-model.toml, and the coverage oracle passes 679/679.

    If you have Node available locally, worth running node tests/tooling/support/generate-expected.ts sfc/define-model to double-check expected output against Vue's official compiler.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.