Skip to content

Commit

Permalink
Use types only from namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
mobily committed Nov 2, 2022
1 parent d9b4b58 commit 6b6e056
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
6 changes: 3 additions & 3 deletions __tests__/Function/after.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expectType } from 'ts-expect'

import { F, N, O, Option } from '../..'
import { F, N, O } from '../..'

const fn = (n: number) => {
return `called ${n} times`
Expand All @@ -12,9 +12,9 @@ const fn2 = (n: number, x: string) => {

describe('after', () => {
it('provides correct types', () => {
expectType<(n: number) => Option<string>>(F.after(2, fn))
expectType<(n: number) => O.Option<string>>(F.after(2, fn))
expectType<(n: number, x: string) => string>(F.after(2, fn2))
expectType<(n: number) => Option<number>>(F.after(2, N.add(2)))
expectType<(n: number) => O.Option<number>>(F.after(2, N.add(2)))
})

it('handles multiple parameters', function () {
Expand Down
14 changes: 7 additions & 7 deletions __tests__/Function/tryCatch.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expectType } from 'ts-expect'

import { R, Result, F, pipe, O } from '../..'
import { R, F, pipe, O } from '../..'

type User = {
readonly name: string
Expand All @@ -12,11 +12,11 @@ const throwError = (_x: number): number => {

describe('tryCatch', () => {
it('provides correct types', () => {
expectType<Result<unknown, Error>>(F.tryCatch('<>', JSON.parse))
expectType<Result<User, Error>>(
expectType<R.Result<unknown, Error>>(F.tryCatch('<>', JSON.parse))
expectType<R.Result<User, Error>>(
F.tryCatch<string, User>('{"name": "Joe"}', JSON.parse),
)
expectType<Result<number, Error>>(F.tryCatch(1, throwError))
expectType<R.Result<number, Error>>(F.tryCatch(1, throwError))
F.tryCatch('hello', str => {
expectType<string>(str)
})
Expand Down Expand Up @@ -48,11 +48,11 @@ describe('tryCatch', () => {

describe('tryCatch (pipe)', () => {
it('provides correct types', () => {
expectType<Result<unknown, Error>>(pipe('<>', F.tryCatch(JSON.parse)))
expectType<Result<User, Error>>(
expectType<R.Result<unknown, Error>>(pipe('<>', F.tryCatch(JSON.parse)))
expectType<R.Result<User, Error>>(
pipe('{"name": "Joe"}', F.tryCatch<string, User>(JSON.parse)),
)
expectType<Result<number, Error>>(F.tryCatch(1, throwError))
expectType<R.Result<number, Error>>(F.tryCatch(1, throwError))
pipe(
'hello',
F.tryCatch(str => {
Expand Down
3 changes: 0 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
export { pipe } from './pipe'
export { flow } from './flow'

export { Option } from './Option'
export { Result, Ok, Error } from './Result'

export * as F from './Function'
export * as A from './Array'
export * as R from './Result'
Expand Down

0 comments on commit 6b6e056

Please sign in to comment.