Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions test/types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,12 @@ describe('Flagsmith Types', () => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const incorrectNumberFlag: string = typedFlagsmith.getValue("numberFlag")
});
test('should accept the same trait types in identify as in setTraits', async () => {
const { flagsmith } = getFlagsmith({});
const typedFlagsmith = flagsmith as IFlagsmith<string, "plan" | "session_id">
await typedFlagsmith.setTraits({ plan: "pro", session_id: { value: "abc", transient: true } })
await typedFlagsmith.identify("user", { plan: "pro", session_id: { value: "abc", transient: true } })
//@ts-expect-error - trait not defined
await typedFlagsmith.identify("user", { fail: "x" })
});
});
2 changes: 1 addition & 1 deletion types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ T extends string = string
/**
* Identify user, triggers a call to get flags if `flagsmith.init` has been called
* */
identify: (userId: string, traits?: Record<T, IFlagsmithValue>) => Promise<void>;
identify: (userId: string, traits?: Record<T, IFlagsmithTrait>) => Promise<void>;
/**
* Retrieves the current state of flagsmith
*/
Expand Down
Loading