This repository was archived by the owner on Jan 16, 2022. It is now read-only.
Feature: Strict Typing for AutoComplete Component#503
Merged
juanpicado merged 2 commits intoverdaccio:masterfrom Jun 26, 2020
Merged
Feature: Strict Typing for AutoComplete Component#503juanpicado merged 2 commits intoverdaccio:masterfrom
juanpicado merged 2 commits intoverdaccio:masterfrom
Conversation
|
Kudos, SonarCloud Quality Gate passed!
|
tmkn
commented
Jun 25, 2020
| /* eslint-disable verdaccio/jsx-spread */ | ||
| const renderInputComponent = (inputProps): JSX.Element => { | ||
| const renderInputComponent: RenderInputComponent<Suggestion> = inputProps => { | ||
| // @ts-ignore |
Contributor
Author
There was a problem hiding this comment.
this is the new ts-ignore, since there is currently no way to type startAdornment & disableUnderline
Member
There was a problem hiding this comment.
Ok, we can find a solution later for this
juanpicado
approved these changes
Jun 26, 2020
Member
juanpicado
left a comment
There was a problem hiding this comment.
Great ! thanks Thomas :) nice to see more typings. I learn few things already.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR makes
AutoComplete.tsxcompatible with TypeScriptsstrictmode.Unfortunately I had to introduce a
@ts-ignoredirective in 1 place since the providedRenderInputComponent<T>type does not allow to specify custom input props which we make use of. See here: https://github.com/moroshko/react-autosuggest#input-props-propThe first generic in
RenderInputComponent<T>only models the Suggestion, so there is currently no way to type custom input props. Ideally in the future it will allow a 2nd generic that allows you to model them likeRenderInputComponent<Suggestion, CustomInputProps>.I already specified the custom input prop that would need to be used:
type CustomInputProps = Pick<Props, 'disableUnderline' | 'startAdornment'>;So once this is fixed we can remove the tsignore again and fill in the 2nd generic and this should be it.