Adjust types for the encoder to allow null strings
Summary
In order to create top level arrays, or objects, or to place an element in an array, one needs to pass in null for the key. However, with the typing definitions for assemblyscript-json, and the default tsconfig for assemblyscript proper, null is not a valid argument to these functions
Current Solution
For right now, you can use changetype<string>(0) to get around this.
Suggested Solution
It would be nice to have all of the name types to be alternated with null.
I'll try to make a PR later, but I'm pretty busy right now.
It would be nice to have all of the
nametypes to be alternated withnull.
Hmm, is this already supported by AssemblyScript? Do you have any example?
I think all non-primitive types in AssemblyScript can be alternated with null. Since strings are basically just uint16le arrays, they count as non-primitive.
(Just to double check, I compiled and ran this function
export function f(input: string | null): void {
if (input === null) {
console.logS("nope, it's null");
} else {
console.logS(input);
}
}
It worked as expected.)