feat(napi): allow empty enums

This commit is contained in:
antoniomuso 2022-03-06 12:27:25 +01:00 committed by LongYinan
parent ee0279e540
commit f783e9537f
5 changed files with 9 additions and 3 deletions

View file

@ -884,9 +884,6 @@ impl ConvertToAST for syn::ItemEnum {
Visibility::Public(_) => {}
_ => bail_span!(self, "only public enum allowed"),
}
if self.variants.is_empty() {
bail_span!(self, "cannot export empty enum to JS");
}
self.attrs.push(Attribute {
pound_token: Default::default(),

View file

@ -65,6 +65,9 @@ Generated by [AVA](https://avajs.dev).
/** Tasty */␊
Duck = 2␊
}␊
export const enum Empty {␊
}␊
/** You could break the step and for an new continuous value. */␊
export const enum CustomNumEnum {␊
One = 1,␊

View file

@ -54,6 +54,9 @@ export const enum Kind {
Cat = 1,
/** Tasty */
Duck = 2
}
export const enum Empty {
}
/** You could break the step and for an new continuous value. */
export const enum CustomNumEnum {

View file

@ -11,6 +11,9 @@ pub enum Kind {
Duck,
}
#[napi]
pub enum Empty {}
/// You could break the step and for an new continuous value.
#[napi]
pub enum CustomNumEnum {