Theo's Typesafe CultTTC
Theo's Typesafe Cult3y ago
24 replies
Vimes

Type of return from await

getting a TS error stating "34:9 Error: Unsafe assignment of an any value." on my await in getServerSideProps. Tried to scour the docs for a solution but can't find anywhere where someone sets a type that works for me await.
getAudit is a JS function, not TS (yet). Any ideas on how I should best solve this?
export const getServerSideProps: GetServerSideProps = async (params) => {
  const audit= await getAudit(`/granskninger/${params.query.slug}`); //  34:9  Error: Unsafe assignment of an `any` value. + 34:48  Error: Invalid type "string | string[] | undefined" of template literal expression. 
  return {
    props: { audit }
  };
};


I have the "correct" props for my render function in the page
type Props = {
  audit: {
    content: {
      descendants: {  items: ContentProps[]; };
      id: string;
      level: number;
      name: string;

    };
  };
};
Was this page helpful?