Skip to content

Commit

Permalink
Replace as any
Browse files Browse the repository at this point in the history
  • Loading branch information
Rochmar Nicolas (DevExpress) committed Jul 31, 2024
1 parent cc0ab58 commit f64349e
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ const FeedbackEmitter = Emitter.inherit({
},

});
(FeedbackEmitter as any).lock = function (deferred) {
// @ts-expect-error
FeedbackEmitter.lock = function (deferred) {
const lockInactive = activeFeedback ? activeFeedback.lockInactive() : noop;

deferred.done(lockInactive);
Expand All @@ -172,7 +173,8 @@ registerEmitter({
],
});

export const { lock } = (FeedbackEmitter as any);
// @ts-expect-error
export const { lock } = FeedbackEmitter;
export {
ACTIVE_EVENT_NAME as active,
INACTIVE_EVENT_NAME as inactive,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ const EventManager = Class.inherit({
_attachHandlers() {
readyCallbacks.add(() => {
const document = domAdapter.getDocument();
(eventsEngine as any).subscribeGlobal(document, addNamespace(pointerEvents.down, MANAGER_EVENT), this._pointerDownHandler.bind(this));
(eventsEngine as any).subscribeGlobal(document, addNamespace(pointerEvents.move, MANAGER_EVENT), this._pointerMoveHandler.bind(this));
(eventsEngine as any).subscribeGlobal(document, addNamespace([pointerEvents.up, pointerEvents.cancel].join(' '), MANAGER_EVENT), this._pointerUpHandler.bind(this));
(eventsEngine as any).subscribeGlobal(document, addNamespace(wheelEventName, MANAGER_EVENT), this._mouseWheelHandler.bind(this));
// @ts-expect-error
eventsEngine.subscribeGlobal(document, addNamespace(pointerEvents.down, MANAGER_EVENT), this._pointerDownHandler.bind(this));
// @ts-expect-error
eventsEngine.subscribeGlobal(document, addNamespace(pointerEvents.move, MANAGER_EVENT), this._pointerMoveHandler.bind(this));
// @ts-expect-error
eventsEngine.subscribeGlobal(document, addNamespace([pointerEvents.up, pointerEvents.cancel].join(' '), MANAGER_EVENT), this._pointerUpHandler.bind(this));
// @ts-expect-error
eventsEngine.subscribeGlobal(document, addNamespace(wheelEventName, MANAGER_EVENT), this._mouseWheelHandler.bind(this));
});
},

Expand Down Expand Up @@ -280,8 +284,10 @@ const registerEmitter = function (emitterConfig) {
});

if (disposeEmitter) {
if ((eventManager as any).isActive(element)) {
(eventManager as any).resetEmitter(emitter);
// @ts-expect-error
if (eventManager.isActive(element)) {
// @ts-expect-error
eventManager.resetEmitter(emitter);
}

emitter && emitter.dispose();
Expand Down
15 changes: 10 additions & 5 deletions packages/devextreme/js/__internal/events/core/m_events_engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ const EVENT_PROPERTIES = [
];

function matchesSafe(target, selector) {
return !isWindow(target) && target.nodeName !== '#document' && (domAdapter as any).elementMatches(target, selector);
// @ts-expect-error
return !isWindow(target) && target.nodeName !== '#document' && domAdapter.elementMatches(target, selector);
}
const elementDataMap = new WeakMap();
let guid = 0;
Expand Down Expand Up @@ -187,7 +188,8 @@ function detectPassiveEventHandlersSupport() {
},
});

(window as any).addEventListener('test', null, options);
// @ts-expect-error
window.addEventListener('test', null, options);
// eslint-disable-next-line no-empty
} catch (e) { }

Expand Down Expand Up @@ -321,7 +323,8 @@ function getHandlersController(element, eventName) {
};
}

eventData.removeListener = (domAdapter as any).listen(element, NATIVE_EVENTS_TO_SUBSCRIBE[eventName] || eventName, eventData.nativeHandler, nativeListenerOptions);
// @ts-expect-error
eventData.removeListener = domAdapter.listen(element, NATIVE_EVENTS_TO_SUBSCRIBE[eventName] || eventName, eventData.nativeHandler, nativeListenerOptions);
}

