Skip to content
dreamcode
dreamcode
Map
TS Expert Challenge
Section challenge · AdvancedTypeScript
Reward: +70 XP
PROBLEM

TS Expert Challenge

Define a mapped type StringifyProperties<T> which maps all properties of type T to be of type string.

Write a function stringifyConfig(config) that takes an object, converts all of its property values to strings using String(), and returns the transformed object conforming to StringifyProperties<T>. Ensure you iterate through all owned keys of the input object.

Examples
stringifyConfig({ port: 80 })
{ port: "80" }
stringifyConfig({ debug: true, val: 0 })
{ debug: "true", val: "0" }
solution.ts
TYPESCRIPT
Saved as you type

Tests

0 of 3 passing
  • { port: 80 } → { port: '80' }
    stringifyConfig({ port: 80 })
    expected { port: "80" }
  • { debug: true, val: 0 } → { debug: 'true', val: '0' }
    stringifyConfig({ debug: true, val: 0 })
    expected { debug: "true", val: "0" }
  • {} → {}
    stringifyConfig({})
    expected {}
On the line
+70 XP
Pass all 3 tests to claim it.