This seems like it should be in the documentation, but it isn't.
I have a shape type.
type ThisIsMyShapeType = shape(
'some_prop' => bool,
);
How do I instantiate an object of this type ?
This seems like it should be in the documentation, but it isn't.
I have a shape type.
type ThisIsMyShapeType = shape(
'some_prop' => bool,
);
How do I instantiate an object of this type ?
You use the same
shapekeyword:In Hack, shapes use structural typing so you don't need to declare your variable is a
ThisIsMyShapeType-- the typechecker will verify that$xhas all of the right fields to match the type.There are quite a few examples in the official documentation.