简体   繁体   中英

How to fix this JS into TS?

{ for (var i: number = 0; i < selectedProfile.length; i++) {
    if (i % 3 === 2) {
      <div className="sliderContainer">
    }
  } 
}

An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type.ts(2356). A parameter initializer is only allowed in a function or constructor implementation.

How can I fix this this? Error happening on the first line?

Interface definition of a object in that array would be the following:

export interface ILinkedInProfile { 
  postContent: string; 
  postUrl: string; 
  profileUrl: string; 
  action: string; 
  imgUrl: string; 
  likeCount: number; 
  companyName: string; 
}

The Property 'length' does not exist on the type of Object.

You can try Object.keys(selectedProfile).length to get it's length

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM