flowmotion
flowmotion
TTCTheo's Typesafe Cult
Created by flowmotion on 2/26/2025 in #questions
Create a TS function to deep call .toString() on all Date objects without type casting?
Hi, I was working on a function which should transform any instance of a specific object (for demo lets use the Date object) to a string. I wanted its signature to be like <T>(input: T) => Stringified<T> where Stringified<T> is the exact same type except the Date instaces are now string.
const withDate = {
name: 'somelist'
items: [
{id: '1', createdAt: new Date()},
{id: '2', createdAt: new Date()}
],
createdAt: new Date()
}
const withDate = {
name: 'somelist'
items: [
{id: '1', createdAt: new Date()},
{id: '2', createdAt: new Date()}
],
createdAt: new Date()
}
this would become:
const withStringDate = {
name: 'somelist'
items: [
{id: '1', createdAt: '1.1.2025'},
{id: '2', createdAt: '1.1.2025'}
],
createdAt: '1.1.2025'
}
const withStringDate = {
name: 'somelist'
items: [
{id: '1', createdAt: '1.1.2025'},
{id: '2', createdAt: '1.1.2025'}
],
createdAt: '1.1.2025'
}
I tried to do this, but all attempts i did, I had to use type casting with a seperate TS type to make sure it gave me the correct type. Is it possible to do this wihout casting and without using the any type?
3 replies
TTCTheo's Typesafe Cult
Created by flowmotion on 12/30/2023 in #questions
Deploying t3 on netlify?
I read the documentation regarding netlify deployment, but it seems there might be something missing, because just seting up netlify as in the docs doesn't work. Wont I need to somehow create netlify serverless functions that run the trpc procedures?
4 replies