lisk-sdk
lisk-sdk copied to clipboard
Replace Interfaces with `type` , `type alias` & `intersection`
Description
Currently we have interfaces with similar elements. We can replace them using type, type alias & intersection feature.
Motivation
Elements are duplicated. We can simply use type alias for an existing type & merge similar types using intersection
Additional Information
- https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#type-aliases
- https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#differences-between-type-aliases-and-interfaces
Do you mean replace all interfaces with types or only in applicable scenarios?
For the above issue, you can solve it by extending the Keys interface e.g.
By extending an interface, we can reduce the duplication. In my humble opinion, this is not an interface issue but more of a design issue as you can still have duplication with type/type aliases as well.
-
Only in current file
-
Yes, code duplication could be avoided using
extending interface also. Not sure, if AuthAccount reallyextendsKeysfrom OOP perspective. Since they are not directly parent/child, hencetypeseems a better alternative. -
Using type alias (there is no duplication)
type RegisterMultisignatureParams = Keys
Also here framework/src/modules/reward/types.ts
Closing this issue for no activity