diff --git a/packages/webidl-dts-gen/src/fixes.ts b/packages/webidl-dts-gen/src/fixes.ts index a73098b..5980805 100644 --- a/packages/webidl-dts-gen/src/fixes.ts +++ b/packages/webidl-dts-gen/src/fixes.ts @@ -34,7 +34,7 @@ export const fixes = { for (let i = 0; i < lines.length; i++) { const line = lines[i] - const match = /([a-zA-Z0-9]+) implements ([a-zA-Z0-9]+);/gi.exec(line) + const match = /([a-zA-Z0-9_]+) implements ([a-zA-Z0-9_]+);/gi.exec(line) if (!match) { continue diff --git a/packages/webidl-dts-gen/tst/index.spec.ts b/packages/webidl-dts-gen/tst/index.spec.ts index ab9d999..ada8a5d 100644 --- a/packages/webidl-dts-gen/tst/index.spec.ts +++ b/packages/webidl-dts-gen/tst/index.spec.ts @@ -253,6 +253,29 @@ describe('convert', () => { await expectSourceToBeEqual(actual, expected) }) + it('supports "implements" identifiers with underscores', async () => { + const idl = ` + interface Foo_Bar { + void bar(); + }; + interface Baz_Bal { + }; + Baz_Bal implements Foo_Bar; + ` + + const actual = await convert(idl, { emscripten: true }) + + const expected = withDefaultEmscriptenOutput(` + class Foo_Bar { + bar(): void; + } + class Baz_Bal extends Foo_Bar { + } + `) + + await expectSourceToBeEqual(actual, expected) + }) + it('ignores commented out "implements" expressions', async () => { const idl = ` interface Foo {