Within my class, I have included a Proxy which is structured as follows:
export class Row<T extends ModelItems> {
private _row: T = <T>{}
public constructor(rowItems?: T) {
if (rowItems) { this._row = rowItems }
return new Proxy(this, {
get: function (target, prop) {
return (<any>target)[prop] || target._row[prop] || ''
}
/* set(): snipped */
}
}
My issue arises when using the code snippet below:
interface User {
id: number
first: string
last: string
username: string
}
let row = new Row<User>({/* My object */})
I am looking for a way to display items defined in the User
interface when typing row
. Currently, only the methods and properties at the root level of the object are suggested.
I attempted the following approach:
export interface Row<T extends ModelItems> {
[key: string]: T
}
However, this solution does not seem to be effective apart from highlighting that my methods are not properly defined.