Quantcast
Channel: User Adam Arold - Stack Overflow
Browsing all 39 articles
Browse latest View live

Comment by Adam Arold on How to augment 3rd party modules with extra...

The whole point is to have TE because it helps with VS Code auto-importing (eg: when I type TE it will automatically give me the option to import TE. So i need it to be an actual object. The only...

View Article



Comment by Adam Arold on In NestJs, how to inject a service based on its...

How can I choose which implementation to use if I have more? I don't want to put it in my service class (PayementService here) but rather configure it outside of the use site.

View Article

Comment by Adam Arold on Kotlin - versus

@Kratos it is a shorthand, and I think they did it this way for Java compatibility reasons.

View Article

Comment by Adam Arold on Creating zod schema for generic interface

Fun fact: I was trying to do the exact same thing as you when I came to this google result.

View Article

Comment by Adam Arold on How to constrain a type parameter as a subset of...

I fixed my question. So I need generics because this will be used in a factory function, and this type expresses all the services that can be injected into my business functions. I want those places to...

View Article


Comment by Adam Arold on How to configure Typescript to infer discriminated...

Wow, this is awesome. I was thinking that this was due to some Typescript misconfiguration issue. Thanks for this!

View Article

Comment by Adam Arold on How to convert a nested data structure to an...

fromJS has only 1 type parameter and I tried it (see my question).

View Article

Comment by Adam Arold on How to convert a nested data structure to an...

This is not a solution. I have my types that I can't change. I need a solution that uses my types.

View Article


Comment by Adam Arold on How to produce accurate UNIX timestamps regardless...

What's NTP? Also...it seems that the server knows the time, but it is in a different timezone. I just learned that Date has a getTimezoneOffset() function that will tell me the offset to UTC. I never...

View Article


Session.flash is not cleared after Session.get when using Remix

I'm using Session.flash do display a flash message to the user, and it seems that the flash message persists even after calling Session.get. In my case I:Redirect with a flash message after a...

View Article

Point of using Dependency Injection (and for that matter an IoC Container) in...

I read ESR's essay named "How to become a hacker?" several years ago (link can be found in my profile) and Eric suggested learning LISP. Well I'm learning LISP for quite a while and I like it so much...

View Article

Can't connect to Kafka broker using Spring Boot

I have a standard Spring Boot setup with some Kafka configuration that has a @Listener in it:@SpringBootApplicationpublic class MyApp { public static void main(String[] args) {...

View Article

How can I define a mapped type that places an constraint on the value based...

I have the following types (simplified for brewity):type Wrapper<T extends string> = { value: T}type Mapping = { [T in string]: Wrapper<T>}My goal with this is to constrain the possible...

View Article


How to read the value of a generic type parameter in Typescript?

I have an interface that represents an event and it can have a type that I use for discriminated unions:export type Event<T extends string> = { /** * The type of the event.. */ type: T;};This...

View Article

How to use the captor function with jest-mock-extended?

I'm trying to write a test where I'd like to capture the argument of a function. If I understand correctly I'd have to use captor() for this but I can't dig up any examples of how to do so. Simply...

View Article


How is this dynamic type lookup feature of Typescript called?

I've just looked into the source code (or rather the type headers) of discord.js and I found that it looks up the possible key-type combinations from an interface in this function:public on<K...

View Article

Is there a way to produce a type that combines field types from a tuple of...

I have a structure that describes a specific configuration value:import * as z from 'zod';export type ConfigurationProperty<V> = { type: string; // ... schema: z.Schema<V>; // Zod...

View Article


How to reuse a jest test for multiple impementations of the same interface?

I have a test:describe("Given a config repository", () => { let target: ConfigRepository; beforeEach(() => { target = InMemoryConfigRepository(); }); test("When creating a new config, Then it is...

View Article

How to get access to a variable in a ReaderTaskEither from an error handling...

I have this code where I use ReaderTaskEither:export const AddUserToTeam = ({ userId, teamId }: AddUserToTeamDto) => { return pipe( // 👇 Uses ReaderTaskEither Do, bind("deps", () =>...

View Article

How to write a Kotlinesque extension function in Typescript?

I Kotlin if I have an interface like this:interface User { val name: String val email: String}I can write an extension function like this anywhere in the code:fun User.toUserDto(): UserDto { TODO()}In...

View Article
Browsing all 39 articles
Browse latest View live


Latest Images