Skip to content

identify() should accept IFlagsmithTrait for traits parameter (parity with setTraits) #383

@talissoncosta

Description

@talissoncosta

Problem

flagsmith.identify() accepts traits as Record<T, IFlagsmithValue> where IFlagsmithValue = string | number | boolean | null, while flagsmith.setTraits() accepts Record<T, IFlagsmithTrait> where IFlagsmithTrait = IFlagsmithValue | TraitEvaluationContext.

This means you can't pass a TraitEvaluationContext (e.g. transient traits) via identify() — you have to call identify() first, then setTraits() separately.

Expected behaviour

identify() should accept IFlagsmithTrait for traits, matching setTraits():

// Currently:
identify: (userId: string, traits?: Record<T, IFlagsmithValue>) => Promise<void>;

// Should be:
identify: (userId: string, traits?: Record<T, IFlagsmithTrait>) => Promise<void>;

Notes

  • The runtime implementation in flagsmith-core.ts already handles TraitEvaluationContext in identify() via the isTraitEvaluationContext() type guard — this is purely a type definition fix.
  • Change is in types.d.ts line 231.

Reported by a customer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions