4 ms·
Some languages allow to define type alias, name of this type can be self-explanatory: type FullName = string; function combineName(first: string, last: str
by geakstr 1y ago
Some languages allow to define type alias, name of this type can be self-explanatory:
type FullName = string;
function combineName(first: string, last: string): FullName;
Also documentation comment for function is what specifically solves this - describes what function does and returns.
- hyperhello 1y agoNeither really addresses the issue. Making a type for a single kind of string seems like an abuse of types just to shoehorn the documentation in. Documentation can be used directly of course, but that moots all of this -- just document? Yeah, but naming the variable is super quick compared to either.
- oneoverten 1y agoVariable names is just documentation. Having types that can assert some condition on the underlying value is not even comparable to "having a named return variable". (just document? just name variables?) You don't care about what the name of the returned value is, you care about what *it is*.
- avandekleut 1y agoTypescript nukes primitive aliases like this sadly. Intellisense will just infer it as "string".