Simplify ensure() by using the keyof operator
- Dominant language
- TypeScript
- Stars
- 129
- Forks
- 125
- PR merge metrics
- No merged PRs in 30d
Description
**I'm submitting a feature request**
* **Library Version:**
1.1.2
**Please tell us about your environment:**
* **Operating System:**
Linux (kubuntu)
* **Node Version:**
6.14.1
* **NPM Version:**
3.10.10
* **JSPM Version**
JSPM 0.16.53
* **Language:**
TypeScript 2.8.1
**Current behavior:**
`ValidationRules.ensure(...)` accepts both a string or a function. The string should be a property name, and the function should return the property. We are using a function to make use of the Typescript type checking. However, in our code coverage, these functions are mentioned as not being covered by the component tests. This is because the function is never actually executed, but parsed in the PropertyAccessorParser.
**Desired behavior:**
An easy solution would be to make the ensure(...) argument a `keyof TObject`. This would both cover the need for type checking and remove the need for a function parser.
Contributor guide
Research direction
Start by locating ValidationRules.ensure and the PropertyAccessorParser mentioned in the issue, then trace how the ensure argument is typed and interpreted. Done means the property argument uses TypeScript keyof typing for type checking and the function-parser path is no longer needed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100