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

Unions based on JS class name and typeof? #158

Open
Lupus opened this issue Sep 30, 2021 · 0 comments
Open

Unions based on JS class name and typeof? #158

Lupus opened this issue Sep 30, 2021 · 0 comments

Comments

@Lupus
Copy link

Lupus commented Sep 30, 2021

TypeScript very often has the following unions defined:

export type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration;

export interface TypeOperatorNode extends TypeNode {
        readonly kind: SyntaxKind.TypeOperator;
        readonly operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword;
        readonly type: TypeNode;
    }


getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): string | number | undefined;

Some of them can be discriminated by class constructor names, others can be discriminated by the type of value (string vs number for example). Currently gen_js_api does not seem to support this use cases. Would be great to have such feature.

@Lupus Lupus changed the title Enums based on JS class name and typeof? Unions based on JS class name and typeof? Sep 30, 2021
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