gen_js_api icon indicating copy to clipboard operation
gen_js_api copied to clipboard

Unions based on JS class name and typeof?

Open Lupus opened this issue 4 years ago • 0 comments

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 avatar Sep 30 '21 09:09 Lupus