[@emotion/styled] styled() function props argument losing typing. #2898
-
Current behavior: import styled from "@emotion/styled";
import { theme } from "../../theme";
import type { Props, Variant } from "./Typography.types";
const getStyles = (variant: Variant | undefined) =>
theme.typography[variant as Variant] || {};
const StyledTypography = styled("p")<Props>(
{
margin: "0 1px",
},
(props) => ({
...getStyles(props.variant),
"text-align": props.align,
})
);
export { StyledTypography }; This seems to be a rule in tsconfig's compilerOptions, but I have not been able to pinpoint the exact root. I've tried adding them one by one and it seems to happen at random rules (it doesn't always break at the same one). As far as I can tell, this happens when I use the To reproduce: Requirements: pnpm installed. I'm not entirely sure if it's relevant (it MIGHT be), but that's what the project uses.
Expected behavior: @emotion/styled passes all types to the Environment information:
Notes:
Sorry for the lengthy explanation! Hope I was clear enough. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
I commented out this line from "preserveSymlinks": true,
I'm not exactly sure why that option was causing the behavior you observed, but FWIW, I have never used this compiler option, and I would not recommend using it unless you have a compelling reason to do so. |
Beta Was this translation helpful? Give feedback.
-
@srmagura Hi! Thanks for the prompt reply. You are right, removing it did fix my issue (though caused some others on some other areas of my project). I was able to work around my issues, but it does seem that |
Beta Was this translation helpful? Give feedback.
I commented out this line from
packages/tsconfig/base.json
and it started working:tsc
(in theui-tools
folder) now reports 2 errors which are both legit.preserveSymlinks
in the TypeScript docsI'm not exactly sure why that option was causing the behavior you observed, but FWIW, I have never used this compiler option, and I would not recommend using it unless you have a compelling reason to do so.