Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AppBar] Fix component type #37172

Merged
merged 1 commit into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
Loading