Get keys of a Typescript interface as array of strings

后端 未结 12 1734
攒了一身酷
攒了一身酷 2020-11-28 03:05

I\'ve a lot of tables in Lovefield and their respective Interfaces for what columns they have.
Example:

export interface IMyTable {
  id: number;
  t         


        
12条回答
  •  难免孤独
    2020-11-28 03:51

    This should work

    var IMyTable: Array = ["id", "title", "createdAt", "isDeleted"];
    

    or

    var IMyTable: (keyof IMyTable)[] = ["id", "title", "createdAt", "isDeleted"];
    

提交回复
热议问题