Closed hynek closed 1 year ago
Looks good! One minor thing: It turns out you don't strictly need the TypeAlias
annotation. I was typing it out of habit (I like to be explicit about this so I can see at first glance if something is a module-level variable or a construct only used for type annotations). But Type checkers can also infer this (it doesn't do anything at runtime).
But since the audience for this documentation is not specifically Type Enjoyers (like me), you could shorten the example a bit by leaving it off. It type-checks as is and your users don't have to learn what a TypeAlias
is.
Right! Also, NewType
instead of Annotated should work too, no? I guess I’ll simplify Primary and make Secondary use NewType to cover both.
Yes, NewType
also works! I hadn't thought about that. I like Annotated
better because NewType
is a bit cumbersome to use (having to type the name twice). But probably good to document both options.
fixes #40, fixes #41
Anything to add, @trendels?