Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions packages/devextreme/js/__internal/core/component_registrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,28 @@ interface ComponentInstance {

type ComponentMember = (...args: unknown[]) => unknown;

interface ComponentClass {
getInstance: (element: Element) => ComponentInstance | undefined;
new (element: Element, options?: unknown): ComponentInstance;
interface ComponentClass<TInstance = ComponentInstance> {
getInstance: (element: Element) => TInstance | undefined;
new (element: Element, options?: unknown): TInstance;
}

type ComponentNamespace = Record<string, ComponentClass>;
type ComponentNamespace = Record<string, ComponentClass<object>>;

function registerComponent(name: string, componentClass: ComponentClass): void;
function registerComponent(name: string, componentClass: ComponentClass<object>): void;
function registerComponent(
name: string,
namespace: ComponentNamespace,
componentClass: ComponentClass,
componentClass: ComponentClass<object>,
): void;
function registerComponent(
name: string,
namespace: ComponentNamespace | ComponentClass,
componentClass?: ComponentClass,
namespace: ComponentNamespace | ComponentClass<object>,
componentClass?: ComponentClass<object>,
): void {
let registeredClass = componentClass;

if (!registeredClass) {
registeredClass = namespace as ComponentClass;
registeredClass = namespace as ComponentClass<object>;
} else {
(namespace as ComponentNamespace)[name] = registeredClass;
}
Expand Down
6 changes: 2 additions & 4 deletions packages/devextreme/js/__internal/core/format_helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { injector as dependencyInjector } from '@ts/core/utils/dependency_inject
import { getGlobalFormatByDataType } from './global_format_config';

export default dependencyInjector({
format(value, format) {
format(value, format?) {
const formatIsValid = (isString(format) && format !== '')
|| isPlainObject(format) || isFunction(format);
const valueIsValid = isNumeric(value) || (isDate(value) && !isNaN(value.getTime()));
Expand All @@ -30,7 +30,6 @@ export default dependencyInjector({
if (!formatIsValid && isNumeric(value)) {
const globalNumberFormat = getGlobalFormatByDataType('number');
if (globalNumberFormat) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return numberLocalization.format(value, globalNumberFormat);
}
}
Expand All @@ -47,7 +46,6 @@ export default dependencyInjector({
const resolvedFormat = isString(format) ? { type: format } : format;

if (isNumeric(value)) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return numberLocalization.format(value, resolvedFormat);
}

Expand Down Expand Up @@ -77,7 +75,7 @@ export default dependencyInjector({
};
},

getDateFormatByDifferences(dateDifferences, intervalFormat) {
getDateFormatByDifferences(dateDifferences, intervalFormat?) {
const resultFormat: Format[] = [];
const needSpecialSecondFormatter = intervalFormat && dateDifferences.millisecond
&& !(dateDifferences.year || dateDifferences.month || dateDifferences.day);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { extend } from '@ts/core/utils/m_extend';
import { humanize } from '@ts/core/utils/m_inflector';
import { format as stringFormat } from '@ts/core/utils/m_string';

export type MessageFormatter = () => string;
export type MessageFormatter = (...values: unknown[]) => string;
export type MessageDictionary = Record<string, Record<string, string>>;

const baseDictionary: MessageDictionary = extend(true, {}, defaultMessages);
Expand Down Expand Up @@ -109,7 +109,6 @@ const messageLocalization = dependencyInjector({
// eslint-disable-next-line prefer-rest-params
const values = Array.prototype.slice.call(arguments, 1);

// @ts-expect-error
return formatter?.apply(this, values) || '';
},
});
Expand Down
2 changes: 1 addition & 1 deletion packages/devextreme/js/__internal/core/utils/m_common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export const noop = function () {};
// @ts-expect-error only void function can be called with new
export const asyncNoop = function () { return new Deferred().resolve().promise(); };

export const grep = function (elements, checkFunction, invert) {
export const grep = function (elements, checkFunction, invert?) {
const result: any[] = [];
let check;
const expectedCheck = !invert;
Expand Down
3 changes: 3 additions & 0 deletions packages/devextreme/js/__internal/core/utils/m_deferred.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Callbacks from '@js/core/utils/callbacks';
import type { DeferredObj as DeferredInstance } from '@js/core/utils/deferred';
import { extend } from '@js/core/utils/extend';
import { isDeferred, isDefined, isPromise } from '@js/core/utils/type';

Expand Down Expand Up @@ -169,10 +170,12 @@ export function setStrategy(value) {
whenFunc = value.when;
}

export function Deferred<T>(): DeferredInstance<T>;
export function Deferred() {
return new DeferredObj();
}

export function when<T>(...values: (DeferredInstance<T> | T)[]): DeferredInstance<T>;
export function when() {
// @ts-expect-error
return whenFunc.apply(this, arguments);
Expand Down
3 changes: 1 addition & 2 deletions packages/devextreme/js/__internal/ui/themes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ function initContext(newContext): void {
}

function getCssClasses(themeName?: string): string[] {
// @ts-expect-error ts-error
// eslint-disable-next-line @stylistic/max-len
// eslint-disable-next-line no-param-reassign,@typescript-eslint/no-use-before-define, @typescript-eslint/prefer-nullish-coalescing
themeName = themeName || current();
Expand Down Expand Up @@ -287,7 +286,7 @@ export function detachCssClasses(element: dxElementWrapper): void {

// eslint-disable-next-line @stylistic/max-len
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types,@typescript-eslint/explicit-function-return-type,consistent-return
export function current(options) {
export function current(options?) {
if (!arguments.length) {
currentThemeName = currentThemeName || readThemeMarker();
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
Expand Down
16 changes: 7 additions & 9 deletions packages/devextreme/js/__internal/viz/axes/base_axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,15 @@
/* eslint-disable @typescript-eslint/no-unused-expressions */
/* eslint-disable @typescript-eslint/prefer-optional-chain */

import { noop as _noop } from '@js/core/utils/common';
import dateUtils from '@js/core/utils/date';
import { Deferred, when } from '@js/core/utils/deferred';
import { extend } from '@js/core/utils/extend';
import { adjust } from '@js/core/utils/math';
import formatHelper from '@ts/core/format_helper';
import { noop as _noop } from '@ts/core/utils/m_common';
import { dateUtils } from '@ts/core/utils/m_date';
import { Deferred, when } from '@ts/core/utils/m_deferred';
import { extend } from '@ts/core/utils/m_extend';
import { adjust, multiplyInExponentialForm } from '@ts/core/utils/m_math';
import {
isDate, isDefined, isFunction, isPlainObject, type,
} from '@js/core/utils/type';
import formatHelper from '@js/format_helper';
import { multiplyInExponentialForm } from '@ts/core/utils/m_math';
} from '@ts/core/utils/m_type';
import constants from '@ts/viz/axes/axes_constants';
import { calculateCanvasMargins, measureLabels } from '@ts/viz/axes/axes_utils';
import createConstantLine from '@ts/viz/axes/constant_line';
Expand Down Expand Up @@ -1965,7 +1964,6 @@ export let Axis = class Axis {
const ticks = this._getTicks(range, incidentOccurred, false);

if (!range.isEmpty() && options.type === constants.discrete && options.dataType === 'datetime' && !this._hasLabelFormat && ticks.ticks.length) {
// @ts-expect-error getDateFormatByTicks is not in the FormatHelper typings
options.label.format = formatHelper.getDateFormatByTicks(ticks.ticks);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/explicit-function-return-type */

import { isDefined } from '@js/core/utils/type';
import { isDefined } from '@ts/core/utils/m_type';

export default function createConstantLine(axis, options) {
const labelOptions = options.label || {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/explicit-function-return-type */

import dateUtils from '@js/core/utils/date';
import { dateUtils } from '@ts/core/utils/m_date';

const days = [0, 1, 2, 3, 4, 5, 6];

Expand Down
6 changes: 3 additions & 3 deletions packages/devextreme/js/__internal/viz/axes/polar_axes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
/* eslint-disable @typescript-eslint/no-unused-expressions */
/* eslint-disable @typescript-eslint/prefer-optional-chain */

import { noop as _noop } from '@js/core/utils/common';
import { extend } from '@js/core/utils/extend';
import { isDefined } from '@js/core/utils/type';
import { noop as _noop } from '@ts/core/utils/m_common';
import { extend } from '@ts/core/utils/m_extend';
import { isDefined } from '@ts/core/utils/m_type';
import constants from '@ts/viz/axes/axes_constants';
import { calculateCanvasMargins, measureLabels } from '@ts/viz/axes/axes_utils';
import { tick } from '@ts/viz/axes/tick';
Expand Down
15 changes: 5 additions & 10 deletions packages/devextreme/js/__internal/viz/axes/smart_formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
/* eslint-disable @typescript-eslint/no-use-before-define */
/* eslint-disable @typescript-eslint/explicit-function-return-type */

import dateUtils from '@js/core/utils/date';
import { adjust, getExponent, getPrecision } from '@js/core/utils/math';
import formatHelper from '@ts/core/format_helper';
import { getGlobalFormatByDataType } from '@ts/core/global_format_config';
import { dateUtils } from '@ts/core/utils/m_date';
import { adjust, getExponent, getPrecision } from '@ts/core/utils/m_math';
import {
isDefined, isExponential, isFunction, isObject,
} from '@js/core/utils/type';
import formatHelper from '@js/format_helper';
import { getGlobalFormatByDataType } from '@ts/core/global_format_config';
} from '@ts/core/utils/m_type';
import { getAdjustedLog10 as log10 } from '@ts/viz/core/utils';

const _format = formatHelper.format;
Expand Down Expand Up @@ -165,7 +165,6 @@ function getDateTimeFormat(tick, { showTransition, ticks, tickInterval }) {
if (showTransition && ticks.length) {
const indexOfTick = ticks.map(Number).indexOf(+tick);
if (ticks.length === 1 && indexOfTick === 0) {
// @ts-expect-error
typeFormat = formatHelper.getDateFormatByTicks(ticks);
} else {
if (indexOfTick === -1) {
Expand All @@ -175,7 +174,6 @@ function getDateTimeFormat(tick, { showTransition, ticks, tickInterval }) {
nextDateIndex = indexOfTick === 0 ? 1 : -1;
}
const datesDifferences = getDatesDifferences(ticks[prevDateIndex], tick, ticks[nextDateIndex], typeFormat);
// @ts-expect-error
typeFormat = formatHelper.getDateFormatByDifferences(datesDifferences, typeFormat);
}
}
Expand Down Expand Up @@ -227,7 +225,6 @@ function getHighDiffFormat(diff) {
diff[i] = true;
}
}
// @ts-expect-error
return createFormat(formatHelper.getDateFormatByDifferences(diff));
}

Expand All @@ -242,14 +239,12 @@ function getHighAndSelfDiffFormat(diff, interval) {
diff[i] = true;
}
}
// @ts-expect-error
return createFormat(formatHelper.getDateFormatByDifferences(diff));
}

function formatDateRange(startValue, endValue, tickInterval) {
const diff = getDatesDifferences(startValue, endValue);
const typeFormat = dateUtils.getDateFormatByTickInterval(tickInterval);
// @ts-expect-error
const diffFormatType = formatHelper.getDateFormatByDifferences(diff, typeFormat);
const diffFormat = createFormat(diffFormatType);
const values = [];
Expand Down
4 changes: 2 additions & 2 deletions packages/devextreme/js/__internal/viz/axes/strip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/explicit-function-return-type */

import { extend } from '@js/core/utils/extend';
import { isDefined } from '@js/core/utils/type';
import { extend } from '@ts/core/utils/m_extend';
import { isDefined } from '@ts/core/utils/m_type';
import { patchFontOptions } from '@ts/viz/core/utils';

export default function createStrip(axis, options) {
Expand Down
6 changes: 3 additions & 3 deletions packages/devextreme/js/__internal/viz/axes/tick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
/* eslint-disable @typescript-eslint/no-unused-expressions */
/* eslint-disable @typescript-eslint/prefer-optional-chain */

import { Deferred, when } from '@js/core/utils/deferred';
import { extend } from '@js/core/utils/extend';
import { isDefined } from '@js/core/utils/type';
import { Deferred, when } from '@ts/core/utils/m_deferred';
import { extend } from '@ts/core/utils/m_extend';
import { isDefined } from '@ts/core/utils/m_type';

function getPathStyle(options) {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
/* eslint-disable @typescript-eslint/no-use-before-define */
/* eslint-disable @typescript-eslint/explicit-function-return-type */

import dateUtils from '@js/core/utils/date';
import { extend } from '@js/core/utils/extend';
import { adjust, sign } from '@js/core/utils/math';
import { isDefined, isString } from '@js/core/utils/type';
import { dateUtils } from '@ts/core/utils/m_date';
import { extend } from '@ts/core/utils/m_extend';
import { adjust, sign } from '@ts/core/utils/m_math';
import { isDefined, isString } from '@ts/core/utils/m_type';
import {
getCategoriesInfo,
getLog as mathLog,
Expand Down
11 changes: 5 additions & 6 deletions packages/devextreme/js/__internal/viz/axes/xy_axes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
/* eslint-disable @typescript-eslint/no-unused-expressions */
/* eslint-disable @typescript-eslint/prefer-optional-chain */

import { noop } from '@js/core/utils/common';
import dateUtils from '@js/core/utils/date';
import { extend } from '@js/core/utils/extend';
import { isDefined } from '@js/core/utils/type';
import formatHelper from '@js/format_helper';
import formatHelper from '@ts/core/format_helper';
import { noop } from '@ts/core/utils/m_common';
import { dateUtils } from '@ts/core/utils/m_date';
import { extend } from '@ts/core/utils/m_extend';
import { isDefined } from '@ts/core/utils/m_type';
import constants from '@ts/viz/axes/axes_constants';
import { generateDateBreaks } from '@ts/viz/axes/datetime_breaks';
import { getCosAndSin, getLog, patchFontOptions } from '@ts/viz/core/utils';
Expand Down Expand Up @@ -137,7 +137,6 @@ function getMarkerFormat(curDate, prevDate, tickInterval, markerInterval) {
const datesDifferences = prevDate && dateUtils.getDatesDifferences(prevDate, curDate);
if (prevDate && tickInterval !== 'year') {
prepareDatesDifferences(datesDifferences, tickInterval);
// @ts-expect-error
format = formatHelper.getDateFormatByDifferences(datesDifferences);
}
return format;
Expand Down
17 changes: 8 additions & 9 deletions packages/devextreme/js/__internal/viz/chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
/* eslint-disable @typescript-eslint/no-unused-expressions */
/* eslint-disable @typescript-eslint/no-use-before-define */
/* eslint-disable @typescript-eslint/prefer-for-of */
/* eslint-disable @typescript-eslint/prefer-for-of */
/* eslint-disable consistent-return */
/* eslint-disable max-depth */
/* eslint-disable no-bitwise */
Expand All @@ -17,14 +16,14 @@
/* eslint-disable no-param-reassign */
/* eslint-disable no-plusplus */

import registerComponent from '@js/core/component_registrator';
import { noop } from '@js/core/utils/common';
import { extend as _extend } from '@js/core/utils/extend';
import { each as _each } from '@js/core/utils/iterator';
import { getPrecision } from '@js/core/utils/math';
import { getHeight } from '@js/core/utils/size';
import { isDefined as _isDefined, type } from '@js/core/utils/type';
import { hasWindow } from '@js/core/utils/window';
import { registerComponent } from '@ts/core/component_registrator';
import { noop } from '@ts/core/utils/m_common';
import { extend as _extend } from '@ts/core/utils/m_extend';
import { each as _each } from '@ts/core/utils/m_iterator';
import { getPrecision } from '@ts/core/utils/m_math';
import { getHeight } from '@ts/core/utils/m_size';
import { isDefined as _isDefined, type } from '@ts/core/utils/m_type';
import { hasWindow } from '@ts/core/utils/m_window';
import { Crosshair, getMargins } from '@ts/viz/chart_components/crosshair';
import { LayoutManager } from '@ts/viz/chart_components/layout_manager';
import multiAxesSynchronizer from '@ts/viz/chart_components/multi_axes_synchronizer';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,11 @@
/* eslint-disable no-multi-assign */
/* eslint-disable no-nested-ternary */
/* eslint-disable no-param-reassign */
/* eslint-disable prefer-rest-params */
/* eslint-disable prefer-spread */

import { noop as _noop } from '@js/core/utils/common';
import { extend as _extend } from '@js/core/utils/extend';
import { reverseEach as _reverseEach } from '@js/core/utils/iterator';
import { isDefined as _isDefined, type } from '@js/core/utils/type';
// @ts-expect-error
import { areCanvasesDifferent, floorCanvasDimensions } from '@js/viz/utils';

import { noop as _noop } from '@ts/core/utils/m_common';
import { extend as _extend } from '@ts/core/utils/m_extend';
import { reverseEach as _reverseEach } from '@ts/core/utils/m_iterator';
import { isDefined as _isDefined, type } from '@ts/core/utils/m_type';
import { Axis } from '@ts/viz/axes/base_axis';
import type { ThemeValue } from '@ts/viz/core/base_theme_manager';
import { setupWidgetPrototype } from '@ts/viz/core/helpers';
Expand All @@ -30,6 +26,7 @@ import {
} from '@ts/viz/core/utils';
import rangeDataCalculator from '@ts/viz/series/helpers/range_data_calculator';
import { Range } from '@ts/viz/translators/range';
import { areCanvasesDifferent, floorCanvasDimensions } from '@ts/viz/utils';

import { BaseChart } from './base_chart';

Expand Down
Loading
Loading