-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve type narrowing and error handling #1073
Commits on Nov 19, 2024
-
Add a custom error class for errors that aren't user error and can be considered a bug in the code. For now I've scoped this to ListResources, but a similar approach can be adopted for other components too.
Configuration menu - View commit details
-
Copy full SHA for 84470e4 - Browse repository at this point
Copy the full SHA 84470e4View commit details -
Instead of indirectly inferring this from presence of a lastUpdated value for the first group.
Configuration menu - View commit details
-
Copy full SHA for c175886 - Browse repository at this point
Copy the full SHA c175886View commit details -
Configuration menu - View commit details
-
Copy full SHA for 9fab60d - Browse repository at this point
Copy the full SHA 9fab60dView commit details -
This reduces the amount of optional properties and need for scattered type narrowing downstream. Some restructuring of the code was necessary for proper type narrowing. This includes changing the switch/case to if/else which allows redefining variables with the same name in each block.
Configuration menu - View commit details
-
Copy full SHA for c1096d4 - Browse repository at this point
Copy the full SHA c1096d4View commit details -
Add type for versioned resource
This reduces the amount of optional properties and need for scattered type narrowing downstream.
Configuration menu - View commit details
-
Copy full SHA for 950c70f - Browse repository at this point
Copy the full SHA 950c70fView commit details -
Replace displayName null check with conditional type
With the current code, it is not possible for displayName to be unset in getMaxResourceWidth. Make this clear with type narrowing.
Configuration menu - View commit details
-
Copy full SHA for 52c2919 - Browse repository at this point
Copy the full SHA 52c2919View commit details -
Use narrowing instead of non-null assertion
Same behavior but using better practices.
Configuration menu - View commit details
-
Copy full SHA for cd02127 - Browse repository at this point
Copy the full SHA cd02127View commit details -
Properly check that flatData[0] is defined
The previous check was loosely coupled, relying on a non-null assertion. This should be more clear to both the compiler and humans.
Configuration menu - View commit details
-
Copy full SHA for 7aaeb48 - Browse repository at this point
Copy the full SHA 7aaeb48View commit details -
_setDisplayName: Replace optional chaining with proper error handing
With the current code, it is not possible for resources[i-1] to be undefined. Make this clear with type narrowing.
Configuration menu - View commit details
-
Copy full SHA for 14e0e82 - Browse repository at this point
Copy the full SHA 14e0e82View commit details -
Throw an error if IndividualResource cannot be rendered
With the current code, this condition will always fail. Prevent this from silently passing and instead raise an error.
Configuration menu - View commit details
-
Copy full SHA for f8feb3e - Browse repository at this point
Copy the full SHA f8feb3eView commit details