“"tech"”类型的参数不可分配给 'PropsWithChildren<Props>' 类型的参数

Argument of type '"tech"' is not assignable to parameter of type 'PropsWithChildren<Props>'

我在尝试测试函数 getProblemType 时遇到错误。 Argument of type '"tech"' is not assignable to parameter of type 'PropsWithChildren<Props>'. 下面是我的组件的代码。

interface Props {
  type: SupportType;
}

export function getProblemType(srType:SupportType):ProblemTypeEnum {
  switch (srType) {
    case "limit":
      return "LIMIT";
    case "account":
      return "ACCOUNT";
    default:
      return "TECH";
  }
}
const Auth: React.FC<Props> = (props) => {
  const problemType  = getProblemType(props.supportType);
  const supportValidate = apiCalls.callSupport(false, "123", userId, problemType, state.homeRegionName);
 return (<>....</>)
};
export default Auth;

我的测试如下所示

describe("Auth tests", () => {
  let mock : Props;
  const runProblemTypeTest = (url: string, supportType: SupportType) => {
  }
  mount(
      <Auth supportType={supportType}>
        <div>TestChild</div>
      </Authorization>
    );
    expect(apiCalls).toHaveBeenCalledWith(
      false,
      "1234",
      "test",
      getProblemType(supportType),
      "homeRegion"
    );

  it("check getProblemType when support is tech", () => {
    mock.supportType = "tech";
    expect(getProblemType(mock.supportType)).toEqual("TECH");
  });
  
  it("check problem type passed to validate when problem type absent in the url", () => {
    mock.supportType = "tech";
    runProblemTypeTest("http://www.test.com", "tech");
  });
});

当我在 getProblemType 上传递 mock.supportType 时,出现以下错误 Argument of type '"tech"' is not assignable to parameter of type 'PropsWithChildren<Props>'.

测试错误地使用默认导入而不是命名。所以 getProblemType 被分配了组件并期望传递道具。因此错误。通过插入大括号修复:

 import { getProblemType } from "components/Common/Authorization";