Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

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
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #TypeScript #interface #object #arbitrary #numeric #property
ADD COMMENT
Topic
Name
3+6 =