TypeScript · Junior · Question 38 of 75

How do you describe an object with arbitrary string keys and number values using an index signature?

Explanation

An index signature describes a "dictionary". The equivalent is Record<string, number>. With the noUncheckedIndexedAccess flag, obj[key] returns number | undefined, which better reflects reality.

Further reading

Problem with a question

TypeScript · Junior · question 38

Test yourself

Take the TypeScript · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz