Skip to content

Commit 9f509e0

Browse files
committed
refactor typescript@5
1 parent 0f85549 commit 9f509e0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2392
-1365
lines changed

packages/react-google-maps-api-infobox/src/InfoBox.tsx

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* global google */
22
/* eslint-disable filenames/match-regex */
3-
import { InfoBoxOptions } from './types'
3+
import type { InfoBoxOptions } from './types'
44

55
// This handler prevents an event in the InfoBox from being passed on to the map.
66
function cancelHandler(event: Event) {
@@ -19,9 +19,7 @@ export class InfoBox {
1919
position: google.maps.LatLng
2020
zIndex: number | undefined | null
2121
boxClass: string
22-
boxStyle: {
23-
[key: string]: any
24-
}
22+
boxStyle: CSSStyleDeclaration
2523

2624
closeBoxMargin: string
2725
closeBoxURL: string
@@ -76,7 +74,7 @@ export class InfoBox {
7674

7775
// Additional options (unique to InfoBox):
7876
this.boxClass = options.boxClass || 'infoBox'
79-
this.boxStyle = options.boxStyle || {}
77+
this.boxStyle = options.boxStyle || {} as CSSStyleDeclaration
8078
this.closeBoxMargin = options.closeBoxMargin || '2px'
8179
this.closeBoxURL = options.closeBoxURL || 'http://www.google.com/intl/en_us/mapfiles/close.gif'
8280
if (options.closeBoxURL === '') {
@@ -174,9 +172,9 @@ export class InfoBox {
174172
'touchmove',
175173
]
176174

177-
for (let i = 0; i < events.length; i++) {
175+
for (const event of events) {
178176
this.eventListeners.push(
179-
google.maps.event.addListener(this.div, events[i], cancelHandler)
177+
google.maps.event.addListener(this.div, event, cancelHandler)
180178
)
181179
}
182180

@@ -336,7 +334,8 @@ export class InfoBox {
336334
this.div.style.cssText = ''
337335

338336
// Apply style values defined in the boxStyle parameter:
339-
const boxStyle = this.boxStyle
337+
const boxStyle: CSSStyleDeclaration = this.boxStyle
338+
340339
for (const i in boxStyle) {
341340

342341
if (Object.prototype.hasOwnProperty.call(boxStyle, i)) {
@@ -670,8 +669,8 @@ export class InfoBox {
670669
}
671670

672671
if (this.eventListeners) {
673-
for (let i = 0; i < this.eventListeners.length; i++) {
674-
google.maps.event.removeListener(this.eventListeners[i])
672+
for (const eventListener of this.eventListeners) {
673+
google.maps.event.removeListener(eventListener)
675674
}
676675

677676
this.eventListeners = null
@@ -704,6 +703,7 @@ export class InfoBox {
704703
return function applyExtend(this: A, object: typeof google.maps.OverlayView): A {
705704
for (const property in object.prototype) {
706705
if (!Object.prototype.hasOwnProperty.call(this, property)) {
706+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
707707
// @ts-ignore
708708
this.prototype[property] = object.prototype[property as keyof google.maps.OverlayView]
709709
}

packages/react-google-maps-api-infobox/src/types.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
export interface InfoBoxOptions {
22
alignBottom?: boolean | undefined
33
boxClass?: string | undefined
4-
boxStyle?: {
5-
[key: string]: any
6-
} | undefined
4+
boxStyle?: CSSStyleDeclaration | undefined
75
closeBoxMargin?: string | undefined
86
closeBoxURL?: string | undefined
97
content?: string | Node | undefined
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,17 @@
11
{
2+
"extends": "../../tsconfig.json",
23
"rootDir": ".",
34
"include": ["src/**/*"],
45
"exclude": ["node_modules"],
6+
"types": ["googlemaps"],
57
"compilerOptions": {
68
"module": "esnext",
79
"moduleResolution": "node",
810
"target": "es5",
911
"jsx": "react",
1012
"lib": ["dom", "es2017"],
11-
"declaration": true,
12-
"declarationDir": "dist",
1313
"rootDir": "src",
14-
"strict": true,
15-
"allowJs": false,
16-
"checkJs": false,
17-
"noUnusedLocals": true,
18-
"noUnusedParameters": true,
19-
"noImplicitReturns": true,
20-
"noErrorTruncation": true,
21-
"noFallthroughCasesInSwitch": true,
22-
"noImplicitThis": true,
23-
"forceConsistentCasingInFileNames": true,
24-
"allowSyntheticDefaultImports": true
14+
"declaration": true,
15+
"declarationDir": "dist"
2516
}
2617
}

0 commit comments

Comments
 (0)