How to ensure all keys in object are strings?

140 views Asked by At

Playground

How do I get this key to be a string when it also has to be a keyof T?

function hello <T extends {[key: string]: string}> (object: T, key: keyof T) {
  hasToBeString(key)
              // ^?
}

const hasToBeString = (v: string) => {
  return v
}

enter image description here

0

There are 0 answers