Usage with existing io-ts instances
Is it possible to combine buildDecoder with existing types? io-ts adds a lot of value outside of simple validation. It can also transform input. Whether thats casting one type to another or setting defaults. Is it possible to integrate the instances this project generates with hand crafted io-ts types?
For instance, how could io-ts-transformer be used with these types? Is it possible to generate the Config type?
import { withFallback } from 'io-ts-types/lib/withFallback'
const Options = t.type({
logLevel: withFallback(t.string, 'info')
})
const Config = t.type({
folder: t.string,
options: Options
})
I think, the typelevel interface may look like this, but right now I don't see clearly how to implement transformation of this expression. I need some time to research this.

That is an interesting thought. It immediately looks like you lose the reference to the options decoder, but Im sure theres some compiler magic thats happening to ensure that the options instance is still used there.
This is really exciting though. Right now, to me, this package is as useful as typescript-is. It can transform my types into validators. The real potential value of io-ts is integrating with their huge ecosystem of decoders. It can allow us to write declarative defaults, input normalizers, and essentially shift the paradigm of io inputs from
input -> validator -> parse
to
input -> parse
I don't mention all this to attempt to prioritize my feature request, you're doing free work so do things at your own pace. I am just calling it out because it is very exciting to me. In case you are interested, there is a great article on the subtle but important difference in one vs the other https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate
The feature is released in the latest version of the package. I'm not sure if there are no bugs, so it would be nice if you could help me with testing this. Please read the 3th point of the section "Io-ts-transformer already can" in the readme file before you try using this feature.
The readme generally makes sense here. Raw io-ts types need to define recursive elements so it makes sense that recursion needs to be explicitly defined for those instances. I will poke at it this week and see if I can break anything :)
looks like the latest version of the io-ts-transformer is borked
> [email protected] build /Users/andrew/Code/scratchwork/try-io-ts-transformer
> webpack
[io-ts-transformer info]: If you will get any problems using this transformer, please
leave an issue on GitHub https://github.com/awerlogus/io-ts-transformer/issues with your types example
/Users/andrew/Code/scratchwork/try-io-ts-transformer/node_modules/.pnpm/registry.npmjs.org/typescript/3.8.3/node_modules/typescript/lib/typescript.js:98681
throw e;
^
Error: Debug Failure. False expression.
at Object.setTextPos (/Users/andrew/Code/scratchwork/try-io-ts-transformer/node_modules/.pnpm/registry.npmjs.org/typescript/3.8.3/node_modules/typescript/lib/typescript.js:10115:22)
at addSyntheticNodes (/Users/andrew/Code/scratchwork/try-io-ts-transformer/node_modules/.pnpm/registry.npmjs.org/typescript/3.8.3/node_modules/typescript/lib/typescript.js:134829:20)
at createSyntaxList (/Users/andrew/Code/scratchwork/try-io-ts-transformer/node_modules/.pnpm/registry.npmjs.org/typescript/3.8.3/node_modules/typescript/lib/typescript.js:134851:13)
at processNodes (/Users/andrew/Code/scratchwork/try-io-ts-transformer/node_modules/.pnpm/registry.npmjs.org/typescript/3.8.3/node_modules/typescript/lib/typescript.js:134814:27)
at visitNodes (/Users/andrew/Code/scratchwork/try-io-ts-transformer/node_modules/.pnpm/registry.npmjs.org/typescript/3.8.3/node_modules/typescript/lib/typescript.js:18436:24)
at Object.forEachChild (/Users/andrew/Code/scratchwork/try-io-ts-transformer/node_modules/.pnpm/registry.npmjs.org/typescript/3.8.3/node_modules/typescript/lib/typescript.js:18673:24)
at SourceFileObject.NodeObject.forEachChild (/Users/andrew/Code/scratchwork/try-io-ts-transformer/node_modules/.pnpm/registry.npmjs.org/typescript/3.8.3/node_modules/typescript/lib/typescript.js:134791:23)
at createChildren (/Users/andrew/Code/scratchwork/try-io-ts-transformer/node_modules/.pnpm/registry.npmjs.org/typescript/3.8.3/node_modules/typescript/lib/typescript.js:134823:14)
at SourceFileObject.NodeObject.getChildren (/Users/andrew/Code/scratchwork/try-io-ts-transformer/node_modules/.pnpm/registry.npmjs.org/typescript/3.8.3/node_modules/typescript/lib/typescript.js:134768:56)
at visitor (/Users/andrew/Code/scratchwork/try-io-ts-transformer/node_modules/.pnpm/registry.npmjs.org/io-ts-transformer/[email protected][email protected]/node_modules/io-ts-transformer/transformer.js:162:35)
at findFromIoTsUsages (/Users/andrew/Code/scratchwork/try-io-ts-transformer/node_modules/.pnpm/registry.npmjs.org/io-ts-transformer/[email protected][email protected]/node_modules/io-ts-transformer/transformer.js:165:12)
at /Users/andrew/Code/scratchwork/try-io-ts-transformer/node_modules/.pnpm/registry.npmjs.org/io-ts-transformer/[email protected][email protected]/node_modules/io-ts-transformer/transformer.js:74:30
at transformSourceFileOrBundle (/Users/andrew/Code/scratchwork/try-io-ts-transformer/node_modules/.pnpm/registry.npmjs.org/typescript/3.8.3/node_modules/typescript/lib/typescript.js:74631:57)
at transformation (/Users/andrew/Code/scratchwork/try-io-ts-transformer/node_modules/.pnpm/registry.npmjs.org/typescript/3.8.3/node_modules/typescript/lib/typescript.js:92009:24)
at transformRoot (/Users/andrew/Code/scratchwork/try-io-ts-transformer/node_modules/.pnpm/registry.npmjs.org/typescript/3.8.3/node_modules/typescript/lib/typescript.js:92030:82)
at Object.map (/Users/andrew/Code/scratchwork/try-io-ts-transformer/node_modules/.pnpm/registry.npmjs.org/typescript/3.8.3/node_modules/typescript/lib/typescript.js:551:29)
at Object.transformNodes (/Users/andrew/Code/scratchwork/try-io-ts-transformer/node_modules/.pnpm/registry.npmjs.org/typescript/3.8.3/node_modules/typescript/lib/typescript.js:92016:30)
at emitJsFileOrBundle (/Users/andrew/Code/scratchwork/try-io-ts-transformer/node_modules/.pnpm/registry.npmjs.org/typescript/3.8.3/node_modules/typescript/lib/typescript.js:92554:32)
at emitSourceFileOrBundle (/Users/andrew/Code/scratchwork/try-io-ts-transformer/node_modules/.pnpm/registry.npmjs.org/typescript/3.8.3/node_modules/typescript/lib/typescript.js:92506:13)
at forEachEmittedFile (/Users/andrew/Code/scratchwork/try-io-ts-transformer/node_modules/.pnpm/registry.npmjs.org/typescript/3.8.3/node_modules/typescript/lib/typescript.js:92258:34)
at Object.emitFiles (/Users/andrew/Code/scratchwork/try-io-ts-transformer/node_modules/.pnpm/registry.npmjs.org/typescript/3.8.3/node_modules/typescript/lib/typescript.js:92487:9)
at emitWorker (/Users/andrew/Code/scratchwork/try-io-ts-transformer/node_modules/.pnpm/registry.npmjs.org/typescript/3.8.3/node_modules/typescript/lib/typescript.js:98590:33)
at /Users/andrew/Code/scratchwork/try-io-ts-transformer/node_modules/.pnpm/registry.npmjs.org/typescript/3.8.3/node_modules/typescript/lib/typescript.js:98569:66
at runWithCancellationToken (/Users/andrew/Code/scratchwork/try-io-ts-transformer/node_modules/.pnpm/registry.npmjs.org/typescript/3.8.3/node_modules/typescript/lib/typescript.js:98665:24)
at Object.emit (/Users/andrew/Code/scratchwork/try-io-ts-transformer/node_modules/.pnpm/registry.npmjs.org/typescript/3.8.3/node_modules/typescript/lib/typescript.js:98569:20)
at Object.getEmitOutput (/Users/andrew/Code/scratchwork/try-io-ts-transformer/node_modules/.pnpm/registry.npmjs.org/ts-loader/[email protected]/node_modules/ts-loader/dist/instances.js:361:21)
at provideDeclarationFilesToWebpack (/Users/andrew/Code/scratchwork/try-io-ts-transformer/node_modules/.pnpm/registry.npmjs.org/ts-loader/[email protected]/node_modules/ts-loader/dist/after-compile.js:185:41)
at /Users/andrew/Code/scratchwork/try-io-ts-transformer/node_modules/.pnpm/registry.npmjs.org/ts-loader/[email protected]/node_modules/ts-loader/dist/after-compile.js:24:9
at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/andrew/Code/scratchwork/try-io-ts-transformer/node_modules/.pnpm/registry.npmjs.org/tapable/1.1.3/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:14:1)
at AsyncSeriesHook.lazyCompileHook (/Users/andrew/Code/scratchwork/try-io-ts-transformer/node_modules/.pnpm/registry.npmjs.org/tapable/1.1.3/node_modules/tapable/lib/Hook.js:154:20)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `webpack`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/andrew/.npm/_logs/2020-03-09T18_06_41_945Z-debug.log
(hydra-studio) ✘ andrew ~/Code/scratchwork/try-io-ts-transformer
it seems like I can repro with just an import
import * as either from 'fp-ts/lib/Either'
import * as t from 'io-ts'
import { buildDecoder } from 'io-ts-transformer'
(full repro here https://github.com/andykais/try-io-ts-transformer)
It's a very strange bug. It did not appear until the new version of package was published. I fixed this one.
unsure. On a related note, just as a useful tracking tool, a lot repos like to use the releases page on their repo to keep track of their published versions, breaking changes, bug fixes, etc. It was a little hard for me to discover what changed where with this package. The Versions tab on your npm package page can tell me when packages were published, but not what changed. Here is the releases page on io-ts for example https://github.com/gcanti/io-ts/releases
Some people just keep a simple CHANGELOG.md in the root of their project as well.
I'm too lazy to maintain all this versioning infrastructure. Just want to fix all bugs left and then start writing a diploma report about this project.