如何在Vscode中更改CSS版本



我使用的是节点v.12.18.4和typscript 4.5我在编译时得到这个错误:

未能编译。

/Users/mariana/Augment Therapy/at-app/src/components/nav-item.tsx
TypeScript error in /Users/mariana/Augment Therapy/at-app/src/components/nav-item.tsx(14,30):
Argument of type '(theme: Theme) => { item: { display: string; paddingTop: number; paddingBottom: number; }; itemLeaf: { display: string; paddingTop: number; paddingBottom: number; }; button: { padding: string; justifyContent: string; textTransform: "none"; letterSpacing: number; width: string; color: string; }; ... 4 more ...; activ...' is not assignable to parameter of type 'Styles<Theme, {}, "button" | "label" | "icon" | "active" | "item" | "itemLeaf" | "buttonLeaf" | "expandIcon">'.
Type '(theme: Theme) => { item: { display: string; paddingTop: number; paddingBottom: number; }; itemLeaf: { display: string; paddingTop: number; paddingBottom: number; }; button: { padding: string; justifyContent: string; textTransform: "none"; letterSpacing: number; width: string; color: string; }; ... 4 more ...; activ...' is not assignable to type 'StyleRulesCallback<Theme, {}, "button" | "label" | "icon" | "active" | "item" | "itemLeaf" | "buttonLeaf" | "expandIcon">'.
Call signature return types '{ item: { display: string; paddingTop: number; paddingBottom: number; }; itemLeaf: { display: string; paddingTop: number; paddingBottom: number; }; button: { padding: string; justifyContent: string; textTransform: "none"; letterSpacing: number; width: string; color: string; }; ... 4 more ...; active: { ...; }; }' and 'StyleRules<{}, "button" | "label" | "icon" | "active" | "item" | "itemLeaf" | "buttonLeaf" | "expandIcon">' are incompatible.
The types of 'active' are incompatible between these types.
Type '{ color: string; background: string; fontWeight: Property.FontWeight | undefined; '& $icon': { color: string; }; }' is not assignable to type 'CSSProperties | CreateCSSProperties<{}> | PropsFunc<{}, CreateCSSProperties<{}>>'.
Type '{ color: string; background: string; fontWeight: Property.FontWeight | undefined; '& $icon': { color: string; }; }' is not assignable to type 'CreateCSSProperties<{}>'.
Types of property 'fontWeight' are incompatible.
Type 'FontWeight | undefined' is not assignable to type 'FontWeightProperty | PropsFunc<{}, FontWeightProperty | undefined> | undefined'.
Type 'string & {}' is not assignable to type 'FontWeightProperty | PropsFunc<{}, FontWeightProperty | undefined> | undefined'.
Type 'string & {}' is not assignable to type '"lighter"'.  TS2345
12 | import ExpandLessIcon from '@material-ui/icons/ExpandLess';
13 | 
> 14 | const useStyles = makeStyles((theme: Theme) => ({
|                              ^
15 |   item: {
16 |     display: 'block',
17 |     paddingTop: 0,

@下面的Diego指出了CSS的根本问题。有人知道修复方法吗?或者如何将我的CSS类型锁定为3.0.9?谢谢

这不是由TypeScript引起的,而是由以下问题引起的:https://github.com/frenic/csstype/issues/148

请与npm ls csstype核实您的node_modules中有哪些版本的csstype。我敢打赌,某些依赖关系已解析为csstype3.0.10

最新更新