-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
v5.14.1 component props show only one default tag - TypeError #38034
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
Comments
I'm having the same issue with |
I couldn't reproduce it in the latest version The cc @sai6855 |
Yep running into this also on |
Indeed, I'm on |
And here's my {
"compilerOptions": {
"experimentalDecorators": true,
"target": "ESNext",
"lib": ["dom", "dom.iterable", "esnext"],
"types": ["vite/client", "vite-plugin-svgr/client", "google.accounts"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"baseUrl": "./",
"paths": {
"@/*": ["./src/*"],
"translate": ["./src/services/i18n"],
"strings": ["./src/resources/strings/LocalizedStrings"]
}
},
"include": ["src"]
} |
Here's my config
|
using |
This sandbox reproduces the issue https://codesandbox.io/p/sandbox/adoring-wave-xsmtx6 |
@dahyorr Your sandbox is also using TS 5.x it seems (according to the If you are getting it with |
|
I forked this sandbox: https://codesandbox.io/s/runtime-surf-nsfhmn-forked-pf2j4h?file=/src/App.tsx This is more or less what OP originally reported and it doesn't repro here:
As for the other error caused by this other component:
It works if |
@dahyorr here is the working sandbox which is fork of yours. so basically i've omitted component type from - const Stage: React.FC<React.PropsWithChildren<BoxProps>> = ({
+ const Stage: React.FC<Omit<React.PropsWithChildren<BoxProps>, "component">> = ({
https://codesandbox.io/s/mutable-currying-dmwjlj?file=/src/App.tsx Type error could be because of conflicting |
@remarkablemark can you share codesandbox repros, i can suggest you the workaround |
I checked exactly in which case this occurs and this is when https://codesandbox.io/p/sandbox/heuristic-waterfall-m44zhm?file=%2Fpages%2Findex.tsx%3A5%2C7 |
@pawelmidur here is the working sandbox of your fork https://codesandbox.io/p/sandbox/headless-fire-nzfrh5?file=%2Fpages%2Findex.tsx%3A20%2C8 - interface ITypographyMaxLineProps extends TypographyProps {
- maxLines?: number;
- }
- const TypographyMaxLine = ({
- maxLines,
- ...props
- }: ITypographyMaxLineProps): JSX.Element => {
+ type ITypographyMaxLineProps<C extends React.ElementType> =
+ TypographyProps<C> & {
+ maxLines?: number;
+ };
+ function TypographyMaxLine<C extends React.ElementType>({
+ maxLines,
+ ...props
+ }: ITypographyMaxLineProps<C>): JSX.Element {
|
BTW the same code provided in sandbox also throwing type errors for versions less than 5.14.1. here is the sandbox with same code but uses mui/material 5.14.0 and you can see type errors here also https://codesandbox.io/s/condescending-snow-c339s9?file=/Demo.tsx |
In my case, the error was caused by the <Link
// href="#"
component="button"
sx={{
color: 'inherit',
textDecorationColor: 'inherit',
font: 'inherit',
verticalAlign: 'baseline'
}}
onClick={login}
>
{strings.mainSignInButtonTitle}
</Link> Removing the |
the problem came form here I think
as C is not specified it takes the default value define in the Component for a link it is "a" for example So now it restrict the 'component' property to its default value |
this commit seems to be responsible |
I have the same issue with both <MenuItem key="pricing" component={Link} href="/pricing"...
<Button variant="outlined" href="/" component={Link} sx={{margin: "auto"}}>... I'm using: "@emotion/cache": "^11.11.0",
"@emotion/css": "^11.11.0",
"@emotion/react": "^11.11.0",
"@emotion/server": "^11.11.0",
"@emotion/styled": "^11.11.0",
"@mui/icons-material": "^5.14.1",
"@mui/lab": "^5.0.0-alpha.137",
"@mui/material": "^5.14.1",
"@mui/x-date-pickers": "^6.10.1",
"next": "^13.4.11",
"typescript": "^5.1.6", |
I want to say that the errors are no longer appearing for me in v5.14.2 |
Closing this issue. It works from |
Uh oh!
There was an error while loading. Please reload this page.
Duplicates
Latest version
Steps to reproduce 🕹
Link to live example:
<Typography component="div" />
Steps:
component
for<Typography>
show only "span" can not set "div"Current behavior 😯
No overload matches this call.
Overload 1 of 2, '(props: { component: "div"; } & TypographyOwnProps & CommonProps & Omit<Omit<DetailedHTMLProps<HTMLAttributes, HTMLDivElement>, "ref"> & { ...; }, "border" | ... 100 more ... | "variantMapping"> & { ...; }): Element | null', gave the following error.
Type '{ component: "div"; sx: { display: "block" | "-webkit-box"; textOverflow: "initial" | "ellipsis"; overflow: "hidden"; lineClamp: string; WebkitLineClamp: (string & {}) | SystemCssProperties | ... 13 more ... | undefined; WebkitBoxOrient: "initial" | "vertical"; } | ... 5 more ... | { ...; }; ... 364 more ...;...' is not assignable to type 'Omit<Omit<DetailedHTMLProps<HTMLAttributes, HTMLDivElement>, "ref"> & { ref?: ((instance: HTMLDivElement | null) => void) | ... 2 more ... | undefined; }, "border" | ... 100 more ... | "variantMapping">'.
Types of property 'ref' are incompatible.
Type '((instance: HTMLSpanElement | null) => void) | RefObject | null | undefined' is not assignable to type '((instance: HTMLDivElement | null) => void) | RefObject | null | undefined'.
Type 'RefObject' is not assignable to type '((instance: HTMLDivElement | null) => void) | RefObject | null | undefined'.
Type 'RefObject' is not assignable to type 'RefObject'.
Property 'align' is missing in type 'HTMLSpanElement' but required in type 'HTMLDivElement'.
Overload 2 of 2, '(props: DefaultComponentProps<TypographyTypeMap<{}, "span">>): Element | null', gave the following error.
Type '{ component: string; sx: { display: "block" | "-webkit-box"; textOverflow: "initial" | "ellipsis"; overflow: "hidden"; lineClamp: string; WebkitLineClamp: (string & {}) | SystemCssProperties | ... 13 more ... | undefined; WebkitBoxOrient: "initial" | "vertical"; } | ... 5 more ... | { ...; }; ... 364 more ......' is not assignable to type 'IntrinsicAttributes & TypographyOwnProps & CommonProps & Omit<Omit<DetailedHTMLProps<HTMLAttributes, HTMLSpanElement>, "ref"> & { ...; }, "border" | ... 100 more ... | "variantMapping">'.
Property 'component' does not exist on type 'IntrinsicAttributes & TypographyOwnProps & CommonProps & Omit<Omit<DetailedHTMLProps<HTMLAttributes, HTMLSpanElement>, "ref"> & { ...; }, "border" | ... 100 more ... | "variantMapping">'.ts(2769)
lib.dom.d.ts(6524, 5): 'align' is declared here.
Expected behavior 🤔
Expected:
<Typography component="div" />
will be not show type errorContext 🔦
No response
Your environment 🌎
System:
OS: Linux 5.15 Debian GNU/Linux 11 (bullseye) 11 (bullseye)
Binaries:
Node: 18.16.0 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 9.5.1 - /usr/local/bin/npm
Browsers:
Chrome: Not Found
npmPackages:
@emotion/react: 11.11.1 => 11.11.1
@emotion/styled: 11.11.0 => 11.11.0
@mui/base: 5.0.0-beta.8
@mui/core-downloads-tracker: 5.14.1
@mui/icons-material: 5.14.1 => 5.14.1
@mui/lab: 5.0.0-alpha.137 => 5.0.0-alpha.137
@mui/material: 5.14.1 => 5.14.1
@mui/private-theming: 5.13.7
@mui/styled-engine: 5.13.2
@mui/system: 5.14.1 => 5.14.1
@mui/types: 7.2.4
@mui/utils: 5.14.1
@mui/x-date-pickers: 6.10.0 => 6.10.0
@types/react: ^18.2.15 => 18.2.15
react: ^18.2.0 => 18.2.0
react-dom: ^18.2.0 => 18.2.0
typescript: 5.1.6 => 5.1.6
The text was updated successfully, but these errors were encountered: