null

The CandidType object null corresponds to the Candid type null, is inferred to be a TypeScript null, and will be decoded into a JavaScript null at runtime.

TypeScript or JavaScript:

import { Canister, Null, query } from 'azle/experimental';

export default Canister({
    getNull: query([], Null, () => {
        return null;
    }),
    printNull: query([Null], Null, (null_) => {
        console.log(typeof null_);
        return null_;
    })
});

Candid:

service : () -> {
    getNull : () -> (null) query;
    printNull : (null) -> (null) query;
}

dfx:

dfx canister call candid_canister printNull '(null)'
(null : null)