mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-28 00:06:53 +01:00
39145e2617
This changes the two interfaces IChangeRequest and IChangeRequestSchedule to be union types instead of interfaces. It also extracts the constituents of those union types into proper types themselves (so that they can be used in function type signatures etc). It also updates the type names. This turned out to be more work than I had imagined, but I think the end result pays off, giving us more type safety and control. I wanted to use just `ChangeRequest` for the IChangeRequest type, but that caused issues due to naming collisions with the `ChangeRequest` component that we have, causing tests to fail. I've named it `ChangeRequestType` as a potential solution, but suggestions are welcome. The relevant changes are in `frontend/src/component/changeRequest/changeRequest.types.ts`. Everything else is updated references and some necessary refactoring to respect the new types.
6 lines
235 B
TypeScript
6 lines
235 B
TypeScript
import { ChangeRequestType } from './changeRequest.types';
|
|
|
|
export const changesCount = (changeRequest: ChangeRequestType) =>
|
|
changeRequest.features.flatMap((feature) => feature.changes).length +
|
|
changeRequest.segments.length;
|