Closed nhenin closed 1 year ago
The default output parameter O
from t.Type
is A
. So your code evaluates to t.Type<Test, Test>
which is not correct as your newtype output will be string
and not TokenName
. You need to define the output manually.
import * as t from "io-ts";
import { iso, Newtype } from "newtype-ts";
import { fromNewtype } from "io-ts-types";
type TokenName = Newtype<{ readonly TokenName: unique symbol }, string> ;
const TokenName = fromNewtype<TokenName>(t.string)
type Test = { role_token: TokenName }
type TestOutput = { role_token: string }
const b : t.Type<Test, TestOutput> = t.type({role_token:TokenName})
or just let typescript infer the type.
Thanks :-)
🐛 Bug report
Current Behavior
gives me the following compile issue on
b
:I'd like to use these components in a some Recursive Types..
Your environment