In my current project, I am working on creating a declaration file for the quadstore library. This library has a class that requires a constructor parameter called contextKey
. The value of this parameter determines the name of a field on method arguments. To put it simply, in Typescript terms, it would look something like this:
interface MethodArg {
a: string;
b: string;
<<The property name here depends on the value of contextKey>>: string;
}
class A {
constructor(options?: {contextKey: string}) {}
fn(arg: MethodArg) {...}
}
I am currently exploring how to declare the type of MethodArg
so that its third property's name is dependent on the value provided to the class constructor. Is it even possible to achieve this in a declaration file?