Answers for "TypeScript interface for object with arbitrary numeric property names?"

0

TypeScript interface for object with arbitrary numeric property names?

interface NumberToString {
    [n: number]: string;
}

var x: NumberToString;
x = { 1: 42 }; // Error
x[1].charAt(0); // OK

x['foo'] = 'bar'; // Still not an error, though
Posted by: Guest on December-04-2020

Code answers related to "TypeScript interface for object with arbitrary numeric property names?"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language