forked from jgraph/mxgraph
-
Notifications
You must be signed in to change notification settings - Fork 199
Closed
Milestone
Description
Looks like in newer versions of Typescript (i think 4.9 and above) this code is failed to transpile:
maxGraph/packages/core/src/util/EventUtils.ts
Lines 124 to 134 in d30e3a2
| export const isLeftMouseButton = (evt: MouseEvent) => { | |
| // Special case for mousemove and mousedown we check the buttons | |
| // if it exists because which is 0 even if no button is pressed | |
| if ('buttons' in evt && (evt.type === 'mousedown' || evt.type === 'mousemove')) { | |
| return evt.buttons === 1; | |
| } | |
| if ('which' in evt) { | |
| return evt.which === 1; | |
| } | |
| return evt.button === 1; | |
| }; |
error is Error: src/util/EventUtils.ts(133,14): error TS2339: Property 'button' does not exist on type 'never'
The easiest way to reproduce is to copy this method into https://www.typescriptlang.org/play?ts=next
The way to fix this error with minimum changes is replace 'which' in evt with evt.which !== undefined at line 130.
Possible reason - which is marked as deprecated, so 'which' in evt check now casts evt to never type
Metadata
Metadata
Assignees
Labels
No labels