Allow type of "data" property to be set using generic type #135
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Right now there is no way to set the type of
file.dataexcept withas. In general,asin TypeScript conveys incomplete typings for external libraries or insufficient time to fix an issue with types. You want to reduceasin a code base as much as possible in order for it to be a red flag when it comes up. However, with I/O we tap outside of types and telling our code which shape a resulting object will have is necessary. Other libraries achieve this by simply exposing a generic type param on classes or methods like this:The advantage is that this conveys intent, that the typings are as clean as they can be. It would be great if you could add this as a third param to the types!
++ Yes. This would be quite helpful.
yse, I have this, It kind of bothers me
As I've encountered this limitation multiple times, I created a small wrapper for
gray-matterusingzodto actually validate front matter and get proper type inference, e.g.: