Skip to content

HTMLInputElement have incompatible type for "selectionDirection" and setSelectionRange #32449

@xileftenurb

Description

@xileftenurb

TypeScript Version: 3.6.0-dev.20190717
Search Terms:
selectionDirection HTMLInputElement DOM definition
Code

const el : HTMLTextAreaElement = new HTMLTextAreaElement();
const direction = el.selectionDirection;
el.setSelectionRange(el.selectionStart, el.selectionEnd, direction );

Expected behavior:
No error, as el.selectionDirection is definitely a good value for selectionDirection

Actual behavior:
tsc throw an error because el.selectionDirection is of type "string" and el.setSelectionRange only accept "forward" | "backward" | "none"

solution :
HTMLInputElement.selectionDirection should be of type : "forward" | "backward" | "none" instead of type string. in lib.dom.d.ts at line 7332.

Related Issues:
the bug was introduced by the fixing of setSelectionRange as discuted in issue #20419 and PR #20459

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions