feat: Add type to ion-select interfaces
See original GitHub issueFeature Request
The IonSelect
and interface should allow us to define which value are we expecting.
Ionic version: [x] 5.x
Describe the Feature Request
When working with CustomEvent
’s that carry IonSelect
as detail we have to always cast the value because the current type is any
function newSoundType(event: CustomEvent<IonSelect>): void {
const myValue = event.detail.value as MyType; // Here value is any!
this.updateTrainingConfigWith(myValue);
}
Describe Preferred Solution
The IonSelect
interface should accept an optional T
generic type, if none is given, then keep using any
Describe Alternatives
Instead of using CustomEvent<IonSelect>
one can also use CustomEvent<{value: MyType}>
but then you can not be sure what is the source of that event.
Related Code Implementation using Interface with an value as an optional defined type
Implementation using Type instead of interface with a mapped NON Optional value
I wanted to create a PR but I was not sure where to edit this 😢
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
The
core/api.txt
file is basically a list of all of Ionic Framework’s public APIs. We use this when generating documentation and for keeping track of new features in the framework. Takingion-input
as an example, the “Properties”, “Events”, “Methods”, and “CSS Custom Properties” tables in the documentation (https://ionicframework.com/docs/api/input) are generated from thisapi.txt
file.We have a contributing guide that shows you how to make a PR, build the framework, lint, etc.
Yesterday I merged a PR that adds this functionality 😊 . The feature should be available in an upcoming release of Ionic Framework: https://github.com/ionic-team/ionic-framework/commit/7c2d0c981ab91930478c4b76220ce4ec4ed4e471