Skip to content

Commit 777890a

Browse files
authored
Merge pull request #144 from OutSystems/ROU-4631
ROU-4631: improvements to the types in the code
2 parents a3b6127 + 386274b commit 777890a

148 files changed

Lines changed: 892 additions & 852 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
// eslint-disable-next-line @typescript-eslint/no-unused-vars
22
namespace OSFramework.Maps.Configuration {
3-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
43
export abstract class AbstractConfiguration implements IConfiguration {
5-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
6-
constructor(config: any) {
4+
constructor(config: unknown) {
5+
const _localConfig = config as unknown[];
76
let key;
8-
for (key in config) {
9-
if (config[key] !== undefined) {
10-
this[key] = config[key];
7+
for (key in _localConfig) {
8+
if (_localConfig[key] !== undefined) {
9+
this[key] = _localConfig[key];
1110
}
1211
}
1312
}
1413

15-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
16-
public abstract getProviderConfig(): any;
14+
public abstract getProviderConfig(): unknown;
1715
}
1816
}

src/OSFramework/Maps/Configuration/IConfiguration.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ namespace OSFramework.Maps.Configuration {
88
/**
99
* Method responsible for the translation of configuration from OS to Provider
1010
*/
11-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
12-
getProviderConfig(): any;
11+
getProviderConfig(): unknown;
1312
}
1413
}

src/OSFramework/Maps/Configuration/IConfigurationMarker.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ namespace OSFramework.Maps.Configuration {
55
* Defines the basic structure for Map objects
66
*/
77
export interface IConfigurationMarker extends IConfiguration {
8-
allowDrag: boolean;
9-
iconHeight: number;
10-
iconUrl: string;
11-
iconWidth: number;
12-
location: string;
13-
title: string;
8+
allowDrag?: boolean;
9+
iconHeight?: number;
10+
iconUrl?: string;
11+
iconWidth?: number;
12+
location?: string;
13+
title?: string;
1414
}
1515
}

src/OSFramework/Maps/DrawingTools/AbstractDrawingTools.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// eslint-disable-next-line @typescript-eslint/no-unused-vars
22
namespace OSFramework.Maps.DrawingTools {
33
export abstract class AbstractDrawingTools<
4-
W,
5-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
4+
W extends IDrawingToolsProvider,
65
T extends Configuration.IConfigurationDrawingTools
76
> implements IDrawingTools
87
{
@@ -15,8 +14,7 @@ namespace OSFramework.Maps.DrawingTools {
1514
private _widgetId: string;
1615

1716
protected _built: boolean;
18-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
19-
protected _createElements: Array<any>;
17+
protected _createElements: Array<unknown>;
2018
protected _drawingToolsEvents: Event.DrawingTools.DrawingToolsEventsManager;
2119
protected _provider: W;
2220

@@ -35,8 +33,7 @@ namespace OSFramework.Maps.DrawingTools {
3533
public get config(): T {
3634
return this._config;
3735
}
38-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
39-
public get createdElements(): Array<any> {
36+
public get createdElements(): Array<unknown> {
4037
return this._createElements;
4138
}
4239
public get drawingToolsEvents(): Event.DrawingTools.DrawingToolsEventsManager {
@@ -95,8 +92,10 @@ namespace OSFramework.Maps.DrawingTools {
9592
this._setWidgetId();
9693
}
9794

98-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
99-
public changeProperty(propertyName: string, propertyValue: any): void {
95+
public changeProperty(
96+
propertyName: string,
97+
propertyValue: unknown
98+
): void {
10099
//Update Shape's config when the property is available
101100
if (this.config.hasOwnProperty(propertyName)) {
102101
this.config[propertyName] = propertyValue;
@@ -113,8 +112,7 @@ namespace OSFramework.Maps.DrawingTools {
113112
public changeToolProperty(
114113
toolId: string,
115114
propertyName: string,
116-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
117-
propertyValue: any
115+
propertyValue: unknown
118116
): void {
119117
const tool = this._tools.get(toolId);
120118
tool.changeProperty(propertyName, propertyValue);
@@ -131,9 +129,8 @@ namespace OSFramework.Maps.DrawingTools {
131129
return id === this._uniqueId || id === this.widgetId;
132130
}
133131

134-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
135132
public getProviderConfig(): Configuration.IConfigurationDrawingTools {
136-
return this._config.getProviderConfig();
133+
return this._config.getProviderConfig() as Configuration.IConfigurationDrawingTools;
137134
}
138135

139136
public hasTool(toolId: string): boolean {
@@ -169,8 +166,7 @@ namespace OSFramework.Maps.DrawingTools {
169166
return this.providerEvents.indexOf(eventName) !== -1;
170167
}
171168

172-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
173-
public abstract get providerEvents(): any;
169+
public abstract get providerEvents(): Array<string>;
174170

175171
public abstract refreshProviderEvents(): void;
176172
}

src/OSFramework/Maps/DrawingTools/AbstractTool.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,10 @@ namespace OSFramework.Maps.DrawingTools {
7474
this._setWidgetId();
7575
}
7676

77-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
78-
public changeProperty(propertyName: string, propertyValue: any): void {
77+
public changeProperty(
78+
propertyName: string,
79+
propertyValue: unknown
80+
): void {
7981
//Update Shape's config when the property is available
8082
if (this.config.hasOwnProperty(propertyName)) {
8183
this.config[propertyName] = propertyValue;
@@ -99,12 +101,10 @@ namespace OSFramework.Maps.DrawingTools {
99101
}
100102

101103
public getProviderConfig(): T {
102-
return this._config.getProviderConfig();
104+
return this._config.getProviderConfig() as T;
103105
}
106+
public abstract get options(): unknown;
104107

105-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
106-
public abstract get options(): any;
107-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
108-
public abstract addCompletedEvent(e?: any): void;
108+
public abstract addCompletedEvent(e?: unknown): void;
109109
}
110110
}

src/OSFramework/Maps/DrawingTools/Factory.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace OSFramework.Maps.DrawingTools {
44
export function MakeDrawingTools(
55
map: OSMap.IMap,
66
drawingToolsId: string,
7-
configs: Configuration.IConfiguration
7+
configs: JSON
88
): DrawingTools.IDrawingTools {
99
switch (map.providerType) {
1010
case Enum.ProviderType.Google:
@@ -31,7 +31,7 @@ namespace OSFramework.Maps.DrawingTools {
3131
drawingTools: DrawingTools.IDrawingTools,
3232
toolId: string,
3333
type: Enum.DrawingToolsTypes,
34-
configs: Configuration.IConfiguration
34+
configs: JSON
3535
): DrawingTools.ITool {
3636
switch (map.providerType) {
3737
case Enum.ProviderType.Google:

src/OSFramework/Maps/DrawingTools/IDrawingTools.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,21 @@ namespace OSFramework.Maps.DrawingTools {
55
Interface.ISearchById,
66
Interface.IDisposable {
77
config: Configuration.IConfigurationDrawingTools; //IConfigurationDrawingTools
8-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
9-
createdElements: Array<any>;
8+
createdElements: Array<unknown>;
109
/** Events from the DrawingTools */
1110
drawingToolsEvents: Event.DrawingTools.DrawingToolsEventsManager;
1211
isReady: boolean;
1312
map: OSMap.IMap; //IMap
14-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
15-
provider: any;
13+
provider: IDrawingToolsProvider;
1614
/** Events from the DrawingTools provider */
17-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
18-
providerEvents: any;
15+
providerEvents: unknown;
1916
tools: Array<ITool>;
2017
uniqueId: string;
2118
widgetId: string;
2219

2320
/** Adds a Tool into the DrawingTools element */
2421
addTool(tool: ITool): ITool;
25-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
26-
changeProperty(propertyName: string, propertyValue: any): void;
22+
changeProperty(propertyName: string, propertyValue: unknown): void;
2723
/**
2824
* Change property of a Tool from the DrawingTools by specifying the property name and the new value
2925
* @param toolId id of the Tool
@@ -33,8 +29,7 @@ namespace OSFramework.Maps.DrawingTools {
3329
changeToolProperty(
3430
toolId: string,
3531
propertyName: string,
36-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
37-
propertyValue: any
32+
propertyValue: unknown
3833
): void;
3934
/**
4035
* Boolean that indicates whether the DrawingTools element has a tool with the same uniqueId or not
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2+
namespace OSFramework.Maps.DrawingTools {
3+
export interface IDrawingToolsProvider {
4+
addListener?(
5+
eventName: string,
6+
cb: OSFramework.Maps.Callbacks.Generic
7+
): void;
8+
get?(name: string): unknown;
9+
getPosition?(): unknown;
10+
setDrawingOptions?(options: unknown): void;
11+
setOptions?(options: unknown): void;
12+
}
13+
}

src/OSFramework/Maps/DrawingTools/ITool.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ namespace OSFramework.Maps.DrawingTools {
88
drawingTools: IDrawingTools;
99
isReady: boolean;
1010
map: OSMap.IMap; //IMap
11-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
12-
options: any;
11+
options: unknown;
1312
type: string;
1413
uniqueId: string;
1514
widgetId: string;
@@ -19,9 +18,7 @@ namespace OSFramework.Maps.DrawingTools {
1918
* The new handlers will create the shape/markers elements and remove the overlay created by the drawing tool on the map
2019
* @param e is only used by the leaflet implementation, is used to access the configs info on the creation of a new shape/marker
2120
*/
22-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
23-
addCompletedEvent(e?: any): void;
24-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
25-
changeProperty(propertyName: string, propertyValue: any): void;
21+
addCompletedEvent(e?: unknown): void;
22+
changeProperty(propertyName: string, propertyValue: unknown): void;
2623
}
2724
}

src/OSFramework/Maps/Event/AbstractEvent.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
// eslint-disable-next-line @typescript-eslint/no-unused-vars
22
namespace OSFramework.Maps.Event {
3-
type Handler = {
4-
eventHandler: Callbacks.Generic;
5-
uniqueId: string; //Event unique identifier
6-
};
7-
83
/**
94
* Abstract class that will be responsible for the basic behaviours of a link, namely storing the callbacks.
105
*
@@ -16,9 +11,9 @@ namespace OSFramework.Maps.Event {
1611
*/
1712
// eslint-disable-next-line @typescript-eslint/no-unused-vars
1813
export abstract class AbstractEvent<T> implements IEvent<T> {
19-
private _handlers: Handler[] = [];
14+
private _handlers: IHandler[] = [];
2015

21-
protected get handlers(): Handler[] {
16+
protected get handlers(): IHandler[] {
2217
return this._handlers;
2318
}
2419

@@ -46,12 +41,16 @@ namespace OSFramework.Maps.Event {
4641
}
4742
}
4843

49-
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/explicit-module-boundary-types
50-
public trigger(data?: T, ...args): void {
44+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
45+
public trigger(data?: T, ...args: unknown[]): void {
5146
this._handlers
5247
.slice(0)
5348
.forEach((h) =>
54-
Helper.CallbackAsyncInvocation(h.eventHandler, data)
49+
Helper.CallbackAsyncInvocation(
50+
h.eventHandler,
51+
data,
52+
...args
53+
)
5554
);
5655
}
5756
}

0 commit comments

Comments
 (0)