You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, thanks for the work you're putting into this!
There are couple of places in the Go API where the type of a field is only known at runtime (eg. Page.Properties), so the field is typed as interface{} in Go. One approach that's used eg. by the protobuf runtime is to use an interface with a "dummy" method that uniquely identifies the implementors, which helps both IDEs/language servers to do autocompletion and the compiler to ensure that the code is correct.
Long overdue update on this: There were some changes in Notion API's version 2022-06-28 that allowed removing the blank interface for Page.Properties (ref). But because Notion reverted that change (ref) I also reverted (ref).
Long story short: This issue is still relevant, and indeed, I agree interface{} should be avoided/removed. I'm not 100% sure yet about the "dummy" method interface though. In the meantime, I'm afraid users of this client will have to do some type assertion/manual labour to figure out what types to use.
First of all, thanks for the work you're putting into this!
There are couple of places in the Go API where the type of a field is only known at runtime (eg.
Page.Properties
), so the field is typed asinterface{}
in Go. One approach that's used eg. by the protobuf runtime is to use an interface with a "dummy" method that uniquely identifies the implementors, which helps both IDEs/language servers to do autocompletion and the compiler to ensure that the code is correct.A simple example
let me know if you think this approach makes sense, and I can try to send a PR.
The text was updated successfully, but these errors were encountered: