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

Cannot import from io-ts-types #104

Closed joefiorini closed 5 years ago

joefiorini commented 5 years ago

I'm trying to import from io-ts-types and I get an error that node_modules/io-ts-types/lib/index.d.ts is not a module. I've tried reinstalling it a few times, to no avail. It appears the index.d.ts is empty, which may be the cause of the issue? I forked a sample repo in which I was immediately able to reproduce the issue. Just clone it, run yarn install and run yarn tsc. You should see the error quoted above.

All libraries should be latest as of filing this issue. TypeScript version: 3.6.2 io-ts: 2.0.1 io-ts-types: 0.5.0

giogonzo commented 5 years ago

Currently index.ts is just an empty file 😕 I'm not sure wether this was intentional or not

In any case I'd always prefer specific imports (e.g. import { IntFromString } from "io-ts-types/lib/IntFromString";) so as to be able to build without installing undesired dependencies (i.e. monocle-ts is only needed for a subset of the combinators)

sgronblo commented 5 years ago

I also ran into this immediately. I think it would help if the README.md included some concrete examples of how to use the library.