Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MouseWheelEvent -> WheelEvent - Intentional Breaking Change #9071

Closed
kitsonk opened this issue Jun 10, 2016 · 3 comments
Closed

MouseWheelEvent -> WheelEvent - Intentional Breaking Change #9071

kitsonk opened this issue Jun 10, 2016 · 3 comments
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Fixed A PR has been merged for this issue

Comments

@kitsonk
Copy link
Contributor

kitsonk commented Jun 10, 2016

TypeScript Version:

nightly (v1.9.0-dev.20160610-1.0)

Code

let mouseWheelEvent: MouseWheelEvent;

Expected behavior:

Compiles without issue...

Actual behavior:

Errors with error TS2304: Cannot find name 'MouseWheelEvent'.

It appears up until about 21 days ago when the lib.dom.d.ts was updated, what was previously named MouseWheelEvent is now named WheelEvent. Looking it seems that historically IE/Edge had referred to it as MouseWheelEvent and now refers to it by the living DOM standard of WheelEvent, but I suspect this will cause a lot of breakage and downstream typings libraries (I have at least two sets of typings that are now "broken").

I suspect it is in everyone's best interest to move forward, but I suspect this will cause some carnage when TS2.0 gets released and maybe should go into whatever breaking changes pile there is.

For reference, a simple workaround is to put within a .d.ts file within the scope of the project:

declare type MouseWheelEvent = WheelEvent;
@mhegazy
Copy link
Contributor

mhegazy commented Jun 10, 2016

This seems like a reasonable fix.

@mhegazy mhegazy added the Bug A bug in TypeScript label Jun 10, 2016
@mhegazy mhegazy added this to the TypeScript 2.0 milestone Jun 10, 2016
@mhegazy mhegazy added the Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript label Jun 10, 2016
@zhengbli zhengbli added Fixed A PR has been merged for this issue and removed Fixed in TSJS repo labels Jun 17, 2016
@use-strict
Copy link

use-strict commented Jul 27, 2016

@mhegazy, seems to me having a type alias is not very useful without the constructor signature. I wonder why it was removed. AFAIK, IE still uses MouseWheelEvent. For instance, we had this code that breaks now:

let delta: number;
if (typeof MouseWheelEvent !== 'undefined' && ev instanceof MouseWheelEvent) {
    delta = -ev.wheelDelta;
} else if (ev instanceof WheelEvent) {
    delta = ev.deltaY;
}

Is the intention to only have standard APIs in the lib, without ms* specific things? Since we still target IE11, how should we handle such cases? e.g. msRequestAnimationFrame, which was also removed.

@use-strict
Copy link

Also, the type alias makes it impossible to augment the interface with extra properties, in the project scope.

This snippet is the old definition. I tried adding this manually in the project but it conflicts with the standard definitions:

interface MouseWheelEvent extends MouseEvent {
    wheelDelta: number;
    wheelDeltaX: number;
    wheelDeltaY: number;
    initMouseWheelEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, buttonArg: number, relatedTargetArg: EventTarget, modifiersListArg: string, wheelDeltaArg: number): void;
}

declare var MouseWheelEvent: {
    prototype: MouseWheelEvent;
    new(): MouseWheelEvent;
}

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

4 participants