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

Recursive types with Omit types leads to Reference Type Not Set Yet error since v1.0.0 #1276

Closed
ssc-hrep3 opened this issue Jun 1, 2022 · 6 comments · Fixed by #1593
Closed

Comments

@ssc-hrep3
Copy link

ssc-hrep3 commented Jun 1, 2022

Hi there

First of all, thank you for maintaining this great library. I just found an issue, which only occurs in the most recent version v1.0.0. With v0.95, it worked without any problems. Here is an example of the issue:

export type Item = {
  type: 'item';
};
export type Group = {
  type: 'group';
  members: Member[];
};
type Member = { depth: number } & (Item | Group);
export type RootNoMembers = Item | Omit<Group, 'members'>;

The error says Reference type not set yet. I assume, it has something to do with the recursive type in combination with the union types and Omit<>.

The error does not occur when I remove the Omit<Group, 'members'> and replace it with an explicit type { type: 'group' }.

Do you have any idea, what could be the root cause of this?

@ssc-hrep3 ssc-hrep3 changed the title Recursive types with union types leads to Reference Type Not Set Yet error since v1.0.0 Recursive types with Omit types leads to Reference Type Not Set Yet error since v1.0.0 Jun 1, 2022
@domoritz
Copy link
Member

domoritz commented Jun 1, 2022

Huh, thanks for the issue. Could you try cloning this repo and do a binary search to identify the commit that causes the issue? There should be an associated pull request.

@bettercalljason
Copy link

bettercalljason commented Oct 19, 2022

I did the binary search as suggested and found the commit that causes the issue: 653fa77. And this is the associated pull request: #985.

Before that, it works fine. We would love to upgrade to the latest ts-json-schema-generator version but this issue prevents it 😢

Do you have an idea what could be the issue?

@domoritz
Copy link
Member

domoritz commented Dec 3, 2022

@joshkel could you take a look at this issue and whether it was introduced in your pull request?

@domoritz
Copy link
Member

domoritz commented Mar 3, 2023

Even this simple case leads to issues

export type Geometry = GeometryCollection;

export interface GeometryCollection<G extends Geometry = Geometry> {
    geometries: G[];
}

export type Type = GeometryCollection;

@domoritz
Copy link
Member

domoritz commented Mar 3, 2023

Actually this

export interface GeoJsonObject {
    type: GeometryCollection["type"];
}

export interface GeometryCollection extends GeoJsonObject {
    type: "GeometryCollection";
}

export type Type = GeometryCollection;

@github-actions
Copy link

github-actions bot commented Mar 3, 2023

🚀 Issue was released in v1.3.0-next.2 🚀

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

Successfully merging a pull request may close this issue.

3 participants