I need to pick only two properties whose names are not yet defined from a type, and create a new type from there with one of these properties required and anoth
I'm hitting this wall since days now and I'm not sure anymore if I'm the problem or if typescript is broken... I defined a generic class with the generic extend
I am trying to create a generic type to make sure the first parameter to be a class. However, the factory function parameter cannot be replaced by a generic typ
I have following the code: const events = { a: ['event1' as const, 'event2' as const], b: ['event3' as const, 'event4' as const], }; class SomeClass<
I have a custom interface like this: interface Pointer<T> { id: string } id is a pointer to other data structures, but the id field doesn't contain inf
Given the following type: export type MyType = { a: boolean; b: number; } I want to create a type: export type Mapper<T> = { key: keyof T;
Assume that we have some class that has an important generic variable T and another class we have two fields, one wrapped, and one not: class Wrapper<V> {
TypeScript newbie here, having problems with Object.fromEntries. I'm trying to pares form and cast its values to something else. For example, given homogeneous
I'm trying to open a typescript method using generics. There is an object with methods (the comment indicated different types of function parameters) const emai
I'm trying to make a settings system for my desktop app. having a config that includes several settings like add_while_paused, min_chars, and startup_settings (
This is very much like my other question, but this time using classes instead of plain objects. class Error1 extends Error { constructor(message: string, pu
Suppose the following example class class X<T> { constructor(readonly t: Extract<'a' | 'b', T>) {} } The point is that the type function Extract
I would like to dynamically generate some tests, for that I have to call a method with the method name to be called and then all the test setup is done and the
Playground link I have these general definitions: type Module<P extends Payloads, C extends Children> = { payloads: P; children: C; }; type Child
I have a type: type Action<I extends unknown[], O> = (...args: I) => Promise<O>; and some test cases: // should be [boolean, s
I've been trying to make a type whose indexer has a return type which is based upon a string literal for the key. export enum Units { Enum = 'enum', Str
Is it possible to achieve the folowing in Typescript: I want the type of state.initial to be deduced as a tuple based on the input to the takeConfig. It would a
I was not able to find an answer to the question why function thisDoesNotWork causes an error. In contrast, function thisWorks transpiles the line anyArgs.whate
I'd like to write a function which gets a value from an object given an array of property keys. It would look something like this: function getValue<O, K ext
This class holds either a single Item or an array of items Item[], determined by a setting at runtime (this.config.isMultiple). How can I narrow down the class'