special.callMethod(eventName, 'add', element, [handleObject]);
Expand Down Expand Up @@ -552,7 +555,8 @@ function iterate(callback) {
iterateEventNames.apply(this, args);
}
} else {
iterateEventNames.apply(this, arguments as any);
// @ts-expect-error
iterateEventNames.apply(this, arguments);
}
};
}
Expand Down Expand Up @@ -606,7 +610,8 @@ function initEvent(EventClass) {

initEvent(normalizeEventArguments(function (src, config) {
const srcIsEvent = src instanceof eventsEngine.Event
|| (hasWindow() && src instanceof (window as any).Event)
// @ts-expect-error
|| (hasWindow() && src instanceof window.Event)
|| (src.view?.Event && src instanceof src.view.Event);

if (srcIsEvent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const KeyboardProcessor = Class.inherit({
this._isComposingJustFinished = !this._isComposing;
},
});

(KeyboardProcessor as any).createKeyDownOptions = createKeyDownOptions;
// @ts-expect-error
KeyboardProcessor.createKeyDownOptions = createKeyDownOptions;

export default KeyboardProcessor;
3 changes: 2 additions & 1 deletion packages/devextreme/js/__internal/events/core/m_wheel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ const wheel = {
fireEvent({
type: EVENT_NAME,
originalEvent: e,
// @ts-expect-error
delta: this._normalizeDelta(deltaY, deltaMode),
deltaX,
deltaY,
deltaZ,
deltaMode,
pointerType: 'mouse',
} as any);
});

e.stopPropagation();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ const ScrollEmitter = GestureEmitter.inherit((function () {
},

_end(e) {
const endEventDelta = eventDelta(this._prevEventData, eventData(e) as any);
// @ts-expect-error
const endEventDelta = eventDelta(this._prevEventData, eventData(e));
let velocity = { x: 0, y: 0 };

if (!isDxMouseWheelEvent(e) && endEventDelta.time < INERTIA_TIMEOUT) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ const setGestureCover = callOnce(() => {
const $cover = $('<div>')
.addClass(GESTURE_COVER_CLASS)
.css('pointerEvents', 'none');

(eventsEngine as any).subscribeGlobal($cover, 'dxmousewheel', (e) => {
// @ts-expect-error
eventsEngine.subscribeGlobal($cover, 'dxmousewheel', (e) => {
e.preventDefault();
});

Expand Down Expand Up @@ -145,7 +145,8 @@ const GestureEmitter = Emitter.inherit({

_directionConfirmed(e) {
const touchBoundary = this._getTouchBoundary(e);
const delta = eventDelta(this._startEventData, eventData(e) as any);
// @ts-expect-error
const delta = eventDelta(this._startEventData, eventData(e));
const deltaX = abs(delta.x);
const deltaY = abs(delta.y);

Expand All @@ -170,7 +171,8 @@ const GestureEmitter = Emitter.inherit({

_adjustStartEvent(e) {
const touchBoundary = this._getTouchBoundary(e);
const delta = eventDelta(this._startEventData, eventData(e) as any);
// @ts-expect-error
const delta = eventDelta(this._startEventData, eventData(e));

this._startEvent.pageX += sign(delta.x) * touchBoundary;
this._startEvent.pageY += sign(delta.y) * touchBoundary;
Expand Down Expand Up @@ -227,8 +229,10 @@ const GestureEmitter = Emitter.inherit({
_end: noop,

});
(GestureEmitter as any).initialTouchBoundary = TOUCH_BOUNDARY;
(GestureEmitter as any).touchBoundary = function (newBoundary) {
// @ts-expect-error
GestureEmitter.initialTouchBoundary = TOUCH_BOUNDARY;
// @ts-expect-error
GestureEmitter.touchBoundary = function (newBoundary) {
if (isDefined(newBoundary)) {
TOUCH_BOUNDARY = newBoundary;
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const ACTION_TO_EVENT_MAP = {
};

const IMMEDIATE_TIMEOUT = 180;

const Swipeable = (DOMComponent as any).inherit({
// @ts-expect-error
const Swipeable = DOMComponent.inherit({

_getDefaultOptions() {
return extend(this.callBase(), {
Expand Down
3 changes: 2 additions & 1 deletion packages/devextreme/js/__internal/events/m_hold.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ const HoldEmitter = Emitter.inherit({
},

_touchWasMoved(e) {
const delta = eventDelta(this._startEventData, eventData(e) as any);
// @ts-expect-error
const delta = eventDelta(this._startEventData, eventData(e));

return abs(delta.x) > TOUCH_BOUNDARY || abs(delta.y) > TOUCH_BOUNDARY;
},
Expand Down
7 changes: 4 additions & 3 deletions packages/devextreme/js/__internal/events/m_pointer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ const getStrategy = (support, { tablet, phone }) => {

return MouseStrategy;
};

const EventStrategy = getStrategy(support, devices.real() as any);
// @ts-expect-error
const EventStrategy = getStrategy(support, devices.real());

each(EventStrategy.map, (pointerEvent, originalEvents) => {
registerEvent(pointerEvent, new EventStrategy(pointerEvent, originalEvents));
Expand All @@ -43,12 +43,13 @@ const pointer = {
};

function getStrategyFromGlobalConfig() {
const eventStrategyName = GlobalConfig().pointerEventStrategy as any;
const eventStrategyName = GlobalConfig().pointerEventStrategy;

return {
'mouse-and-touch': MouseAndTouchStrategy,
touch: TouchStrategy,
mouse: MouseStrategy,
// @ts-expect-error
}[eventStrategyName];
}

Expand Down
3 changes: 2 additions & 1 deletion packages/devextreme/js/__internal/events/m_remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ beforeCleanData((elements) => {
// @ts-expect-error
if ($element.prop(eventPropName)) {
$element[0][eventPropName] = null;
eventsEngine.triggerHandler($element, removeEvent as any);
// @ts-expect-error
eventsEngine.triggerHandler($element, removeEvent);
}
}
});
Expand Down
12 changes: 8 additions & 4 deletions packages/devextreme/js/__internal/events/pointer/m_mouse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,14 @@ const MouseStrategy = BaseStrategy.inherit({
},

});
(MouseStrategy as any).map = eventMap;
(MouseStrategy as any).normalize = normalizeMouseEvent;
(MouseStrategy as any).activate = activateStrategy;
(MouseStrategy as any).resetObserver = function () {
// @ts-expect-error
MouseStrategy.map = eventMap;
// @ts-expect-error
MouseStrategy.normalize = normalizeMouseEvent;
// @ts-expect-error
MouseStrategy.activate = activateStrategy;
// @ts-expect-error
MouseStrategy.resetObserver = function () {
observer.reset();
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const activateStrategy = function () {
if (activated) {
return;
}

(MouseStrategy as any).activate();
// @ts-expect-error
MouseStrategy.activate();

activated = true;
};
Expand Down Expand Up @@ -66,7 +66,8 @@ const MouseAndTouchStrategy = BaseStrategy.inherit({
},

_fireEvent(args) {
const normalizer = isMouseEvent(args.originalEvent) ? (MouseStrategy as any).normalize : (TouchStrategy as any).normalize;
// @ts-expect-error
const normalizer = isMouseEvent(args.originalEvent) ? MouseStrategy.normalize : TouchStrategy.normalize;

return this.callBase(extend(normalizer(args.originalEvent), args));
},
Expand Down

0 comments on commit f64349e

Please sign in to comment.