Skip to content

Commit 13d2aa1

Browse files
committed
build: resolve type bundling issues
Updating `@angular/bazel` to `14.0.0-next.15` reveals some issues with type bundling. These changes aim to resolve the issues by moving some code around.
1 parent fb9ff16 commit 13d2aa1

File tree

9 files changed

+117
-17
lines changed

9 files changed

+117
-17
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"@angular-devkit/build-angular": "14.0.0-next.12",
7272
"@angular-devkit/core": "14.0.0-next.12",
7373
"@angular-devkit/schematics": "14.0.0-next.12",
74-
"@angular/bazel": "14.0.0-next.14",
74+
"@angular/bazel": "14.0.0-next.15",
7575
"@angular/cli": "14.0.0-next.12",
7676
"@angular/compiler-cli": "14.0.0-next.15",
7777
"@angular/dev-infra-private": "https://github.com/angular/dev-infra-private-builds.git#335aad1b04b3d95cd4cb1d719e73b93d4e90cce3",

src/components-examples/material/chips/chips-harness/chips-harness-example.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ import {Component} from '@angular/core';
99
})
1010
export class ChipsHarnessExample {
1111
isDisabled = false;
12-
remove = jasmine.createSpy('remove spy');
13-
add = jasmine.createSpy('add spy');
12+
remove: () => void = jasmine.createSpy('remove spy');
13+
add: () => void = jasmine.createSpy('add spy');
1414
}

src/google-maps/map-marker-clusterer/map-marker-clusterer.spec.ts

+7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ import {
1212
createMarkerSpy,
1313
} from '../testing/fake-google-map-utils';
1414
import {MapMarkerClusterer} from './map-marker-clusterer';
15+
import {
16+
AriaLabelFn,
17+
Calculator,
18+
ClusterIconStyle,
19+
MarkerClusterer,
20+
MarkerClustererOptions,
21+
} from './marker-clusterer-types';
1522

