D
Deno

help

Dynamic interfaces

KKay7/28/2023
Is it possible to have like an interface that has a type entry and when it is a string for example the interface has a maxlength and minlength or when its a number it has a max and min?
NNeTT7/28/2023
Why not use two separate interfaces
KKay7/28/2023
cous i have a function that accepts an entry wich can be multiple. but are all based on one. i saw this once where if you set the type to string you can set a default ut if you set the type to int you cans et a min and max so for example
interface {
type: "string" | "number" | "somethingElse"
name: string
description: string
min: number // This entry would only exist if type is number
max: number // This entry would only exist if type is number
default: string // This entry would only exist if type is string
}
interface {
type: "string" | "number" | "somethingElse"
name: string
description: string
min: number // This entry would only exist if type is number
max: number // This entry would only exist if type is number
default: string // This entry would only exist if type is string
}
SSyrupThinker7/28/2023
Something like this?
type XyzBase = { name: string; description: string };
type Xyz =
& XyzBase
& (
| { type: "string"; maxlength: number; minlength: number; default: string }
| { type: "number"; min: number; max: number }
| { type: "somethingElse" }
);
type XyzBase = { name: string; description: string };
type Xyz =
& XyzBase
& (
| { type: "string"; maxlength: number; minlength: number; default: string }
| { type: "number"; min: number; max: number }
| { type: "somethingElse" }
);
KKay7/29/2023
yhea thx :)

Looking for more? Join the community!

Recommended Posts
Disable / Replace Loading FaviconHaven't found anything regarding it and likely is not possible, however I thought I might as well sDeno test Leaking resourcesHi i currently try to get used to deno.test but Deno.readTextFile makes the test end in the followinDeno.Command arg with an asterisk?I am trying to execute a shell command from Deno, where one of the command args contains an asterisk`deno compile` in Nix results in `deno repl` starting instead of actual programI wrote following Nix impure derivation for my Deno app: ```nix packages.api = pkgs.stdenv.mkDerivat`@sentry/node` is throwing an export error on Deno DeployHello, this is my first time using Deno. I was trying to use the `@sentry/node` client on deploy, basync mapIs there anyway using the stdlib to map from one array to another array, with the work being done coHTTP 206 + HTML5 video streaming with Freshhow do I implement an endpoint to stream a video to a HTML video player using HTTP 206 in Fresh? Herrusty_v8 extracting stack trace when a promise rejectsHi, i am trying to get the stack trace and print it out when a promise rejects. ```rust if promise.sNode-API related segmentation faultAny idea what could be causing this crash? I'm using Node-API and the same module is working fine injwt generation and verificationjwt verification(using JOSE package) is working perfectly only when i have set b64 parameter insideHosting a node project on deploy?Can we host a NodeJS project using Deno Deploy or do we need some conversion first?anyone have a modern container workflow for the serverless framework?I was able to find code that executed at one point in time. It no longer does. I’d really like to i