Skip to content

Property 'firstName' does not exist on type 'Option'. Property 'firstName' does not exist on type 'string'. #786

Closed
@NatashaBlong

Description

@NatashaBlong

Version

react-bootstrap-typeahead - 6.1.1
I am also using Typescript for my application

Steps to reproduce

import { Typeahead } from 'react-bootstrap-typeahead';

export default function ExampleForm(): ReactElement {

// The example code is straight from the examples in GitHub

   return(
        <Typeahead
          labelKey={option => `${option.firstName} ${option.lastName}`}
          options={[
            {firstName: 'Art', lastName: 'Blakey'},
            {firstName: 'Jimmy', lastName: 'Cobb'},
            {firstName: 'Elvin', lastName: 'Jones'},
            {firstName: 'Max', lastName: 'Roach'},
            {firstName: 'Tony', lastName: 'Williams'},
          ]}
        />
   );
}

Expected Behavior

No Errors

Actual Behavior

.firstName and .lastName are underlined in the labelKey field, with the following errors:

Property 'firstName' does not exist on type 'Option'.
Property 'firstName' does not exist on type 'string'.

Property 'lastName' does not exist on type 'Option'.
Property 'lastName' does not exist on type 'string'.

The strange thing is that when i run the code in localhost, the typeahead displays and functions as expected.
However the above errors do cause compiling errors when testing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions