Skip to content

Commit

Permalink
Try different enum technique
Browse files Browse the repository at this point in the history
  • Loading branch information
zzorba committed Aug 19, 2024
1 parent 536c59a commit c8ee4b9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,6 @@ import { decl_type_name } from "./EnumTemplate"

{%- macro type_omit_instanceof(type_name, decl_type_name) %}
export type {{ type_name }} = InstanceType<
typeof {{ decl_type_name }}[keyof Omit<typeof {{ decl_type_name }}, 'instanceOf' | '__uniffiTypeName' | '__variant' | '__variantName'>]
typeof {{ decl_type_name }}[keyof Omit<typeof {{ decl_type_name }}, 'instanceOf'>]
>;
{%- endmacro %}
18 changes: 15 additions & 3 deletions typescript/src/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,20 @@
*/
export class UniffiEnum {
constructor(
private readonly __uniffiTypeName: string,
private readonly __variantName: string,
private readonly __variant: number,
/*
* This method should be private, but typescript requires
* it be public because it cannot enforce it.
*/
public readonly __uniffiTypeName: string,
/*
* This method should be private, but typescript requires
* it be public because it cannot enforce it.
*/
public readonly __variantName: string,
/*
* This method should be private, but typescript requires
* it be public because it cannot enforce it.
*/
public readonly __variant: number
) {}
}

0 comments on commit c8ee4b9

Please sign in to comment.