How can I create a type declaration for an external module and use a mapped type for this declaration? Currently, the module appears as:
declare module "deferred-regl"{
import { Regl } from 'regl'
type IDregl<T> = {
setRegl: (regl?: Regl) => void
queue: any[]
setQueue: (queuInput: any[]) => void
(): IDregl<Regl>
[K in keyof T]: () => <T[K]>
};
export default function defRegl(): IDregl<Regl>
}
The error is occurring at the
[K in keyof T]: () => <T[K]>
line with messages like:
Cannot find name 'K'. [2304]
Cannot find name 'keyof'. [2304]
I wish to extend the Regl type with additional properties and methods, while also wrapping existing keys on Regl with functions. Initially, I tried using an interface:
export interface IDregl extends Regl{
setRegl: (regl?: Regl) => void
queue: any[]
setQueue: (queuInput: any[]) => void
(): IDregl
}
However, I struggled with annotating the Regl properties as functions and eventually switched from using an interface to a type.