html5 - How can I use DOMStringMap in TypeScript? -
let's have function:
angular.foreach(myelements, function prepareelements(myel: htmlelement, index) { myel.dataset.myproperty = "whatever"; })
the problem error ts2094: property 'myproperty' not exist on value of type 'domstringmap'
i don't understand interface
in lib.d.ts
interface domstringmap { } declare var domstringmap: { prototype: domstringmap; new (): domstringmap; }
then later on...
interface htmlelement { dataset: domstringmap; hidden: boolean; msgetinputcontext(): msinputmethodcontext; }
is me or little unclear?
i tried casting <domstringmap>myel.dataset.myproperty = "whatever"
, did nothing...
the domstringmap interface empty because spec not finalized : https://developer.mozilla.org/en/docs/web/api/domstringmap
in meantime can use: myel.dataset['myproperty'] = "whatever";
Comments
Post a Comment