-
Notifications
You must be signed in to change notification settings - Fork 917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement demo of using JSDoc to support type checking js #2502
base: multiple_maps
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,8 @@ | |
} | ||
], | ||
"scripts": { | ||
"test": "jest && npm run eslint", | ||
"check-types": "tsc", | ||
"test": "npm run check-types && npm run jest && npm run eslint", | ||
"jest": "jest", | ||
"test:watch": "jest --watch", | ||
"eslint": "node node_modules/eslint/bin/eslint www src" | ||
|
@@ -55,8 +56,10 @@ | |
}, | ||
"homepage": "https://github.com/mapsplugin/cordova-plugin-googlemaps", | ||
"devDependencies": { | ||
"@types/googlemaps": "^3.30.16", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will make sure we are passing the appropriate params to google maps api. |
||
"cordova-js": "^4.2.4", | ||
"eslint": "^5.7.0", | ||
"jest": "^23.6.0" | ||
"jest": "^23.6.0", | ||
"typescript": "^3.1.6" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
|
||
|
||
// @ts-ignore | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is needed because of cordova custom module resolution |
||
var BaseArrayClass = require('cordova-plugin-googlemaps.BaseArrayClass'); | ||
|
||
var geocoder = null; | ||
|
@@ -146,6 +147,12 @@ QUEUE.on('next', function() { | |
}); | ||
|
||
module.exports = { | ||
/** | ||
* | ||
* @param {(result: GeocoderResult[]) => void} onSuccess | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This provides type checking by using JsDoc format. |
||
* @param {(err: string) => void} onError | ||
* @param {[GeocoderRequest]} args | ||
*/ | ||
'geocode': function(onSuccess, onError, args) { | ||
var request = args[0]; | ||
var geocoderRequest = {}; | ||
|
@@ -176,4 +183,5 @@ module.exports = { | |
}; | ||
|
||
|
||
// @ts-ignore | ||
require('cordova/exec/proxy').add('PluginGeocoder', module.exports); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"module": "commonjs", | ||
"allowJs": true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
"checkJs": true, | ||
"noEmit": true, | ||
"esModuleInterop": true | ||
}, | ||
"include": [ | ||
"src/browser/PluginGeocoder.js", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add sources as we go to incrementally type the project over time. |
||
"typings/**/*.d.ts" | ||
], | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
interface ILatLng { | ||
lat: number; | ||
lng: number; | ||
} | ||
|
||
interface ILatLngBounds { | ||
northeast: ILatLng; | ||
southwest: ILatLng; | ||
} | ||
|
||
interface GeocoderRequest { | ||
/** | ||
* The address property or position property is required. | ||
* You can not specify both property at the same time. | ||
* | ||
* [geocoding usage1] | ||
* let request: GeocoderRequest = { | ||
* address: "Los Angeles, California, USA" | ||
* } | ||
* | ||
* [geocoding usage2] | ||
* let request: GeocoderRequest = { | ||
* address: [ | ||
* "Los Angeles, California, USA", | ||
* "San Francisco, California, USA", | ||
* ] | ||
* } | ||
*/ | ||
address?: string | string[]; | ||
/** | ||
* | ||
* [reverse-geocoding usage1] | ||
* let request: GeocoderRequest = { | ||
* position: {"lat": 37.421655, "lng": -122.085637} | ||
* } | ||
* | ||
* [reverse-geocoding usage2] | ||
* let request: GeocoderRequest = { | ||
* position: [ | ||
* {"lat": 37.421655, "lng": -122.085637}, | ||
* {"lat": 37.332, "lng": -122.030781} | ||
* ] | ||
* } | ||
*/ | ||
position?: ILatLng | ILatLng[]; | ||
|
||
bounds?: ILatLng | ILatLng[]; | ||
} | ||
|
||
interface GeocoderResult { | ||
adminArea?: string; | ||
country?: string; | ||
countryCode?: string; | ||
extra?: { | ||
featureName?: string; | ||
lines?: string[]; | ||
permises?: string; | ||
phone?: string; | ||
url?: string; | ||
}; | ||
locale?: string; | ||
locality?: string; | ||
position?: ILatLng; | ||
postalCode?: string; | ||
subAdminArea?: string; | ||
subLocality?: string; | ||
subThoroughfare?: string; | ||
thoroughfare?: string; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add type checking as part of the test process.