int16
The CandidType
object int16
corresponds to the Candid type int16, is inferred to be a TypeScript number
, and will be decoded into a JavaScript Number at runtime.
TypeScript or JavaScript:
import { Canister, int16, query } from 'azle/experimental';
export default Canister({
getInt16: query([], int16, () => {
return 32_767;
}),
printInt16: query([int16], int16, (int16) => {
console.log(typeof int16);
return int16;
})
});
Candid:
service : () -> {
getInt16 : () -> (int16) query;
printInt16 : (int16) -> (int16) query;
}
dfx:
dfx canister call candid_canister printInt16 '(32_767 : int16)'
(32_767 : int16)