feat(napi): allow empty enums
This commit is contained in:
parent
ee0279e540
commit
f783e9537f
5 changed files with 9 additions and 3 deletions
|
@ -884,9 +884,6 @@ impl ConvertToAST for syn::ItemEnum {
|
||||||
Visibility::Public(_) => {}
|
Visibility::Public(_) => {}
|
||||||
_ => bail_span!(self, "only public enum allowed"),
|
_ => 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 {
|
self.attrs.push(Attribute {
|
||||||
pound_token: Default::default(),
|
pound_token: Default::default(),
|
||||||
|
|
|
@ -65,6 +65,9 @@ Generated by [AVA](https://avajs.dev).
|
||||||
/** Tasty */␊
|
/** Tasty */␊
|
||||||
Duck = 2␊
|
Duck = 2␊
|
||||||
}␊
|
}␊
|
||||||
|
export const enum Empty {␊
|
||||||
|
␊
|
||||||
|
}␊
|
||||||
/** You could break the step and for an new continuous value. */␊
|
/** You could break the step and for an new continuous value. */␊
|
||||||
export const enum CustomNumEnum {␊
|
export const enum CustomNumEnum {␊
|
||||||
One = 1,␊
|
One = 1,␊
|
||||||
|
|
Binary file not shown.
3
examples/napi/index.d.ts
vendored
3
examples/napi/index.d.ts
vendored
|
@ -54,6 +54,9 @@ export const enum Kind {
|
||||||
Cat = 1,
|
Cat = 1,
|
||||||
/** Tasty */
|
/** Tasty */
|
||||||
Duck = 2
|
Duck = 2
|
||||||
|
}
|
||||||
|
export const enum Empty {
|
||||||
|
|
||||||
}
|
}
|
||||||
/** You could break the step and for an new continuous value. */
|
/** You could break the step and for an new continuous value. */
|
||||||
export const enum CustomNumEnum {
|
export const enum CustomNumEnum {
|
||||||
|
|
|
@ -11,6 +11,9 @@ pub enum Kind {
|
||||||
Duck,
|
Duck,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[napi]
|
||||||
|
pub enum Empty {}
|
||||||
|
|
||||||
/// You could break the step and for an new continuous value.
|
/// You could break the step and for an new continuous value.
|
||||||
#[napi]
|
#[napi]
|
||||||
pub enum CustomNumEnum {
|
pub enum CustomNumEnum {
|
||||||
|
|
Loading…
Reference in a new issue