hoshi
hoshi
TTCTheo's Typesafe Cult
Created by hoshi on 8/3/2024 in #questions
How to test nextjs app against dockerized postgres container (Vercel)
I have a ct3a deployed to Vercel's free tier. I was wondering if it's possible to spin up a postgres container in Vercel's CI and run some tests before creating deployment previews/etc.
4 replies
TTCTheo's Typesafe Cult
Created by hoshi on 9/30/2022 in #questions
Typescript Function to make specific nested keys non nullable?
Does anyone know of a Typescript Function to make a bunch of provided nested keys non-nullable? Sometimes I want to reuse a GQL type but want to remove a bunch of nulls/undefined from nested keys. E.g.
type User = {
id: number | null | undefined;
address:
| {
unitNumber: string | null;
streetNumber: string | null;
street: string | null;
metadata: {
nearPark: boolean | null;
} | null;
}
| null
| undefined;
};

type ValidatedUser = NonNullableByPath<
User,
"id" | "address.streetNumber" | "address.street" | "address.metadata"
>;
type User = {
id: number | null | undefined;
address:
| {
unitNumber: string | null;
streetNumber: string | null;
street: string | null;
metadata: {
nearPark: boolean | null;
} | null;
}
| null
| undefined;
};

type ValidatedUser = NonNullableByPath<
User,
"id" | "address.streetNumber" | "address.street" | "address.metadata"
>;
I came up with this so far but I wouldn't be surprised if someone already knows of a better solution: https://www.typescriptlang.org/play?#code/C4TwDgpgBA4hwCUD2TgAUCGwAWAeAKgHxQC8U+UEAHsBAHYAmAzlAAYAkA3gJZ0BmEAE5RkqAL4A6Lk2CDeAczGsoAfhEpgUAFxQ6EAG5CA3AChQkWPAByEGRAaYcAdW45RwXCajkANF-WolDT0zFAycnTyJsRkFNS0jCwcnO6SXLwCwjZ2DEqqUNm0DNq6BsYmJgD0lQUQ9lDASFDcALZggkiGzZpMTa5Q2BiMADa2UEhgwNxIdBjDUADWECBMKlU1TkgArsPFAEbQ8oIQWM18UI7YLPEhLIX2lyy8dhjFSOfhCuu19Y1Qxy1OtAWhAWgdBCx3hcsNgGoNNBhjlAMFAAERMLZ7AC0YBhqIkUAAohJ5ATuOdLqQ0RhUVAAD7UiR7WncFjtTrcBj2Hz-UFA6moszgaBWGZWHbDDB7UYAIRAlwIPMpN0SYVkChiUE4-gA2gBpZp0RbLKH4AC6OgNKtCl383jUoro4uGkulEAI+rNhDtJStwVVcEQGgVl293ntBTFEqlsvlMNwjudrtGHr1Xp5gfuDhhLjcGlwlx5esIYfDOnwntMYlMQosAFUmEIqdrvJydHQtmCmwyOy76VAtowIHxePZTN5XgxjkwmFofQyW+Gl4PXOKu4IdJ9Iv3e8Nx0vw+E6sA1+DN+rtz2JfuD2rjvBzxF5Dvrz6lyDgK8sBgdIvb949ERTBBAWHQ9hQUYhhfF0bwPMRoL3N8oDEeddAlVDBy5Ec9AYKsa3MaAADU5k5LB7AbJsyETaM3TlBV-AowQ-G8VFOVpBlUUnacmAkI9rE7cF2OpBgp1sHi+OAITOJE7iJA-L9P0FQhTCAA Also we need a Typescript tag 😉
13 replies