Skip to content

Commit

Permalink
fix(bingen): use any for JsonObject typescript type
Browse files Browse the repository at this point in the history
In addition to Object, the type could be null, boolean, Array, string,
number.
  • Loading branch information
thewtex committed Aug 21, 2023
1 parent adbc0c6 commit 08ed5bc
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Image } from 'itk-wasm'

interface CompareDoubleImagesNodeResult {
/** Metrics for the baseline with the fewest number of pixels outside the tolerances. */
metrics: Object
metrics: any

/** Absolute difference image */
differenceImage: Image
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface CompareDoubleImagesResult {
webWorker: Worker | null

/** Metrics for the baseline with the fewest number of pixels outside the tolerances. */
metrics: Object
metrics: any

/** Absolute difference image */
differenceImage: Image
Expand Down
3 changes: 1 addition & 2 deletions src/bindgen/typescript/function-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ function readFileIfNotInterfaceType(forNode, interfaceType, varName, indent) {
return `${indent}mountDirs.add(path.dirname(${varName} as string))\n`
} else {
if (interfaceType === 'TextFile') {

return `${indent}let ${varName}File = ${varName}\n${indent}if (${varName} instanceof File) {\n${indent} const ${varName}Buffer = await ${varName}.arrayBuffer()\n${indent} ${varName}File = { path: ${varName}.name, data: new TextDecoder().decode(${varName}Buffer) }\n${indent}}\n`
} else {
return `${indent}let ${varName}File = ${varName}\n${indent}if (${varName} instanceof File) {\n${indent} const ${varName}Buffer = await ${varName}.arrayBuffer()\n${indent} ${varName}File = { path: ${varName}.name, data: new Uint8Array(${varName}Buffer) }\n${indent}}\n`
Expand Down Expand Up @@ -203,7 +202,7 @@ function functionModule (srcOutputDir, forNode, interfaceJson, modulePascalCase,
if (interfaceType.includes('Stream')) {
data = `{ data: ${camel} } `
} else if (interfaceType === 'JsonObject') {
data = `{ data: ${camel} as Object } `
data = `{ data: ${camel} as any } `
}
functionContent += ` { type: InterfaceTypes.${interfaceType}, data: ${data} },\n`
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ const interfaceJsonTypeToTypeScriptType = new Map([
['UINT:UINT', 'number'],
['FLOAT', 'number'],
['FLOAT:FLOAT', 'number'],
['INPUT_JSON', 'Object'],
['OUTPUT_JSON', 'Object'],
['INPUT_JSON', 'any'],
['OUTPUT_JSON', 'any'],
])

export default interfaceJsonTypeToTypeScriptType

0 comments on commit 08ed5bc

Please sign in to comment.