In typescript, for in loop is used to report errors.

I defined a file api.ts:

export default {
    login: "/account/login post"
}

introduce import api from". / api"

into another file

then loop through the api

for(const key in api) {
     console.log(api[key]);
}

the error message: Element implicitly has an "any" type because type" {login: string;} "has no index signature. is reported at this time.

ts version: 3.0.0

which god has encountered this kind of problem, please let me know, thank you!

Dec.19,2021

resolved. Post my solution:

import api from './api'



const Api: any = api;   //


for(const key in Api) {
    APIFunction[key] = gen(Api[key])
}

just started to learn ts, to write here is not, read the document, I solved this.

     interface Person {
      name: string;
      age: number;
     };
     let i:any;
     let person: Person = {
        name: 'dc',
        age: 35
      };
      const c = <T, K extends keyof T>(o: T, name: K): T[K] => {
        return o[name];
      };
      for(i in person){
        c(person,i)
      }
      
      
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e48da5-59d37.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e48da5-59d37.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?