Skip to content

Commit db18b40

Browse files
authored
feat(multiple): add support for TypeScript 4.4 (#23646)
Updates to the latest version of Angular and TypeScript, and resolves the various build errors.
1 parent be263e5 commit db18b40

File tree

18 files changed

+229
-188
lines changed

18 files changed

+229
-188
lines changed

integration/ts-compat/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ write_file(
1313
# List of TypeScript packages that we want to run the compatibility test against.
1414
# The list contains NPM module names that resolve to the desired TypeScript version.
1515
typescript_version_packages = [
16-
"typescript-4.2",
1716
"typescript",
1817
]
1918

package.json

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -52,33 +52,33 @@
5252
},
5353
"version": "13.0.0-next.7",
5454
"dependencies": {
55-
"@angular/animations": "13.0.0-next.2",
56-
"@angular/common": "13.0.0-next.2",
57-
"@angular/compiler": "13.0.0-next.2",
58-
"@angular/core": "13.0.0-next.2",
59-
"@angular/forms": "13.0.0-next.2",
60-
"@angular/platform-browser": "13.0.0-next.2",
55+
"@angular/animations": "13.0.0-next.8",
56+
"@angular/common": "13.0.0-next.8",
57+
"@angular/compiler": "13.0.0-next.8",
58+
"@angular/core": "13.0.0-next.8",
59+
"@angular/forms": "13.0.0-next.8",
60+
"@angular/platform-browser": "13.0.0-next.8",
6161
"@types/googlemaps": "^3.43.1",
6262
"@types/youtube": "^0.0.42",
6363
"core-js-bundle": "^3.8.2",
6464
"material-components-web": "13.0.0-canary.860ad06a1.0",
6565
"rxjs": "^6.5.3",
6666
"rxjs-tslint-rules": "^4.33.1",
6767
"systemjs": "0.19.43",
68-
"tslib": "^2.2.0",
68+
"tslib": "^2.3.0",
6969
"zone.js": "~0.11.3"
7070
},
7171
"devDependencies": {
72-
"@angular-devkit/build-optimizer": "0.1300.0-next.1",
73-
"@angular-devkit/core": "13.0.0-next.1",
74-
"@angular-devkit/schematics": "13.0.0-next.1",
75-
"@angular/bazel": "13.0.0-next.2",
76-
"@angular/compiler-cli": "13.0.0-next.2",
72+
"@angular-devkit/build-optimizer": "0.1300.0-next.6",
73+
"@angular-devkit/core": "13.0.0-next.6",
74+
"@angular-devkit/schematics": "13.0.0-next.6",
75+
"@angular/bazel": "13.0.0-next.8",
76+
"@angular/compiler-cli": "13.0.0-next.8",
7777
"@angular/dev-infra-private": "https://github.com/angular/dev-infra-private-builds.git#5744e8e7ca5b3dfa76ad73b7b0eff271a108a737",
78-
"@angular/localize": "13.0.0-next.2",
79-
"@angular/platform-browser-dynamic": "13.0.0-next.2",
80-
"@angular/platform-server": "13.0.0-next.2",
81-
"@angular/router": "13.0.0-next.2",
78+
"@angular/localize": "13.0.0-next.8",
79+
"@angular/platform-browser-dynamic": "13.0.0-next.8",
80+
"@angular/platform-server": "13.0.0-next.8",
81+
"@angular/router": "13.0.0-next.8",
8282
"@axe-core/webdriverjs": "^4.1.0",
8383
"@babel/core": "^7.13.10",
8484
"@babel/traverse": "^7.13.0",
@@ -145,7 +145,7 @@
145145
"@rollup/plugin-babel": "^5.3.0",
146146
"@rollup/plugin-commonjs": "^18.0.0",
147147
"@rollup/plugin-node-resolve": "^13.0.5",
148-
"@schematics/angular": "13.0.0-next.1",
148+
"@schematics/angular": "13.0.0-next.6",
149149
"@types/browser-sync": "^2.26.1",
150150
"@types/fs-extra": "^9.0.5",
151151
"@types/glob": "^7.1.3",
@@ -226,15 +226,14 @@
226226
"tsickle": "0.39.1",
227227
"tslint": "^6.1.3",
228228
"tsutils": "^3.21.0",
229-
"typescript": "~4.3.2",
230-
"typescript-4.2": "npm:[email protected]",
229+
"typescript": "~4.4.2",
231230
"vrsource-tslint-rules": "6.0.0",
232231
"yaml": "^1.10.0"
233232
},
234233
"resolutions": {
235-
"@angular/dev-infra-private/typescript": "~4.3.2",
234+
"@angular/dev-infra-private/typescript": "~4.4.2",
236235
"browser-sync-client": "2.26.13",
237-
"dgeni-packages/typescript": "4.3.2",
236+
"dgeni-packages/typescript": "4.4.2",
238237
"**/https-proxy-agent": "5.0.0"
239238
}
240239
}

