1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

How can I extract the properties of an interface using TypeScript (preferably with no 3rd...

Discussão em 'Angular' iniciado por DaNe505, Setembro 30, 2024.

  1. DaNe505

    DaNe505 Guest

    I need to get the properties of an interface to make sure that they match an object that implements it. For unit testing purposes.

    So if changes are made to the interface the unit test should break if it isn't updated with the new members.

    I've tried using the ts-transformer-keys package but it throws an error about not being a function.

    interface Test {
    mem1: boolean,
    mem2: string
    }


    I would like to do something like this:

    console.log(Object.keys(Test))


    and expect

    ['mem1', 'mem2'];

    Continue reading...

Compartilhe esta Página