Skip to content
This repository has been archived by the owner on Sep 1, 2022. It is now read-only.

refactor(getCookie): retrieve memoized directly #335

Merged
merged 3 commits into from
Apr 26, 2022

Conversation

mxdvl
Copy link
Contributor

@mxdvl mxdvl commented Apr 19, 2022

What does this change?

There’s no need to check if the value exists before retrieving it, as the default behaviour of get on a Map is to return undefined if the key is missing. If the key exists, return it directly.

Why?

This allows us to reach true 100% coverage, as the missing code path was unreachable.

From the duplicate issue #328

Currently, we don’t have 100% coverage because of a TS limitation.
There’s safety built-in the get method, so let’s use it directly.

We could alternatively use a //@ts-expect-error or an as string type assertion.

There’s no need to check if the value exists before
retrieving it, as the default behaviour of `get` on a Map
is to return undefined if the key is missing. If the key
exists, return it directly.

This allows us to reach true 100% coverage,
as the missing code path was unreachable.
@mxdvl mxdvl requested a review from a team as a code owner April 19, 2022 09:07
@coveralls
Copy link

coveralls commented Apr 19, 2022

Coverage Status

Coverage increased (+0.2%) to 100.0% when pulling 76cd36a on mxdvl/no-impossible-state into bcb965e on main.

src/cookies/getCookie.ts Show resolved Hide resolved
@mxdvl mxdvl requested a review from sndrs April 19, 2022 12:31
@mxdvl mxdvl merged commit 740036f into main Apr 26, 2022
@mxdvl mxdvl deleted the mxdvl/no-impossible-state branch April 26, 2022 08:50
@github-actions
Copy link

🎉 This PR is included in version 5.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants