function validate(user) {
if (typeof user !== "object" || user === null)
throw new Error("Expected user to be User");
if (typeof user.name !== "string")
throw new Error("Expected user.name to be a string");
if (typeof user.id !== "number" || user.id < 10)
throw new Error("Expected user.id to be a number, to be greater than 10");
if (typeof user.obj !== "object" || user.obj === null)
throw new Error("Expected user.obj to be an object");
if (typeof user.obj["a-special-key"] !== "string")
throw new Error("Expected user.obj.a-special-key to be a string");
}
validate({
name: "abc",
id: 4,
obj: {
'a-special-key': "test"
}
});
Additional context
Add any other context about the problem here.
Describe the bug Properties are accessed using PropertyAccessExpression, but must use ElementAccessExpression that contain special characters.
Playground link playground
Expected behavior
Additional context Add any other context about the problem here.