From 08ed5bc1ca794b81be2f17c80cee14bb6a5616e6 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Sat, 19 Aug 2023 21:39:02 -0400 Subject: [PATCH] fix(bingen): use any for JsonObject typescript type In addition to Object, the type could be null, boolean, Array, string, number. --- .../typescript/src/compare-double-images-node-result.ts | 2 +- .../typescript/src/compare-double-images-result.ts | 2 +- src/bindgen/typescript/function-module.js | 3 +-- .../typescript/interface-json-type-to-typescript-type.js | 4 ++-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/compare-images/typescript/src/compare-double-images-node-result.ts b/packages/compare-images/typescript/src/compare-double-images-node-result.ts index db8f0b3ef..f53e61419 100644 --- a/packages/compare-images/typescript/src/compare-double-images-node-result.ts +++ b/packages/compare-images/typescript/src/compare-double-images-node-result.ts @@ -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 diff --git a/packages/compare-images/typescript/src/compare-double-images-result.ts b/packages/compare-images/typescript/src/compare-double-images-result.ts index 657307674..3a2452122 100644 --- a/packages/compare-images/typescript/src/compare-double-images-result.ts +++ b/packages/compare-images/typescript/src/compare-double-images-result.ts @@ -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 diff --git a/src/bindgen/typescript/function-module.js b/src/bindgen/typescript/function-module.js index a3ebcd7d0..c982dea22 100644 --- a/src/bindgen/typescript/function-module.js +++ b/src/bindgen/typescript/function-module.js @@ -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` @@ -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` } diff --git a/src/bindgen/typescript/interface-json-type-to-typescript-type.js b/src/bindgen/typescript/interface-json-type-to-typescript-type.js index 35c7cc383..0f91ff2b2 100644 --- a/src/bindgen/typescript/interface-json-type-to-typescript-type.js +++ b/src/bindgen/typescript/interface-json-type-to-typescript-type.js @@ -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 \ No newline at end of file