issues with static and dynamic state in CompetitionSuggestion
- Dominant language
- TypeScript
- Stars
- 14
- Forks
- 13
- PR merge metrics
- No merged PRs in 30d
Description
re: static and dynamic state in `CompetitionSuggestion`. I find it quite confused.
Looking at `Competition.suggestions()`. It is defined to return `CompetitionSuggestion[]`.
`CompetitionSuggestion` is defined to contain three properties, `id, `suggestionId?` and `staticState?`.
I think you may already realize this: It actually can contain much more than that. `Competition.suggestions()` invokes `CompetitionSuggestion.search()` which, via `mapItemToObject` results in returning an object that contains the full complement of properties in `ICompetitionSuggestion`, which with the current code is (mistakenly) the equivalent of both static state and dynamic state.
Yet these properties are hidden from the consumer of `Competition.suggestions()` because the return value `CompetitionSuggestion[]` doesn't declare them.
Moreover, after having retrieved all these (hidden) properties in `CompetitionSuggestion`, its value of `staticState` remains undefined.
Further, when I invoke `Competition.suggestions()` I am getting back `CompetitionSuggestions` that don't contain the method `fetchStaticState`. So the only way I currently have to obtain the desired properties is a hack that casts the `CompetitionSuggestion` to `ICompetitionSuggestion`.
Contributor guide
Research direction
Start by tracing Competition.suggestions() through CompetitionSuggestion.search() and mapItemToObject, then compare the public CompetitionSuggestion type with ICompetitionSuggestion and the available fetchStaticState method. Done should mean the returned type, runtime object, and static/dynamic state behavior agree without requiring a cast.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100