Cobain
Cobain
Explore posts from servers
Aarktype
Created by Cobain on 10/9/2024 in #questions
Function which receives a arktype's 'type'
I understand, thanks!
13 replies
Aarktype
Created by Cobain on 10/9/2024 in #questions
Function which receives a arktype's 'type'
Yeah typescript with generic types in functions has never worked well
13 replies
Aarktype
Created by Cobain on 10/9/2024 in #questions
Function which receives a arktype's 'type'
if I don't cast it, the parsedResponse has this type: finalizeDistillation<T, _distill<T, { endpoint: "out"; }>>
13 replies
Aarktype
Created by Cobain on 10/9/2024 in #questions
Function which receives a arktype's 'type'
So casting here is ok
13 replies
Aarktype
Created by Cobain on 10/9/2024 in #questions
Function which receives a arktype's 'type'
async rateLimitedCallApi<T>(url: string, schema: Type<T>): Promise<T> {
await this.rate_limiter.acquire();

const response = await fetch(url, this.request_data);
if (!response.ok) {
throw Error(`Invalid request: ${response}`);
}

const json = await response.json();
const parsedResponse = schema(json);

if (parsedResponse instanceof type.errors) throw parsedResponse;

return parsedResponse as T;
}
async rateLimitedCallApi<T>(url: string, schema: Type<T>): Promise<T> {
await this.rate_limiter.acquire();

const response = await fetch(url, this.request_data);
if (!response.ok) {
throw Error(`Invalid request: ${response}`);
}

const json = await response.json();
const parsedResponse = schema(json);

if (parsedResponse instanceof type.errors) throw parsedResponse;

return parsedResponse as T;
}
13 replies
Aarktype
Created by Cobain on 9/20/2024 in #questions
Use native ts type
Right I was doing that but and by default TS considered it string, doing what Dimava suggested makes this union of string literals that I wanted, thanks!
5 replies
HHono
Created by Cobain on 9/9/2024 in #help
Multiple platforms, same project
I might as well use turborepo for this
7 replies
HHono
Created by Cobain on 9/9/2024 in #help
Multiple platforms, same project
I hope is not confusing lol
7 replies
HHono
Created by Cobain on 9/9/2024 in #help
Multiple platforms, same project
No description
7 replies
Aarktype
Created by Cobain on 9/6/2024 in #questions
Represent the File class
right thanks
23 replies
HHono
Created by Cobain on 9/9/2024 in #help
Multiple platforms, same project
Ok thanks will try it
7 replies
Aarktype
Created by Cobain on 9/6/2024 in #questions
Represent the File class
great thanks, also if i have to validate an object which has lots of keys, but i only want to validate it has the ones im interested in, is there a way to do like a "partial validation"?
23 replies
Aarktype
Created by Cobain on 9/6/2024 in #questions
Represent the File class
Ok I ended doing that. When I access later a type declared in the scope doing types.example, the typing of example doesn't only include itself but all the other scope data, but will only validate the first part right? here:
const Coin: Type<{
id: string;
symbol: string;
description?: string;
image_url?: string.url;
}, {
id: string;
coin: {
id: string;
symbol: string;
description?: string;
image_url?: string.url;
};
const Coin: Type<{
id: string;
symbol: string;
description?: string;
image_url?: string.url;
}, {
id: string;
coin: {
id: string;
symbol: string;
description?: string;
image_url?: string.url;
};
23 replies
Aarktype
Created by Cobain on 9/6/2024 in #questions
Represent the File class
Ok, thanks for the quick response
23 replies
Aarktype
Created by Cobain on 9/6/2024 in #questions
Represent the File class
Right ok, yeah probably gonna think about the performance side as the main reason i'm trying to switch from Zod is this
23 replies
Aarktype
Created by Cobain on 9/6/2024 in #questions
Represent the File class
Another unrelated question, is there a way to reference to another type's attributes when declaring a new type? something like this:
/** The Token entity */
export const Token = type({
id: "string",
symbol: "string",
"description?": "string",
tickers: Ticker.array(),
"image_url?": "string.url"
})

/** A candle of a coin in a point in time */
export const Candle = type({
coin_id: Token.id
})
/** The Token entity */
export const Token = type({
id: "string",
symbol: "string",
"description?": "string",
tickers: Ticker.array(),
"image_url?": "string.url"
})

/** A candle of a coin in a point in time */
export const Candle = type({
coin_id: Token.id
})
23 replies
Aarktype
Created by Cobain on 9/6/2024 in #questions
Represent the File class
Thanks!
23 replies
DTDrizzle Team
Created by Cobain on 4/25/2024 in #help
Struggling with subqueries
thanks for the help!
3 replies
TTCTheo's Typesafe Cult
Created by Cobain on 1/25/2024 in #questions
How to monitor and analyze web app and api usage?
Oh haven't seen it, thanks!
4 replies
TTCTheo's Typesafe Cult
Created by Cobain on 11/19/2023 in #questions
JSON Parsing, TRPC Client error
Totally random
6 replies