Skip to content

DOMStringMap is defined as an empty interface - this makes it awkward to use #1852

Closed
@sccolbert

Description

@sccolbert

The DOMStringMap interface is defined as follows:

https://github.com/Microsoft/TypeScript/blob/master/src/lib/dom.generated.d.ts#L10556

interface DOMStringMap {
}
declare var DOMStringMap: {
    prototype: DOMStringMap;
    new(): DOMStringMap;
}

This means it's a compile error to directly access the object properties, but it's also an implicit any error if the --noImplicitAny switch is turned on in the compiler. This makes using a node's dataset somewhat arduous since a cast is required.

I'm not sure if there is some way to declare that an object has arbitrary properties of some given type, but perhaps a minimal working solution would be to give this interface a string indexer:

interface DOMStringMap {
  [key: string]: string;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptFixedA PR has been merged for this issueRevisitAn issue worth coming back to

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions