I am in the process of developing a new augmented, generic interface that is based on an existing interface. The original interface sets out the properties that the object will possess (root
). The enhanced type should also have these properties, but instead of any
, I need a more intricate object. It's important to note that the interface IStyleObj
is utilized within a generic class, where the generic type is supplied to the generic interface.
During my experiments, I encountered the following errors which I am struggling to resolve:
"IStyleObj<T>"
'T' is declared but its value is never read.ts(6133)
"Key in keyof"
A computed property name must be of type 'string', 'number', 'symbol', or 'any'.ts(2464)
Member '[K in keyof' implicitly has an 'any' type.ts(7008)
"... T"
Cannot find name 'T'.ts(2304)
"class: any"
'any' only refers to a type, but is being used as a value here.ts(2693)
Here is my current code snippet:
// Child.ts
interface IStyles {
root?: any
}
// Base.ts
interface IStyleObj<T> {
[K in keyof T]: {
class: any
style: any
}
}
export default class Base<IStyles = {}> {
get styles (): IStyleObj<IStyles> {
// ...
}
}