gcanti / io-ts-types

A collection of codecs and combinators for use with io-ts
https://gcanti.github.io/io-ts-types/
MIT License
311 stars 40 forks source link

Export all types from index #129

Closed Kinrany closed 4 years ago

Kinrany commented 4 years ago

🚀 Feature request

I'd like to be able to import io-ts-types once and have all the codecs/combinators, like Ramda. AFAIK right now each thing must be imported from its own file.

Current Behavior

import { fromNullable } from 'io-ts-types/lib/fromNullable';
import { DateFromISOString } from 'io-ts-types/lib/DateFromISOString';

Desired Behavior

import { fromNullable, DateFromISOString } from 'io-ts-types/lib';

Suggested Solution

Add index files with re-exports.

Who does this impact? Who is this for?

All users except those who import individual files for bundle size reasons.

Bundle size is not a concern on NodeJS, where io-ts can be used for validation.

Describe alternatives you've considered

It would be ideal to just import 'io-ts-types'. Not sure if that's possible.

Your environment

Software Version(s)
fp-ts 2.6.1
io-ts 2.2.3
io-ts-types 0.5.6
TypeScript 3.9.3
waynevanson commented 4 years ago

Absolutely one up. io-ts exports from index.

Was there a reason there is no export from index? @gcanti

gcanti commented 4 years ago

@waynevanson IIRC the reason was that it would require all peer dependencies

{
  "fp-ts": "^2.0.0",
  "io-ts": "^2.0.0",
  "monocle-ts": "^2.0.0",
  "newtype-ts": "^0.3.2"
}
Kinrany commented 4 years ago

The peer dependencies are there either way, are they not? There's no machine-readable way to specify that you're only going to use a part of the library's surface.

waynevanson commented 4 years ago

According to the documentation at https://github.com/gcanti/io-ts-types#installation:

starting from 0.5.0 you must install fp-ts, io-ts and monocle-ts manually (fp-ts, io-ts and monocle-ts are listed in peerDependency)

I feel like @Kinrany is correct; peer dependencies will need to be installed anyway.

@gcanti Should we wait until 0.6.0 is out, or should we do it beforehand?

gcanti commented 4 years ago

Should we wait until 0.6.0 is out, or should we do it beforehand?

@waynevanson do it beforehand, there's no ETA for v0.6.0 at the moment

waynevanson commented 4 years ago

@gcanti wow time flies when you're having fun! I'll come back within a week advising where I'm at.