Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix implements support for identifiers with underscores #306

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/webidl-dts-gen/src/fixes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions packages/webidl-dts-gen/tst/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down