如何在 Vscode 中更改 CSS 版本?

How to change CSS version in Vscode?

我正在使用 node 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。我敢打赌,某些依赖项已解析为 csstype 3.0.10.