Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eslint.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1401,6 +1401,7 @@ export default typescript.config([
rules: {
'@typescript-eslint/no-non-null-assertion': 'error',
...(enableTypeAwareLinting && {
'@typescript-eslint/no-unsafe-argument': 'error',
'@typescript-eslint/no-unsafe-return': 'error',
}),
},
Expand Down
2 changes: 1 addition & 1 deletion static/app/components/core/layout/container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ export const Container = styled(
},
{
shouldForwardProp: prop => {
if (omitContainerProps.has(prop as any)) {
if (omitContainerProps.has(prop as keyof ContainerLayoutProps | 'as')) {
return false;
}
return isPropValid(prop);
Expand Down
2 changes: 1 addition & 1 deletion static/app/components/core/layout/flex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export interface FlexPropsWithRenderFunction<T extends ContainerElement = 'div'>

export const Flex = styled(Container, {
shouldForwardProp: prop => {
return !omitFlexProps.has(prop as any);
return !omitFlexProps.has(prop as keyof FlexLayoutProps | 'as');
},
})<FlexProps<any> | FlexPropsWithRenderFunction<any>>`
${p => rc('display', p.display ?? 'flex', p.theme, v => v ?? 'flex')};
Expand Down
2 changes: 1 addition & 1 deletion static/app/components/core/layout/grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export type GridPropsWithRenderFunction<T extends ContainerElement = 'div'> =

export const Grid = styled(Container, {
shouldForwardProp: prop => {
return !omitGridProps.has(prop as any);
return !omitGridProps.has(prop as keyof GridLayoutProps | 'as');
},
})<GridProps<any> | GridPropsWithRenderFunction<any>>`
${p => rc('display', p.display ?? 'grid', p.theme, v => v ?? 'grid')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ export function SegmentedControl<Value extends string>({
}: SegmentedControlProps<Value>) {
const ref = useRef<HTMLDivElement>(null);

const collection = useCollection(props as any, collectionFactory);
const collection = useCollection(
props as Parameters<typeof useCollection>[0],
collectionFactory
);
const ariaProps = {
...props,
value,
Expand Down
2 changes: 1 addition & 1 deletion static/app/components/core/select/async.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
query: typeof onQuery === 'function' ? onQuery(query) : {query},
})
.then(
data => cb(null, data),
(data: TData) => cb(null, data),
(err: Error) => cb(err)
);
}, 250);
Expand Down Expand Up @@ -115,7 +115,7 @@
<Select
// The key is used as a way to force a reload of the options:
// https://github.com/JedWatson/react-select/issues/1879#issuecomment-316871520
key={value}

Check failure on line 118 in static/app/components/core/select/async.tsx

View workflow job for this annotation

GitHub Actions / typescript

Type 'unknown' is not assignable to type 'Key | null | undefined'.

Check failure on line 118 in static/app/components/core/select/async.tsx

View workflow job for this annotation

GitHub Actions / typescript (mdx)

Type 'unknown' is not assignable to type 'Key | null | undefined'.
ref={forwardedRef}
value={value}
defaultOptions={defaultOptions}
Expand Down
10 changes: 7 additions & 3 deletions static/app/components/core/select/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ export type ControlProps<OptionType extends OptionTypeBase = GeneralSelectValue>
* Because this type is embedded in the OptionType generic we
* can't have a good type here.
*/
value?: any;
value?: unknown;
};

// TODO(ts) The exported component uses forwardRef.
Expand Down Expand Up @@ -581,8 +581,12 @@ export function Select<OptionType extends GeneralSelectValue = GeneralSelectValu

mappedValue =
props.multiple && Array.isArray(value)
? value.map(val => flatOptions.find(option => compare(option.value, val)))
: flatOptions.find(opt => compare(opt.value, value)) || noMatchFallback;
? value.map((val: OptionType['value'] | null | undefined) =>
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
flatOptions.find(option => compare(option.value, val))
)
: // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
flatOptions.find(opt => compare(opt.value, value)) || noMatchFallback;
Comment on lines +584 to +589
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.

instead of adding eslint comments here, what if we update the compare function?

  const compare = (a: unknown, b: unknown) => {
    if (props.isValueEqual && defined(a) && defined(b)) {
      return props.isValueEqual(
        a as OptionType['value'],
        b as OptionType['value'],
      );
    }
    return a === b;
  };

Copy link
Copy Markdown
Collaborator Author

@TkDodo TkDodo May 21, 2026

Choose a reason for hiding this comment

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

the problem is that opt.value is of type any because of some underlying types in react-select we can’t change :/ The eslint comment surfaces this, I think changing the input types to unkonwn with a type assertion might just lead to wrong things being passed in

}

// Override the default style with in-field labels if they are provided
Expand Down
2 changes: 1 addition & 1 deletion static/app/components/core/separator/separator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const Separator = styled(
},
{
shouldForwardProp: prop => {
if (omitSeparatorProps.has(prop as any)) {
if (omitSeparatorProps.has(prop as keyof SeparatorProps)) {
return false;
}
return isPropValid(prop);
Expand Down
Loading