packages.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# version for the placeholders.
44
ANGULAR_PACKAGE_VERSION = "^13.0.0-0 || ^14.0.0-0"
55
MDC_PACKAGE_VERSION = "13.0.0-canary.860ad06a1.0"
6-
TSLIB_PACKAGE_VERSION = "^2.2.0"
6+
TSLIB_PACKAGE_VERSION = "^2.3.0"
77
RXJS_PACKAGE_VERSION = "^6.5.3 || ^7.0.0"
88

99
# Each placer holder is used to stamp versions during the build process, replacing the key with it's

scripts/caretaking/firebase-functions/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"firebase-functions": "^3.11.0"
1212
},
1313
"devDependencies": {
14-
"typescript": "^4.3.2",
14+
"typescript": "^4.4.2",
1515
"firebase-tools": "^8.6.0"
1616
},
1717
"private": true

scripts/caretaking/firebase-functions/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3794,10 +3794,10 @@ typedarray@^0.0.6:
37943794
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
37953795
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
37963796

3797-
typescript@^4.3.2:
3798-
version "4.3.2"
3799-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.2.tgz#399ab18aac45802d6f2498de5054fcbbe716a805"
3800-
integrity sha512-zZ4hShnmnoVnAHpVHWpTcxdv7dWP60S2FsydQLV8V5PbS3FifjWFFRiHSWpDJahly88PRyV5teTSLoq4eG7mKw==
3797+
typescript@^4.4.2:
3798+
version "4.4.3"
3799+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.3.tgz#bdc5407caa2b109efd4f82fe130656f977a29324"
3800+
integrity sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA==
38013801

38023802
unique-string@^1.0.0:
38033803
version "1.0.0"

src/cdk/drag-drop/client-rect.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ export function getMutableClientRect(element: Element): ClientRect {
2020
bottom: clientRect.bottom,
2121
left: clientRect.left,
2222
width: clientRect.width,
23-
height: clientRect.height
24-
};
23+
height: clientRect.height,
24+
x: clientRect.x,
25+
y: clientRect.y
26+
} as ClientRect;
2527
}
2628

