0

Given the following class:

class Example {
 get name () {
  return 'thomas'
 }

 age () {
   return 30
 }

}

I can get the keys as a type:

type ExampleKeys = keyof Example

However this returns all of the keys.

Is it possible to only get getters? Or Only get Methods? I'd suppose if you can get one you can exclude to get the other.

ThomasReggi
  • 55,053
  • 85
  • 237
  • 424
  • If this helps, you can get all the "function" keys: `type FunctionKeys = { [P in keyof T]: T[P] extends Function ? P : never }[keyof T];` then you can exclude them from the list of all keys – Aleksey L. Jan 12 '20 at 10:10
  • Does this answer your question? [How to exclude getter only properties from type in typescript](https://stackoverflow.com/questions/52443276/how-to-exclude-getter-only-properties-from-type-in-typescript) – Aleksey L. Jan 12 '20 at 10:11

0 Answers0