Expected
interface IData {
key: string;
value: any;
}
Actual
interface IData {
key: string;
value: string;
}
To reproduce with template linting rules
- Create an example project.
$ npx create-expo-app --template
Need to install the following packages:
create-expo-app
Ok to proceed? (y) y
✔ Choose a template: › Blank (TypeScript)
✔ What is your app named? … example-app
...
$ cd example-app
$ npm install react-native-section-alphabet-list
- Define a list of objects e.g.
const data: Array<IData> = [
{ key: "0", value: {name: "Boston"}},
{ key: "1", value: {name:"Yellowknife"}}
]
- Note linting error:
(property) IData.value: string
Type '{ name: string; }' is not assignable to type 'string'.ts(2322)
types.d.ts(4, 5): The expected type comes from property 'value' which is declared here on type 'IData'
Proposal
Convert IData.value to a generic with a type of any used within the library to remain backwards compatible.
Overall this allows the module to be far more flexible by passing IData.value transparently to an overridden renderCustomItem prop.
Expected
Actual
To reproduce with template linting rules
Proposal
Convert IData.value to a generic with a type of
anyused within the library to remain backwards compatible.Overall this allows the module to be far more flexible by passing
IData.valuetransparently to an overriddenrenderCustomItemprop.