Skip to content

Commit 4804b85

Browse files
mcreinhardcopybara-github
authored andcommitted
fix: use latest Maps JS API typings
PiperOrigin-RevId: 924919782
1 parent 9d1fe0b commit 4804b85

17 files changed

Lines changed: 534 additions & 313 deletions

File tree

package-lock.json

Lines changed: 6 additions & 5 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/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/place_utils.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: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,14 @@ describe('PlaceDataProvider', () => {
6363
fetchFieldsSpy.and.callFake(
6464
async ({fields}: google.maps.places.FetchFieldsRequest) => {
6565
if (fields.includes('displayName')) {
66-
place.displayName = 'Fake Place';
66+
Object.defineProperty(place, 'displayName', {
67+
get: () => 'Fake Place',
68+
});
6769
}
6870
if (fields.includes('rating')) {
69-
place.rating = 5;
71+
Object.defineProperty(place, 'rating', {
72+
get: () => 5,
73+
});
7074
}
7175
return {place};
7276
});
@@ -78,6 +82,9 @@ describe('PlaceDataProvider', () => {
7882
Promise<{provider: PlaceDataProvider, fetchFieldsSpy: jasmine.Spy}> {
7983
const fetchFieldsSpy = jasmine.createSpy('fetchFields');
8084
env.fakeGoogleMapsHarness!.placeConstructor = (options) => {
85+
if (!options.id) {
86+
throw new Error('Place constructor requires an id.');
87+
}
8188
const place = makeFakePlace({
8289
id: options.id,
8390
fetchFields,

src/place_building_blocks/place_field_boolean/place_field_boolean_test.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {Environment} from '../../testing/environment.js';
1313
import {makeFakePlace} from '../../testing/fake_place.js';
1414
import {LifecycleSpyController} from '../../testing/lifecycle_spy.js';
1515
import type {PlaceResult} from '../../utils/googlemaps_types.js';
16+
import {mapsJsData} from '../../utils/place_utils.js';
1617

1718
import {BooleanField, PLACE_BOOLEAN_FIELDS, PlaceFieldBoolean} from './place_field_boolean.js';
1819

@@ -68,7 +69,7 @@ describe('place field boolean test', () => {
6869
servesWine: true,
6970

7071
businessStatus: 'OPERATIONAL' as google.maps.places.BusinessStatus,
71-
regularOpeningHours: {periods: [], weekdayDescriptions: []},
72+
regularOpeningHours: mapsJsData({periods: [], weekdayDescriptions: [], specialDays: []}),
7273
utcOffsetMinutes: 0,
7374
isOpen: async () => true,
7475
});
@@ -104,7 +105,7 @@ describe('place field boolean test', () => {
104105
servesWine: false,
105106

106107
businessStatus: 'OPERATIONAL' as google.maps.places.BusinessStatus,
107-
regularOpeningHours: {periods: [], weekdayDescriptions: []},
108+
regularOpeningHours: mapsJsData({periods: [], weekdayDescriptions: [], specialDays: []}),
108109
utcOffsetMinutes: 0,
109110
isOpen: async () => false,
110111
});
@@ -247,7 +248,7 @@ describe('place field boolean test', () => {
247248
const openPlace = makeFakePlace({
248249
id: '1234567890',
249250
businessStatus: 'OPERATIONAL' as google.maps.places.BusinessStatus,
250-
regularOpeningHours: {periods: [], weekdayDescriptions: []},
251+
regularOpeningHours: mapsJsData({periods: [], weekdayDescriptions: [], specialDays: []}),
251252
utcOffsetMinutes: 0,
252253
isOpen: async () => true,
253254
});
@@ -277,7 +278,7 @@ describe('place field boolean test', () => {
277278
const isOpenSpy = jasmine.createSpy('isOpen');
278279
const noBusinessStatusPlace = makeFakePlace({
279280
id: '1234567890',
280-
regularOpeningHours: {periods: [], weekdayDescriptions: []},
281+
regularOpeningHours: mapsJsData({periods: [], weekdayDescriptions: [], specialDays: []}),
281282
isOpen: isOpenSpy,
282283
});
283284
const noOpeningHoursPlace = makeFakePlace({
@@ -289,7 +290,7 @@ describe('place field boolean test', () => {
289290
const noUtcOffsetPlace = makeFakePlace({
290291
id: '1234567890',
291292
businessStatus: 'OPERATIONAL' as google.maps.places.BusinessStatus,
292-
regularOpeningHours: {periods: [], weekdayDescriptions: []},
293+
regularOpeningHours: mapsJsData({periods: [], weekdayDescriptions: [], specialDays: []}),
293294
isOpen: isOpenSpy,
294295
});
295296

@@ -311,7 +312,7 @@ describe('place field boolean test', () => {
311312
const place = makeFakePlace({
312313
id: '1234567890',
313314
businessStatus: 'OPERATIONAL' as google.maps.places.BusinessStatus,
314-
regularOpeningHours: {periods: [], weekdayDescriptions: []},
315+
regularOpeningHours: mapsJsData({periods: [], weekdayDescriptions: [], specialDays: []}),
315316
utcOffsetMinutes: 0,
316317
isOpen: isOpenSpy,
317318
});
@@ -350,7 +351,7 @@ describe('place field boolean test', () => {
350351
const place = makeFakePlace({
351352
id: '1234567890',
352353
businessStatus: 'OPERATIONAL' as google.maps.places.BusinessStatus,
353-
regularOpeningHours: {periods: [], weekdayDescriptions: []},
354+
regularOpeningHours: mapsJsData({periods: [], weekdayDescriptions: [], specialDays: []}),
354355
utcOffsetMinutes: 0,
355356
});
356357
const [el] = await prepareState(html`

src/place_building_blocks/place_field_text/place_field_text.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,15 +286,16 @@ export class PlaceFieldText extends PlaceDataConsumer {
286286
}
287287
}
288288

289-
private renderBusinessStatus(status: google.maps.places.BusinessStatus|null|
290-
undefined): string|null|undefined {
289+
private renderBusinessStatus(
290+
status: google.maps.places.BusinessStatusString|null|undefined): string
291+
|null|undefined {
291292
if (!status) return status;
292293
switch (status) {
293-
case 'CLOSED_PERMANENTLY' as google.maps.places.BusinessStatus:
294+
case 'CLOSED_PERMANENTLY':
294295
return this.getMsg('PLACE_CLOSED_PERMANENTLY');
295-
case 'CLOSED_TEMPORARILY' as google.maps.places.BusinessStatus:
296+
case 'CLOSED_TEMPORARILY':
296297
return this.getMsg('PLACE_CLOSED_TEMPORARILY');
297-
case 'OPERATIONAL' as google.maps.places.BusinessStatus:
298+
case 'OPERATIONAL':
298299
return this.getMsg('PLACE_OPERATIONAL');
299300
default:
300301
return undefined;

src/place_building_blocks/place_field_text/place_field_text_test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {Environment} from '../../testing/environment.js';
1313
import {FakeLatLng} from '../../testing/fake_lat_lng.js';
1414
import {makeFakePlace} from '../../testing/fake_place.js';
1515
import type {PlaceResult} from '../../utils/googlemaps_types.js';
16+
import {mapsJsData} from '../../utils/place_utils.js';
1617

1718
import {PLACE_RESULT_TEXT_FIELDS, PLACE_TEXT_FIELDS, PlaceFieldText, TextField} from './place_field_text.js';
1819

@@ -33,10 +34,10 @@ const fakePlace = makeFakePlace({
3334
internationalPhoneNumber: '+1 234-567-8910',
3435
location: new FakeLatLng(1, 2),
3536
nationalPhoneNumber: '(234) 567-8910',
36-
plusCode: {
37+
plusCode: mapsJsData({
3738
compoundCode: '1234+AB Some Place',
3839
globalCode: 'ABCD1234+AB',
39-
},
40+
}),
4041
rating: 4.5,
4142
types: ['restaurant'],
4243
userRatingCount: 123,

0 commit comments

Comments
 (0)