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

Search: the id prop on SearchResult should accept string as value #2135

Closed
darewreck54 opened this issue Sep 27, 2017 · 1 comment
Closed
Labels

Comments

@darewreck54
Copy link

From looking at the type definition for SearchResult.d.ts, the [key:strig]: any should allow me to add any additional props. However, when in typescript it will give warnings about them.

Warning: Failed prop type: Invalid prop results supplied to Search

It seems like it doesn't effect the functionality, but console gets flooded with these warnings Is this a typescript issue only and is there a workaround.

Example:

When you define the results:

  {
    "title": "Gusikowski LLC",
    "description": "User-friendly reciprocal parallelism",
    "image": "https://s3.amazonaws.com/uifaces/faces/twitter/alecarpentier/128.jpg",
    "price": "$34.11"
  }

In my case, I added

  {
    "tester": "a"
    "title": "Gusikowski LLC",
    "description": "User-friendly reciprocal parallelism",
    "image": "https://s3.amazonaws.com/uifaces/faces/twitter/alecarpentier/128.jpg",
    "price": "$34.11"
  }

"tester" will be treated as an unknown property and warnings will come.

Also another question, is it possible to update the id to be an any. In my case, i have a string value of a GUID but because it's a number I can't set it.

export interface SearchResultProps {
  [key: string]: any;

  /** An element type to render as (string or function). */
  as?: any;

  /** The item currently selected by keyboard shortcut. */
  active?: boolean;

  /** Additional classes. */
  className?: string;

  /** Additional text with less emphasis. */
  description?: string;

  /** A unique identifier. */
  id?: number;

Thanks,
Derek

@layershifter
Copy link
Member

Warning: Failed prop type: Invalid prop results supplied to Search

This comes from propTypes and duplicates #1681.

Also another question, is it possible to update the id to be an any.

any - no, but I almost sure that it can string. Good suggestion, PR is comming.

@layershifter layershifter changed the title Typescript warnings when trying to add additional props to SearchResults Search: the id prop on SearchResult should accept string as value Sep 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants