Reputation: 101
I have a problem about type manipulation
class A {}
class B extends A {}
class C extends A {}
function exampleFn1<T extends Record<string, A>>( t: T ) {
for( const v of Object.values( t ) )
new v(); // TS2351: This expression is not constructable.
// Type 'A' has no construct signatures.
}
function exampleFn2<T extends Record<string, typeof A>>( t: T ) {
for( const v of Object.values( t ) )
new v(); // ok
}
Although there is no error by the second method, I want to get A
instead of typeof A
, how can I do
type A = typeof Example;
type B = RemoveTypeof<A>; // Expect type B = Example
Upvotes: 1
Views: 880