Skip to content
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
tmkn:feature/typings/autocomplete
Jun 26, 2020
Merged

Feature: Strict Typing for AutoComplete Component#503
juanpicado merged 2 commits intoverdaccio:masterfrom
tmkn:feature/typings/autocomplete

Conversation

@tmkn
Copy link
Copy Markdown
Contributor

@tmkn tmkn commented Jun 25, 2020

This PR makes AutoComplete.tsx compatible with TypeScripts strict mode.
Unfortunately I had to introduce a @ts-ignore directive in 1 place since the provided RenderInputComponent<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-prop

The 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 like RenderInputComponent<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.

@sonarqubecloud
Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

/* eslint-disable verdaccio/jsx-spread */
const renderInputComponent = (inputProps): JSX.Element => {
const renderInputComponent: RenderInputComponent<Suggestion> = inputProps => {
// @ts-ignore
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the new ts-ignore, since there is currently no way to type startAdornment & disableUnderline

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, we can find a solution later for this

Copy link
Copy Markdown
Member

@juanpicado juanpicado left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great ! thanks Thomas :) nice to see more typings. I learn few things already.

@juanpicado juanpicado merged commit 4a61fd3 into verdaccio:master Jun 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants