happykit / flags

⛳️ Feature Flags for Next.js
https://happykit.dev
MIT License
1.02k stars 11 forks source link

Enable concise syntax of `response.cookie(...flagBag.cookie)` #10

Open dferber90 opened 2 years ago

dferber90 commented 2 years ago

This originally existed on an unreleased branch in 77bfb6ff3f22167c8655987ff44aaa975bf5f292 but had to be removed as a TypeScript warning appeared on the calling side of response.cookie(...flagBag.cookie):

A spread argument must either have a tuple type or be passed to a rest parameter.

The code works, but I could not figure out the correct type.

Reintroducing this would allow developers to use response.cookie(...flagBag.cookie) instead of response.cookie(...flagBag.cookie.args).

dferber90 commented 2 years ago

flagBag.setCookie(response) would be a nicer way of handling this. Then we can drop flagBag.cookie.args.