Is there a way to implement an item with its type derived from the arguments of a class constructor in TypeScript? If not, what is the reason behind it?
class Toolbar {
constructor(adit: string, options: { container: stirng }) { }
}
type ModudleSetting<T extends object = {}> = [
{ new(adit: string, options: T): any },
T,
]
function registerMoudle(moduleSetting: ModudleSetting) {
}
registerMoudle([Toolbar, { a: 'asdasd' }])
I was expecting that the type of { a: 'asdasd' }
would be { container: stirng }
, but unfortunately it is not.