diff --git a/.changeset/khaki-mails-cheer.md b/.changeset/khaki-mails-cheer.md new file mode 100644 index 0000000..8938e26 --- /dev/null +++ b/.changeset/khaki-mails-cheer.md @@ -0,0 +1,5 @@ +--- +"webidl-dts-gen": minor +--- + +feat: use webidl `value.name` for emscripten setter parameter name diff --git a/packages/webidl-dts-gen/src/convert-idl.ts b/packages/webidl-dts-gen/src/convert-idl.ts index 18f8ee2..5d8ed89 100644 --- a/packages/webidl-dts-gen/src/convert-idl.ts +++ b/packages/webidl-dts-gen/src/convert-idl.ts @@ -386,7 +386,7 @@ function createEmscriptenAttributeSetter(value: webidl2.AttributeMemberType) { ts.factory.createParameterDeclaration( [], undefined, - 'value', + value.name, undefined, convertType(idlType), ), @@ -397,7 +397,7 @@ function createEmscriptenAttributeSetter(value: webidl2.AttributeMemberType) { ts.factory.createParameterDeclaration( [], undefined, - 'value', + value.name, undefined, convertType(idlType), ), diff --git a/packages/webidl-dts-gen/tst/index.spec.ts b/packages/webidl-dts-gen/tst/index.spec.ts index e129e22..21e1cc4 100644 --- a/packages/webidl-dts-gen/tst/index.spec.ts +++ b/packages/webidl-dts-gen/tst/index.spec.ts @@ -208,7 +208,7 @@ describe('convert', () => { withDefaultEmscriptenOutput( 'class Foo {', // ' get_position(): number;', // - ' set_position(value: number): void;', // + ' set_position(position: number): void;', // ' position: number;', // '}', // ), @@ -228,7 +228,7 @@ describe('convert', () => { withDefaultEmscriptenOutput( 'class Foo {', // ' get_position(index: number): number;', // - ' set_position(index: number, value: number): void;', // + ' set_position(index: number, position: number): void;', // ' position: number;', // '}', // ),