Skip to content

Commit 1ad9ef0

Browse files
authored
build: update to Typescript 3.6 (#17428)
1 parent d6e7893 commit 1ad9ef0

File tree

24 files changed

+280
-359
lines changed

24 files changed

+280
-359
lines changed

.bazelrc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,10 @@ test --test_output=errors
3838
build:release --workspace_status_command="node ./tools/bazel-stamp-vars.js"
3939

4040
################################
41-
# Settings for Ivy #
41+
# View Engine / Ivy toggle #
4242
################################
4343

44-
# We want to compile with Ivy and with "ngtsc".
45-
# To build for ViewEngine, use --define=compile=legacy.
44+
# Use "legacy" for ViewEngine and "aot" for Ivy
4645
build --define=compile=aot
4746

4847
#######################

package.json

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"yarn": ">= 1.17.3"
1414
},
1515
"scripts": {
16-
"postinstall": "node --preserve-symlinks --preserve-symlinks-main tools/bazel/postinstall-patches.js | ivy-ngcc --properties main",
16+
"postinstall": "node --preserve-symlinks --preserve-symlinks-main tools/bazel/postinstall-patches.js | ngcc --properties main",
1717
"build": "bash ./scripts/build-packages-dist.sh",
1818
"bazel:buildifier": "find . -type f \\( -name \"*.bzl\" -or -name WORKSPACE -or -name BUILD -or -name BUILD.bazel \\) ! -path \"*/node_modules/*\" | xargs buildifier -v --warnings=attr-cfg,attr-license,attr-non-empty,attr-output-default,attr-single-file,constant-glob,ctx-args,depset-iteration,depset-union,dict-concatenation,duplicated-name,filetype,git-repository,http-archive,integer-division,load,load-on-top,native-build,native-package,output-group,package-name,package-on-top,redefined-variable,repository-name,same-origin-load,string-iteration,unused-variable,unsorted-dict-items,out-of-order-load",
1919
"bazel:format-lint": "yarn -s bazel:buildifier --lint=warn --mode=check",
@@ -41,33 +41,33 @@
4141
"requiredAngularVersion": "^9.0.0-0 || ^10.0.0-0",
4242
"requiredMDCVersion": "^4.0.0-alpha.0",
4343
"dependencies": {
44-
"@angular/animations": "9.0.0-next.10",
45-
"@angular/common": "9.0.0-next.10",
46-
"@angular/compiler": "9.0.0-next.10",
47-
"@angular/core": "9.0.0-next.10",
48-
"@angular/elements": "9.0.0-next.10",
49-
"@angular/forms": "9.0.0-next.10",
50-
"@angular/platform-browser": "9.0.0-next.10",
44+
"@angular/animations": "^9.0.0-next.12",
45+
"@angular/common": "^9.0.0-next.12",
46+
"@angular/compiler": "^9.0.0-next.12",
47+
"@angular/core": "^9.0.0-next.12",
48+
"@angular/elements": "^9.0.0-next.12",
49+
"@angular/forms": "^9.0.0-next.12",
50+
"@angular/platform-browser": "^9.0.0-next.12",
5151
"@types/googlemaps": "^3.37.0",
5252
"@types/youtube": "^0.0.38",
5353
"@webcomponents/custom-elements": "^1.1.0",
5454
"core-js": "^2.6.9",
5555
"material-components-web": "^4.0.0-canary.062ade5c0.0",
5656
"rxjs": "^6.5.3",
5757
"systemjs": "0.19.43",
58-
"tsickle": "^0.35.0",
58+
"tsickle": "^0.37.0",
5959
"tslib": "^1.10.0",
6060
"zone.js": "~0.10.2"
6161
},
6262
"devDependencies": {
63-
"@angular-devkit/core": "^9.0.0-next.9",
64-
"@angular-devkit/schematics": "^9.0.0-next.9",
65-
"@angular/bazel": "9.0.0-next.10",
66-
"@angular/compiler-cli": "9.0.0-next.10",
67-
"@angular/platform-browser-dynamic": "9.0.0-next.10",
68-
"@angular/platform-server": "9.0.0-next.10",
69-
"@angular/router": "9.0.0-next.10",
70-
"@angular/upgrade": "9.0.0-next.10",
63+
"@angular-devkit/core": "^9.0.0-next.12",
64+
"@angular-devkit/schematics": "^9.0.0-next.12",
65+
"@angular/bazel": "^9.0.0-next.12",
66+
"@angular/compiler-cli": "^9.0.0-next.12",
67+
"@angular/platform-browser-dynamic": "^9.0.0-next.12",
68+
"@angular/platform-server": "^9.0.0-next.12",
69+
"@angular/router": "^9.0.0-next.12",
70+
"@angular/upgrade": "^9.0.0-next.12",
7171
"@bazel/bazel": "^0.29.0",
7272
"@bazel/buildifier": "^0.29.0",
7373
"@bazel/ibazel": "^0.10.3",
@@ -77,7 +77,7 @@
7777
"@bazel/protractor": "^0.38.3",
7878
"@firebase/app-types": "^0.3.2",
7979
"@octokit/rest": "^16.28.7",
80-
"@schematics/angular": "^9.0.0-next.9",
80+
"@schematics/angular": "^9.0.0-next.12",
8181
"@types/browser-sync": "^2.26.1",
8282
"@types/fs-extra": "^4.0.3",
8383
"@types/glob": "^5.0.33",
@@ -89,7 +89,7 @@
8989
"@types/merge2": "^0.3.30",
9090
"@types/minimist": "^1.2.0",
9191
"@types/mock-fs": "^3.6.30",
92-
"@types/node": "^7.0.21",
92+
"@types/node": "^12.11.1",
9393
"@types/parse5": "^5.0.0",
9494
"@types/run-sequence": "^0.0.29",
9595
"@types/send": "^0.14.5",
@@ -98,7 +98,7 @@
9898
"browser-sync": "^2.26.7",
9999
"chalk": "^2.4.2",
100100
"clang-format": "^1.2.4",
101-
"codelyzer": "^5.1.2",
101+
"codelyzer": "^5.2.0",
102102
"conventional-changelog": "^3.0.5",
103103
"dgeni": "^0.4.11",
104104
"dgeni-packages": "^0.27.1",
@@ -153,11 +153,11 @@
153153
"tsconfig-paths": "^2.3.0",
154154
"tslint": "^5.20.0",
155155
"tsutils": "^3.0.0",
156-
"typescript": "3.5.3",
156+
"typescript": "^3.6.4",
157157
"uglify-js": "^2.8.14",
158158
"vrsource-tslint-rules": "5.1.1"
159159
},
160160
"resolutions": {
161-
"dgeni-packages/typescript": "3.5.3"
161+
"dgeni-packages/typescript": "3.6.4"
162162
}
163163
}

