Skip to content

Commit 1e9d379

Browse files
committed
fix(emscripten): implements statement should take precedence over JSImplementation for inheritance
1 parent f9d845a commit 1e9d379

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

packages/webidl-dts-gen/src/convert-idl.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ function convertInterface(idl: InterfaceIDL, options: Options) {
222222
inheritance.push(ts.factory.createExpressionWithTypeArguments(ts.factory.createIdentifier(idl.inheritance), undefined))
223223
}
224224

225-
if (emscriptenJSImplementation) {
225+
if (emscriptenJSImplementation && inheritance.length === 0) {
226226
let attributeValue = emscriptenJSImplementation.rhs.value as string
227227
attributeValue = attributeValue.replace(/^"(.*)"$/, '$1')
228228
inheritance.push(ts.factory.createExpressionWithTypeArguments(ts.factory.createIdentifier(attributeValue), undefined))

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

+32
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,38 @@ describe('convert', () => {
346346
expect(ts).toContain('class ShapeFilterJS extends ShapeFilter {')
347347
expect(ts).toContain('ShouldCollide(inShape2: number, inSubShapeIDOfShape2: number): boolean;')
348348
})
349+
350+
it('implements statement should take precedence over JSImplementation for inheritance', async () => {
351+
const idl = multiLine(
352+
'interface PathConstraintPath {',
353+
' boolean IsLooping();',
354+
' void SetIsLooping(boolean inIsLooping);',
355+
' unsigned long GetRefCount();',
356+
' void AddRef();',
357+
' void Release();',
358+
'};',
359+
'',
360+
'interface PathConstraintPathEm {',
361+
'};',
362+
'',
363+
'PathConstraintPathJS implements PathConstraintPath;',
364+
'',
365+
'[JSImplementation="PathConstraintPathEm"]',
366+
'interface PathConstraintPathJS {',
367+
' [Const] void PathConstraintPathJS();',
368+
' [Const] float GetPathMaxFraction();',
369+
' [Const] float GetClosestPoint([Const] Vec3 inPosition, float inFractionHint);',
370+
' [Const] void GetPointOnPath(float inFraction, Vec3 outPathPosition, Vec3 outPathTangent, Vec3 outPathNormal, Vec3 outPathBinormal);',
371+
'};',
372+
)
373+
374+
const ts = await convert(idl, { emscripten: true })
375+
376+
console.log(ts)
377+
378+
expect(ts).toContain('class PathConstraintPath {')
379+
expect(ts).toContain('class PathConstraintPathJS extends PathConstraintPath {')
380+
})
349381
})
350382
})
351383

0 commit comments

Comments
 (0)