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

Failure when generating empty union #296

Open
tuluce opened this issue Dec 10, 2024 · 0 comments
Open

Failure when generating empty union #296

tuluce opened this issue Dec 10, 2024 · 0 comments

Comments

@tuluce
Copy link
Member

tuluce commented Dec 10, 2024

What happened?

When we have a union type with no sub-types:

MyEmptyUnion:
  union: {}

The following class is generated:

export type IMyEmptyUnion;

export interface IMyEmptyUnionVisitor<T> {
    'unknown': (obj: IMyEmptyUnion) => T;
}

function visit<T>(obj: IMyEmptyUnion, visitor: IMyEmptyUnionVisitor<T>): T {
    return visitor.unknown(obj);
}

export const IMyEmptyUnion = {
    visit: visit
};

And compileTypeScript step fails with:

myEmptyUnion.ts(1,26): error TS4081: Exported type alias 'IMyEmptyUnion' has or is using private name ''.
myEmptyUnion.ts(1,26): error TS1005: '=' expected.

What did you want to happen?

I'd expect a compilable empty union class, or I'd expect Conjure spec layer to disallow empty unions.

More details

This bug was introduced with the version 5.6.0, looking at the diff 5.5.0...5.6.0, I suspect #247 might have caused it.

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

1 participant