Given a Type:
type TestType = {
a?: string;
b?: number;
c?: boolean;
};
I want to create a class that implements TestType
with all its properties names where the types could be different.
If not, raise an error.
I've tried with Pick
, Required
, etc. without success.
Example (error):
/* Error, not all TestType properties are implemented */
class TestClass implements TestType {}
Example (correct):
class TestClass implemenets TestType {
a?: boolean; // Different type
b?: number; // Same type
c?: string; // Different type
}
Can this be achieved with Typescript?
Thanks!