Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(option): better return type for Option constructors #1834

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Option.ts
Expand Up @@ -140,15 +140,15 @@ export type Option<A> = None | Some<A>
* @category constructors
* @since 2.0.0
*/
export const none: Option<never> = _.none
export const none: None = _.none

/**
* Constructs a `Some`. Represents an optional value that exists.
*
* @category constructors
* @since 2.0.0
*/
export const some: <A>(a: A) => Option<A> = _.some
export const some: <A>(a: A) => Some<A> = _.some

/**
* Returns a *smart constructor* based on the given predicate.
Expand Down
4 changes: 2 additions & 2 deletions src/internal.ts
Expand Up @@ -17,10 +17,10 @@ export const isNone = (fa: Option<unknown>): fa is None => fa._tag === 'None'
export const isSome = <A>(fa: Option<A>): fa is Some<A> => fa._tag === 'Some'

/** @internal */
export const none: Option<never> = { _tag: 'None' }
export const none: None = { _tag: 'None' }

/** @internal */
export const some = <A>(a: A): Option<A> => ({ _tag: 'Some', value: a })
export const some = <A>(a: A): Some<A> => ({ _tag: 'Some', value: a })

// -------------------------------------------------------------------------------------
// Either
Expand Down