Skip to content

Commit

Permalink
fix: emscripten enum values should be numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
isaac-mason committed Aug 19, 2023
1 parent a39ea15 commit 3868ce5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/chatty-eyes-bow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"webidl-dts-gen": minor
---

fix: emscripten enum values should be numbers
2 changes: 1 addition & 1 deletion packages/webidl-dts-gen/src/convert-idl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ function convertEnum(idl: webidl2.EnumType, options: Options, emscriptenEnumMemb
const variableDeclaration = ts.factory.createVariableDeclaration(
ts.factory.createIdentifier(member),
undefined,
ts.factory.createTypeReferenceNode('any', undefined),
ts.factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword),
)

return ts.factory.createVariableStatement(
Expand Down
8 changes: 4 additions & 4 deletions packages/webidl-dts-gen/tst/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ describe('convert', () => {

expect(ts).toBe(
withDefaultEmscriptenOutput(
'const bar: any;', //
'const baz: any;', //
'const bar: number;', //
'const baz: number;', //
'type Foo = typeof bar | typeof baz;', //
'function _emscripten_enum_Foo_bar(): Foo;', //
'function _emscripten_enum_Foo_baz(): Foo;', //
Expand All @@ -158,8 +158,8 @@ describe('convert', () => {

expect(ts).toBe(
withDefaultEmscriptenOutput(
'const bar: any;', //
'const baz: any;', //
'const bar: number;', //
'const baz: number;', //
'type Foo = typeof bar | typeof baz;', //
'function _emscripten_enum_Foo_bar(): Foo;', //
'function _emscripten_enum_Foo_baz(): Foo;', //
Expand Down

0 comments on commit 3868ce5

Please sign in to comment.