Thursday, 25 July 2019

typescript what is {[key: string]: any;}

https://github.com/microsoft/typed-rest-client/blob/bdd88a921c2b5d27ff6cdcfe798996befc99c976/lib/Interfaces.ts

in above code you can see code like this:

interface AA {[key: string]: any}

that means AA is an object with string key and value for anything e.g.

let aa = <AA>{};
aa["xxx"] = {}
aa['dd'] = []


No comments:

Post a comment