Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IData.value is explicitly of type string resulting in TypeScript incompatibility if an object is preferred #54

Open
NVRC opened this issue Nov 24, 2022 · 0 comments

Comments

@NVRC
Copy link

NVRC commented Nov 24, 2022

Expected

interface IData {
  key: string;
  value: any;
} 

Actual

interface IData {
  key: string;
  value: string;
}

To reproduce with template linting rules

  1. 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
  1. Define a list of objects e.g.
const data: Array<IData> = [
  { key: "0", value: {name: "Boston"}},
  { key: "1", value: {name:"Yellowknife"}}
]
  1. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant