diff --git a/crates/macro/src/parser/mod.rs b/crates/macro/src/parser/mod.rs index cae6fd52..97c180f4 100644 --- a/crates/macro/src/parser/mod.rs +++ b/crates/macro/src/parser/mod.rs @@ -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(), diff --git a/examples/napi/__test__/typegen.spec.ts.md b/examples/napi/__test__/typegen.spec.ts.md index 922e7ee0..abc7f874 100644 --- a/examples/napi/__test__/typegen.spec.ts.md +++ b/examples/napi/__test__/typegen.spec.ts.md @@ -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,␊ diff --git a/examples/napi/__test__/typegen.spec.ts.snap b/examples/napi/__test__/typegen.spec.ts.snap index d1341ed1..993f8591 100644 Binary files a/examples/napi/__test__/typegen.spec.ts.snap and b/examples/napi/__test__/typegen.spec.ts.snap differ diff --git a/examples/napi/index.d.ts b/examples/napi/index.d.ts index b17d1384..2365a292 100644 --- a/examples/napi/index.d.ts +++ b/examples/napi/index.d.ts @@ -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 { diff --git a/examples/napi/src/enum.rs b/examples/napi/src/enum.rs index 8f6a928a..58e1cd12 100644 --- a/examples/napi/src/enum.rs +++ b/examples/napi/src/enum.rs @@ -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 {