Skip to content

Commit

Permalink
[AppBar] Fix component type (#37172)
Browse files Browse the repository at this point in the history
  • Loading branch information
sai6855 committed May 9, 2023
1 parent 8acb5dd commit 609e2a6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
16 changes: 9 additions & 7 deletions packages/mui-material/src/AppBar/AppBar.d.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import * as React from 'react';
import { SxProps } from '@mui/system';
import { DistributiveOmit, OverridableStringUnion } from '@mui/types';
import { OverridableStringUnion } from '@mui/types';
import { OverridableComponent, OverrideProps } from '@mui/material/OverridableComponent';
import { PropTypes, Theme } from '..';
import { PaperProps } from '../Paper';
import { AppBarClasses } from './appBarClasses';
import { ExtendPaperTypeMap } from '../Paper/Paper';

export interface AppBarPropsColorOverrides {}

export interface AppBarTypeMap<P = {}, D extends React.ElementType = 'header'> {
props: P &
DistributiveOmit<PaperProps, 'position' | 'color' | 'classes'> & {
export type AppBarTypeMap<P = {}, D extends React.ElementType = 'header'> = ExtendPaperTypeMap<
{
props: P & {
/**
* Override or extend the styles applied to the component.
*/
Expand Down Expand Up @@ -39,8 +39,10 @@ export interface AppBarTypeMap<P = {}, D extends React.ElementType = 'header'> {
*/
sx?: SxProps<Theme>;
};
defaultComponent: D;
}
defaultComponent: D;
},
'position' | 'color' | 'classes'
>;

/**
*
Expand Down
9 changes: 8 additions & 1 deletion packages/mui-material/src/AppBar/AppBar.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import AppBar from '@mui/material/AppBar';
import { expectType } from '@mui/types';

const CustomComponent: React.FC<{ stringProp: string; numberProp: number }> =
function CustomComponent() {
Expand All @@ -12,7 +13,13 @@ function AppBarTest() {
<AppBar />
<AppBar elevation={4} />

<AppBar component="a" href="test" />
<AppBar
component="a"
href="test"
onClick={(event) => {
expectType<React.MouseEvent<HTMLAnchorElement, MouseEvent>, typeof event>(event);
}}
/>
<AppBar component={CustomComponent} stringProp="test" numberProp={0} />
{/* @ts-expect-error missing stringProp and numberProp */}
<AppBar component={CustomComponent} />
Expand Down

0 comments on commit 609e2a6

Please sign in to comment.