Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested types inlined instead of referencing #8

Open
schibrikov opened this issue Dec 27, 2019 · 4 comments
Open

Nested types inlined instead of referencing #8

schibrikov opened this issue Dec 27, 2019 · 4 comments

Comments

@schibrikov
Copy link

schibrikov commented Dec 27, 2019

When some type refers to other type like

interface MySecondInterface {
	field: MyFirstInterface;
}

ts-to-io inlines all the fields of MyFirstInterface just like

const MySecondInterface = t.type({
	field: t.type({
		property: t.number
	});
})

Instead, I'd like to see

const MySecondInterface = t.type({
	field: MyFirstInterface // generated io-ts type name
})

Is it a goal for this project?

@plumdog
Copy link

plumdog commented Feb 19, 2020

I found this behaviour surprising too. I would expect anything that could refer to another type to reference that type, rather than being replicated.

I can't see an obvious way to alter this behaviour in the code.

@raine
Copy link

raine commented Mar 26, 2020

👍 This would be great

@juusaw
Copy link
Owner

juusaw commented May 13, 2020

Hi, I would also prefer this to be the behavior and definitely see it as an improvement to the project. I will try to into it more at some point but so far my impression is that this would be difficult to achieve with the TS compiler API – although I may be wrong about this. The API documentation is somewhat incomplete so a bit of exploration into the internals would likely be needed to see if this would be possible and how much work it would take.

This change would also enable support for recursive types which would be a nice improvement.

@ahrjarrett
Copy link

ahrjarrett commented Aug 1, 2020

I vote we add a feature-request label to this issue. I agree this would be awesome. Is @juusaw still able and interested in this package?

If so, I think seeing that there are goals and areas we might need help would make the issues page look less like a list of things that are broken, and more like a kind of roadmap.

Personally I think this library is the ticket I need to overcome objections to introducing fp-ts in production at work. io-ts is a wonderful library, but I feel like ts-to-io is the missing piece of the story.

FP can be a hardsell and loses a lot of battles without having a chance to demonstrate its usefulness; this could be the gateway drug that gets a skeptical team curious enough to give it a shot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants