From a83dac6ef27ee5a269180ac39ea3d5045b82df56 Mon Sep 17 00:00:00 2001 From: sai6855 <60743144+sai6855@users.noreply.github.com> Date: Sat, 22 Apr 2023 00:17:45 +0530 Subject: [PATCH 1/8] fix --- .../src/Autocomplete/Autocomplete.d.ts | 3 ++- .../src/Autocomplete/Autocomplete.spec.tsx | 21 ++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/packages/mui-material/src/Autocomplete/Autocomplete.d.ts b/packages/mui-material/src/Autocomplete/Autocomplete.d.ts index 20c557ef3a3332..c3431a935a68b5 100644 --- a/packages/mui-material/src/Autocomplete/Autocomplete.d.ts +++ b/packages/mui-material/src/Autocomplete/Autocomplete.d.ts @@ -293,4 +293,5 @@ export default function Autocomplete< Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ->(props: AutocompleteProps): JSX.Element; + ChipComponent extends React.ElementType = 'div', +>(props: AutocompleteProps): JSX.Element; diff --git a/packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx b/packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx index b4120b5c4bd6b8..a7029f055ab74c 100644 --- a/packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx +++ b/packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx @@ -1,5 +1,6 @@ import * as React from 'react'; import Autocomplete, { + AutocompleteOwnerState, AutocompleteProps, AutocompleteRenderGetTagProps, } from '@mui/material/Autocomplete'; @@ -11,7 +12,8 @@ interface MyAutocompleteProps< Multiple extends boolean | undefined, DisableClearable extends boolean | undefined, FreeSolo extends boolean | undefined, -> extends AutocompleteProps { + ChipComponent extends React.ElementType = 'div', +> extends AutocompleteProps { myProp?: string; } @@ -20,8 +22,21 @@ function MyAutocomplete< Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ->(props: MyAutocompleteProps) { - return ; + ChipComponent extends React.ElementType = 'div', +>(props: MyAutocompleteProps) { + return ( + { + expectType< + AutocompleteOwnerState, + typeof ownerState + >(ownerState); + + return ''; + }} + /> + ); } // multiple prop can be assigned for components that extend AutocompleteProps From dcb4c7e4d79b10a25a19dd8310166db3770677b5 Mon Sep 17 00:00:00 2001 From: sai6855 <60743144+sai6855@users.noreply.github.com> Date: Sun, 7 May 2023 20:30:44 +0530 Subject: [PATCH 2/8] chipcomponent type fix --- packages/mui-material/src/Autocomplete/Autocomplete.d.ts | 2 +- packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/mui-material/src/Autocomplete/Autocomplete.d.ts b/packages/mui-material/src/Autocomplete/Autocomplete.d.ts index c3431a935a68b5..b9773c9d05ed25 100644 --- a/packages/mui-material/src/Autocomplete/Autocomplete.d.ts +++ b/packages/mui-material/src/Autocomplete/Autocomplete.d.ts @@ -293,5 +293,5 @@ export default function Autocomplete< Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, - ChipComponent extends React.ElementType = 'div', + ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent'], >(props: AutocompleteProps): JSX.Element; diff --git a/packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx b/packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx index a7029f055ab74c..851517dc3142a1 100644 --- a/packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx +++ b/packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx @@ -6,6 +6,7 @@ import Autocomplete, { } from '@mui/material/Autocomplete'; import TextField from '@mui/material/TextField'; import { expectType } from '@mui/types'; +import { ChipTypeMap } from '@mui/material/Chip'; interface MyAutocompleteProps< T, @@ -22,7 +23,7 @@ function MyAutocomplete< Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, - ChipComponent extends React.ElementType = 'div', + ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent'], >(props: MyAutocompleteProps) { return ( Date: Sun, 7 May 2023 20:31:57 +0530 Subject: [PATCH 3/8] chipcomponent type fix --- packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx b/packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx index 851517dc3142a1..943a0892963135 100644 --- a/packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx +++ b/packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx @@ -13,7 +13,7 @@ interface MyAutocompleteProps< Multiple extends boolean | undefined, DisableClearable extends boolean | undefined, FreeSolo extends boolean | undefined, - ChipComponent extends React.ElementType = 'div', + ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent'] > extends AutocompleteProps { myProp?: string; } From e410a9f75e50cda5c8e921b20f9afe623cfba053 Mon Sep 17 00:00:00 2001 From: sai6855 <60743144+sai6855@users.noreply.github.com> Date: Sun, 7 May 2023 20:36:28 +0530 Subject: [PATCH 4/8] prettier --- packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx b/packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx index 943a0892963135..9545125bdf956e 100644 --- a/packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx +++ b/packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx @@ -13,7 +13,7 @@ interface MyAutocompleteProps< Multiple extends boolean | undefined, DisableClearable extends boolean | undefined, FreeSolo extends boolean | undefined, - ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent'] + ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent'], > extends AutocompleteProps { myProp?: string; } From 01d198d788e0e87c57ac39d75f20d065f4a2e640 Mon Sep 17 00:00:00 2001 From: sai6855 <60743144+sai6855@users.noreply.github.com> Date: Tue, 9 May 2023 16:04:10 +0530 Subject: [PATCH 5/8] added a test which tests "span" for chip component --- .../src/Autocomplete/Autocomplete.spec.tsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx b/packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx index 9545125bdf956e..7682a42ed2ded1 100644 --- a/packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx +++ b/packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx @@ -40,6 +40,18 @@ function MyAutocomplete< ); } + + options={['1', '2', '3']} + renderTags={(value, getTagProps, ownerState) => { + expectType, typeof ownerState>( + ownerState, + ); + + return ''; + }} + renderInput={() => null} +/>; + // multiple prop can be assigned for components that extend AutocompleteProps Date: Tue, 9 May 2023 16:08:24 +0530 Subject: [PATCH 6/8] removed extra code --- .../src/Autocomplete/Autocomplete.spec.tsx | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx b/packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx index 7682a42ed2ded1..5dbc21c4891f23 100644 --- a/packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx +++ b/packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx @@ -25,19 +25,7 @@ function MyAutocomplete< FreeSolo extends boolean | undefined = false, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent'], >(props: MyAutocompleteProps) { - return ( - { - expectType< - AutocompleteOwnerState, - typeof ownerState - >(ownerState); - - return ''; - }} - /> - ); + return ; } From a9ae809591a1e622f0feb30d4a35a3efd0989ec6 Mon Sep 17 00:00:00 2001 From: sai6855 <60743144+sai6855@users.noreply.github.com> Date: Tue, 9 May 2023 16:22:29 +0530 Subject: [PATCH 7/8] trigger From 1a6ad02bf2c81dfea47f589cfda5c12098886645 Mon Sep 17 00:00:00 2001 From: ZeeshanTamboli Date: Tue, 9 May 2023 16:47:22 +0530 Subject: [PATCH 8/8] add comment on Autocomplete TypeScript test --- packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx b/packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx index 5dbc21c4891f23..236486b43de6c0 100644 --- a/packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx +++ b/packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx @@ -28,6 +28,7 @@ function MyAutocomplete< return ; } +// Test for ChipComponent generic type options={['1', '2', '3']} renderTags={(value, getTagProps, ownerState) => {