Property ''@font-face'' is incompatible with index signature.
See original GitHub issueI’m using the material ui createStyles and try to inject the complete styles of body1.
const useStyles = makeStyles()((theme) => ({
root: {
...theme.typography.body1,
},
}))
This will however give an error:
Argument of type '(theme: Theme) => { root: { backgroundColor: string; '@font-face'?: Fontface | Fontface[] | undefined; accentColor?: AccentColor | undefined; ... 783 more ...; vectorEffect?: VectorEffect | undefined; }; }' is not assignable to parameter of type 'Record<"root", CSSObject> | ((theme: Theme, params: void, classes: Record<never, string>) => Record<"root", CSSObject>)'.
Type '(theme: Theme) => { root: { backgroundColor: string; '@font-face'?: Fontface | Fontface[] | undefined; accentColor?: AccentColor | undefined; ... 783 more ...; vectorEffect?: VectorEffect | undefined; }; }' is not assignable to type '(theme: Theme, params: void, classes: Record<never, string>) => Record<"root", CSSObject>'.
Call signature return types '{ root: { backgroundColor: string; '@font-face'?: Fontface | Fontface[] | undefined; accentColor?: AccentColor | undefined; alignContent?: AlignContent | undefined; ... 782 more ...; vectorEffect?: VectorEffect | undefined; }; }' and 'Record<"root", CSSObject>' are incompatible.
The types of 'root' are incompatible between these types.
Type '{ backgroundColor: string; '@font-face'?: Fontface | Fontface[] | undefined; accentColor?: Property.AccentColor | undefined; alignContent?: Property.AlignContent | undefined; ... 782 more ...; vectorEffect?: Property.VectorEffect | undefined; }' is not assignable to type 'CSSObject'.
Property ''@font-face'' is incompatible with index signature.
Type 'Fontface | Fontface[]' is not assignable to type 'CSSInterpolation'.
Type 'Fontface' is not assignable to type 'CSSInterpolation'.
Type 'Fontface' is not assignable to type 'CSSObject'.
Index signature for type 'string' is missing in type 'FontFace<0 | (string & {}), string & {}> & { fallbacks?: FontFace<0 | (string & {}), string & {}>[] | undefined; }'.ts(2345)
I’ve ran into this issue in another situation in the past and in that case it was a version mismatch with csstype
, but I’ve tripple checked but this doesn’t seem to be the case.
It is because of this line in Material UI, if I temporarily comment this out, it wont throw the error: https://github.com/mui-org/material-ui/blob/master/packages/mui-material/src/styles/createTypography.d.ts#L38
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Property is incompatible with index signature - Stack Overflow
Property '"b"' is incompatible with index signature. Type 'undefined' is not assignable to type 'number'. it works if I rename the key ...
Read more >Symbol is incompatible with index signature #21962 - GitHub
I'm trying to use both the index signature in my interface and some symbol fields. They don't seem to work very well together....
Read more >Index Signatures in TypeScript - Dmitri Pavlutin
Property 'baseSalary' is incompatible with index signature. Type 'string' is not assignable to type 'number'.
Read more >Getting Started with Index Signatures in TypeScript
Assume that we have a theme object which allows us to configure the color properties that can be used across the application. The...
Read more >How to Shape Types with Index signature | by Juno Ng - Medium
An index signature define what the interface is. It is like a blueprint to the interface. If other properties of the interface conflict...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Created a minimal helper function to solve the issue:
Using it like this:
Which happens here as well by the way: https://github.com/mui-org/material-ui/blob/259952855e31dfde8c9daa3d7d00f6d88e35f27b/packages/mui-styled-engine/src/index.d.ts#L27-L29