The following code will produce the "cannot read property of null" JS error:
Serializer.addProperty("question", { name: "prop1", choices: (obj: Base) => {
return obj.getType() === "text" ? [1, 2, 3] : [4, 5, 6];
} });
const survey = new SurveyModel();
survey.fromJSON({
elements: [
{ type: "text", name: "q1", prop1: 2 },
{ type: "checkbox", name: "q2", prop1: 5 }
]
}, { validatePropertyValues: true });