Skip to content

fix: CaptureType lost generic parameters in @microsoft/fast-element v3 #7577

@radium-v

Description

@radium-v

🐛 Bug Report

CaptureType lost its type parameters between v2 and v3. In 2.10.4 it was interface CaptureType<TSource, TParent> {}; in 3.0.0-rc.1 it's interface CaptureType {}. The change landed in PR #7489 (commit 4656c46a5, titled "chore: remove hydratable view and unused code") and isn't called out in MIGRATION.md or the changelog. Any directive helper that returns CaptureType<TSource, TParent> now fails with TS2315. FAST's own built-in directives used that signature in v2.

💻 Repro or Code Sample

The change in packages/fast-element/src/templating/template.ts:

-export interface CaptureType<TSource, TParent> {}
+export interface CaptureType {}

A v2-era directive helper, copied from Fluent UI's start-end.ts:

export function endSlotTemplate<TSource extends StartEnd = StartEnd, TParent = any>(
    options: EndOptions<TSource, TParent>,
): CaptureType<TSource, TParent> {
    return html` <slot name="end" ${ref('end')}>${staticallyCompose(options.end)}</slot> `.inline();
}

Under 3.0.0-rc.1:

TS2315: Type 'CaptureType' is not generic.

🤔 Expected Behavior

CaptureType should keep its type parameters. Default them to any so existing v3-branch callsites that pass no arguments continue to compile:

export interface CaptureType<TSource = any, TParent = any> {}

😯 Current Behavior

💁 Possible Solution

Restore the generics with any defaults:

export interface CaptureType<TSource = any, TParent = any> {}

The interface body is empty, so the parameters carry no structural type information. They exist to thread TSource/TParent from the surrounding template through directive helpers. Defaults keep every v3-branch internal callsite compiling unchanged.

A follow-up could revisit the built-in directives (ref, slotted, children, etc.) and decide which should expose CaptureType<TSource, TParent> so the source-type inference channel is restored end-to-end. That isn't required to unblock consumers.

I'm willing to contribute the fix on the v3 release branch.

🔦 Context

Caught while upgrading the Fluent UI web components monorepo from @microsoft/fast-element@2.10.4 to 3.0.0-rc.1. Fluent UI's slot template helpers (startSlotTemplate, endSlotTemplate) follow the v2 pattern. They no longer compile.

If the team intends to keep CaptureType non-generic, the change still needs a MIGRATION.md entry. Dropping type parameters from a @public interface without warning is a breaking change.

🌍 Your Environment

  • OS & Device: macOS on Apple Silicon
  • Browser: N/A (TypeScript compile-time issue)
  • Version: @microsoft/fast-element@3.0.0-rc.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions