text

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

TypeScript or JavaScript:

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

export default Canister({
    getString: query([], text, () => {
        return 'Hello world!';
    }),
    printString: query([text], text, (string) => {
        console.log(typeof string);
        return string;
    })
});

Candid:

service : () -> {
    getString : () -> (text) query;
    printString : (text) -> (text) query;
}

dfx:

dfx canister call candid_canister printString '("Hello world!")'
("Hello world!")