JustSomeDev
JustSomeDev
Explore posts from servers
TTCTheo's Typesafe Cult
Created by JustSomeDev on 12/2/2024 in #questions
Is there a way to use varadic arguments to recurse a type?
So like pluck({a: {b: 2}}, "a", "b") will be type safe and can somehow store the state of that type?
6 replies
XXata
Created by JustSomeDev on 11/27/2024 in #help
New Xata dedicated cluster version string?
Hey! Doing the updates of pgversions.com on behalf of Neon, asked here previously about the dedicated cluster version string, has this bumped up because of the recent minor releases at all?
3 replies
TTCTheo's Typesafe Cult
Created by JustSomeDev on 11/16/2024 in #questions
RFC: Does this syntax make sense?
Hey! I am writing a RPC solution in TS (that goes out to a lot of other languages), and not really sure what channel this should go in (it is a question, but a question asking for feedback), but I would really like comments on how I wish to handle situations where you might have an atomic set of functions where one result can go into another (batching can also be done this way whilst sharing the transaction). How do people feel about a syntax like this?
const [iban, paymentId] = client.atomic((client, { variable, pluck }) => {
// Defines a variable to store the IBAN. Note that this is syntactic sugar for what will happen
// during the request.
const iban = variable<string>("iban");

// Defines the array of requests the server must process. This is all bundled up and sent as a
// single request.
return [
// Firstly, we will store something in the array by getting an item, plucking a key, and then
// storing the variable. The server gets the pluck info, so it can optimise here if it wishes.
// No requirement, though.
iban.store(pluck(client.charities.getByName("AKT"), "iban")),

// Now say we want to add that IBAN to a list. This would typically require 2 API calls, but we
// have the variable here (it NEEDS to be set first). Lets use that to add it to the list. Note
// that this is atomic, and using the database transaction hook on the backend (or commit/rollback
// hooks).
client.payments.makeIbanPayment(iban, 100),
] as const;
});
const [iban, paymentId] = client.atomic((client, { variable, pluck }) => {
// Defines a variable to store the IBAN. Note that this is syntactic sugar for what will happen
// during the request.
const iban = variable<string>("iban");

// Defines the array of requests the server must process. This is all bundled up and sent as a
// single request.
return [
// Firstly, we will store something in the array by getting an item, plucking a key, and then
// storing the variable. The server gets the pluck info, so it can optimise here if it wishes.
// No requirement, though.
iban.store(pluck(client.charities.getByName("AKT"), "iban")),

// Now say we want to add that IBAN to a list. This would typically require 2 API calls, but we
// have the variable here (it NEEDS to be set first). Lets use that to add it to the list. Note
// that this is atomic, and using the database transaction hook on the backend (or commit/rollback
// hooks).
client.payments.makeIbanPayment(iban, 100),
] as const;
});
1 replies
XXata
Created by JustSomeDev on 10/18/2024 in #help
Xata dedicated instance version string
Hey, I am a contractor representing Neon. We recently shipped https://pgversions.com/ and we put the shared instance pg version string as the one there We saw this comment on YC -> https://news.ycombinator.com/item?id=41878149 and we were wondering if someone could send the connection string for a dedicated instance please. Thanks!
6 replies
TTCTheo's Typesafe Cult
Created by JustSomeDev on 5/13/2024 in #questions
TypeScript Compiler API: Recursively resolve type
I am struggling to recursively resolve types with the TypeScript compiler API. Say I have for example an application containing the following type:
import z from "zod";

export const schema = z.boolean();

type MyAwesomeInput = z.infer<typeof schema>;
import z from "zod";

export const schema = z.boolean();

type MyAwesomeInput = z.infer<typeof schema>;
and I load it into a program and get the source file. How do I recursively resolve the type of MyAwesomeInput (I presume s.statements[2].type) to the TS type please? I notice VS Code does this, so I presume it is possible.
2 replies