Your solution is the second alternative proposed in the article: the “Nullable field” solution.
It’s an example of a classic tradeoff between enforcing correctness and invariants “by construction” vs at runtime. Since the field is nullable, the AST is not necessarily correct by construction, as the programmer may have forgotten to include a type when required. The correctness of compilers using such representations involves either checked or unchecked assertions where the type field is used to ensure that it is set appropriately.
The article continues with various strategies to avoid needing to defer this correctness checking to the runtime by providing various statically-checked alternatives.
Because there is a lot of additional stuff you may want to add to a node at the later stages of translation, not only the type field: you may also want a usage count, reference from usages, reference to the defining function, global/local value numbers, "can be an immediate in an instruction/requires load from constant pool" flags, the allocated register, the allocated spill slot, etc. Surely you don't put all of that backend-specific (or even single-pass specific) stuff into a supposedly generic AST node that your frontend produces?
This is not possible since this information is not available at all times. For example imagine C++ where a variable is typed with auto. Just after parsing you have an AST which doesn't yet include the real static type the variable has.
It’s an example of a classic tradeoff between enforcing correctness and invariants “by construction” vs at runtime. Since the field is nullable, the AST is not necessarily correct by construction, as the programmer may have forgotten to include a type when required. The correctness of compilers using such representations involves either checked or unchecked assertions where the type field is used to ensure that it is set appropriately.
The article continues with various strategies to avoid needing to defer this correctness checking to the runtime by providing various statically-checked alternatives.