Skip to content

Commit e2d3127

Browse files
Fix implements support for identifiers with underscores (#310)
* Fix `implements` support for identifiers with underscores * chore: add changeset --------- Co-authored-by: “Isaac <[email protected]>
1 parent 214829b commit e2d3127

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

.changeset/sharp-houses-compete.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"webidl-dts-gen": patch
3+
---
4+
5+
Fix 'implements' support for identifiers with underscores

packages/webidl-dts-gen/src/fixes.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const fixes = {
3434
for (let i = 0; i < lines.length; i++) {
3535
const line = lines[i]
3636

37-
const match = /([a-zA-Z0-9]+) implements ([a-zA-Z0-9]+);/gi.exec(line)
37+
const match = /([a-zA-Z0-9_]+) implements ([a-zA-Z0-9_]+);/gi.exec(line)
3838

3939
if (!match) {
4040
continue

packages/webidl-dts-gen/tst/index.spec.ts

+23
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,29 @@ describe('convert', () => {
253253
await expectSourceToBeEqual(actual, expected)
254254
})
255255

256+
it('supports "implements" identifiers with underscores', async () => {
257+
const idl = `
258+
interface Foo_Bar {
259+
void bar();
260+
};
261+
interface Baz_Bal {
262+
};
263+
Baz_Bal implements Foo_Bar;
264+
`
265+
266+
const actual = await convert(idl, { emscripten: true })
267+
268+
const expected = withDefaultEmscriptenOutput(`
269+
class Foo_Bar {
270+
bar(): void;
271+
}
272+
class Baz_Bal extends Foo_Bar {
273+
}
274+
`)
275+
276+
await expectSourceToBeEqual(actual, expected)
277+
})
278+
256279
it('ignores commented out "implements" expressions', async () => {
257280
const idl = `
258281
interface Foo {

0 commit comments

Comments
 (0)