Type alias with inherited type parameter constraints
Is there any way to do this? I want SVLTN to just be a short-name alias for SomeVeryLongTypeName, and I want it to have the same parameter types, but I don't want to have to specify all of them explicitly.
What I would like more is:
Anyone?
6 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
if both of the types are yours, this is a horrible idea for maintainability, you would have 2 things pointing to the same thing. long variable names are fine
if it's coming from outside, then you can just import as, like sno2 mentions
i disagree that it's a "horrible idea for maintainability", why would you say that?
because it makes the maintainer need to know that A = B and B = B when they could just know that B = B and settle with that. adds another layer of knowledge that doesn't need to exist
🤷♂️ i guess it all depends. this is something that borders on a DSL, and the "real alias" reads like an acronym rather than "SVLTN", but point taken!
You can also do sno's aliasing in a re-export declaration:
export type { Long as L } from "./long.ts.";
Or simply an export declaration export { Long as L };