Skip to content

Commit 3872a68

Browse files
mcreinhardcopybara-github
authored andcommitted
refactor: update Maps JS API typings to 3.65.0
PiperOrigin-RevId: 924919782
1 parent 9d1fe0b commit 3872a68

22 files changed

Lines changed: 549 additions & 465 deletions

examples/angular_sample_app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"@angular/cli": "^16.1.6",
3030
"@angular/compiler-cli": "^16.1.7",
3131
"@ngx-env/builder": "^16.1.2",
32-
"@types/google.maps": "~3.55.8",
32+
"@types/google.maps": "~3.65.0",
3333
"typescript": "~5.0.2"
3434
}
3535
}

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 83 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
"@rollup/plugin-node-resolve": "^15.2.1",
7777
"@rollup/plugin-replace": "^5.0.2",
7878
"@rollup/plugin-terser": "^0.4.3",
79-
"@types/google.maps": "~3.55.8",
79+
"@types/google.maps": "~3.65.0",
8080
"@types/jasmine": "^4.3.6",
8181
"@types/react": "^18.2.24",
8282
"@web/test-runner": "^0.17.1",
@@ -100,42 +100,86 @@
100100
"!**/*_test.ts",
101101
"!src/testing/*.ts"
102102
],
103-
"output": ["custom-elements.json"]
103+
"output": [
104+
"custom-elements.json"
105+
]
104106
},
105107
"docs": {
106108
"command": "node build/make_docs.js",
107-
"dependencies": ["cem"],
108-
"files": ["**/doc_src/*", "build/make_docs.js", "custom-elements.json"],
109-
"output": ["README.md", "src/**/README.md", "!src/react/README.md"]
109+
"dependencies": [
110+
"cem"
111+
],
112+
"files": [
113+
"**/doc_src/*",
114+
"build/make_docs.js",
115+
"custom-elements.json"
116+
],
117+
"output": [
118+
"README.md",
119+
"src/**/README.md",
120+
"!src/react/README.md"
121+
]
110122
},
111123
"build": {
112-
"dependencies": ["build:ts"]
124+
"dependencies": [
125+
"build:ts"
126+
]
113127
},
114128
"build:react": {
115129
"command": "node build/make_react.js",
116-
"dependencies": ["cem"],
117-
"files": ["build/make_react.js", "custom-elements.json"],
118-
"output": ["src/react/index.ts"]
130+
"dependencies": [
131+
"cem"
132+
],
133+
"files": [
134+
"build/make_react.js",
135+
"custom-elements.json"
136+
],
137+
"output": [
138+
"src/react/index.ts"
139+
]
119140
},
120141
"build:ts": {
121142
"command": "tsc",
122-
"dependencies": ["build:react"],
123-
"files": ["tsconfig.json", "src/**/*.ts"],
124-
"output": [".tsbuildinfo", "lib/**/*"],
143+
"dependencies": [
144+
"build:react"
145+
],
146+
"files": [
147+
"tsconfig.json",
148+
"src/**/*.ts"
149+
],
150+
"output": [
151+
".tsbuildinfo",
152+
"lib/**/*"
153+
],
125154
"clean": "if-file-deleted"
126155
},
127156
"build:package": {
128157
"command": ". build/finalize_package.sh",
129-
"dependencies": ["build:ts"],
130-
"files": ["build/finalize_package.sh", "lib/base/constants.js"],
131-
"output": ["lib/**/*.js", "lib/**/*.md"],
158+
"dependencies": [
159+
"build:ts"
160+
],
161+
"files": [
162+
"build/finalize_package.sh",
163+
"lib/base/constants.js"
164+
],
165+
"output": [
166+
"lib/**/*.js",
167+
"lib/**/*.md"
168+
],
132169
"clean": false
133170
},
134171
"build:bundle": {
135172
"command": "rollup -c build/rollup.config.js",
136-
"dependencies": ["build:package"],
137-
"files": ["build/rollup.config.js", "lib/**/*.js"],
138-
"output": ["dist/index.min.js"]
173+
"dependencies": [
174+
"build:package"
175+
],
176+
"files": [
177+
"build/rollup.config.js",
178+
"lib/**/*.js"
179+
],
180+
"output": [
181+
"dist/index.min.js"
182+
]
139183
},
140184
"example:prepare": {
141185
"command": "chmod +x build/start_example.sh"
@@ -145,7 +189,10 @@
145189
"env": {
146190
"PORT": "8001"
147191
},
148-
"dependencies": ["build:package", "example:prepare"],
192+
"dependencies": [
193+
"build:package",
194+
"example:prepare"
195+
],
149196
"service": {
150197
"readyWhen": {
151198
"lineMatches": "You can now view \\S+ in the browser"
@@ -157,7 +204,10 @@
157204
"env": {
158205
"PORT": "8002"
159206
},
160-
"dependencies": ["build:bundle", "example:prepare"],
207+
"dependencies": [
208+
"build:bundle",
209+
"example:prepare"
210+
],
161211
"service": {
162212
"readyWhen": {
163213
"lineMatches": "Web Dev Server started"
@@ -169,7 +219,10 @@
169219
"env": {
170220
"PORT": "8003"
171221
},
172-
"dependencies": ["build:package", "example:prepare"],
222+
"dependencies": [
223+
"build:package",
224+
"example:prepare"
225+
],
173226
"service": {
174227
"readyWhen": {
175228
"lineMatches": "Angular Live Development Server is listening on localhost"
@@ -183,13 +236,19 @@
183236
"example:js_sample_app",
184237
"example:angular_sample_app"
185238
],
186-
"files": ["e2e/**/*.js"],
239+
"files": [
240+
"e2e/**/*.js"
241+
],
187242
"output": []
188243
},
189244
"test": {
190245
"command": "wtr",
191-
"dependencies": ["build:ts"],
192-
"files": ["web-test-runner.config.js"],
246+
"dependencies": [
247+
"build:ts"
248+
],
249+
"files": [
250+
"web-test-runner.config.js"
251+
],
193252
"output": []
194253
}
195254
}

src/address_validation/suggest_validation_action.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
import {Address, AddressValidation, Granularity} from '../utils/googlemaps_types.js';
7+
import {Address, AddressValidation} from '../utils/googlemaps_types.js';
88

99

1010
/** Suggested action to take for this validation result. */
@@ -46,7 +46,7 @@ function isMissingNonSubpremiseComponent(result: AddressValidation): boolean {
4646
*/
4747
function hasValidationGranularityOther(result: AddressValidation): boolean {
4848
return !result.verdict?.validationGranularity ||
49-
result.verdict.validationGranularity === Granularity.OTHER;
49+
result.verdict.validationGranularity === 'OTHER';
5050
}
5151

5252
function hasSuspiciousComponent(result: AddressValidation): boolean {
@@ -70,7 +70,9 @@ function hasMajorInference(result: AddressValidation): boolean {
7070
]);
7171
return !!result.address &&
7272
result.address.components.some(
73-
c => c.isInferred && !minorComponents.has(c.componentType))
73+
// TODO: Align with 3.65 typings
74+
// @ts-ignore
75+
c => c.isInferred && !minorComponents.has(c.componentType!))
7476
}
7577

7678
function hasReplacement(result: AddressValidation): boolean {
@@ -158,4 +160,4 @@ export function suggestValidationAction(response: AddressValidation):
158160
return {suggestedAction: SuggestedAction.ADD_SUBPREMISES};
159161
}
160162
return {suggestedAction: SuggestedAction.ACCEPT};
161-
}
163+
}

src/address_validation/suggest_validation_action_test.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,19 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7+
// TODO: Align with 3.65 typings
8+
// @ts-nocheck
9+
710
// import 'jasmine'; (google3-only)
811

9-
import {Address, AddressComponent, AddressValidation, ConfirmationLevel, Granularity, Verdict} from '../utils/googlemaps_types.js';
12+
import {Address, AddressComponent, AddressValidation, Verdict} from '../utils/googlemaps_types.js';
1013

1114
import {SuggestedAction, suggestValidationAction} from './suggest_validation_action.js';
1215

1316
const GOOD_VERDICT: Verdict = {
14-
inputGranularity: Granularity.PREMISE,
15-
validationGranularity: Granularity.PREMISE,
16-
geocodeGranularity: Granularity.PREMISE,
17+
inputGranularity: 'PREMISE',
18+
validationGranularity: 'PREMISE',
19+
geocodeGranularity: 'PREMISE',
1720
isAddressComplete: true,
1821
hasUnconfirmedComponents: false,
1922
hasInferredComponents: false,
@@ -67,7 +70,7 @@ describe('SuggestValidationAction', () => {
6770

6871
it('returns FIX when the validation granularity is OTHER', () => {
6972
const suggestion = suggestValidationAction(makeFakeValidationResponse(
70-
{}, {...GOOD_VERDICT, validationGranularity: Granularity.OTHER}));
73+
{}, {...GOOD_VERDICT, validationGranularity: 'OTHER'}));
7174
expect(suggestion.suggestedAction).toBe(SuggestedAction.FIX);
7275
});
7376

@@ -76,7 +79,7 @@ describe('SuggestValidationAction', () => {
7679
{
7780
components: [{
7881
...LOCALITY_COMPONENT,
79-
confirmationLevel: ConfirmationLevel.UNCONFIRMED_AND_SUSPICIOUS
82+
confirmationLevel: 'UNCONFIRMED_AND_SUSPICIOUS'
8083
}]
8184
},
8285
GOOD_VERDICT));

src/place_building_blocks/place_attribution/place_attribution_test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {html, TemplateResult} from 'lit';
1010

1111
import {Environment} from '../../testing/environment.js';
1212
import {makeFakePlace} from '../../testing/fake_place.js';
13+
import {mapsJsData} from '../../utils/googlemaps_types.js';
1314

1415
import {PlaceAttribution} from './place_attribution.js';
1516

@@ -64,8 +65,8 @@ describe('place attribution test', () => {
6465
const place = makeFakePlace({
6566
id: '1234567890',
6667
attributions: [
67-
{provider: 'Foo', providerURI: 'https://foo.com'},
68-
{provider: 'Bar', providerURI: null}
68+
mapsJsData({provider: 'Foo', providerURI: 'https://foo.com'}),
69+
mapsJsData({provider: 'Bar', providerURI: null})
6970
]
7071
});
7172

src/place_building_blocks/place_data_provider/place_data_provider_test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,15 @@ describe('PlaceDataProvider', () => {
6363
fetchFieldsSpy.and.callFake(
6464
async ({fields}: google.maps.places.FetchFieldsRequest) => {
6565
if (fields.includes('displayName')) {
66-
place.displayName = 'Fake Place';
66+
// Properties of Place are getter-only in the typings
67+
Object.defineProperty(place, 'displayName', {
68+
get: () => 'Fake Place',
69+
});
6770
}
6871
if (fields.includes('rating')) {
69-
place.rating = 5;
72+
Object.defineProperty(place, 'rating', {
73+
get: () => 5,
74+
});
7075
}
7176
return {place};
7277
});

0 commit comments

Comments
 (0)