From 4ab0e3b8855556c6bf57e680c60f056d718f9d31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fausto=20N=C3=BA=C3=B1ez=20Alberro?= Date: Wed, 17 Jul 2019 13:56:06 +0200 Subject: [PATCH 1/4] Add tsconfig.json with "strict" and a "typecheck" npm script Running `npm run typecheck` will run the TypeScript compiler without emitting files to check for type errors in index.d.ts --- package-lock.json | 116 +++++++++++++++++++++++++++++----------------- package.json | 4 +- tsconfig.json | 8 ++++ 3 files changed, 84 insertions(+), 44 deletions(-) create mode 100644 tsconfig.json diff --git a/package-lock.json b/package-lock.json index c22dba68..bf90fba2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "google-maps-react", - "version": "2.0.2", + "version": "2.0.3", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -10,21 +10,11 @@ "integrity": "sha512-N/vLiUTQPnkUZFUKK2NpCGg0IGV5jyFKf5YBMcfp+6HDsXWd0BoNG5BJgtggdqhNySM6q7z8u3UPlkfZ8+9dIA==", "dev": true }, - "@types/prop-types": { - "version": "15.5.6", - "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.5.6.tgz", - "integrity": "sha512-ZBFR7TROLVzCkswA3Fmqq+IIJt62/T7aY/Dmz+QkU7CaW2QFqAitCE8Ups7IzmGhcN1YWMBT4Qcoc07jU9hOJQ==", - "dev": true - }, "@types/react": { - "version": "16.4.18", - "resolved": "https://registry.npmjs.org/@types/react/-/react-16.4.18.tgz", - "integrity": "sha512-eFzJKEg6pdeaukVLVZ8Xb79CTl/ysX+ExmOfAAqcFlCCK5TgFDD9kWR0S18sglQ3EmM8U+80enjUqbfnUyqpdA==", - "dev": true, - "requires": { - "@types/prop-types": "*", - "csstype": "^2.2.0" - } + "version": "15.6.26", + "resolved": "https://registry.npmjs.org/@types/react/-/react-15.6.26.tgz", + "integrity": "sha512-wNoXCIzRp2dBHch6fekXU6PRbjHs/VjK1yXNFfPRiBM54Vt3yQt9F5Yb4e34AU1c+mdyxLh6e1AVdvfplI1RMQ==", + "dev": true }, "abab": { "version": "1.0.3", @@ -2212,12 +2202,6 @@ "cssom": "0.3.x" } }, - "csstype": { - "version": "2.5.7", - "resolved": "https://registry.npmjs.org/csstype/-/csstype-2.5.7.tgz", - "integrity": "sha512-Nt5VDyOTIIV4/nRFswoCKps1R5CD1hkiyjBE9/thNaNZILLEviVw9yWQw15+O+CpNjQKB/uvdcxFFOrSflY3Yw==", - "dev": true - }, "d": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/d/-/d-1.0.0.tgz", @@ -3236,7 +3220,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.1.1", @@ -3287,7 +3272,8 @@ "balanced-match": { "version": "0.4.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "bcrypt-pbkdf": { "version": "1.0.1", @@ -3302,6 +3288,7 @@ "version": "0.0.9", "bundled": true, "dev": true, + "optional": true, "requires": { "inherits": "~2.0.0" } @@ -3310,6 +3297,7 @@ "version": "2.10.1", "bundled": true, "dev": true, + "optional": true, "requires": { "hoek": "2.x.x" } @@ -3318,6 +3306,7 @@ "version": "1.1.7", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^0.4.1", "concat-map": "0.0.1" @@ -3326,7 +3315,8 @@ "buffer-shims": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "caseless": { "version": "0.12.0", @@ -3343,12 +3333,14 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "combined-stream": { "version": "1.0.5", "bundled": true, "dev": true, + "optional": true, "requires": { "delayed-stream": "~1.0.0" } @@ -3356,17 +3348,20 @@ "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "cryptiles": { "version": "2.0.5", @@ -3412,7 +3407,8 @@ "delayed-stream": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "delegates": { "version": "1.0.0", @@ -3438,7 +3434,8 @@ "extsprintf": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "forever-agent": { "version": "0.6.1", @@ -3460,12 +3457,14 @@ "fs.realpath": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "fstream": { "version": "1.0.11", "bundled": true, "dev": true, + "optional": true, "requires": { "graceful-fs": "^4.1.2", "inherits": "~2.0.0", @@ -3521,6 +3520,7 @@ "version": "7.1.2", "bundled": true, "dev": true, + "optional": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -3533,7 +3533,8 @@ "graceful-fs": { "version": "4.1.11", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "har-schema": { "version": "1.0.5", @@ -3572,7 +3573,8 @@ "hoek": { "version": "2.16.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "http-signature": { "version": "1.1.1", @@ -3589,6 +3591,7 @@ "version": "1.0.6", "bundled": true, "dev": true, + "optional": true, "requires": { "once": "^1.3.0", "wrappy": "1" @@ -3597,7 +3600,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.4", @@ -3609,6 +3613,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -3622,7 +3627,8 @@ "isarray": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "isstream": { "version": "0.1.2", @@ -3695,12 +3701,14 @@ "mime-db": { "version": "1.27.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "mime-types": { "version": "2.1.15", "bundled": true, "dev": true, + "optional": true, "requires": { "mime-db": "~1.27.0" } @@ -3709,6 +3717,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -3716,12 +3725,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "mkdirp": { "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -3774,7 +3785,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "oauth-sign": { "version": "0.8.2", @@ -3792,6 +3804,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -3821,7 +3834,8 @@ "path-is-absolute": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "performance-now": { "version": "0.2.0", @@ -3832,7 +3846,8 @@ "process-nextick-args": { "version": "1.0.7", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "punycode": { "version": "1.4.1", @@ -3870,6 +3885,7 @@ "version": "2.2.9", "bundled": true, "dev": true, + "optional": true, "requires": { "buffer-shims": "~1.0.0", "core-util-is": "~1.0.0", @@ -3914,6 +3930,7 @@ "version": "2.6.1", "bundled": true, "dev": true, + "optional": true, "requires": { "glob": "^7.0.5" } @@ -3921,7 +3938,8 @@ "safe-buffer": { "version": "5.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "semver": { "version": "5.3.0", @@ -3979,6 +3997,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -3989,6 +4008,7 @@ "version": "1.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.0.1" } @@ -4003,6 +4023,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -4017,6 +4038,7 @@ "version": "2.2.1", "bundled": true, "dev": true, + "optional": true, "requires": { "block-stream": "*", "fstream": "^1.0.2", @@ -4072,7 +4094,8 @@ "util-deprecate": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "uuid": { "version": "3.0.1", @@ -4101,7 +4124,8 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, @@ -8201,6 +8225,12 @@ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", "dev": true }, + "typescript": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.3.tgz", + "integrity": "sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g==", + "dev": true + }, "ua-parser-js": { "version": "0.7.14", "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.14.tgz", diff --git a/package.json b/package.json index d29f72af..549850b4 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,8 @@ "lintfix": "eslint ./src --fix", "testonly": "NODE_ENV=test mocha $npm_package_options_mocha", "test": "npm run lint && npm run testonly", - "test-watch": "npm run testonly -- --watch --watch-extensions js" + "test-watch": "npm run testonly -- --watch --watch-extensions js", + "typecheck": "tsc --noEmit" }, "devDependencies": { "@types/googlemaps": "^3", @@ -74,6 +75,7 @@ "react-router-dom": "^4.2.2", "sinon": "^1.17.3", "style-loader": "^0.13.1", + "typescript": "^3.5.3", "url-loader": "^0.5.7", "webpack": "^1.13.0" }, diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..628b334b --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "module": "commonjs", + "strict": true, + "noEmit": true + }, + "files": ["index.d.ts"] +} From 809da52e139ce412315a5b37b244fbb54f715fd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fausto=20N=C3=BA=C3=B1ez=20Alberro?= Date: Wed, 17 Jul 2019 13:58:29 +0200 Subject: [PATCH 2/4] Make types pass with strict tsconfig --- index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index 9499bf60..2efdc08f 100644 --- a/index.d.ts +++ b/index.d.ts @@ -24,9 +24,9 @@ export interface IProvidedProps { loaded?: boolean } -type mapEventHandler = (mapProps?: IMapProps, map?: google.maps.Map, event?) => any +type mapEventHandler = (mapProps?: IMapProps, map?: google.maps.Map, event?: google.maps.MouseEvent) => void -type Style = Object +type Style = Record export interface IMapProps extends google.maps.MapOptions { google: GoogleAPI @@ -64,7 +64,7 @@ export interface IMapProps extends google.maps.MapOptions { onZoomChanged?: mapEventHandler } -type markerEventHandler = (props?: IMarkerProps, marker?: google.maps.Marker, event?) => any +type markerEventHandler = (props?: IMarkerProps, marker?: google.maps.Marker, event?: google.maps.MouseEvent) => any export interface IMarkerProps extends Partial { mapCenter?: google.maps.LatLng | google.maps.LatLngLiteral From b712aa23128b5a8c594b49e2d691f77602bdbab2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fausto=20N=C3=BA=C3=B1ez=20Alberro?= Date: Wed, 17 Jul 2019 13:59:41 +0200 Subject: [PATCH 3/4] Add the "zoom" field to IMapProps --- index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/index.d.ts b/index.d.ts index 2efdc08f..36dcc36d 100644 --- a/index.d.ts +++ b/index.d.ts @@ -39,6 +39,7 @@ export interface IMapProps extends google.maps.MapOptions { centerAroundCurrentLocation?: boolean initialCenter?: google.maps.LatLngLiteral center?: google.maps.LatLngLiteral + zoom?: number visible?: boolean From be73e415ed01c03bd221297e0acb44daf9ea42af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fausto=20N=C3=BA=C3=B1ez=20Alberro?= Date: Thu, 8 Aug 2019 15:54:08 +0200 Subject: [PATCH 4/4] Remove duplicate draggableCursor key that breaks IE11 Due to strict mode on ES5 having a syntax error for it --- dist/index.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index ec3b293a..4b1005fe 100644 --- a/dist/index.js +++ b/dist/index.js @@ -267,7 +267,6 @@ noClear: this.props.noClear, styles: this.props.styles, gestureHandling: this.props.gestureHandling, - draggableCursor: this.props.draggableCursor, draggingCursor: this.props.draggingCursor }); @@ -408,7 +407,6 @@ fullscreenControl: _propTypes2.default.bool, scrollwheel: _propTypes2.default.bool, draggable: _propTypes2.default.bool, - draggableCursor: _propTypes2.default.string, keyboardShortcuts: _propTypes2.default.bool, disableDoubleClickZoom: _propTypes2.default.bool, noClear: _propTypes2.default.bool,