Home > Mobile >  Retrieve inferred string literal from object keys
Retrieve inferred string literal from object keys

Time:01-29

I'm trying to create a type that defines the value based on the key. If the key extends $${string} (e.g. $foo) the value should be the key without the prefix e.g. foo. If the key doens't extend $${string} (e.g. boo) the values should be null.

Example

const example = {
  $foo: 'foo',
  boo: null,
}

Here is an isolated example I created to get it done - but it doesn't work as intended when I apply it to the code below.

  • Related