Here is some code snippet that exhibits a specific issue:
type FooType = 'Bar';
abstract class Meow<T extends FooType> {
baz: T = 'Bar';
}
An error is triggered stating
Type '"Bar"' is not assignable to type 'T'
.
The confusion arises because if baz
has the specified type T
, why wouldn't it allow any value from FooType
?
What adjustments are needed to enable the class property baz
to accept any value in line with FooType
, as well as other string literals that potential sub-classes might desire?