Skip to content

Commit

Permalink
fix(bindgen): skip files in function module output counts
Browse files Browse the repository at this point in the history
  • Loading branch information
thewtex committed Sep 26, 2023
1 parent 4e38ec5 commit 3ff0d73
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/bindgen/typescript/function-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,9 @@ function functionModule (srcOutputDir, forNode, interfaceJson, modulePascalCase,
}
}
functionContent += '\n'
outputCount++
if (!interfaceType.includes('File')) {
outputCount++
}
} else {
functionContent += ` args.push(${camel}.toString())\n\n`
}
Expand Down Expand Up @@ -428,10 +430,11 @@ function functionModule (srcOutputDir, forNode, interfaceJson, modulePascalCase,
if (!forNode) {
functionContent += ' webWorker: usedWebWorker as Worker,\n'
}
interfaceJson.outputs.forEach((output, index) => {
outputCount = 0
interfaceJson.outputs.forEach((output) => {
const camel = camelCase(output.name)
const interfaceType = interfaceJsonTypeToInterfaceType.get(output.type)
const outputIndex = haveArray ? `${camel}Index` : index.toString()
const outputIndex = haveArray ? `${camel}Index` : outputCount.toString()
if (interfaceType.includes('TextStream') || interfaceType.includes('BinaryStream')) {
if (haveArray) {
const isArray = output.itemsExpectedMax > 1
Expand All @@ -457,6 +460,9 @@ function functionModule (srcOutputDir, forNode, interfaceJson, modulePascalCase,
functionContent += ` ${camel}: outputs[${outputIndex}].data as ${interfaceType},\n`
}
}
if (!interfaceType.includes('File')) {
outputCount++
}
})
functionContent += ' }\n'
functionContent += ' return result\n'
Expand Down

0 comments on commit 3ff0d73

Please sign in to comment.