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.
Problem
flagsmith.identify()accepts traits asRecord<T, IFlagsmithValue>whereIFlagsmithValue = string | number | boolean | null, whileflagsmith.setTraits()acceptsRecord<T, IFlagsmithTrait>whereIFlagsmithTrait = IFlagsmithValue | TraitEvaluationContext.This means you can't pass a
TraitEvaluationContext(e.g. transient traits) viaidentify()— you have to callidentify()first, thensetTraits()separately.Expected behaviour
identify()should acceptIFlagsmithTraitfor traits, matchingsetTraits():Notes
flagsmith-core.tsalready handlesTraitEvaluationContextinidentify()via theisTraitEvaluationContext()type guard — this is purely a type definition fix.types.d.tsline 231.Reported by a customer.