Flagsmith / Flagsmith/flagsmith-js-client
identify() should accept IFlagsmithTrait for traits parameter (parity with setTraits)
- Dominant language
- TypeScript
- Stars
- 67
- Forks
- 45
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 4
Description
## Problem
`flagsmith.identify()` accepts traits as `Record` where `IFlagsmithValue = string | number | boolean | null`, while `flagsmith.setTraits()` accepts `Record` 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()`:
```typescript
// Currently:
identify: (userId: string, traits?: Record) => Promise;
// Should be:
identify: (userId: string, traits?: Record) => Promise;
```
## 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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.