D
Deno

help

Type alias with inherited type parameter constraints

Aabi6/17/2023
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.
type SomeVeryLongTypeName<A extends ..., B extends ..., ...> = ...
type SVLTN<A extends ..., B extends ..., ...> = SomeVeryLongTypeName<A, B, ...>
type SomeVeryLongTypeName<A extends ..., B extends ..., ...> = ...
type SVLTN<A extends ..., B extends ..., ...> = SomeVeryLongTypeName<A, B, ...>
What I would like more is:
type SVLTN = SomeVeryLongTypeName<???>
type SVLTN = SomeVeryLongTypeName<???>
Anyone?
UUUnknown User6/19/2023
2 Messages Not Public
Sign In & Join Server To View
TTheYuriG6/19/2023
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
Aabi6/19/2023
i disagree that it's a "horrible idea for maintainability", why would you say that?
TTheYuriG6/19/2023
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
Aabi6/19/2023
šŸ¤·ā€ā™‚ļø 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!
AAapoAlas6/19/2023
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 };

Looking for more? Join the community!

Recommended Posts
Fresh: global stateIs it possible to have a global state that can be accessed from anywhere? Currently I'm passing the Run Deno on Linux without /proc mountedI have a few automatic scripts using deno to run stuff, and wanted to migrate them to another MachinReasons to choose Node.jsI've been tasked to write a list of pros/cons of Deno in comparison to Node.js. I am quite honestly Reejs not working on Deno v1.34```js deno run -A npm:reejs [INFO] Saving important data... [TIP] If the error indeno.land published the same GitHub tag twicehttps://deno.land/x/smee_client_unofficial@v1.2.3 Could someone please just delete the older one?Uncaught (in promise) eof for websocket/root/.pm2/logs/twitter-follow-checker-error.log last 15 lines: 0|twitter_ | Deno hangs on errorWhy does Deno hang when XML.parse throws an error? ``` let text = '<xml><xbrli:xbrl><hi>Hello</hi><[SOLVED] deno.lock keeps getting populated with dependencies I don't needI have tried to use a syntax highlighter before and have since removed it from my project, but everyWhat a method prefixed with `#` means?This is perhaps the stupidest question ever. But I often see method with names prefixed with a `#`Logger names and prefixesIs there any obvious way on how to configure std/log so that loggers named `my-prefix/foo/bar` and `Deno and `npm:mongodb` problem with `node:`?``` āÆ deno check --reload main.ts error: Relative import path "net" not prefixed with / or ./ or ../DiscordJS "Error: Not implemented: ClientRequest.options.createConnection"```ts import { GatewayDispatchEvents, GatewayIntentBits, InteractionType, MessageFlags, Client } froUsing Superagent in Deno?Has anyone managed to make Superagent work nicely in Deno? ``` _ { type: "error", message: "BroOak ā€“ ctx.assert with custom response headersAm I doing this wrong? No extra custom headers are being set in the response as far as I can see in npm:undici doesn't workhttps://github.com/denoland/deno/issues/16710 Marked as resolved by this issue but does not work in Abusing prototype CryptoKey in `node:crypto`Is there any way that I can set the prototype of an object to specifically `CryptoKey` as defined byUncaught (in promise) TypeError: cannot read headers: request closedWhat is this? How to fix it?Async OP that returns value instead of promiseIn `deno_runtime` is possible to have async op that returns the resolved value instead of promise? K