gcanti / gcanti/io-ts-codegen

Brands in recursive types result in interface being misplaced

Open
#40 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
159
Forks
14
PR merge metrics
No merged PRs in 30d

Description

Calling `t.brandCombinator` on a recursive feild results in something like this:

```
const Schema: t.RecursiveType> = t.recursion('Schema', () => t.brand(_Schema, (x): x is t.Branded<_Schema, XPropertiesBrand> => true, 'XProperties')
interface XPropertiesBrand {
readonly XProperties: unique symbol
})
```

The interface is placed within the recurisve expression.

That happens because of this line: https://github.com/gcanti/io-ts-codegen/blob/0be18841a50ceb0a45ade7f4bf0d9b365e33018c/src/index.ts#L788

One idea for a fix: another function instead of `printRuntime` (ie `printDefinitions`) could be used to print this sort of thing.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.