2729
/**
@@ -41,7 +43,14 @@ export function isInsideClientRect(clientRect: ClientRect, x: number, y: number)
4143
* @param top Amount to add to the `top` position.
4244
* @param left Amount to add to the `left` position.
4345
*/
44-
export function adjustClientRect(clientRect: ClientRect, top: number, left: number) {
46+
export function adjustClientRect(clientRect: {
47+
top: number;
48+
bottom: number;
49+
left: number;
50+
right: number;
51+
width: number;
52+
height: number;
53+
}, top: number, left: number) {
4554
clientRect.top += top;
4655
clientRect.bottom = clientRect.top + clientRect.height;
4756

src/cdk/drag-drop/directives/drag.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,19 +1530,19 @@ describe('CdkDrag', () => {
15301530
const dragElement = fixture.componentInstance.dragElement.nativeElement;
15311531
const handle = fixture.componentInstance.handleElement.nativeElement;
15321532

1533-
expect(dragElement.style.webkitTapHighlightColor).toBeFalsy();
1533+
expect((dragElement.style as any).webkitTapHighlightColor).toBeFalsy();
15341534

15351535
startDraggingViaMouse(fixture, handle);
15361536

1537-
expect(dragElement.style.webkitTapHighlightColor).toBe('transparent');
1537+
expect((dragElement.style as any).webkitTapHighlightColor).toBe('transparent');
15381538

15391539
dispatchMouseEvent(document, 'mousemove', 50, 100);
15401540
fixture.detectChanges();
15411541

15421542
dispatchMouseEvent(document, 'mouseup', 50, 100);
15431543
fixture.detectChanges();
15441544

1545-
expect(dragElement.style.webkitTapHighlightColor).toBeFalsy();
1545+
expect((dragElement.style as any).webkitTapHighlightColor).toBeFalsy();
15461546
}));
15471547

15481548
it('should preserve any existing `webkitTapHighlightColor`', fakeAsync(() => {
@@ -1556,19 +1556,19 @@ describe('CdkDrag', () => {
15561556
const dragElement = fixture.componentInstance.dragElement.nativeElement;
15571557
const handle = fixture.componentInstance.handleElement.nativeElement;
15581558

1559-
dragElement.style.webkitTapHighlightColor = 'purple';
1559+
(dragElement.style as any).webkitTapHighlightColor = 'purple';
15601560

15611561
startDraggingViaMouse(fixture, handle);
15621562

1563-
expect(dragElement.style.webkitTapHighlightColor).toBe('transparent');
1563+
expect((dragElement.style as any).webkitTapHighlightColor).toBe('transparent');
15641564

15651565
dispatchMouseEvent(document, 'mousemove', 50, 100);
15661566
fixture.detectChanges();
15671567

15681568
dispatchMouseEvent(document, 'mouseup', 50, 100);
15691569
fixture.detectChanges();
15701570

1571-
expect(dragElement.style.webkitTapHighlightColor).toBe('purple');
1571+
expect((dragElement.style as any).webkitTapHighlightColor).toBe('purple');
15721572
}));
15731573

15741574
it('should throw if drag handle is attached to an ng-container', fakeAsync(() => {

src/cdk/drag-drop/drag-ref.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ export class DragRef<T = any> {
756756
this._toggleNativeDragInteractions();
757757

758758
if (this._handles) {
759-
this._rootElement.style.webkitTapHighlightColor = this._rootElementTapHighlight;
759+
(this._rootElement.style as any).webkitTapHighlightColor = this._rootElementTapHighlight;
760760
}
761761

762762
if (!this._hasStartedDragging) {
@@ -884,8 +884,9 @@ export class DragRef<T = any> {
884884
// otherwise iOS will still add it, even though all the drag interactions on the handle
885885
// are disabled.
886886
if (this._handles.length) {
887-
this._rootElementTapHighlight = rootElement.style.webkitTapHighlightColor || '';
888-
rootElement.style.webkitTapHighlightColor = 'transparent';
887+
const rootStyles = rootElement.style as any;
888+
this._rootElementTapHighlight = rootStyles.webkitTapHighlightColor || '';
889+
rootStyles.webkitTapHighlightColor = 'transparent';
889890
}
890891

891892
this._hasStartedDragging = this._hasMoved = false;

src/cdk/drag-drop/drop-list-ref.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ const enum AutoScrollHorizontalDirection {NONE, LEFT, RIGHT}
6565
*/
6666
export interface DropListRefInternal extends DropListRef {}
6767

68+
type RootNode = DocumentOrShadowRoot & {
69+
// As of TS 4.4 the built in DOM typings don't include `elementFromPoint` on `ShadowRoot`,
70+
// even though it exists (see https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot).
71+
// This type is a utility to avoid having to add casts everywhere.
72+
elementFromPoint(x: number, y: number): Element | null;
73+
};
74+
6875
/**
6976
* Reference to a drop list. Used to manipulate or dispose of the container.
7077
*/
@@ -193,7 +200,7 @@ export class DropListRef<T = any> {
193200
private readonly _stopScrollTimers = new Subject<void>();
194201

195202
/** Shadow root of the current element. Necessary for `elementFromPoint` to resolve correctly. */
196-
private _cachedShadowRoot: DocumentOrShadowRoot | null = null;
203+
private _cachedShadowRoot: RootNode | null = null;
197204

198205
/** Reference to the document. */
199206
private _document: Document;
@@ -568,7 +575,8 @@ export class DropListRef<T = any> {
568575
// Otherwise check if we can start scrolling the viewport.
569576
if (!verticalScrollDirection && !horizontalScrollDirection) {
570577
const {width, height} = this._viewportRuler.getViewportSize();
571-
const clientRect = {width, height, top: 0, right: width, bottom: height, left: 0};
578+
const clientRect =
579+
{width, height, top: 0, right: width, bottom: height, left: 0} as ClientRect;
572580
verticalScrollDirection = getVerticalScrollDirection(clientRect, pointerY);
573581
horizontalScrollDirection = getHorizontalScrollDirection(clientRect, pointerX);
574582
scrollNode = window;
@@ -935,10 +943,10 @@ export class DropListRef<T = any> {
935943
* in order to ensure that the element has been moved into the shadow DOM. Doing it inside the
936944
* constructor might be too early if the element is inside of something like `ngFor` or `ngIf`.
937945
*/
938-
private _getShadowRoot(): DocumentOrShadowRoot {
946+
private _getShadowRoot(): RootNode {
939947
if (!this._cachedShadowRoot) {
940948
const shadowRoot = _getShadowRoot(coerceElement(this.element));
941-
this._cachedShadowRoot = shadowRoot || this._document;
949+
this._cachedShadowRoot = (shadowRoot || this._document) as RootNode;
942950
}
943951

944952
return this._cachedShadowRoot;

src/cdk/overlay/position/flexible-connected-position-strategy.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ export type FlexibleConnectedPositionStrategyOrigin = ElementRef | Element | Poi
3838
height?: number;
3939
};
4040

41+
/** Equivalent of `ClientRect` without some of the properties we don't care about. */
42+
type Dimensions = Omit<ClientRect, 'x' | 'y' | 'toJSON'>;
43+
4144
/**
4245
* A strategy for positioning overlays. Using this strategy, an overlay is given an
4346
* implicit position relative some origin element. The relative position is defined in terms of
@@ -71,13 +74,13 @@ export class FlexibleConnectedPositionStrategy implements PositionStrategy {
7174
private _positionLocked = false;
7275

7376
/** Cached origin dimensions */
74-
private _originRect: ClientRect;
77+
private _originRect: Dimensions;
7578

7679
/** Cached overlay dimensions */
77-
private _overlayRect: ClientRect;
80+
private _overlayRect: Dimensions;
7881

7982
/** Cached viewport dimensions */
80-
private _viewportRect: ClientRect;
83+
private _viewportRect: Dimensions;
8184

8285
/** Amount of space that must be maintained between the overlay and the edge of the viewport. */
8386
private _viewportMargin = 0;
@@ -467,7 +470,7 @@ export class FlexibleConnectedPositionStrategy implements PositionStrategy {
467470
/**
468471
* Gets the (x, y) coordinate of a connection point on the origin based on a relative position.
469472
*/
470-
private _getOriginPoint(originRect: ClientRect, pos: ConnectedPosition): Point {
473+
private _getOriginPoint(originRect: Dimensions, pos: ConnectedPosition): Point {
471474
let x: number;
472475
if (pos.originX == 'center') {
473476
// Note: when centering we should always use the `left`
@@ -496,7 +499,7 @@ export class FlexibleConnectedPositionStrategy implements PositionStrategy {
496499
*/
497500
private _getOverlayPoint(
498501
originPoint: Point,
499-
overlayRect: ClientRect,
502+
overlayRect: Dimensions,
500503
pos: ConnectedPosition): Point {
501504

502505
// Calculate the (overlayStartX, overlayStartY), the start of the
@@ -525,7 +528,7 @@ export class FlexibleConnectedPositionStrategy implements PositionStrategy {
525528
}
526529

527530
/** Gets how well an overlay at the given point will fit within the viewport. */
528-
private _getOverlayFit(point: Point, rawOverlayRect: ClientRect, viewport: ClientRect,
531+
private _getOverlayFit(point: Point, rawOverlayRect: Dimensions, viewport: Dimensions,
529532
position: ConnectedPosition): OverlayFit {
530533

531534
// Round the overlay rect when comparing against the
@@ -569,7 +572,7 @@ export class FlexibleConnectedPositionStrategy implements PositionStrategy {
569572
* @param point The (x, y) coordinates of the overlat at some position.
570573
* @param viewport The geometry of the viewport.
571574
*/
572-
private _canFitWithFlexibleDimensions(fit: OverlayFit, point: Point, viewport: ClientRect) {
575+
private _canFitWithFlexibleDimensions(fit: OverlayFit, point: Point, viewport: Dimensions) {
573576
if (this._hasFlexibleDimensions) {
574577
const availableHeight = viewport.bottom - point.y;
575578
const availableWidth = viewport.right - point.x;
@@ -598,7 +601,7 @@ export class FlexibleConnectedPositionStrategy implements PositionStrategy {
598601
* originPoint.
599602
*/
600603
private _pushOverlayOnScreen(start: Point,
601-
rawOverlayRect: ClientRect,
604+
rawOverlayRect: Dimensions,
602605
scrollPosition: ViewportScrollPosition): Point {
603606
// If the position is locked and we've pushed the overlay already, reuse the previous push
604607
// amount, rather than pushing it again. If we were to continue pushing, the element would
@@ -1029,7 +1032,7 @@ export class FlexibleConnectedPositionStrategy implements PositionStrategy {
10291032
}
10301033

10311034
/** Narrows the given viewport rect by the current _viewportMargin. */
1032-
private _getNarrowedViewportRect(): ClientRect {
1035+
private _getNarrowedViewportRect(): Dimensions {
10331036
// We recalculate the viewport rect here ourselves, rather than using the ViewportRuler,
10341037
// because we want to use the `clientWidth` and `clientHeight` as the base. The difference
10351038
// being that the client properties don't include the scrollbar, as opposed to `innerWidth`
@@ -1111,7 +1114,7 @@ export class FlexibleConnectedPositionStrategy implements PositionStrategy {
11111114
}
11121115

11131116
/** Returns the ClientRect of the current origin. */
1114-
private _getOriginRect(): ClientRect {
1117+
private _getOriginRect(): Dimensions {
11151118
const origin = this._origin;
11161119

11171120
if (origin instanceof ElementRef) {
@@ -1165,7 +1168,7 @@ interface FallbackPosition {
11651168
originPoint: Point;
11661169
overlayPoint: Point;
11671170
overlayFit: OverlayFit;
1168-
overlayRect: ClientRect;
1171+
overlayRect: Dimensions;
11691172
}
11701173

11711174
/** Position and size of the overlay sizing wrapper for a specific position. */
@@ -1182,7 +1185,7 @@ interface BoundingBoxRect {
11821185
interface FlexibleFit {
11831186
position: ConnectedPosition;
11841187
origin: Point;
1185-
overlayRect: ClientRect;
1188+
overlayRect: Dimensions;
11861189
boundingBoxRect: BoundingBoxRect;
11871190
}
11881191

@@ -1232,7 +1235,7 @@ function getPixelValue(input: number|string|null|undefined): number|null {
12321235
* deviations in the `ClientRect` returned by the browser (e.g. when zoomed in with a percentage
12331236
* size, see #21350).
12341237
*/
1235-
function getRoundedBoundingClientRect(clientRect: ClientRect): ClientRect {
1238+
function getRoundedBoundingClientRect(clientRect: Dimensions): Dimensions {
12361239
return {
12371240
top: Math.floor(clientRect.top),
12381241
right: Math.floor(clientRect.right),

0 commit comments

Comments
 (0)