1623
describe('MapMarkerClusterer', () => {
1724
let mapSpy: jasmine.SpyObj<google.maps.Map>;

src/google-maps/map-marker-clusterer/map-marker-clusterer.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
// Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1265
1010
/// <reference types="google.maps" />
11-
/// <reference path="marker-clusterer-types.ts" />
1211

1312
import {
1413
AfterContentInit,
@@ -31,6 +30,14 @@ import {takeUntil} from 'rxjs/operators';
3130
import {GoogleMap} from '../google-map/google-map';
3231
import {MapEventManager} from '../map-event-manager';
3332
import {MapMarker} from '../map-marker/map-marker';
33+
import {
34+
AriaLabelFn,
35+
Calculator,
36+
Cluster,
37+
ClusterIconStyle,
38+
MarkerClusterer,
39+
MarkerClustererOptions,
40+
} from './marker-clusterer-types';
3441

3542
/** Default options for a clusterer. */
3643
const DEFAULT_CLUSTERER_OPTIONS: MarkerClustererOptions = {};
@@ -199,7 +206,7 @@ export class MapMarkerClusterer implements OnInit, AfterContentInit, OnChanges,
199206
ngOnInit() {
200207
if (this._canInitialize) {
201208
const clustererWindow = window as unknown as typeof globalThis & {
202-
MarkerClusterer?: MarkerClusterer;
209+
MarkerClusterer?: typeof MarkerClusterer;
203210
};
204211

205212
if (!clustererWindow.MarkerClusterer && (typeof ngDevMode === 'undefined' || ngDevMode)) {
@@ -214,7 +221,7 @@ export class MapMarkerClusterer implements OnInit, AfterContentInit, OnChanges,
214221
// We'll bring it back in inside the `MapEventManager` only for the events that the
215222
// user has subscribed to.
216223
this._ngZone.runOutsideAngular(() => {
217-
this.markerClusterer = new MarkerClusterer(
224+
this.markerClusterer = new clustererWindow.MarkerClusterer!(
218225
this._googleMap.googleMap!,
219226
[],
220227
this._combineOptions(),

src/google-maps/map-marker-clusterer/marker-clusterer-types.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* See
1515
* googlemaps.github.io/v3-utility-library/classes/_google_markerclustererplus.markerclusterer.html
1616
*/
17-
declare class MarkerClusterer {
17+
export declare class MarkerClusterer {
1818
constructor(
1919
map: google.maps.Map,
2020
markers?: google.maps.Marker[],
@@ -93,7 +93,7 @@ declare class MarkerClusterer {
9393
*
9494
* See googlemaps.github.io/v3-utility-library/classes/_google_markerclustererplus.cluster.html
9595
*/
96-
declare class Cluster {
96+
export declare class Cluster {
9797
constructor(markerClusterer: MarkerClusterer);
9898
getCenter(): google.maps.LatLng;
9999
getMarkers(): google.maps.Marker[];
@@ -108,7 +108,7 @@ declare class Cluster {
108108
* googlemaps.github.io/v3-utility-library/classes/
109109
* _google_markerclustererplus.markerclustereroptions.html
110110
*/
111-
declare interface MarkerClustererOptions {
111+
export declare interface MarkerClustererOptions {
112112
ariaLabelFn?: AriaLabelFn;
113113
averageCenter?: boolean;
114114
batchSize?: number;
@@ -136,7 +136,7 @@ declare interface MarkerClustererOptions {
136136
* googlemaps.github.io/v3-utility-library/interfaces/
137137
* _google_markerclustererplus.clustericonstyle.html
138138
*/
139-
declare interface ClusterIconStyle {
139+
export declare interface ClusterIconStyle {
140140
anchorIcon?: [number, number];
141141
anchorText?: [number, number];
142142
backgroundPosition?: string;
@@ -160,7 +160,7 @@ declare interface ClusterIconStyle {
160160
* googlemaps.github.io/v3-utility-library/interfaces/
161161
* _google_markerclustererplus.clustericoninfo.html
162162
*/
163-
declare interface ClusterIconInfo {
163+
export declare interface ClusterIconInfo {
164164
index: number;
165165
text: string;
166166
title: string;
@@ -171,14 +171,14 @@ declare interface ClusterIconInfo {
171171
*
172172
* See googlemaps.github.io/v3-utility-library/modules/_google_markerclustererplus.html#arialabelfn
173173
*/
174-
declare type AriaLabelFn = (text: string) => string;
174+
export declare type AriaLabelFn = (text: string) => string;
175175

176176
/**
177177
* Function type alias for calculating how a marker cluster is displayed.
178178
*
179179
* See googlemaps.github.io/v3-utility-library/modules/_google_markerclustererplus.html#calculator
180180
*/
181-
declare type Calculator = (
181+
export declare type Calculator = (
182182
markers: google.maps.Marker[],
183183
clusterIconStylesCount: number,
184184
) => ClusterIconInfo;

src/google-maps/public-api.ts

+6
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,9 @@ export {MapTrafficLayer} from './map-traffic-layer/map-traffic-layer';
2929
export {MapTransitLayer} from './map-transit-layer/map-transit-layer';
3030
export {MapHeatmapLayer, HeatmapData} from './map-heatmap-layer/map-heatmap-layer';
3131
export {MapGeocoder, MapGeocoderResponse} from './map-geocoder/map-geocoder';
32+
export {
33+
MarkerClustererOptions,
34+
ClusterIconStyle,
35+
AriaLabelFn,
36+
Calculator,
37+
} from './map-marker-clusterer/marker-clusterer-types';

src/google-maps/testing/fake-google-map-utils.ts

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9+
import {MarkerClusterer} from '../map-marker-clusterer/marker-clusterer-types';
10+
911
// The global `window` variable is typed as an intersection of `Window` and `globalThis`.
1012
// We re-declare `window` here and omit `globalThis` as it is typed with the actual Google
1113
// Maps types which we intend to override with jasmine spies for testing. Keeping `globalThis`

tools/public_api_guard/google-maps/google-maps.md

+78
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,44 @@ import { OnInit } from '@angular/core';
1818
import { QueryList } from '@angular/core';
1919
import { SimpleChanges } from '@angular/core';
2020

21+
// @public
22+
export type AriaLabelFn = (text: string) => string;
23+
24+
// @public
25+
export type Calculator = (markers: google.maps.Marker[], clusterIconStylesCount: number) => ClusterIconInfo;
26+
27+
// @public
28+
export interface ClusterIconStyle {
29+
// (undocumented)
30+
anchorIcon?: [number, number];
31+
// (undocumented)
32+
anchorText?: [number, number];
33+
// (undocumented)
34+
backgroundPosition?: string;
35+
// (undocumented)
36+
className?: string;
37+
// (undocumented)
38+
fontFamily?: string;
39+
// (undocumented)
40+
fontStyle?: string;
41+
// (undocumented)
42+
fontWeight?: string;
43+
// (undocumented)
44+
height: number;
45+
// (undocumented)
46+
textColor?: string;
47+
// (undocumented)
48+
textDecoration?: string;
49+
// (undocumented)
50+
textLineHeight?: number;
51+
// (undocumented)
52+
textSize?: number;
53+
// (undocumented)
54+
url?: string;
55+
// (undocumented)
56+
width: number;
57+
}
58+
2159
// @public
2260
const DEFAULT_HEIGHT = "500px";
2361

@@ -657,6 +695,46 @@ export class MapTransitLayer extends MapBaseLayer {
657695
static ɵfac: i0.ɵɵFactoryDeclaration<MapTransitLayer, never>;
658696
}
659697

698+
// @public
699+
export interface MarkerClustererOptions {
700+
// (undocumented)
701+
ariaLabelFn?: AriaLabelFn;
702+
// (undocumented)
703+
averageCenter?: boolean;
704+
// (undocumented)
705+
batchSize?: number;
706+
// (undocumented)
707+
batchSizeIE?: number;
708+
// (undocumented)
709+
calculator?: Calculator;
710+
// (undocumented)
711+
clusterClass?: string;
712+
// (undocumented)
713+
enableRetinaIcons?: boolean;
714+
// (undocumented)
715+
gridSize?: number;
716+
// (undocumented)
717+
ignoreHidden?: boolean;
718+
// (undocumented)
719+
imageExtension?: string;
720+
// (undocumented)
721+
imagePath?: string;
722+
// (undocumented)
723+
imageSizes?: number[];
724+
// (undocumented)
725+
maxZoom?: number;
726+
// (undocumented)
727+
minimumClusterSize?: number;
728+
// (undocumented)
729+
styles?: ClusterIconStyle[];
730+
// (undocumented)
731+
title?: string;
732+
// (undocumented)
733+
zIndex?: number;
734+
// (undocumented)
735+
zoomOnClick?: boolean;
736+
}
737+
660738
// (No @packageDocumentation comment for this package)
661739

662740
```

yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,10 @@
124124
dependencies:
125125
tslib "^2.3.0"
126126

127-
"@angular/[email protected].14":
128-
version "14.0.0-next.14"
129-
resolved "https://registry.yarnpkg.com/@angular/bazel/-/bazel-14.0.0-next.14.tgz#9ce0649af3c9aa05fd5896b99aa325e3ec078da2"
130-
integrity sha512-eSNX7aRUBNplRxJaZh5WlZp81vlbgx9oO4qSbrv3D7wmftq1sdimycjrpg7gC8vh/zkDid29gZ5m5UI6m0n4AA==
127+
"@angular/[email protected].15":
128+
version "14.0.0-next.15"
129+
resolved "https://registry.yarnpkg.com/@angular/bazel/-/bazel-14.0.0-next.15.tgz#bfaf42c8009e9767879fb8e4775327e449718302"
130+
integrity sha512-IMkqtdYnjspEgkNk5PnoQY5Y5fiQLjuT4C2F3bPWdIVdGRGMXR13AegIF4PtOEFjEFPPOflnY2ocAzaD1wVHKg==
131131
dependencies:
132132
"@microsoft/api-extractor" "7.22.2"
133133
shelljs "^0.8.5"

0 commit comments

Comments
 (0)