scripts/circleci/setup-ivy-ngcc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Script that sets up Ivy ngcc to postprocess installed node modules. The script achieves
33
* this by updating the "postinstall" script in the "package.json". This is necessary because
4-
* Bazel manages its own version of the node modules and needs to run ivy-ngcc on its own when
4+
* Bazel manages its own version of the node modules and needs to run ngcc on its own when
55
* installing dependencies.
66
*/
77

@@ -13,7 +13,7 @@ const projectDir = join(__dirname, '../../');
1313
const packageJsonPath = join(projectDir, 'package.json');
1414
const packageJson = require(packageJsonPath);
1515

16-
const postInstallCommand = `ivy-ngcc --properties main module`;
16+
const postInstallCommand = `ngcc --properties main module`;
1717

1818
if (!packageJson['scripts']) {
1919
packageJson['scripts'] = {};

src/cdk-experimental/dialog/dialog-container.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export function throwDialogContentAlreadyAttachedError() {
7373
},
7474
})
7575
export class CdkDialogContainer extends BasePortalOutlet implements OnDestroy {
76-
private _document: Document;
76+
private readonly _document: Document;
7777

7878
/** State of the dialog animation. */
7979
_state: 'void' | 'enter' | 'exit' = 'enter';
@@ -95,7 +95,7 @@ export class CdkDialogContainer extends BasePortalOutlet implements OnDestroy {
9595

9696
@HostBinding('attr.role') get _role() { return this._config.role; }
9797

98-
@HostBinding('attr.aria-modal') _ariaModal = true;
98+
@HostBinding('attr.aria-modal') _ariaModal: boolean = true;
9999

100100
@HostBinding('attr.tabindex') get _tabindex() { return -1; }
101101
// tslint:disable:no-host-decorator-in-concrete

src/cdk/clipboard/clipboard.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import {DOCUMENT} from '@angular/common';
22
import {TestBed} from '@angular/core/testing';
3+
import {Clipboard} from './clipboard';
4+
import {PendingCopy} from './pending-copy';
35

4-
import {Clipboard, PendingCopy} from './clipboard';
56

67
const COPY_CONTENT = 'copy content';
78

src/cdk/clipboard/clipboard.ts

Lines changed: 3 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
import {DOCUMENT} from '@angular/common';
1010
import {Inject, Injectable} from '@angular/core';
11+
import {PendingCopy} from './pending-copy';
12+
1113

1214
/**
1315
* A service for copying text to the clipboard.
@@ -18,7 +20,7 @@ import {Inject, Injectable} from '@angular/core';
1820
*/
1921
@Injectable({providedIn: 'root'})
2022
export class Clipboard {
21-
private _document: Document;
23+
private readonly _document: Document;
2224

2325
constructor(@Inject(DOCUMENT) document: any) {
2426
this._document = document;
@@ -51,72 +53,3 @@ export class Clipboard {
5153
return new PendingCopy(text, this._document);
5254
}
5355
}
54-
55-
/**
56-
* A pending copy-to-clipboard operation.
57-
*
58-
* The implementation of copying text to the clipboard modifies the DOM and
59-
* forces a relayout. This relayout can take too long if the string is large,
60-
* causing the execCommand('copy') to happen too long after the user clicked.
61-
* This results in the browser refusing to copy. This object lets the
62-
* relayout happen in a separate tick from copying by providing a copy function
63-
* that can be called later.
64-
*
65-
* Destroy must be called when no longer in use, regardless of whether `copy` is
66-
* called.
67-
*/
68-
export class PendingCopy {
69-
private _textarea: HTMLTextAreaElement|undefined;
70-
71-
constructor(text: string, private readonly _document: Document) {
72-
const textarea = this._textarea = this._document.createElement('textarea');
73-
const styles = textarea.style;
74-
75-
// Hide the element for display and accessibility. Set an
76-
// absolute position so the page layout isn't affected.
77-
styles.opacity = '0';
78-
styles.position = 'absolute';
79-
styles.left = styles.top = '-999em';
80-
textarea.setAttribute('aria-hidden', 'true');
81-
textarea.value = text;
82-
this._document.body.appendChild(textarea);
83-
}
84-
85-
/** Finishes copying the text. */
86-
copy(): boolean {
87-
const textarea = this._textarea;
88-
let successful = false;
89-
90-
try { // Older browsers could throw if copy is not supported.
91-
if (textarea) {
92-
const currentFocus = this._document.activeElement;
93-
94-
textarea.select();
95-
textarea.setSelectionRange(0, textarea.value.length);
96-
successful = this._document.execCommand('copy');
97-
98-
if (currentFocus && currentFocus instanceof HTMLElement) {
99-
currentFocus.focus();
100-
}
101-
}
102-
} catch {
103-
// Discard error.
104-
// Initial setting of {@code successful} will represent failure here.
105-
}
106-
107-
return successful;
108-
}
109-
110-
/** Cleans up DOM changes used to perform the copy operation. */
111-
destroy() {
112-
const textarea = this._textarea;
113-
114-
if (textarea) {
115-
if (textarea.parentNode) {
116-
textarea.parentNode.removeChild(textarea);
117-
}
118-
119-
this._textarea = undefined;
120-
}
121-
}
122-
}

src/cdk/clipboard/copy-to-clipboard.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {Clipboard} from './clipboard';
2626
})
2727
export class CdkCopyToClipboard {
2828
/** Content to be copied. */
29-
@Input('cdkCopyToClipboard') text = '';
29+
@Input('cdkCopyToClipboard') text: string = '';
3030

3131
/**
3232
* Emits when some text is copied to the clipboard. The

src/cdk/clipboard/pending-copy.ts

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
/**
10+
* A pending copy-to-clipboard operation.
11+
*
12+
* The implementation of copying text to the clipboard modifies the DOM and
13+
* forces a relayout. This relayout can take too long if the string is large,
14+
* causing the execCommand('copy') to happen too long after the user clicked.
15+
* This results in the browser refusing to copy. This object lets the
16+
* relayout happen in a separate tick from copying by providing a copy function
17+
* that can be called later.
18+
*
19+
* Destroy must be called when no longer in use, regardless of whether `copy` is
20+
* called.
21+
*/
22+
export class PendingCopy {
23+
private _textarea: HTMLTextAreaElement|undefined;
24+
25+
constructor(text: string, private readonly _document: Document) {
26+
const textarea = this._textarea = this._document.createElement('textarea');
27+
const styles = textarea.style;
28+
29+
// Hide the element for display and accessibility. Set an
30+
// absolute position so the page layout isn't affected.
31+
styles.opacity = '0';
32+
styles.position = 'absolute';
33+
styles.left = styles.top = '-999em';
34+
textarea.setAttribute('aria-hidden', 'true');
35+
textarea.value = text;
36+
this._document.body.appendChild(textarea);
37+
}
38+
39+
/** Finishes copying the text. */
40+
copy(): boolean {
41+
const textarea = this._textarea;
42+
let successful = false;
43+
44+
try { // Older browsers could throw if copy is not supported.
45+
if (textarea) {
46+
const currentFocus = this._document.activeElement;
47+
48+
textarea.select();
49+
textarea.setSelectionRange(0, textarea.value.length);
50+
successful = this._document.execCommand('copy');
51+
52+
if (currentFocus && currentFocus instanceof HTMLElement) {
53+
currentFocus.focus();
54+
}
55+
}
56+
} catch {
57+
// Discard error.
58+
// Initial setting of {@code successful} will represent failure here.
59+
}
60+
61+
return successful;
62+
}
63+
64+
/** Cleans up DOM changes used to perform the copy operation. */
65+
destroy() {
66+
const textarea = this._textarea;
67+
68+
if (textarea) {
69+
if (textarea.parentNode) {
70+
textarea.parentNode.removeChild(textarea);
71+
}
72+
73+
this._textarea = undefined;
74+
}
75+
}
76+
}

src/cdk/clipboard/public-api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
export * from './clipboard';
1010
export * from './clipboard-module';
1111
export * from './copy-to-clipboard';
12+
export * from './pending-copy';

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ export class CdkDrag<T = any> implements AfterViewInit, OnChanges, OnDestroy {
251251
}),
252252
// Listen if the state of any of the handles changes.
253253
switchMap((handles: QueryList<CdkDragHandle>) => {
254-
return merge(...handles.map(item => item._stateChanges));
254+
return merge(...handles.map(item => item._stateChanges)) as Observable<CdkDragHandle>;
255255
}),
256256
takeUntil(this._destroyed)
257257
).subscribe(handleInstance => {

src/cdk/overlay/overlay-config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ export class OverlayConfig {
6161

6262
constructor(config?: OverlayConfig) {
6363
if (config) {
64-
const configKeys = Object.keys(config) as Array<keyof OverlayConfig>;
64+
// Use `Iterable` instead of `Array` because TypeScript, as of 3.6.3,
65+
// loses the array generic type in the `for of`. But we *also* have to use `Array` because
66+
// typescript won't iterate over an `Iterable` unless you compile with `--downlevelIteration`
67+
const configKeys =
68+
Object.keys(config) as Iterable<keyof OverlayConfig> & Array<keyof OverlayConfig>;
6569
for (const key of configKeys) {
6670
if (config[key] !== undefined) {
6771
// TypeScript, as of version 3.5, sees the left-hand-side of this expression

src/cdk/table/sticky-styler.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,10 @@ export class StickyStyler {
219219
};
220220

221221
let zIndex = 0;
222-
for (const dir of STICKY_DIRECTIONS) {
222+
// Use `Iterable` instead of `Array` because TypeScript, as of 3.6.3,
223+
// loses the array generic type in the `for of`. But we *also* have to use `Array` because
224+
// typescript won't iterate over an `Iterable` unless you compile with `--downlevelIteration`
225+
for (const dir of STICKY_DIRECTIONS as Iterable<StickyDirection> & Array<StickyDirection>) {
223226
if (element.style[dir]) {
224227
zIndex += zIndexIncrements[dir];
225228
}

src/material-experimental/mdc-button/button-base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export class MatButtonBase extends _MatButtonBaseMixin implements CanDisable, Ca
109109
// attributes, add the correct corresponding MDC classes.
110110
for (const pair of HOST_SELECTOR_MDC_CLASS_PAIR) {
111111
if (this._hasHostAttributes(pair.selector)) {
112-
pair.mdcClasses.forEach(className => {
112+
pair.mdcClasses.forEach((className: string) => {
113113
classList.add(className);
114114
});
115115
}

0 commit comments

Comments
 (0)