diff options
author | Jeremy Davis <jeremy.davis@sonarsource.com> | 2022-10-18 11:04:08 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-10-19 20:03:07 +0000 |
commit | 0f13f1b2b89d18ecff62b29ff00b6178d1b9770a (patch) | |
tree | ca2a680026957684e74fe49a3df7913e5003ec25 /server/sonar-web/src/main | |
parent | 7231accc3e97c228da8181525ffb56748ba2bae6 (diff) | |
download | sonarqube-0f13f1b2b89d18ecff62b29ff00b6178d1b9770a.tar.gz sonarqube-0f13f1b2b89d18ecff62b29ff00b6178d1b9770a.zip |
[NO JIRA] Upgrade typescript
Diffstat (limited to 'server/sonar-web/src/main')
4 files changed, 32 insertions, 12 deletions
diff --git a/server/sonar-web/src/main/js/components/controls/Select.tsx b/server/sonar-web/src/main/js/components/controls/Select.tsx index af43b811421..55a994fdd59 100644 --- a/server/sonar-web/src/main/js/components/controls/Select.tsx +++ b/server/sonar-web/src/main/js/components/controls/Select.tsx @@ -96,12 +96,15 @@ export function multiValueRemove< return <div {...props.innerProps}>×</div>; } -export type SelectOptionProps<T, IsMulti extends boolean> = OptionProps<T, IsMulti>; +export type SelectOptionProps<T extends OptionTypeBase, IsMulti extends boolean> = OptionProps< + T, + IsMulti +>; export const SelectOption = components.Option; /* Keeping it as a class to simplify a dozen tests */ export default class Select< - Option, + Option extends OptionTypeBase, IsMulti extends boolean = false, Group extends GroupTypeBase<Option> = GroupTypeBase<Option> > extends React.Component<NamedProps<Option, IsMulti, Group> & StyleExtensionProps> { @@ -124,7 +127,7 @@ export default class Select< } export function CreatableSelect< - Option, + Option extends OptionTypeBase, isMulti extends boolean, Group extends GroupTypeBase<Option> = GroupTypeBase<Option> >(props: AsyncCreatableProps<Option, isMulti, Group>) { @@ -144,7 +147,7 @@ export function CreatableSelect< } export function SearchSelect< - Option, + Option extends OptionTypeBase, IsMulti extends boolean, Group extends GroupTypeBase<Option> = GroupTypeBase<Option> >(props: NamedProps<Option, IsMulti, Group> & AsyncProps<Option, Group> & StyleExtensionProps) { @@ -165,7 +168,11 @@ export function SearchSelect< ); } -export function selectStyle<Option, IsMulti extends boolean, Group extends GroupTypeBase<Option>>( +export function selectStyle< + Option extends OptionTypeBase, + IsMulti extends boolean, + Group extends GroupTypeBase<Option> +>( props?: NamedProps<Option, IsMulti, Group> & AsyncProps<Option, Group> & StyleExtensionProps ): StylesConfig<Option, IsMulti, Group> { return { diff --git a/server/sonar-web/src/main/js/components/controls/__tests__/Select-test.tsx b/server/sonar-web/src/main/js/components/controls/__tests__/Select-test.tsx index 840cef0a826..3360ccd64a1 100644 --- a/server/sonar-web/src/main/js/components/controls/__tests__/Select-test.tsx +++ b/server/sonar-web/src/main/js/components/controls/__tests__/Select-test.tsx @@ -19,7 +19,13 @@ */ import { shallow } from 'enzyme'; import * as React from 'react'; -import { components, GroupTypeBase, InputProps, Props as ReactSelectProps } from 'react-select'; +import { + components, + GroupTypeBase, + InputProps, + OptionTypeBase, + Props as ReactSelectProps +} from 'react-select'; import { LoadingIndicatorProps } from 'react-select/src/components/indicators'; import { MultiValueRemoveProps } from 'react-select/src/components/MultiValue'; import { mockReactSelectIndicatorProps } from '../../../helpers/mocks/react-select'; @@ -75,7 +81,7 @@ describe('Select', () => { }); function shallowRender< - Option, + Option extends OptionTypeBase, IsMulti extends boolean = false, Group extends GroupTypeBase<Option> = GroupTypeBase<Option> >(props: Partial<ReactSelectProps<Option, IsMulti, Group>> = {}) { diff --git a/server/sonar-web/src/main/js/helpers/mocks/react-select.ts b/server/sonar-web/src/main/js/helpers/mocks/react-select.ts index d25e6abf791..17f4562c437 100644 --- a/server/sonar-web/src/main/js/helpers/mocks/react-select.ts +++ b/server/sonar-web/src/main/js/helpers/mocks/react-select.ts @@ -17,10 +17,17 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { ControlProps, GroupTypeBase, IndicatorProps, InputProps, OptionProps } from 'react-select'; +import { + ControlProps, + GroupTypeBase, + IndicatorProps, + InputProps, + OptionProps, + OptionTypeBase +} from 'react-select'; export function mockReactSelectOptionProps< - OptionType, + OptionType extends OptionTypeBase, IsMulti extends boolean, GroupType extends GroupTypeBase<OptionType> = GroupTypeBase<OptionType> >( @@ -38,7 +45,7 @@ export function mockReactSelectInputProps(): InputProps { } export function mockReactSelectControlProps< - OptionType, + OptionType extends OptionTypeBase, IsMulti extends boolean, GroupType extends GroupTypeBase<OptionType> = GroupTypeBase<OptionType> >(): ControlProps<OptionType, IsMulti, GroupType> { @@ -46,7 +53,7 @@ export function mockReactSelectControlProps< } export function mockReactSelectIndicatorProps< - OptionType, + OptionType extends OptionTypeBase, IsMulti extends boolean, GroupType extends GroupTypeBase<OptionType> = GroupTypeBase<OptionType> >(_option: OptionType): IndicatorProps<OptionType, IsMulti, GroupType> { diff --git a/server/sonar-web/src/main/js/helpers/query.ts b/server/sonar-web/src/main/js/helpers/query.ts index 19eaf60e319..2cadbc21282 100644 --- a/server/sonar-web/src/main/js/helpers/query.ts +++ b/server/sonar-web/src/main/js/helpers/query.ts @@ -85,7 +85,7 @@ export function parseAsOptionalArray<T>( } export function serializeDate(value?: Date, serializer = toNotSoISOString): string | undefined { - if (value != null && value.toISOString) { + if (value != null) { return serializer(value); } return undefined; |