MattIPv4
MattIPv4
CDCloudflare Developers
Created by JesterIruka on 4/17/2025 in #general-help
Unstable DNS in Brazil (again)
If it goes down again, a traceroute might be more useful to run to see where the traffic is being dropped. If you can gather a bunch of traceroutes showing a repeated issue, fire them off to whoever it points to (I suspect the ISP)
38 replies
ZZod
Created by MattIPv4 on 4/14/2025 in #questions
MattIPv4 - :WaveDoggo: I think this might be a ...
So I wasn't far off with what I had before manually setting the type for just the src, just needed to set the type manually for the entire schema
26 replies
ZZod
Created by MattIPv4 on 4/14/2025 in #questions
MattIPv4 - :WaveDoggo: I think this might be a ...
Ahah!
type ImagePng = (typeof import("*.png"))["default"];
type ImageJpg = (typeof import("*.jpg"))["default"];
type ImageJpeg = (typeof import("*.jpeg"))["default"];
type ImageImport = ImagePng | ImageJpg | ImageJpeg;

// Manually set the type of the schema to avoid TS inferring `ImageImport` and `Position`
// We want `ImageImport` to retain its original type using `import` calls
type ZodImageObject = z.ZodObject<{
src: z.ZodType<ImageImport>;
alt: z.ZodString;
}>;

export const ambassadorImageSchema: ZodImageObject = z.object({
src: z.custom<ImageImport>(),
alt: z.string(),
});
type ImagePng = (typeof import("*.png"))["default"];
type ImageJpg = (typeof import("*.jpg"))["default"];
type ImageJpeg = (typeof import("*.jpeg"))["default"];
type ImageImport = ImagePng | ImageJpg | ImageJpeg;

// Manually set the type of the schema to avoid TS inferring `ImageImport` and `Position`
// We want `ImageImport` to retain its original type using `import` calls
type ZodImageObject = z.ZodObject<{
src: z.ZodType<ImageImport>;
alt: z.ZodString;
}>;

export const ambassadorImageSchema: ZodImageObject = z.object({
src: z.custom<ImageImport>(),
alt: z.string(),
});
Results in:
import * as __jpeg from '*.jpeg';
import * as __jpg from '*.jpg';
import * as __png from '*.png';

type ImagePng = (typeof __png)["default"];
type ImageJpg = (typeof __jpg)["default"];
type ImageJpeg = (typeof __jpeg)["default"];
type ImageImport = ImagePng | ImageJpg | ImageJpeg;
type ZodImageObject = z.ZodObject<{
src: z.ZodType<ImageImport>;
alt: z.ZodString;
position: z.ZodOptional<z.ZodEffects<z.ZodString, Position>>;
}>;
declare const ambassadorImageSchema: ZodImageObject;
import * as __jpeg from '*.jpeg';
import * as __jpg from '*.jpg';
import * as __png from '*.png';

type ImagePng = (typeof __png)["default"];
type ImageJpg = (typeof __jpg)["default"];
type ImageJpeg = (typeof __jpeg)["default"];
type ImageImport = ImagePng | ImageJpg | ImageJpeg;
type ZodImageObject = z.ZodObject<{
src: z.ZodType<ImageImport>;
alt: z.ZodString;
position: z.ZodOptional<z.ZodEffects<z.ZodString, Position>>;
}>;
declare const ambassadorImageSchema: ZodImageObject;
26 replies
ZZod
Created by MattIPv4 on 4/14/2025 in #questions
MattIPv4 - :WaveDoggo: I think this might be a ...
But really, it could be anything, hence wanting to have this use those import()s correctly so that it'll just use whatever type the user of the library has setup in their module augmentations
26 replies
ZZod
Created by MattIPv4 on 4/14/2025 in #questions
MattIPv4 - :WaveDoggo: I think this might be a ...
One of our usages uses plain Webpack and returns a string for the file path, the other is Next.js which'll return an object with the file path, width, height, etc.
26 replies
ZZod
Created by MattIPv4 on 4/14/2025 in #questions
MattIPv4 - :WaveDoggo: I think this might be a ...
What that bundler is and what it returns for those imports is up to the user of this library
26 replies
ZZod
Created by MattIPv4 on 4/14/2025 in #questions
MattIPv4 - :WaveDoggo: I think this might be a ...
And so a bundler of some type is going to process them
26 replies
ZZod
Created by MattIPv4 on 4/14/2025 in #questions
MattIPv4 - :WaveDoggo: I think this might be a ...
They are images being imported
26 replies