TypeScript-DOM-lib-generator icon indicating copy to clipboard operation
TypeScript-DOM-lib-generator copied to clipboard

Certain types such as MouseEvent.button not defined

Open JasonGore opened this issue 3 years ago • 3 comments

I noticed some values for types such as MouseEvent.button are defined in Web API specs but are not defined in lib.dom.ts:

0: Main button pressed, usually the left button or the un-initialized state
1: Auxiliary button pressed, usually the wheel button or the middle button (if present)
2: Secondary button pressed, usually the right button
3: Fourth button, typically the Browser Back button
4: Fifth button, typically the Browser Forward button

If this is intentional, I'm wondering what the rationale is. (I could not find any similar issues or couldn't find the right terms.)

terms: MouseEvent, button

JasonGore avatar Dec 06 '21 17:12 JasonGore

My lib.dom.d.ts from ts4.5 has this in Line 12056:

/** Events that occur due to the user interacting with a pointing device (such as a mouse). Common events using this interface include click, dblclick, mouseup, mousedown. */
interface MouseEvent extends UIEvent {
    readonly altKey: boolean;
    readonly button: number;

Or do you want to have this?

readonly button: 0|1|2|3|4;

HolgerJeromin avatar Dec 07 '21 07:12 HolgerJeromin

Since the spec defines meaning for the values I was looking for something more like:

declare const BUTTON_MAIN: 0;
declare const BUTTON_MIDDLE: 1;
declare const BUTTON_RIGHT: 2;
...

JasonGore avatar Dec 07 '21 18:12 JasonGore

They are not defined in the browsers (others like WebSocket.CLOSED are). So defining them would be an TypeScript only invention. I don't think this would align to the mission of TypeScript.

HolgerJeromin avatar Dec 07 '21 19:12 HolgerJeromin

I think this is well answered 👍

@github-actions close

saschanaz avatar Sep 18 '22 12:09 saschanaz

Closing because @saschanaz is one of the code-owners of this repository.

github-actions[bot] avatar Sep 18 '22 12:09 github-actions[bot]