From bd3e2bf4f80e2375dbc7291e2fd9c521df230d50 Mon Sep 17 00:00:00 2001 From: dxvladislavvolkov Date: Tue, 24 Nov 2026 12:43:08 +0400 Subject: [PATCH 1/2] Improve types for ng demos (map, vectormap, localization) --- .github/workflows/visual-tests-demos.yml | 12 ++- .../Angular/app/app.component.ts | 11 +-- .../UsingGlobalize/Angular/app/app.service.ts | 14 ++-- .../UsingGlobalize/Angular/app/globalize.d.ts | 1 + .../UsingIntl/Angular/app/app.component.ts | 11 +-- .../UsingIntl/Angular/app/app.service.ts | 14 ++-- .../Map/Markers/Angular/app/app.component.ts | 20 ++--- .../Map/Markers/Angular/app/app.service.ts | 18 ++--- .../Angular/app/app.component.ts | 16 ++-- .../Angular/app/app.service.ts | 12 ++- .../Angular/app/app.service.ts | 17 +++-- .../Map/Routes/Angular/app/app.component.ts | 8 +- .../Map/Routes/Angular/app/app.service.ts | 19 +---- .../Angular/app/app.component.ts | 13 ++-- .../BubbleMarkers/Angular/app/app.service.ts | 8 +- .../app/devextreme-vectormap-data.d.ts | 27 +++++++ .../Angular/app/app.component.ts | 10 +-- .../Angular/app/app.service.ts | 24 +----- .../app/devextreme-vectormap-data.d.ts | 27 +++++++ .../Angular/app/app.component.ts | 5 +- .../Angular/app/app.service.ts | 2 +- .../app/devextreme-vectormap-data.d.ts | 27 +++++++ .../Angular/app/app.component.ts | 5 +- .../CustomMapData/Angular/app/app.service.ts | 8 +- .../Angular/app/app.service.ts | 8 +- .../app/devextreme-vectormap-data.d.ts | 27 +++++++ .../Angular/app/app.component.ts | 12 +-- .../Angular/app/app.service.ts | 2 +- .../app/devextreme-vectormap-data.d.ts | 27 +++++++ .../FloorPlan/Angular/app/app.component.ts | 7 +- .../FloorPlan/Angular/app/app.service.ts | 8 +- .../ImageMarkers/Angular/app/app.service.ts | 10 +-- .../app/devextreme-vectormap-data.d.ts | 27 +++++++ .../Legend/Angular/app/app.component.html | 2 +- .../Legend/Angular/app/app.component.ts | 18 ++--- .../Legend/Angular/app/app.service.ts | 14 ++-- .../app/devextreme-vectormap-data.d.ts | 27 +++++++ .../Angular/app/app.component.ts | 3 +- .../MultipleLayers/Angular/app/app.service.ts | 8 +- .../app/devextreme-vectormap-data.d.ts | 27 +++++++ .../Overview/Angular/app/app.component.ts | 23 +++--- .../Overview/Angular/app/app.service.ts | 20 ++++- .../app/devextreme-vectormap-data.d.ts | 28 +++++++ .../Palette/Angular/app/app.component.ts | 16 ++-- .../Palette/Angular/app/app.service.ts | 6 +- .../app/devextreme-vectormap-data.d.ts | 27 +++++++ .../PieMarkers/Angular/app/app.component.ts | 7 +- .../PieMarkers/Angular/app/app.service.ts | 8 +- .../app/devextreme-vectormap-data.d.ts | 27 +++++++ .../Angular/app/app.component.ts | 27 ++++--- .../Angular/app/app.service.ts | 20 ++++- .../app/devextreme-vectormap-data.d.ts | 27 +++++++ .../Angular/app/app.component.ts | 18 +++-- .../Angular/app/app.service.ts | 4 +- .../app/devextreme-vectormap-data.d.ts | 27 +++++++ apps/demos/eslint.config.mjs | 23 ++++++ apps/demos/tsconfig.ngc-check.json | 74 ++++++++++++++++++- 57 files changed, 709 insertions(+), 229 deletions(-) create mode 100644 apps/demos/Demos/Localization/UsingGlobalize/Angular/app/globalize.d.ts create mode 100644 apps/demos/Demos/VectorMap/BubbleMarkers/Angular/app/devextreme-vectormap-data.d.ts create mode 100644 apps/demos/Demos/VectorMap/ColorsCustomization/Angular/app/devextreme-vectormap-data.d.ts create mode 100644 apps/demos/Demos/VectorMap/CustomAnnotations/Angular/app/devextreme-vectormap-data.d.ts create mode 100644 apps/demos/Demos/VectorMap/CustomProjection/Angular/app/devextreme-vectormap-data.d.ts create mode 100644 apps/demos/Demos/VectorMap/DynamicViewport/Angular/app/devextreme-vectormap-data.d.ts create mode 100644 apps/demos/Demos/VectorMap/ImageMarkers/Angular/app/devextreme-vectormap-data.d.ts create mode 100644 apps/demos/Demos/VectorMap/Legend/Angular/app/devextreme-vectormap-data.d.ts create mode 100644 apps/demos/Demos/VectorMap/MultipleLayers/Angular/app/devextreme-vectormap-data.d.ts create mode 100644 apps/demos/Demos/VectorMap/Overview/Angular/app/devextreme-vectormap-data.d.ts create mode 100644 apps/demos/Demos/VectorMap/Palette/Angular/app/devextreme-vectormap-data.d.ts create mode 100644 apps/demos/Demos/VectorMap/PieMarkers/Angular/app/devextreme-vectormap-data.d.ts create mode 100644 apps/demos/Demos/VectorMap/TooltipsCustomization/Angular/app/devextreme-vectormap-data.d.ts create mode 100644 apps/demos/Demos/VectorMap/ZoomingAndCentering/Angular/app/devextreme-vectormap-data.d.ts diff --git a/.github/workflows/visual-tests-demos.yml b/.github/workflows/visual-tests-demos.yml index ae92f60e3d60..d1671d2b0231 100644 --- a/.github/workflows/visual-tests-demos.yml +++ b/.github/workflows/visual-tests-demos.yml @@ -325,16 +325,18 @@ jobs: working-directory: apps/demos run: pnpm run ts-check-vue - # - name: Run check TS for Angular - # working-directory: apps/demos - # run: pnpm run ts-check-ng - - name: Demos - Check React TS id: ts_react continue-on-error: true working-directory: apps/demos run: pnpm run ts-check-react + - name: Demos - Check Angular TS + id: ts_angular + continue-on-error: true + working-directory: apps/demos + run: pnpm run ts-check-ng + - name: Run lint on all demos id: lint_all continue-on-error: true @@ -367,6 +369,7 @@ jobs: env: TS_VUE_OUTCOME: ${{ steps.ts_vue.outcome }} TS_REACT_OUTCOME: ${{ steps.ts_react.outcome }} + TS_ANGULAR_OUTCOME: ${{ steps.ts_angular.outcome }} LINT_ALL_OUTCOME: ${{ steps.lint_all.outcome }} GENERATED_JS_OUTCOME: ${{ steps.generated_js.outcome }} run: | @@ -375,6 +378,7 @@ jobs: for check in \ "Demos - Check Vue TS:$TS_VUE_OUTCOME" \ "Demos - Check React TS:$TS_REACT_OUTCOME" \ + "Demos - Check Angular TS:$TS_ANGULAR_OUTCOME" \ "Run lint on all demos:$LINT_ALL_OUTCOME" \ "Check generated JS demos:$GENERATED_JS_OUTCOME"; do name="${check%%:*}" diff --git a/apps/demos/Demos/Localization/UsingGlobalize/Angular/app/app.component.ts b/apps/demos/Demos/Localization/UsingGlobalize/Angular/app/app.component.ts index 4e2530a00cdc..43422b05a0f5 100644 --- a/apps/demos/Demos/Localization/UsingGlobalize/Angular/app/app.component.ts +++ b/apps/demos/Demos/Localization/UsingGlobalize/Angular/app/app.component.ts @@ -1,6 +1,7 @@ import { bootstrapApplication } from '@angular/platform-browser'; import { Component, enableProdMode, inject } from '@angular/core'; import { DxSelectBoxModule, DxDataGridModule } from 'devextreme-angular'; +import type { DxSelectBoxTypes } from 'devextreme-angular/ui/select-box'; import 'devextreme/common/core/localization/globalize/number'; import 'devextreme/common/core/localization/globalize/date'; @@ -51,7 +52,7 @@ export class AppComponent { Globalize.locale(this.locale); } - private initGlobalize() { + private initGlobalize(): void { Globalize.load( deCldrData, ruCldrData, @@ -62,17 +63,17 @@ export class AppComponent { Globalize.loadMessages(this.service.getDictionary()); } - changeLocale(data) { - this.setLocale(data.value); + changeLocale({ value }: DxSelectBoxTypes.ValueChangedEvent): void { + this.setLocale(value); parent.document.location.reload(); } - private getLocale() { + private getLocale(): string { const locale = sessionStorage.getItem('locale'); return locale != null ? locale : 'en'; } - private setLocale(locale) { + private setLocale(locale: string): void { sessionStorage.setItem('locale', locale); } } diff --git a/apps/demos/Demos/Localization/UsingGlobalize/Angular/app/app.service.ts b/apps/demos/Demos/Localization/UsingGlobalize/Angular/app/app.service.ts index edf6ebb84567..401377f51f33 100644 --- a/apps/demos/Demos/Localization/UsingGlobalize/Angular/app/app.service.ts +++ b/apps/demos/Demos/Localization/UsingGlobalize/Angular/app/app.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; -export class Locale { +export interface Locale { Name: string; Value: string; @@ -17,7 +17,7 @@ const locales: Locale[] = [{ Value: 'ru', }]; -export class Payment { +export interface Payment { PaymentId: number; ContactName: string; @@ -100,7 +100,7 @@ const payments: Payment[] = [{ PaymentDate: '2013/01/11', }]; -export class PaymentView { +export interface PaymentView { Number: string; Contact: string; @@ -112,7 +112,7 @@ export class PaymentView { PaymentDate: string; } -export class Dictionary { +export interface Dictionary { [key: string]: PaymentView; } @@ -142,15 +142,15 @@ const dictionary: Dictionary = { @Injectable() export class Service { - getPayments() { + getPayments(): Payment[] { return payments; } - getLocales() { + getLocales(): Locale[] { return locales; } - getDictionary() { + getDictionary(): Dictionary { return dictionary; } } diff --git a/apps/demos/Demos/Localization/UsingGlobalize/Angular/app/globalize.d.ts b/apps/demos/Demos/Localization/UsingGlobalize/Angular/app/globalize.d.ts new file mode 100644 index 000000000000..a79db8942752 --- /dev/null +++ b/apps/demos/Demos/Localization/UsingGlobalize/Angular/app/globalize.d.ts @@ -0,0 +1 @@ +declare module 'globalize'; diff --git a/apps/demos/Demos/Localization/UsingIntl/Angular/app/app.component.ts b/apps/demos/Demos/Localization/UsingIntl/Angular/app/app.component.ts index 2205394ca124..4a08749abc0f 100644 --- a/apps/demos/Demos/Localization/UsingIntl/Angular/app/app.component.ts +++ b/apps/demos/Demos/Localization/UsingIntl/Angular/app/app.component.ts @@ -1,6 +1,7 @@ import { bootstrapApplication } from '@angular/platform-browser'; import { Component, enableProdMode, inject } from '@angular/core'; import { DxSelectBoxModule, DxDataGridModule } from 'devextreme-angular'; +import type { DxSelectBoxTypes } from 'devextreme-angular/ui/select-box'; import { locale, loadMessages, formatMessage } from 'devextreme-angular/common/core/localization'; @@ -40,23 +41,23 @@ export class AppComponent { locale(this.locale); } - private initMessages() { + private initMessages(): void { loadMessages(deMessages); loadMessages(ruMessages); loadMessages(this.service.getDictionary()); } - changeLocale(data) { - this.setLocale(data.value); + changeLocale({ value }: DxSelectBoxTypes.ValueChangedEvent): void { + this.setLocale(value); parent.document.location.reload(); } - private getLocale() { + private getLocale(): string { const locale = sessionStorage.getItem('locale'); return locale != null ? locale : 'en'; } - private setLocale(locale) { + private setLocale(locale: string): void { sessionStorage.setItem('locale', locale); } } diff --git a/apps/demos/Demos/Localization/UsingIntl/Angular/app/app.service.ts b/apps/demos/Demos/Localization/UsingIntl/Angular/app/app.service.ts index edf6ebb84567..401377f51f33 100644 --- a/apps/demos/Demos/Localization/UsingIntl/Angular/app/app.service.ts +++ b/apps/demos/Demos/Localization/UsingIntl/Angular/app/app.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; -export class Locale { +export interface Locale { Name: string; Value: string; @@ -17,7 +17,7 @@ const locales: Locale[] = [{ Value: 'ru', }]; -export class Payment { +export interface Payment { PaymentId: number; ContactName: string; @@ -100,7 +100,7 @@ const payments: Payment[] = [{ PaymentDate: '2013/01/11', }]; -export class PaymentView { +export interface PaymentView { Number: string; Contact: string; @@ -112,7 +112,7 @@ export class PaymentView { PaymentDate: string; } -export class Dictionary { +export interface Dictionary { [key: string]: PaymentView; } @@ -142,15 +142,15 @@ const dictionary: Dictionary = { @Injectable() export class Service { - getPayments() { + getPayments(): Payment[] { return payments; } - getLocales() { + getLocales(): Locale[] { return locales; } - getDictionary() { + getDictionary(): Dictionary { return dictionary; } } diff --git a/apps/demos/Demos/Map/Markers/Angular/app/app.component.ts b/apps/demos/Demos/Map/Markers/Angular/app/app.component.ts index 712a56ec8e19..851b1914e93e 100644 --- a/apps/demos/Demos/Map/Markers/Angular/app/app.component.ts +++ b/apps/demos/Demos/Map/Markers/Angular/app/app.component.ts @@ -3,9 +3,10 @@ import { Component, enableProdMode, inject, signal, } from '@angular/core'; import { DxMapModule, DxCheckBoxModule, DxButtonModule } from 'devextreme-angular'; +import type { DxCheckBoxTypes } from 'devextreme-angular/ui/check-box'; import { Service } from './app.service'; -import type { APIKey } from './app.service'; +import type { APIKey, Marker } from './app.service'; if (!/localhost/.test(document.location.host)) { enableProdMode(); @@ -32,23 +33,22 @@ export class AppComponent { readonly mapMarkerUrl = signal(this.service.getMarkerUrl()); - readonly markers = signal(this.service.getMarkers()); + readonly markers = signal(this.service.getMarkers()); readonly apiKey: APIKey = { azure: '6N8zuPkBsnfwniNAJkldM3cUgm3lXg3y9gkIKy59benICnnepK4DJQQJ99AIACYeBjFllM6LAAAgAZMPGFXE', }; - checkCustomMarker(data) { - this.mapMarkerUrl.set(data.value ? this.customMarkerUrl : null); + checkCustomMarker({ value }: DxCheckBoxTypes.ValueChangedEvent): void { + this.mapMarkerUrl.set(value ? this.customMarkerUrl : ''); this.markers.set(this.originalMarkers); } - showTooltips() { - this.markers.update((markers) => markers.map((item) => { - const newItem = JSON.parse(JSON.stringify(item)); - newItem.tooltip.isShown = true; - return newItem; - })); + showTooltips(): void { + this.markers.update((markers) => markers.map((item) => ({ + ...item, + tooltip: { ...item.tooltip, isShown: true }, + }))); } } diff --git a/apps/demos/Demos/Map/Markers/Angular/app/app.service.ts b/apps/demos/Demos/Map/Markers/Angular/app/app.service.ts index 0d65046de5de..08d94dc0fe2e 100644 --- a/apps/demos/Demos/Map/Markers/Angular/app/app.service.ts +++ b/apps/demos/Demos/Map/Markers/Angular/app/app.service.ts @@ -1,16 +1,14 @@ import { Injectable } from '@angular/core'; +import type { DxMapTypes } from 'devextreme-angular/ui/map'; -export class Tooltip { - isShown: boolean; +type MapMarker = NonNullable[number]; - text: string; -} - -export class Marker { - location: unknown; - - tooltip: Tooltip; -} +export type Marker = Omit & { + tooltip: { + isShown: boolean; + text: string; + }; +}; export type APIKey = { azure?: string; diff --git a/apps/demos/Demos/Map/OpenStreetMapProvider/Angular/app/app.component.ts b/apps/demos/Demos/Map/OpenStreetMapProvider/Angular/app/app.component.ts index 31879d003f88..21547fc0b1eb 100644 --- a/apps/demos/Demos/Map/OpenStreetMapProvider/Angular/app/app.component.ts +++ b/apps/demos/Demos/Map/OpenStreetMapProvider/Angular/app/app.component.ts @@ -2,7 +2,8 @@ import { bootstrapApplication } from '@angular/platform-browser'; import { Component, enableProdMode, inject, signal, ViewEncapsulation, } from '@angular/core'; -import { DxMapModule, type DxMapTypes } from 'devextreme-angular/ui/map'; +import { DxMapModule } from 'devextreme-angular/ui/map'; +import type { DxMapTypes } from 'devextreme-angular/ui/map'; import { DxSelectBoxModule } from 'devextreme-angular/ui/select-box'; import type { DxSelectBoxTypes } from 'devextreme-angular/ui/select-box'; import 'devextreme/ui/map/openlayers'; @@ -11,6 +12,7 @@ import type LineString from 'ol/geom/LineString.js'; import Attribution from 'ol/control/Attribution.js'; import Polyline from 'ol/format/Polyline.js'; import { Service } from './app.service'; +import type { Marker, Route } from './app.service'; const routeCache = new Map(); @@ -62,11 +64,11 @@ if (!/localhost/.test(document.location.host)) { export class AppComponent { private readonly service = inject(Service); - readonly markers: DxMapTypes.Properties['markers'] = this.service.getMarkers().map((marker) => (marker.iconSrc + readonly markers: Marker[] = this.service.getMarkers().map((marker) => (marker.iconSrc ? { ...marker, onClick: this.onMarkerClick } : marker)); - readonly routes = signal(this.service.getRoutes()); + readonly routes = signal(this.service.getRoutes()); readonly tileServer: DxMapTypes.OsmTileServerConfig = { // Demo only: tiles are served under Developer Express Inc's Stadia Maps subscription via domain-based authentication. @@ -80,7 +82,7 @@ export class AppComponent { readonly calculateRoute = calculateRoute; - private onMarkerClick({ tooltip }: DxMapTypes.MarkerClickEvent) { + private onMarkerClick({ tooltip }: DxMapTypes.MarkerClickEvent): void { tooltip?.option({ showTitle: true, showCloseButton: true, @@ -90,7 +92,7 @@ export class AppComponent { }); } - onMapReady({ originalMap }: DxMapTypes.ReadyEvent) { + onMapReady({ originalMap }: DxMapTypes.ReadyEvent): void { const map = originalMap as OpenLayersMap; // Ensure attribution is visible to comply with the Stadia Maps Terms of Service. const attribution = map.getControls().getArray() @@ -101,11 +103,11 @@ export class AppComponent { map.addControl(new Attribution({ collapsible: false })); } - setMode({ value }: DxSelectBoxTypes.ValueChangedEvent) { + setMode({ value }: DxSelectBoxTypes.ValueChangedEvent): void { this.routes.update((routes) => routes.map((route) => ({ ...route, mode: value }))); } - selectColor({ value }: DxSelectBoxTypes.ValueChangedEvent) { + selectColor({ value }: DxSelectBoxTypes.ValueChangedEvent): void { this.routes.update((routes) => routes.map((route) => ({ ...route, color: value }))); } } diff --git a/apps/demos/Demos/Map/OpenStreetMapProvider/Angular/app/app.service.ts b/apps/demos/Demos/Map/OpenStreetMapProvider/Angular/app/app.service.ts index 9ce716e6aa64..5e66019d024e 100644 --- a/apps/demos/Demos/Map/OpenStreetMapProvider/Angular/app/app.service.ts +++ b/apps/demos/Demos/Map/OpenStreetMapProvider/Angular/app/app.service.ts @@ -1,7 +1,11 @@ import { Injectable } from '@angular/core'; import type { DxMapTypes } from 'devextreme-angular/ui/map'; -const markers: DxMapTypes.Properties['markers'] = [{ +export type Marker = NonNullable[number]; + +export type Route = NonNullable[number]; + +const markers: Marker[] = [{ location: '40.7825, -73.966111', tooltip: { text: 'Central Park' }, }, { @@ -16,7 +20,7 @@ const markers: DxMapTypes.Properties['markers'] = [{ tooltip: { text: 'City Hall Park' }, }]; -const routes: DxMapTypes.Properties['routes'] = [{ +const routes: Route[] = [{ weight: 6, color: 'blue', opacity: 0.5, @@ -31,11 +35,11 @@ const routes: DxMapTypes.Properties['routes'] = [{ @Injectable() export class Service { - getMarkers() { + getMarkers(): Marker[] { return markers; } - getRoutes() { + getRoutes(): Route[] { return routes; } } diff --git a/apps/demos/Demos/Map/ProvidersAndTypes/Angular/app/app.service.ts b/apps/demos/Demos/Map/ProvidersAndTypes/Angular/app/app.service.ts index 135b18e287d9..e6bfebbe228c 100644 --- a/apps/demos/Demos/Map/ProvidersAndTypes/Angular/app/app.service.ts +++ b/apps/demos/Demos/Map/ProvidersAndTypes/Angular/app/app.service.ts @@ -1,11 +1,16 @@ import { Injectable } from '@angular/core'; +import type { DxMapTypes } from 'devextreme-angular/ui/map'; -export class MapSetting { - key: string; +interface MapSetting { + key: TKey; name: string; } +export type MapTypeSetting = MapSetting; + +export type MapProviderSetting = MapSetting; + export type APIKey = { azure?: string; @@ -16,7 +21,7 @@ export type APIKey = { googleStatic?: string; }; -const mapTypes: MapSetting[] = [{ +const mapTypes: MapTypeSetting[] = [{ key: 'roadmap', name: 'Road Map', }, { @@ -27,7 +32,7 @@ const mapTypes: MapSetting[] = [{ name: 'Hybrid Map', }]; -const mapProviders: MapSetting[] = [{ +const mapProviders: MapProviderSetting[] = [{ key: 'azure', name: 'Azure', }, { @@ -40,11 +45,11 @@ const mapProviders: MapSetting[] = [{ @Injectable() export class Service { - getMapTypes(): MapSetting[] { + getMapTypes(): MapTypeSetting[] { return mapTypes; } - getMapProviders(): MapSetting[] { + getMapProviders(): MapProviderSetting[] { return mapProviders; } } diff --git a/apps/demos/Demos/Map/Routes/Angular/app/app.component.ts b/apps/demos/Demos/Map/Routes/Angular/app/app.component.ts index ed4f76df7e3f..59cfc011d00a 100644 --- a/apps/demos/Demos/Map/Routes/Angular/app/app.component.ts +++ b/apps/demos/Demos/Map/Routes/Angular/app/app.component.ts @@ -6,7 +6,7 @@ import { DxMapModule } from 'devextreme-angular'; import { DxSelectBoxModule } from 'devextreme-angular/ui/select-box'; import type { DxSelectBoxTypes } from 'devextreme-angular/ui/select-box'; import { Service } from './app.service'; -import type { APIKey } from './app.service'; +import type { APIKey, Route } from './app.service'; if (!/localhost/.test(document.location.host)) { enableProdMode(); @@ -27,20 +27,20 @@ if (!/localhost/.test(document.location.host)) { export class AppComponent { private readonly service = inject(Service); - readonly routes = signal(this.service.getRoutes()); + readonly routes = signal(this.service.getRoutes()); readonly markers = this.service.getMarkers(); readonly apiKey: APIKey = { azure: '6N8zuPkBsnfwniNAJkldM3cUgm3lXg3y9gkIKy59benICnnepK4DJQQJ99AIACYeBjFllM6LAAAgAZMPGFXE' }; - setMode(e: DxSelectBoxTypes.ValueChangedEvent) { + setMode(e: DxSelectBoxTypes.ValueChangedEvent): void { this.routes.update((routes) => routes.map((item) => { item.mode = e.value; return item; })); } - selectColor(e: DxSelectBoxTypes.ValueChangedEvent) { + selectColor(e: DxSelectBoxTypes.ValueChangedEvent): void { this.routes.update((routes) => routes.map((item) => { item.color = e.value; return item; diff --git a/apps/demos/Demos/Map/Routes/Angular/app/app.service.ts b/apps/demos/Demos/Map/Routes/Angular/app/app.service.ts index b2cc51fc51d8..bb806c80f4d6 100644 --- a/apps/demos/Demos/Map/Routes/Angular/app/app.service.ts +++ b/apps/demos/Demos/Map/Routes/Angular/app/app.service.ts @@ -1,8 +1,9 @@ import { Injectable } from '@angular/core'; +import type { DxMapTypes } from 'devextreme-angular/ui/map'; -export class Marker { - location: unknown; -} +export type Marker = NonNullable[number]; + +export type Route = NonNullable[number]; export type APIKey = { azure?: string; @@ -14,18 +15,6 @@ export type APIKey = { googleStatic?: string; }; -export class Route { - weight: number; - - color: string; - - opacity: number; - - mode: string; - - locations: any[]; -} - const markers: Marker[] = [{ location: '40.7825, -73.966111', }, { diff --git a/apps/demos/Demos/VectorMap/BubbleMarkers/Angular/app/app.component.ts b/apps/demos/Demos/VectorMap/BubbleMarkers/Angular/app/app.component.ts index 9ac8755db9b3..042057052fd3 100644 --- a/apps/demos/Demos/VectorMap/BubbleMarkers/Angular/app/app.component.ts +++ b/apps/demos/Demos/VectorMap/BubbleMarkers/Angular/app/app.component.ts @@ -2,6 +2,7 @@ import { bootstrapApplication } from '@angular/platform-browser'; import { Component, enableProdMode, inject } from '@angular/core'; import { DxVectorMapModule } from 'devextreme-angular'; import * as mapsData from 'devextreme-dist/js/vectormap-data/world.js'; +import type { DxVectorMapTypes } from 'devextreme-angular/ui/vector-map'; import { Service } from './app.service'; if (!/localhost/.test(document.location.host)) { @@ -23,18 +24,18 @@ export class AppComponent { readonly markers = inject(Service).getMarkers(); - readonly customizeText = ({ index }) => ['< 8000K', '8000K to 10000K', '> 10000K'][index]; + readonly customizeText = ({ index }: { index: number }): string => ['< 8000K', '8000K to 10000K', '> 10000K'][index]; - readonly customizeItems = (items: unknown[]) => items.reverse(); + readonly customizeItems = (items: DxVectorMapTypes.LegendItem[]): DxVectorMapTypes.LegendItem[] => items.reverse(); - customizeTooltip({ layer: { type }, attribute }) { - if (type === 'marker') { + readonly customizeTooltip = ({ layer, attribute }: DxVectorMapTypes.MapLayerElement): Record => { + if (layer.type === 'marker') { return { text: attribute('tooltip'), }; } - return null; - } + return {}; + }; } bootstrapApplication(AppComponent); diff --git a/apps/demos/Demos/VectorMap/BubbleMarkers/Angular/app/app.service.ts b/apps/demos/Demos/VectorMap/BubbleMarkers/Angular/app/app.service.ts index 346c88d7df62..99c2264d9703 100644 --- a/apps/demos/Demos/VectorMap/BubbleMarkers/Angular/app/app.service.ts +++ b/apps/demos/Demos/VectorMap/BubbleMarkers/Angular/app/app.service.ts @@ -1,12 +1,12 @@ import { Injectable } from '@angular/core'; -export class FeatureCollection { +export interface FeatureCollection { type: string; features: Feature[]; } -export class Feature { +export interface Feature { type: string; properties: FeatureProperty; @@ -14,7 +14,7 @@ export class Feature { geometry: FeatureGeometry; } -export class FeatureProperty { +export interface FeatureProperty { text: string; value: number; @@ -22,7 +22,7 @@ export class FeatureProperty { tooltip: string; } -export class FeatureGeometry { +export interface FeatureGeometry { type: string; coordinates: number[]; diff --git a/apps/demos/Demos/VectorMap/BubbleMarkers/Angular/app/devextreme-vectormap-data.d.ts b/apps/demos/Demos/VectorMap/BubbleMarkers/Angular/app/devextreme-vectormap-data.d.ts new file mode 100644 index 000000000000..370ec277e5ea --- /dev/null +++ b/apps/demos/Demos/VectorMap/BubbleMarkers/Angular/app/devextreme-vectormap-data.d.ts @@ -0,0 +1,27 @@ +declare module 'devextreme-dist/js/vectormap-data/world.js' { + type Position = number[]; + type Geometry = + | { type: 'Point'; coordinates: Position } + | { type: 'MultiPoint'; coordinates: Position[] } + | { type: 'LineString'; coordinates: Position[] } + | { type: 'MultiLineString'; coordinates: Position[][] } + | { type: 'Polygon'; coordinates: Position[][] } + | { type: 'MultiPolygon'; coordinates: Position[][][] }; + + interface Feature { + type: 'Feature'; + geometry: Geometry; + properties: Record; + } + + interface FeatureCollection { + type: 'FeatureCollection'; + features: Feature[]; + // eslint-disable-next-line spellcheck/spell-checker + bbox?: number[]; + } + + const world: FeatureCollection; + export { world }; + export default world; +} diff --git a/apps/demos/Demos/VectorMap/ColorsCustomization/Angular/app/app.component.ts b/apps/demos/Demos/VectorMap/ColorsCustomization/Angular/app/app.component.ts index 5028ef6bafb5..732bcb42b037 100644 --- a/apps/demos/Demos/VectorMap/ColorsCustomization/Angular/app/app.component.ts +++ b/apps/demos/Demos/VectorMap/ColorsCustomization/Angular/app/app.component.ts @@ -24,8 +24,8 @@ export class AppComponent { private readonly countries = inject(Service).getCountries(); - readonly customizeTooltip = ({ attribute }) => { - const name = attribute('name'); + readonly customizeTooltip = ({ attribute }: DxVectorMapTypes.MapLayerElement): Record => { + const name: string = attribute('name'); const country = this.countries[name]; if (country) { return { @@ -33,10 +33,10 @@ export class AppComponent { color: country.color, }; } - return null; + return {}; }; - readonly customizeLayers = (elements: { attribute: Function, applySettings: Function }[]) => { + readonly customizeLayers = (elements: DxVectorMapTypes.MapLayerElement[]): void => { elements.forEach((element) => { const country = this.countries[element.attribute('name')]; if (country) { @@ -49,7 +49,7 @@ export class AppComponent { }); }; - readonly click = ({ target }: DxVectorMapTypes.ClickEvent) => { + readonly click = ({ target }: DxVectorMapTypes.ClickEvent): void => { if (target && this.countries[target.attribute('name')]) { target.selected(!target.selected()); } diff --git a/apps/demos/Demos/VectorMap/ColorsCustomization/Angular/app/app.service.ts b/apps/demos/Demos/VectorMap/ColorsCustomization/Angular/app/app.service.ts index 11bdd19f1cca..58e601dc72d1 100644 --- a/apps/demos/Demos/VectorMap/ColorsCustomization/Angular/app/app.service.ts +++ b/apps/demos/Demos/VectorMap/ColorsCustomization/Angular/app/app.service.ts @@ -1,32 +1,12 @@ import { Injectable } from '@angular/core'; -export class Country { +export interface Country { totalArea: number; color: string; } -export class Countries { - Russia: Country; - - Canada: Country; - - China: Country; - - 'United States': Country; - - Brazil: Country; - - Australia: Country; - - India: Country; - - Argentina: Country; - - Kazakhstan: Country; - - Algeria: Country; -} +export type Countries = Record; const countries: Countries = { Russia: { totalArea: 17.12, color: '#1564C0' }, diff --git a/apps/demos/Demos/VectorMap/ColorsCustomization/Angular/app/devextreme-vectormap-data.d.ts b/apps/demos/Demos/VectorMap/ColorsCustomization/Angular/app/devextreme-vectormap-data.d.ts new file mode 100644 index 000000000000..370ec277e5ea --- /dev/null +++ b/apps/demos/Demos/VectorMap/ColorsCustomization/Angular/app/devextreme-vectormap-data.d.ts @@ -0,0 +1,27 @@ +declare module 'devextreme-dist/js/vectormap-data/world.js' { + type Position = number[]; + type Geometry = + | { type: 'Point'; coordinates: Position } + | { type: 'MultiPoint'; coordinates: Position[] } + | { type: 'LineString'; coordinates: Position[] } + | { type: 'MultiLineString'; coordinates: Position[][] } + | { type: 'Polygon'; coordinates: Position[][] } + | { type: 'MultiPolygon'; coordinates: Position[][][] }; + + interface Feature { + type: 'Feature'; + geometry: Geometry; + properties: Record; + } + + interface FeatureCollection { + type: 'FeatureCollection'; + features: Feature[]; + // eslint-disable-next-line spellcheck/spell-checker + bbox?: number[]; + } + + const world: FeatureCollection; + export { world }; + export default world; +} diff --git a/apps/demos/Demos/VectorMap/CustomAnnotations/Angular/app/app.component.ts b/apps/demos/Demos/VectorMap/CustomAnnotations/Angular/app/app.component.ts index e9e67bdecf4a..f26361a67f85 100644 --- a/apps/demos/Demos/VectorMap/CustomAnnotations/Angular/app/app.component.ts +++ b/apps/demos/Demos/VectorMap/CustomAnnotations/Angular/app/app.component.ts @@ -3,7 +3,8 @@ import { Component, enableProdMode, inject } from '@angular/core'; import { DecimalPipe } from '@angular/common'; import { DxVectorMapModule } from 'devextreme-angular'; import * as mapsData from 'devextreme-dist/js/vectormap-data/usa.js'; -import { type StatesCollection, Service } from './app.service'; +import { Service } from './app.service'; +import type { StatesCollection } from './app.service'; if (!/localhost/.test(document.location.host)) { enableProdMode(); @@ -25,7 +26,7 @@ export class AppComponent { readonly states = inject(Service).getStatesData(); - readonly getImagePath = (annotation: StatesCollection) => { + readonly getImagePath = (annotation: StatesCollection): string => { const name = annotation.data.name.replace(/\s/, ''); return `../../../../images/flags/${name}.svg`; }; diff --git a/apps/demos/Demos/VectorMap/CustomAnnotations/Angular/app/app.service.ts b/apps/demos/Demos/VectorMap/CustomAnnotations/Angular/app/app.service.ts index 75555dcd9910..40a6322d92b4 100644 --- a/apps/demos/Demos/VectorMap/CustomAnnotations/Angular/app/app.service.ts +++ b/apps/demos/Demos/VectorMap/CustomAnnotations/Angular/app/app.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; -export class StatesCollection { +export interface StatesCollection { coordinates: number[]; offsetX?: number; diff --git a/apps/demos/Demos/VectorMap/CustomAnnotations/Angular/app/devextreme-vectormap-data.d.ts b/apps/demos/Demos/VectorMap/CustomAnnotations/Angular/app/devextreme-vectormap-data.d.ts new file mode 100644 index 000000000000..e5de5ff1844d --- /dev/null +++ b/apps/demos/Demos/VectorMap/CustomAnnotations/Angular/app/devextreme-vectormap-data.d.ts @@ -0,0 +1,27 @@ +declare module 'devextreme-dist/js/vectormap-data/usa.js' { + type Position = number[]; + type Geometry = + | { type: 'Point'; coordinates: Position } + | { type: 'MultiPoint'; coordinates: Position[] } + | { type: 'LineString'; coordinates: Position[] } + | { type: 'MultiLineString'; coordinates: Position[][] } + | { type: 'Polygon'; coordinates: Position[][] } + | { type: 'MultiPolygon'; coordinates: Position[][][] }; + + interface Feature { + type: 'Feature'; + geometry: Geometry; + properties: Record; + } + + interface FeatureCollection { + type: 'FeatureCollection'; + features: Feature[]; + // eslint-disable-next-line spellcheck/spell-checker + bbox?: number[]; + } + + const usa: FeatureCollection; + export { usa }; + export default usa; +} diff --git a/apps/demos/Demos/VectorMap/CustomMapData/Angular/app/app.component.ts b/apps/demos/Demos/VectorMap/CustomMapData/Angular/app/app.component.ts index 6a7dcd153d10..48c3ce947508 100644 --- a/apps/demos/Demos/VectorMap/CustomMapData/Angular/app/app.component.ts +++ b/apps/demos/Demos/VectorMap/CustomMapData/Angular/app/app.component.ts @@ -1,6 +1,7 @@ import { bootstrapApplication } from '@angular/platform-browser'; import { Component, enableProdMode, inject } from '@angular/core'; import { DxVectorMapModule } from 'devextreme-angular'; +import type { DxVectorMapTypes } from 'devextreme-angular/ui/vector-map'; import { Service } from './app.service'; if (!/localhost/.test(document.location.host)) { @@ -33,13 +34,13 @@ export class AppComponent { }, }; - customizeLayer(elements: { attribute: Function, applySettings: Function }[]) { + readonly customizeLayer = (elements: DxVectorMapTypes.MapLayerElement[]): void => { elements.forEach((element) => { element.applySettings({ color: element.attribute('color'), }); }); - } + }; } bootstrapApplication(AppComponent); diff --git a/apps/demos/Demos/VectorMap/CustomMapData/Angular/app/app.service.ts b/apps/demos/Demos/VectorMap/CustomMapData/Angular/app/app.service.ts index 242a180965fa..218e523eed00 100644 --- a/apps/demos/Demos/VectorMap/CustomMapData/Angular/app/app.service.ts +++ b/apps/demos/Demos/VectorMap/CustomMapData/Angular/app/app.service.ts @@ -1,12 +1,12 @@ import { Injectable } from '@angular/core'; -export class FeatureCollection { +export interface FeatureCollection { type: string; features: Feature[]; } -export class Feature { +export interface Feature { type: string; properties: FeatureProperty; @@ -14,13 +14,13 @@ export class Feature { geometry: FeatureGeometry; } -export class FeatureProperty { +export interface FeatureProperty { name: string; color?: string; } -export class FeatureGeometry { +export interface FeatureGeometry { type: string; coordinates: number[][][]; diff --git a/apps/demos/Demos/VectorMap/CustomProjection/Angular/app/app.service.ts b/apps/demos/Demos/VectorMap/CustomProjection/Angular/app/app.service.ts index 4867447e107d..d1a8b24ee4ec 100644 --- a/apps/demos/Demos/VectorMap/CustomProjection/Angular/app/app.service.ts +++ b/apps/demos/Demos/VectorMap/CustomProjection/Angular/app/app.service.ts @@ -1,16 +1,16 @@ import { Injectable } from '@angular/core'; -export class FeatureCollection { +export interface FeatureCollection { type: string; features: Feature[]; } -export class Feature { +export interface Feature { geometry: FeatureGeometry; } -export class FeatureGeometry { +export interface FeatureGeometry { type: string; coordinates: number[][]; @@ -23,7 +23,7 @@ const coordLinesData: FeatureCollection = { // add meridians for (let longitude = -180; longitude <= 180; longitude += 30) { - const lineCoords = []; + const lineCoords: number[][] = []; for (let latitude = -90; latitude <= 90; latitude += 5) { lineCoords.push([longitude, latitude]); } diff --git a/apps/demos/Demos/VectorMap/CustomProjection/Angular/app/devextreme-vectormap-data.d.ts b/apps/demos/Demos/VectorMap/CustomProjection/Angular/app/devextreme-vectormap-data.d.ts new file mode 100644 index 000000000000..370ec277e5ea --- /dev/null +++ b/apps/demos/Demos/VectorMap/CustomProjection/Angular/app/devextreme-vectormap-data.d.ts @@ -0,0 +1,27 @@ +declare module 'devextreme-dist/js/vectormap-data/world.js' { + type Position = number[]; + type Geometry = + | { type: 'Point'; coordinates: Position } + | { type: 'MultiPoint'; coordinates: Position[] } + | { type: 'LineString'; coordinates: Position[] } + | { type: 'MultiLineString'; coordinates: Position[][] } + | { type: 'Polygon'; coordinates: Position[][] } + | { type: 'MultiPolygon'; coordinates: Position[][][] }; + + interface Feature { + type: 'Feature'; + geometry: Geometry; + properties: Record; + } + + interface FeatureCollection { + type: 'FeatureCollection'; + features: Feature[]; + // eslint-disable-next-line spellcheck/spell-checker + bbox?: number[]; + } + + const world: FeatureCollection; + export { world }; + export default world; +} diff --git a/apps/demos/Demos/VectorMap/DynamicViewport/Angular/app/app.component.ts b/apps/demos/Demos/VectorMap/DynamicViewport/Angular/app/app.component.ts index ab35234cb4eb..9280ba397930 100644 --- a/apps/demos/Demos/VectorMap/DynamicViewport/Angular/app/app.component.ts +++ b/apps/demos/Demos/VectorMap/DynamicViewport/Angular/app/app.component.ts @@ -4,8 +4,10 @@ import { } from '@angular/core'; import { DxTextBoxModule, DxSwitchModule } from 'devextreme-angular'; import * as mapsData from 'devextreme-dist/js/vectormap-data/world.js'; -import { DxSelectBoxModule, type DxSelectBoxTypes } from 'devextreme-angular/ui/select-box'; -import { DxVectorMapModule, DxVectorMapComponent, type DxVectorMapTypes } from 'devextreme-angular/ui/vector-map'; +import { DxSelectBoxModule } from 'devextreme-angular/ui/select-box'; +import type { DxSelectBoxTypes } from 'devextreme-angular/ui/select-box'; +import { DxVectorMapModule, DxVectorMapComponent } from 'devextreme-angular/ui/vector-map'; +import type { DxVectorMapTypes } from 'devextreme-angular/ui/vector-map'; import { Service } from './app.service'; if (!/localhost/.test(document.location.host)) { @@ -37,15 +39,15 @@ export class AppComponent { private readonly map = viewChild.required(DxVectorMapComponent); - onValueChanged(e: DxSelectBoxTypes.ValueChangedEvent) { + onValueChanged(e: DxSelectBoxTypes.ValueChangedEvent): void { this.map().instance.viewport(e.value); } - zoomChanged(e: DxVectorMapTypes.ZoomFactorChangedEvent) { + zoomChanged(e: DxVectorMapTypes.ZoomFactorChangedEvent): void { this.zoomFactorValue.set(e.zoomFactor.toFixed(2)); } - centerChanged(e: DxVectorMapTypes.CenterChangedEvent) { + centerChanged(e: DxVectorMapTypes.CenterChangedEvent): void { this.centerValue.set(`${e.center[0].toFixed(3) }, ${e.center[1].toFixed(3)}`); } diff --git a/apps/demos/Demos/VectorMap/DynamicViewport/Angular/app/app.service.ts b/apps/demos/Demos/VectorMap/DynamicViewport/Angular/app/app.service.ts index a68eda63ee60..462482bc5f01 100644 --- a/apps/demos/Demos/VectorMap/DynamicViewport/Angular/app/app.service.ts +++ b/apps/demos/Demos/VectorMap/DynamicViewport/Angular/app/app.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; -export class ViewportCoordinate { +export interface ViewportCoordinate { continent: string; coordinates: number[] | 'null'; diff --git a/apps/demos/Demos/VectorMap/DynamicViewport/Angular/app/devextreme-vectormap-data.d.ts b/apps/demos/Demos/VectorMap/DynamicViewport/Angular/app/devextreme-vectormap-data.d.ts new file mode 100644 index 000000000000..370ec277e5ea --- /dev/null +++ b/apps/demos/Demos/VectorMap/DynamicViewport/Angular/app/devextreme-vectormap-data.d.ts @@ -0,0 +1,27 @@ +declare module 'devextreme-dist/js/vectormap-data/world.js' { + type Position = number[]; + type Geometry = + | { type: 'Point'; coordinates: Position } + | { type: 'MultiPoint'; coordinates: Position[] } + | { type: 'LineString'; coordinates: Position[] } + | { type: 'MultiLineString'; coordinates: Position[][] } + | { type: 'Polygon'; coordinates: Position[][] } + | { type: 'MultiPolygon'; coordinates: Position[][][] }; + + interface Feature { + type: 'Feature'; + geometry: Geometry; + properties: Record; + } + + interface FeatureCollection { + type: 'FeatureCollection'; + features: Feature[]; + // eslint-disable-next-line spellcheck/spell-checker + bbox?: number[]; + } + + const world: FeatureCollection; + export { world }; + export default world; +} diff --git a/apps/demos/Demos/VectorMap/FloorPlan/Angular/app/app.component.ts b/apps/demos/Demos/VectorMap/FloorPlan/Angular/app/app.component.ts index 5d41688cd5e2..01e9f9faf14d 100644 --- a/apps/demos/Demos/VectorMap/FloorPlan/Angular/app/app.component.ts +++ b/apps/demos/Demos/VectorMap/FloorPlan/Angular/app/app.component.ts @@ -1,6 +1,7 @@ import { bootstrapApplication } from '@angular/platform-browser'; import { Component, enableProdMode, inject } from '@angular/core'; import { DxVectorMapModule } from 'devextreme-angular'; +import type { DxVectorMapTypes } from 'devextreme-angular/ui/vector-map'; import { Service } from './app.service'; if (!/localhost/.test(document.location.host)) { @@ -33,14 +34,14 @@ export class AppComponent { readonly buildingData = this.service.getBuildingData(); - customizeTooltip({ layer, attribute }) { + readonly customizeTooltip = ({ layer, attribute }: DxVectorMapTypes.MapLayerElement): Record => { if (layer.name === 'rooms') { return { text: `Square: ${attribute('square')} ft²`, }; } - return null; - } + return {}; + }; } bootstrapApplication(AppComponent); diff --git a/apps/demos/Demos/VectorMap/FloorPlan/Angular/app/app.service.ts b/apps/demos/Demos/VectorMap/FloorPlan/Angular/app/app.service.ts index 6b69ff53cbdf..49fcbac065ed 100644 --- a/apps/demos/Demos/VectorMap/FloorPlan/Angular/app/app.service.ts +++ b/apps/demos/Demos/VectorMap/FloorPlan/Angular/app/app.service.ts @@ -1,12 +1,12 @@ import { Injectable } from '@angular/core'; -export class FeatureCollection { +export interface FeatureCollection { type: string; features: Feature[]; } -export class Feature { +export interface Feature { type: string; properties?: FeatureProperty; @@ -14,13 +14,13 @@ export class Feature { geometry: FeatureGeometry; } -export class FeatureProperty { +export interface FeatureProperty { name: string; square?: number; } -export class FeatureGeometry { +export interface FeatureGeometry { type: string; coordinates: number[][][]; diff --git a/apps/demos/Demos/VectorMap/ImageMarkers/Angular/app/app.service.ts b/apps/demos/Demos/VectorMap/ImageMarkers/Angular/app/app.service.ts index 52a38c0eb464..b184275ba701 100644 --- a/apps/demos/Demos/VectorMap/ImageMarkers/Angular/app/app.service.ts +++ b/apps/demos/Demos/VectorMap/ImageMarkers/Angular/app/app.service.ts @@ -1,12 +1,12 @@ import { Injectable } from '@angular/core'; -export class FeatureCollection { +export interface FeatureCollection { type: string; features: Feature[]; } -export class Feature { +export interface Feature { type: string; properties: FeatureProperty; @@ -14,19 +14,19 @@ export class Feature { geometry: FeatureGeometry; } -export class FeatureProperty { +export interface FeatureProperty { text: string; url: string; } -export class FeatureGeometry { +export interface FeatureGeometry { type: string; coordinates: number[]; } -function getImageUrl(name): string { +function getImageUrl(name: string): string { return `../../../../images/VectorMap/${name}.png`; } diff --git a/apps/demos/Demos/VectorMap/ImageMarkers/Angular/app/devextreme-vectormap-data.d.ts b/apps/demos/Demos/VectorMap/ImageMarkers/Angular/app/devextreme-vectormap-data.d.ts new file mode 100644 index 000000000000..e5de5ff1844d --- /dev/null +++ b/apps/demos/Demos/VectorMap/ImageMarkers/Angular/app/devextreme-vectormap-data.d.ts @@ -0,0 +1,27 @@ +declare module 'devextreme-dist/js/vectormap-data/usa.js' { + type Position = number[]; + type Geometry = + | { type: 'Point'; coordinates: Position } + | { type: 'MultiPoint'; coordinates: Position[] } + | { type: 'LineString'; coordinates: Position[] } + | { type: 'MultiLineString'; coordinates: Position[][] } + | { type: 'Polygon'; coordinates: Position[][] } + | { type: 'MultiPolygon'; coordinates: Position[][][] }; + + interface Feature { + type: 'Feature'; + geometry: Geometry; + properties: Record; + } + + interface FeatureCollection { + type: 'FeatureCollection'; + features: Feature[]; + // eslint-disable-next-line spellcheck/spell-checker + bbox?: number[]; + } + + const usa: FeatureCollection; + export { usa }; + export default usa; +} diff --git a/apps/demos/Demos/VectorMap/Legend/Angular/app/app.component.html b/apps/demos/Demos/VectorMap/Legend/Angular/app/app.component.html index c4b9fe37faf6..35a8c4e340b9 100644 --- a/apps/demos/Demos/VectorMap/Legend/Angular/app/app.component.html +++ b/apps/demos/Demos/VectorMap/Legend/Angular/app/app.component.html @@ -22,7 +22,7 @@ elementType="bubble" dataField="value" [sizeGroups]="[0, 8000, 10000, 50000]" - opacity="0.8" + [opacity]="0.8" > diff --git a/apps/demos/Demos/VectorMap/Legend/Angular/app/app.component.ts b/apps/demos/Demos/VectorMap/Legend/Angular/app/app.component.ts index 87befbf14ee2..41018bd665e5 100644 --- a/apps/demos/Demos/VectorMap/Legend/Angular/app/app.component.ts +++ b/apps/demos/Demos/VectorMap/Legend/Angular/app/app.component.ts @@ -2,6 +2,7 @@ import { bootstrapApplication } from '@angular/platform-browser'; import { Component, enableProdMode, inject } from '@angular/core'; import { DxVectorMapModule } from 'devextreme-angular'; import * as mapsData from 'devextreme-dist/js/vectormap-data/world.js'; +import type { DxVectorMapTypes } from 'devextreme-angular/ui/vector-map'; import { Service } from './app.service'; if (!/localhost/.test(document.location.host)) { @@ -25,27 +26,26 @@ export class AppComponent { readonly markers = this.service.getMarkers(); - private readonly populations: Object = this.service.getPopulations(); + private readonly populations = this.service.getPopulations(); - customizeText({ index, start, end }) { + readonly customizeText: NonNullable = ({ index, start, end }) => { if (index === 0) { return '< 0.5%'; } - return (index === 5) ? '> 3%' : `${start}% to ${end}%`; - } + }; - readonly customizeTooltip = (arg: { attribute: Function }) => ({ + readonly customizeTooltip = (arg: DxVectorMapTypes.MapLayerElement): Record => ({ text: arg.attribute('text'), }); - readonly customizeItems = (items: unknown[]) => items.reverse(); + readonly customizeItems = (items: DxVectorMapTypes.LegendItem[]): DxVectorMapTypes.LegendItem[] => items.reverse(); - readonly customizeLayers = (elements: { attribute: Function }[]) => { + readonly customizeLayers = (elements: DxVectorMapTypes.MapLayerElement[]): void => { elements.forEach((element) => { - const name = element.attribute('name'); + const name: string = element.attribute('name'); const population = this.populations[name]; if (population) { element.attribute('population', population); @@ -53,7 +53,7 @@ export class AppComponent { }); }; - readonly customizeMarkers = ({ index }) => ['< 8000K', '8000K to 10000K', '> 10000K'][index]; + readonly customizeMarkers = ({ index }: { index: number }): string => ['< 8000K', '8000K to 10000K', '> 10000K'][index]; } bootstrapApplication(AppComponent); diff --git a/apps/demos/Demos/VectorMap/Legend/Angular/app/app.service.ts b/apps/demos/Demos/VectorMap/Legend/Angular/app/app.service.ts index cb405006c955..9030a8089352 100644 --- a/apps/demos/Demos/VectorMap/Legend/Angular/app/app.service.ts +++ b/apps/demos/Demos/VectorMap/Legend/Angular/app/app.service.ts @@ -1,12 +1,12 @@ import { Injectable } from '@angular/core'; -export class FeatureCollection { +export interface FeatureCollection { type: string; features: Feature[]; } -export class Feature { +export interface Feature { type: string; properties: FeatureProperty; @@ -14,19 +14,21 @@ export class Feature { geometry: FeatureGeometry; } -export class FeatureProperty { +export interface FeatureProperty { value: number; text: string; } -export class FeatureGeometry { +export interface FeatureGeometry { type: string; coordinates: number[]; } -const populations = { +export type Populations = Record; + +const populations: Populations = { China: 19, India: 17.4, 'United States': 4.44, @@ -149,7 +151,7 @@ const markers: FeatureCollection = { @Injectable() export class Service { - getPopulations() { + getPopulations(): Populations { return populations; } diff --git a/apps/demos/Demos/VectorMap/Legend/Angular/app/devextreme-vectormap-data.d.ts b/apps/demos/Demos/VectorMap/Legend/Angular/app/devextreme-vectormap-data.d.ts new file mode 100644 index 000000000000..370ec277e5ea --- /dev/null +++ b/apps/demos/Demos/VectorMap/Legend/Angular/app/devextreme-vectormap-data.d.ts @@ -0,0 +1,27 @@ +declare module 'devextreme-dist/js/vectormap-data/world.js' { + type Position = number[]; + type Geometry = + | { type: 'Point'; coordinates: Position } + | { type: 'MultiPoint'; coordinates: Position[] } + | { type: 'LineString'; coordinates: Position[] } + | { type: 'MultiLineString'; coordinates: Position[][] } + | { type: 'Polygon'; coordinates: Position[][] } + | { type: 'MultiPolygon'; coordinates: Position[][][] }; + + interface Feature { + type: 'Feature'; + geometry: Geometry; + properties: Record; + } + + interface FeatureCollection { + type: 'FeatureCollection'; + features: Feature[]; + // eslint-disable-next-line spellcheck/spell-checker + bbox?: number[]; + } + + const world: FeatureCollection; + export { world }; + export default world; +} diff --git a/apps/demos/Demos/VectorMap/MultipleLayers/Angular/app/app.component.ts b/apps/demos/Demos/VectorMap/MultipleLayers/Angular/app/app.component.ts index 76f0a451a2dc..93b270870ed0 100644 --- a/apps/demos/Demos/VectorMap/MultipleLayers/Angular/app/app.component.ts +++ b/apps/demos/Demos/VectorMap/MultipleLayers/Angular/app/app.component.ts @@ -2,6 +2,7 @@ import { bootstrapApplication } from '@angular/platform-browser'; import { Component, enableProdMode, inject } from '@angular/core'; import { DxVectorMapModule } from 'devextreme-angular'; import * as mapsData from 'devextreme-dist/js/vectormap-data/world.js'; +import type { DxVectorMapTypes } from 'devextreme-angular/ui/vector-map'; import { Service } from './app.service'; if (!/localhost/.test(document.location.host)) { @@ -23,7 +24,7 @@ export class AppComponent { readonly streamsData = inject(Service).getStreamsData(); - readonly customizeText = ({ color }) => (color === '#3c20c8' ? 'Cold' : 'Warm'); + readonly customizeText: NonNullable = ({ color }) => (color === '#3c20c8' ? 'Cold' : 'Warm'); } bootstrapApplication(AppComponent); diff --git a/apps/demos/Demos/VectorMap/MultipleLayers/Angular/app/app.service.ts b/apps/demos/Demos/VectorMap/MultipleLayers/Angular/app/app.service.ts index c1341e81d653..80e7c15de868 100644 --- a/apps/demos/Demos/VectorMap/MultipleLayers/Angular/app/app.service.ts +++ b/apps/demos/Demos/VectorMap/MultipleLayers/Angular/app/app.service.ts @@ -1,12 +1,12 @@ import { Injectable } from '@angular/core'; -export class FeatureCollection { +export interface FeatureCollection { type: string; features: Feature[]; } -export class Feature { +export interface Feature { type: string; properties: FeatureProperty; @@ -14,11 +14,11 @@ export class Feature { geometry: FeatureGeometry; } -export class FeatureProperty { +export interface FeatureProperty { tag: number; } -export class FeatureGeometry { +export interface FeatureGeometry { type: string; coordinates: number[][][]; diff --git a/apps/demos/Demos/VectorMap/MultipleLayers/Angular/app/devextreme-vectormap-data.d.ts b/apps/demos/Demos/VectorMap/MultipleLayers/Angular/app/devextreme-vectormap-data.d.ts new file mode 100644 index 000000000000..370ec277e5ea --- /dev/null +++ b/apps/demos/Demos/VectorMap/MultipleLayers/Angular/app/devextreme-vectormap-data.d.ts @@ -0,0 +1,27 @@ +declare module 'devextreme-dist/js/vectormap-data/world.js' { + type Position = number[]; + type Geometry = + | { type: 'Point'; coordinates: Position } + | { type: 'MultiPoint'; coordinates: Position[] } + | { type: 'LineString'; coordinates: Position[] } + | { type: 'MultiLineString'; coordinates: Position[][] } + | { type: 'Polygon'; coordinates: Position[][] } + | { type: 'MultiPolygon'; coordinates: Position[][][] }; + + interface Feature { + type: 'Feature'; + geometry: Geometry; + properties: Record; + } + + interface FeatureCollection { + type: 'FeatureCollection'; + features: Feature[]; + // eslint-disable-next-line spellcheck/spell-checker + bbox?: number[]; + } + + const world: FeatureCollection; + export { world }; + export default world; +} diff --git a/apps/demos/Demos/VectorMap/Overview/Angular/app/app.component.ts b/apps/demos/Demos/VectorMap/Overview/Angular/app/app.component.ts index 5898c4554d40..c18ba38df1f4 100644 --- a/apps/demos/Demos/VectorMap/Overview/Angular/app/app.component.ts +++ b/apps/demos/Demos/VectorMap/Overview/Angular/app/app.component.ts @@ -3,7 +3,10 @@ import { Component, enableProdMode, inject } from '@angular/core'; import { DecimalPipe } from '@angular/common'; import { DxVectorMapModule, DxPieChartModule } from 'devextreme-angular'; import * as mapsData from 'devextreme-dist/js/vectormap-data/world.js'; -import { type GdpInfo, Service } from './app.service'; +import type { DxPieChartTypes } from 'devextreme-angular/ui/pie-chart'; +import type { DxVectorMapTypes } from 'devextreme-angular/ui/vector-map'; +import { Service } from './app.service'; +import type { GdpInfo } from './app.service'; if (!/localhost/.test(document.location.host)) { enableProdMode(); @@ -23,26 +26,26 @@ if (!/localhost/.test(document.location.host)) { export class AppComponent { readonly worldMap = mapsData.world; - readonly gdpData: Object = inject(Service).getCountriesGDP(); + readonly gdpData = inject(Service).getCountriesGDP(); readonly pipe = new DecimalPipe('en-US'); - readonly customizeLayers = (elements: Record[]) => { + readonly customizeLayers = (elements: DxVectorMapTypes.MapLayerElement[]): void => { elements.forEach((element) => { const countryGDPData = this.gdpData[element.attribute('name')]; element.attribute('total', countryGDPData?.total || 0); }); }; - readonly customizeText = ({ start, end }) => `${this.pipe.transform(start, '1.0-0')}` - + ' to ' - + `${this.pipe.transform(end, '1.0-0')}`; + readonly customizeText: NonNullable = ({ start, end }) => `${this.pipe.transform(start, '1.0-0')} to ${this.pipe.transform(end, '1.0-0')}`; - readonly customizePieLabel = ({ argument, value }) => `${argument[0].toUpperCase() + argument.slice(1)}: $${value}M`; - - getPieData(name: string): GdpInfo[] { - const data = this.gdpData?.[name]; + readonly customizePieLabel = ({ argument, value }: DxPieChartTypes.PointInfo): string => { + const name = String(argument); + return `${name[0].toUpperCase() + name.slice(1)}: $${value}M`; + }; + getPieData(name: string): GdpInfo[] | null { + const data = this.gdpData[name]; return data ? [ { name: 'industry', value: data.industry }, { name: 'services', value: data.services }, diff --git a/apps/demos/Demos/VectorMap/Overview/Angular/app/app.service.ts b/apps/demos/Demos/VectorMap/Overview/Angular/app/app.service.ts index 8de524442bbf..94f3a30990d1 100644 --- a/apps/demos/Demos/VectorMap/Overview/Angular/app/app.service.ts +++ b/apps/demos/Demos/VectorMap/Overview/Angular/app/app.service.ts @@ -1,12 +1,24 @@ import { Injectable } from '@angular/core'; -export class GdpInfo { +export interface GdpInfo { name: string; - value: number; + value: number | undefined; } -const countriesGDP: Object = { +export interface CountryGDP { + agriculture?: number; + + industry?: number; + + services?: number; + + total?: number; +} + +export type CountriesGDP = Record; + +const countriesGDP: CountriesGDP = { Afghanistan: { agriculture: 34.9, industry: 25, services: 40, total: 20312, }, @@ -674,7 +686,7 @@ const countriesGDP: Object = { @Injectable() export class Service { - getCountriesGDP(): Object { + getCountriesGDP(): CountriesGDP { return countriesGDP; } } diff --git a/apps/demos/Demos/VectorMap/Overview/Angular/app/devextreme-vectormap-data.d.ts b/apps/demos/Demos/VectorMap/Overview/Angular/app/devextreme-vectormap-data.d.ts new file mode 100644 index 000000000000..c50aa3059f60 --- /dev/null +++ b/apps/demos/Demos/VectorMap/Overview/Angular/app/devextreme-vectormap-data.d.ts @@ -0,0 +1,28 @@ +declare module 'devextreme-dist/js/vectormap-data/world.js' { + type Position = number[]; + type Geometry = + | { type: 'Point'; coordinates: Position } + | { type: 'MultiPoint'; coordinates: Position[] } + | { type: 'LineString'; coordinates: Position[] } + | { type: 'MultiLineString'; coordinates: Position[][] } + | { type: 'Polygon'; coordinates: Position[][] } + | { type: 'MultiPolygon'; coordinates: Position[][][] }; + + interface Feature { + type: 'Feature'; + geometry: Geometry; + properties: Record; + } + + interface FeatureCollection { + type: 'FeatureCollection'; + features: Feature[]; + + // eslint-disable-next-line spellcheck/spell-checker + bbox?: number[]; + } + + const world: FeatureCollection; + export { world }; + export default world; +} diff --git a/apps/demos/Demos/VectorMap/Palette/Angular/app/app.component.ts b/apps/demos/Demos/VectorMap/Palette/Angular/app/app.component.ts index ee457e30899f..0a9b8780f849 100644 --- a/apps/demos/Demos/VectorMap/Palette/Angular/app/app.component.ts +++ b/apps/demos/Demos/VectorMap/Palette/Angular/app/app.component.ts @@ -2,6 +2,7 @@ import { bootstrapApplication } from '@angular/platform-browser'; import { Component, enableProdMode, inject } from '@angular/core'; import { DxVectorMapModule } from 'devextreme-angular'; import * as mapsData from 'devextreme-dist/js/vectormap-data/world.js'; +import type { DxVectorMapTypes } from 'devextreme-angular/ui/vector-map'; import { Service } from './app.service'; if (!/localhost/.test(document.location.host)) { @@ -21,28 +22,27 @@ if (!/localhost/.test(document.location.host)) { export class AppComponent { readonly worldMap = mapsData.world; - private readonly populations: Object = inject(Service).getPopulations(); + private readonly populations = inject(Service).getPopulations(); - customizeTooltip({ attribute }: { attribute: Function }) { + readonly customizeTooltip = ({ attribute }: DxVectorMapTypes.MapLayerElement): Record => { if (attribute('population')) { return { text: `${attribute('name')}: ${attribute('population')}% of world population`, }; } - return null; - } + return {}; + }; - readonly customizeLayers = (elements: { attribute: Function }[]) => { + readonly customizeLayers = (elements: DxVectorMapTypes.MapLayerElement[]): void => { elements.forEach((element) => { element.attribute('population', this.populations[element.attribute('name')]); }); }; - customizeText({ index, start, end }: Record) { + readonly customizeText: NonNullable = ({ index, start, end }) => { const text = (index === 0) ? '< 0.5%' : `${start}% to ${end}%`; - return (index === 5) ? '> 3%' : text; - } + }; } bootstrapApplication(AppComponent); diff --git a/apps/demos/Demos/VectorMap/Palette/Angular/app/app.service.ts b/apps/demos/Demos/VectorMap/Palette/Angular/app/app.service.ts index 2608e3a450a1..4d90954b425a 100644 --- a/apps/demos/Demos/VectorMap/Palette/Angular/app/app.service.ts +++ b/apps/demos/Demos/VectorMap/Palette/Angular/app/app.service.ts @@ -1,6 +1,8 @@ import { Injectable } from '@angular/core'; -const populations: Object = { +export type Populations = Record; + +const populations: Populations = { China: 19, India: 17.4, 'United States': 4.44, @@ -45,7 +47,7 @@ const populations: Object = { @Injectable() export class Service { - getPopulations(): Object { + getPopulations(): Populations { return populations; } } diff --git a/apps/demos/Demos/VectorMap/Palette/Angular/app/devextreme-vectormap-data.d.ts b/apps/demos/Demos/VectorMap/Palette/Angular/app/devextreme-vectormap-data.d.ts new file mode 100644 index 000000000000..370ec277e5ea --- /dev/null +++ b/apps/demos/Demos/VectorMap/Palette/Angular/app/devextreme-vectormap-data.d.ts @@ -0,0 +1,27 @@ +declare module 'devextreme-dist/js/vectormap-data/world.js' { + type Position = number[]; + type Geometry = + | { type: 'Point'; coordinates: Position } + | { type: 'MultiPoint'; coordinates: Position[] } + | { type: 'LineString'; coordinates: Position[] } + | { type: 'MultiLineString'; coordinates: Position[][] } + | { type: 'Polygon'; coordinates: Position[][] } + | { type: 'MultiPolygon'; coordinates: Position[][][] }; + + interface Feature { + type: 'Feature'; + geometry: Geometry; + properties: Record; + } + + interface FeatureCollection { + type: 'FeatureCollection'; + features: Feature[]; + // eslint-disable-next-line spellcheck/spell-checker + bbox?: number[]; + } + + const world: FeatureCollection; + export { world }; + export default world; +} diff --git a/apps/demos/Demos/VectorMap/PieMarkers/Angular/app/app.component.ts b/apps/demos/Demos/VectorMap/PieMarkers/Angular/app/app.component.ts index c199d360a231..e29f5cc7a480 100644 --- a/apps/demos/Demos/VectorMap/PieMarkers/Angular/app/app.component.ts +++ b/apps/demos/Demos/VectorMap/PieMarkers/Angular/app/app.component.ts @@ -2,6 +2,7 @@ import { bootstrapApplication } from '@angular/platform-browser'; import { Component, enableProdMode, inject } from '@angular/core'; import { DxVectorMapModule } from 'devextreme-angular'; import * as mapsData from 'devextreme-dist/js/vectormap-data/world.js'; +import type { DxVectorMapTypes } from 'devextreme-angular/ui/vector-map'; import { Service } from './app.service'; if (!/localhost/.test(document.location.host)) { @@ -27,11 +28,11 @@ export class AppComponent { private readonly names = this.service.getNames(); - readonly customizeText = ({ index }: { index: number }) => this.names[index]; + readonly customizeText = ({ index }: { index: number }): string => this.names[index]; - readonly customizeTooltip = ({ layer, attribute }: { layer: Record, attribute: Function }) => ((layer.type === 'marker') + readonly customizeTooltip = ({ layer, attribute }: DxVectorMapTypes.MapLayerElement): Record => ((layer.type === 'marker') ? { text: attribute('tooltip') } - : undefined); + : {}); } bootstrapApplication(AppComponent); diff --git a/apps/demos/Demos/VectorMap/PieMarkers/Angular/app/app.service.ts b/apps/demos/Demos/VectorMap/PieMarkers/Angular/app/app.service.ts index 94f3b53b9d57..d6e4f1bf2d3f 100644 --- a/apps/demos/Demos/VectorMap/PieMarkers/Angular/app/app.service.ts +++ b/apps/demos/Demos/VectorMap/PieMarkers/Angular/app/app.service.ts @@ -1,12 +1,12 @@ import { Injectable } from '@angular/core'; -export class FeatureCollection { +export interface FeatureCollection { type: string; features: Feature[]; } -export class Feature { +export interface Feature { type: string; properties: FeatureProperty; @@ -14,13 +14,13 @@ export class Feature { geometry: FeatureGeometry; } -export class FeatureProperty { +export interface FeatureProperty { values: number[]; tooltip: string; } -export class FeatureGeometry { +export interface FeatureGeometry { type: string; coordinates: number[]; diff --git a/apps/demos/Demos/VectorMap/PieMarkers/Angular/app/devextreme-vectormap-data.d.ts b/apps/demos/Demos/VectorMap/PieMarkers/Angular/app/devextreme-vectormap-data.d.ts new file mode 100644 index 000000000000..370ec277e5ea --- /dev/null +++ b/apps/demos/Demos/VectorMap/PieMarkers/Angular/app/devextreme-vectormap-data.d.ts @@ -0,0 +1,27 @@ +declare module 'devextreme-dist/js/vectormap-data/world.js' { + type Position = number[]; + type Geometry = + | { type: 'Point'; coordinates: Position } + | { type: 'MultiPoint'; coordinates: Position[] } + | { type: 'LineString'; coordinates: Position[] } + | { type: 'MultiLineString'; coordinates: Position[][] } + | { type: 'Polygon'; coordinates: Position[][] } + | { type: 'MultiPolygon'; coordinates: Position[][][] }; + + interface Feature { + type: 'Feature'; + geometry: Geometry; + properties: Record; + } + + interface FeatureCollection { + type: 'FeatureCollection'; + features: Feature[]; + // eslint-disable-next-line spellcheck/spell-checker + bbox?: number[]; + } + + const world: FeatureCollection; + export { world }; + export default world; +} diff --git a/apps/demos/Demos/VectorMap/TooltipsCustomization/Angular/app/app.component.ts b/apps/demos/Demos/VectorMap/TooltipsCustomization/Angular/app/app.component.ts index 35d344fe75f7..ac254ecdd8b4 100644 --- a/apps/demos/Demos/VectorMap/TooltipsCustomization/Angular/app/app.component.ts +++ b/apps/demos/Demos/VectorMap/TooltipsCustomization/Angular/app/app.component.ts @@ -3,7 +3,10 @@ import { Component, enableProdMode, inject } from '@angular/core'; import { DecimalPipe } from '@angular/common'; import { DxVectorMapModule, DxPieChartModule } from 'devextreme-angular'; import * as mapsData from 'devextreme-dist/js/vectormap-data/world.js'; -import { type GdpInfo, Service } from './app.service'; +import type { DxPieChartTypes } from 'devextreme-angular/ui/pie-chart'; +import type { DxVectorMapTypes } from 'devextreme-angular/ui/vector-map'; +import { Service } from './app.service'; +import type { GdpInfo } from './app.service'; if (!/localhost/.test(document.location.host)) { enableProdMode(); @@ -24,26 +27,30 @@ if (!/localhost/.test(document.location.host)) { export class AppComponent { readonly worldMap = mapsData.world; - readonly gdpData: Object = inject(Service).getCountriesGDP(); + readonly gdpData = inject(Service).getCountriesGDP(); private readonly pipe = new DecimalPipe('en-US'); - readonly customizeLayers = (elements: Record[]) => { + readonly customizeLayers = (elements: DxVectorMapTypes.MapLayerElement[]): void => { elements.forEach((element) => { const countryGDPData = this.gdpData[element.attribute('name')]; element.attribute('total', countryGDPData?.total || 0); }); }; - readonly customizeText = ({ start, end }: Record) => `${this.pipe.transform(start, '1.0-0')} to ${this.pipe.transform(end, '1.0-0')}`; + readonly customizeText: NonNullable = ({ start, end }) => `${this.pipe.transform(start, '1.0-0')} to ${this.pipe.transform(end, '1.0-0')}`; - readonly customizePieLabel = ({ argument, value }: { argument: string[], value: unknown }) => `${argument[0].toUpperCase() + argument.slice(1)}: $${value}M`; + readonly customizePieLabel = ({ argument, value }: DxPieChartTypes.PointInfo): string => { + const name = String(argument); + return `${name[0].toUpperCase() + name.slice(1)}: $${value}M`; + }; - getPieData(name: string): GdpInfo[] { - return this.gdpData[name] ? [ - { name: 'industry', value: this.gdpData[name].industry }, - { name: 'services', value: this.gdpData[name].services }, - { name: 'agriculture', value: this.gdpData[name].agriculture }, + getPieData(name: string): GdpInfo[] | null { + const data = this.gdpData[name]; + return data ? [ + { name: 'industry', value: data.industry }, + { name: 'services', value: data.services }, + { name: 'agriculture', value: data.agriculture }, ] : null; } } diff --git a/apps/demos/Demos/VectorMap/TooltipsCustomization/Angular/app/app.service.ts b/apps/demos/Demos/VectorMap/TooltipsCustomization/Angular/app/app.service.ts index 8de524442bbf..94f3a30990d1 100644 --- a/apps/demos/Demos/VectorMap/TooltipsCustomization/Angular/app/app.service.ts +++ b/apps/demos/Demos/VectorMap/TooltipsCustomization/Angular/app/app.service.ts @@ -1,12 +1,24 @@ import { Injectable } from '@angular/core'; -export class GdpInfo { +export interface GdpInfo { name: string; - value: number; + value: number | undefined; } -const countriesGDP: Object = { +export interface CountryGDP { + agriculture?: number; + + industry?: number; + + services?: number; + + total?: number; +} + +export type CountriesGDP = Record; + +const countriesGDP: CountriesGDP = { Afghanistan: { agriculture: 34.9, industry: 25, services: 40, total: 20312, }, @@ -674,7 +686,7 @@ const countriesGDP: Object = { @Injectable() export class Service { - getCountriesGDP(): Object { + getCountriesGDP(): CountriesGDP { return countriesGDP; } } diff --git a/apps/demos/Demos/VectorMap/TooltipsCustomization/Angular/app/devextreme-vectormap-data.d.ts b/apps/demos/Demos/VectorMap/TooltipsCustomization/Angular/app/devextreme-vectormap-data.d.ts new file mode 100644 index 000000000000..370ec277e5ea --- /dev/null +++ b/apps/demos/Demos/VectorMap/TooltipsCustomization/Angular/app/devextreme-vectormap-data.d.ts @@ -0,0 +1,27 @@ +declare module 'devextreme-dist/js/vectormap-data/world.js' { + type Position = number[]; + type Geometry = + | { type: 'Point'; coordinates: Position } + | { type: 'MultiPoint'; coordinates: Position[] } + | { type: 'LineString'; coordinates: Position[] } + | { type: 'MultiLineString'; coordinates: Position[][] } + | { type: 'Polygon'; coordinates: Position[][] } + | { type: 'MultiPolygon'; coordinates: Position[][][] }; + + interface Feature { + type: 'Feature'; + geometry: Geometry; + properties: Record; + } + + interface FeatureCollection { + type: 'FeatureCollection'; + features: Feature[]; + // eslint-disable-next-line spellcheck/spell-checker + bbox?: number[]; + } + + const world: FeatureCollection; + export { world }; + export default world; +} diff --git a/apps/demos/Demos/VectorMap/ZoomingAndCentering/Angular/app/app.component.ts b/apps/demos/Demos/VectorMap/ZoomingAndCentering/Angular/app/app.component.ts index eabdab215fdb..fab0aff85f6b 100644 --- a/apps/demos/Demos/VectorMap/ZoomingAndCentering/Angular/app/app.component.ts +++ b/apps/demos/Demos/VectorMap/ZoomingAndCentering/Angular/app/app.component.ts @@ -3,7 +3,8 @@ import { Component, enableProdMode, inject, viewChild, } from '@angular/core'; import { DxButtonModule } from 'devextreme-angular'; -import { DxVectorMapModule, DxVectorMapComponent, type DxVectorMapTypes } from 'devextreme-angular/ui/vector-map'; +import { DxVectorMapModule, DxVectorMapComponent } from 'devextreme-angular/ui/vector-map'; +import type { DxVectorMapTypes } from 'devextreme-angular/ui/vector-map'; import * as mapsData from 'devextreme-dist/js/vectormap-data/world.js'; import { Service } from './app.service'; @@ -29,25 +30,26 @@ export class AppComponent { readonly markers = inject(Service).getMarkers(); - customizeTooltip(arg) { + readonly customizeTooltip = (arg: DxVectorMapTypes.MapLayerElement): Record => { if (arg.layer.type === 'marker') { return { text: arg.attribute('name'), }; } - return null; - } + return {}; + }; - markerClick(e: DxVectorMapTypes.ClickEvent) { + markerClick(e: DxVectorMapTypes.ClickEvent): void { if (e.target?.layer.type === 'marker') { e.component.center(e.target.coordinates()); e.component.zoomFactor(10); } } - resetClick() { - this.vectorMap().instance.center(null); - this.vectorMap().instance.zoomFactor(null); + resetClick(): void { + // An empty array resets the center to its initial value + this.vectorMap().instance.center([]); + this.vectorMap().instance.zoomFactor(1); } } diff --git a/apps/demos/Demos/VectorMap/ZoomingAndCentering/Angular/app/app.service.ts b/apps/demos/Demos/VectorMap/ZoomingAndCentering/Angular/app/app.service.ts index e8abd683c5e4..93c5b87903ef 100644 --- a/apps/demos/Demos/VectorMap/ZoomingAndCentering/Angular/app/app.service.ts +++ b/apps/demos/Demos/VectorMap/ZoomingAndCentering/Angular/app/app.service.ts @@ -1,10 +1,10 @@ import { Injectable } from '@angular/core'; -export class Attributes { +export interface Attributes { name: string; } -export class Marker { +export interface Marker { coordinates: number[]; attributes: Attributes; diff --git a/apps/demos/Demos/VectorMap/ZoomingAndCentering/Angular/app/devextreme-vectormap-data.d.ts b/apps/demos/Demos/VectorMap/ZoomingAndCentering/Angular/app/devextreme-vectormap-data.d.ts new file mode 100644 index 000000000000..370ec277e5ea --- /dev/null +++ b/apps/demos/Demos/VectorMap/ZoomingAndCentering/Angular/app/devextreme-vectormap-data.d.ts @@ -0,0 +1,27 @@ +declare module 'devextreme-dist/js/vectormap-data/world.js' { + type Position = number[]; + type Geometry = + | { type: 'Point'; coordinates: Position } + | { type: 'MultiPoint'; coordinates: Position[] } + | { type: 'LineString'; coordinates: Position[] } + | { type: 'MultiLineString'; coordinates: Position[][] } + | { type: 'Polygon'; coordinates: Position[][] } + | { type: 'MultiPolygon'; coordinates: Position[][][] }; + + interface Feature { + type: 'Feature'; + geometry: Geometry; + properties: Record; + } + + interface FeatureCollection { + type: 'FeatureCollection'; + features: Feature[]; + // eslint-disable-next-line spellcheck/spell-checker + bbox?: number[]; + } + + const world: FeatureCollection; + export { world }; + export default world; +} diff --git a/apps/demos/eslint.config.mjs b/apps/demos/eslint.config.mjs index d9865a486eef..f85c51547941 100644 --- a/apps/demos/eslint.config.mjs +++ b/apps/demos/eslint.config.mjs @@ -22,6 +22,13 @@ const __dirname = path.dirname(__filename); const spellcheckRule = spellcheckDevextreme[0].rules['spellcheck/spell-checker']; +// Sections whose Angular demos are fixed for strict TS (see "exclude" in tsconfig.ngc-check.json) +const strictAngularSections = [ + 'Localization', + 'Map', + 'VectorMap', +]; + export default [ { ignores: [ @@ -248,6 +255,22 @@ export default [ }, }, + // Angular demos fixed for strict TS + { + files: strictAngularSections.map((section) => `Demos/${section}/**/Angular/**/*.ts`), + rules: { + '@typescript-eslint/no-explicit-any': 'error', + '@typescript-eslint/no-unsafe-function-type': 'error', + '@typescript-eslint/no-wrapper-object-types': 'error', + '@typescript-eslint/consistent-type-imports': ['error', { fixStyle: 'separate-type-imports' }], + '@typescript-eslint/no-import-type-side-effects': 'error', + '@typescript-eslint/consistent-type-assertions': ['error', { + assertionStyle: 'as', + objectLiteralTypeAssertions: 'never', + }], + }, + }, + // jQuery demos { files: ['Demos/**/jQuery/*.*', 'utils/templates/jQuery/**/*.*'], diff --git a/apps/demos/tsconfig.ngc-check.json b/apps/demos/tsconfig.ngc-check.json index 3a691b58182d..2536a6fabaf1 100644 --- a/apps/demos/tsconfig.ngc-check.json +++ b/apps/demos/tsconfig.ngc-check.json @@ -2,7 +2,7 @@ "compilerOptions": { "skipLibCheck": true, "skipDefaultLibCheck": true, - "strict": false, + "strict": true, "verbatimModuleSyntax": true, "module": "ESNext", "moduleResolution": "Node", @@ -18,5 +18,77 @@ "include": [ "Demos/**/Angular/**/*.ts", "shared/anti-forgery/index.d.ts" + ], + // Sections whose Angular demos are not yet fixed for strict mode. Remove a section when its demos are fixed. + "exclude": [ + "Demos/Accordion/**", + "Demos/ActionSheet/**", + "Demos/Autocomplete/**", + "Demos/Box/**", + "Demos/Button/**", + "Demos/ButtonGroup/**", + "Demos/Calendar/**", + "Demos/CardView/**", + "Demos/Charts/**", + "Demos/Chat/**", + "Demos/CheckBox/**", + "Demos/ColorBox/**", + "Demos/Common/**", + "Demos/ContextMenu/**", + "Demos/DataGrid/**", + "Demos/DateBox/**", + "Demos/DateRangeBox/**", + "Demos/Diagram/**", + "Demos/Drawer/**", + "Demos/DropDownBox/**", + "Demos/DropDownButton/**", + "Demos/FieldSet/**", + "Demos/FileManager/**", + "Demos/FileUploader/**", + "Demos/FilterBuilder/**", + "Demos/FloatingActionButton/**", + "Demos/Form/**", + "Demos/Gallery/**", + "Demos/Gantt/**", + "Demos/Gauges/**", + "Demos/HtmlEditor/**", + "Demos/List/**", + "Demos/LoadIndicator/**", + "Demos/LoadPanel/**", + "Demos/Lookup/**", + "Demos/Menu/**", + "Demos/MultiView/**", + "Demos/NumberBox/**", + "Demos/Pagination/**", + "Demos/PivotGrid/**", + "Demos/Popover/**", + "Demos/Popup/**", + "Demos/ProgressBar/**", + "Demos/RadioGroup/**", + "Demos/RangeSelector/**", + "Demos/RangeSlider/**", + "Demos/Resizable/**", + "Demos/ResponsiveBox/**", + "Demos/Scheduler/**", + "Demos/ScrollView/**", + "Demos/SelectBox/**", + "Demos/Slider/**", + "Demos/Sortable/**", + "Demos/SpeechToText/**", + "Demos/Splitter/**", + "Demos/Stepper/**", + "Demos/Switch/**", + "Demos/TabPanel/**", + "Demos/Tabs/**", + "Demos/TagBox/**", + "Demos/TextArea/**", + "Demos/TextBox/**", + "Demos/TileView/**", + "Demos/Toast/**", + "Demos/Toolbar/**", + "Demos/Tooltip/**", + "Demos/TreeList/**", + "Demos/TreeView/**", + "Demos/Validation/**" ] } From f4b749f4d48232cfca7727cdf9c71be1e046e72e Mon Sep 17 00:00:00 2001 From: dxvladislavvolkov Date: Tue, 24 Nov 2026 14:44:22 +0400 Subject: [PATCH 2/2] Change moduleResolution value --- apps/demos/tsconfig.ngc-check.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/demos/tsconfig.ngc-check.json b/apps/demos/tsconfig.ngc-check.json index 2536a6fabaf1..e5d94cba3677 100644 --- a/apps/demos/tsconfig.ngc-check.json +++ b/apps/demos/tsconfig.ngc-check.json @@ -5,7 +5,7 @@ "strict": true, "verbatimModuleSyntax": true, "module": "ESNext", - "moduleResolution": "Node", + "moduleResolution": "Bundler", "ignoreDeprecations": "6.0", "lib": ["es2022", "DOM", "DOM.Iterable"], "resolveJsonModule": true