-
Notifications
You must be signed in to change notification settings - Fork 334
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor what needs overriding when a component needs a specific type…
… for $module Switching to generic typing and a getter makes components that need a custom type for $module require smaller changes with only: - a comment - a method override Smaller impact and it systemises the text of the error message as well. On top of that, TypeScript was not complaining if a component needing custom type didn't redefine `checkModuleType`, only our test for a custom message caught that issue. The price of this refactoring is a heavy line of casting in `checkModuleType` to help TypeScript follow the dynamic type for the moduleType needing to be defined both as a type and as an actual value for use with `instanceof`. Given the simple code of the function, I think we're fine here, especially as we're reducing the risk of human errors by having a less heavy method to override.
- Loading branch information
1 parent
4376e04
commit fa02f52
Showing
2 changed files
with
31 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters