From ca80f521af7471d22e461484c8c2c618c049abdd Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Thu, 4 Apr 2024 21:11:43 -0600 Subject: [PATCH] type fixes --- src/compiler/file_uploader/expand_paths.ts | 4 ++-- src/lib/candid/serde/decode.ts | 4 ++-- src/lib/candid/serde/encode.ts | 4 ++-- src/lib/canister_methods/execute_method.ts | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/compiler/file_uploader/expand_paths.ts b/src/compiler/file_uploader/expand_paths.ts index 3eeaa60441..bf24dc0fa5 100644 --- a/src/compiler/file_uploader/expand_paths.ts +++ b/src/compiler/file_uploader/expand_paths.ts @@ -40,7 +40,7 @@ async function expandDirectory( }, Promise.resolve([]) ); - } catch (error) { - throw new Error(`Error reading directory: ${error}`); + } catch (error: any) { + throw new Error(`Error reading directory: ${error.message}`); } } diff --git a/src/lib/candid/serde/decode.ts b/src/lib/candid/serde/decode.ts index eaa6dfda53..a4cc4fb3d8 100644 --- a/src/lib/candid/serde/decode.ts +++ b/src/lib/candid/serde/decode.ts @@ -17,10 +17,10 @@ import { DecodeVisitor } from './visitors/decode_visitor'; * @param candidType either a built-in IDL data type, or an Azle-defined super-type * @returns the Azle representation of the data */ -export function decode( +export function decode( candidType: CandidType | CandidType[], data: ArrayBuffer -): any | any[] { +): T | T[] { if (Array.isArray(candidType)) { return decodeMultiple(candidType, data); } diff --git a/src/lib/candid/serde/encode.ts b/src/lib/candid/serde/encode.ts index 1bb5857de4..74a759be4f 100644 --- a/src/lib/candid/serde/encode.ts +++ b/src/lib/candid/serde/encode.ts @@ -17,9 +17,9 @@ import { EncodeVisitor } from './visitors/encode_visitor'; * @param candidType either a built-in IDL data type, or an Azle-defined super-type * @returns candid bytes */ -export function encode( +export function encode( candidType: CandidType | CandidType[], - data: any | any[] + data: T | T[] ): Uint8Array { if (Array.isArray(candidType)) { if (Array.isArray(data)) { diff --git a/src/lib/canister_methods/execute_method.ts b/src/lib/canister_methods/execute_method.ts index 9743b33ece..0fe26ce61a 100644 --- a/src/lib/canister_methods/execute_method.ts +++ b/src/lib/canister_methods/execute_method.ts @@ -13,7 +13,7 @@ export function executeMethod( returnCandidType: CandidType, manual: boolean ) { - const decodedArgs = decode(paramCandidTypes, args[0]); + const decodedArgs = decode(paramCandidTypes, args[0]); const result = getResult(decodedArgs, callback);