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 ArticleComment 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 ArticleComment by Adam Arold on Kotlin - versus
@Kratos it is a shorthand, and I think they did it this way for Java compatibility reasons.
View ArticleComment 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 ArticleComment 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 ArticleComment 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 ArticleComment 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 ArticleComment 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 ArticleComment 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 ArticleSession.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 ArticlePoint 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 ArticleCan'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 ArticleHow 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 ArticleHow 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 ArticleHow 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 ArticleHow 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 ArticleIs 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 ArticleHow 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 ArticleHow 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 ArticleHow 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