TypeScript interface for object with arbitrary numeric property names?

The solution for “TypeScript interface for object with arbitrary numeric property names?” can be found here. The following code will assist you in solving the problem.

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

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

0
inline scripts encapsulated in