Skip to content

Commit da13167

Browse files
authored
build: update to typescript 3.9 (#19286)
The Framework team is in the process of updating to TS 3.9 (see angular/angular#36989) which means that soon we'll have to switch to it as well. These changes update us to the latest RC and resolve all of the build issues so that we can quickly switch to the final version once it's available.
1 parent 5284a57 commit da13167

File tree

10 files changed

+40
-18
lines changed

10 files changed

+40
-18
lines changed

integration/ts-compat/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ write_file(
1515
typescript_version_packages = [
1616
"typescript-3.6",
1717
"typescript-3.7",
18+
"typescript-3.8",
1819
"typescript",
1920
]
2021

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,10 @@
161161
"tsickle": "0.38.1",
162162
"tslint": "^6.1.0",
163163
"tsutils": "^3.0.0",
164-
"typescript": "~3.8.3",
164+
"typescript": "3.9.1-rc",
165165
"typescript-3.6": "npm:typescript@~3.6.4",
166166
"typescript-3.7": "npm:typescript@~3.7.0",
167+
"typescript-3.8": "npm:typescript@~3.8.0",
167168
"vrsource-tslint-rules": "5.1.1",
168169
"yaml": "^1.7.2",
169170
"yargs": "15.3.0"

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export class DragRef<T = any> {
164164
* Inline style value of `-webkit-tap-highlight-color` at the time the
165165
* dragging was started. Used to restore the value once we're done dragging.
166166
*/
167-
private _rootElementTapHighlight: string | null;
167+
private _rootElementTapHighlight: string;
168168

169169
/** Subscription to pointer movement events. */
170170
private _pointerMoveSubscription = Subscription.EMPTY;
@@ -772,7 +772,7 @@ export class DragRef<T = any> {
772772
// otherwise iOS will still add it, even though all the drag interactions on the handle
773773
// are disabled.
774774
if (this._handles.length) {
775-
this._rootElementTapHighlight = rootElement.style.webkitTapHighlightColor;
775+
this._rootElementTapHighlight = rootElement.style.webkitTapHighlightColor || '';
776776
rootElement.style.webkitTapHighlightColor = 'transparent';
777777
}
778778

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ type Writeable<T> = { -readonly [P in keyof T]-?: T[P] };
1616
* Extended CSSStyleDeclaration that includes a couple of drag-related
1717
* properties that aren't in the built-in TS typings.
1818
*/
19-
interface DragCSSStyleDeclaration extends CSSStyleDeclaration {
19+
export interface DragCSSStyleDeclaration extends CSSStyleDeclaration {
2020
webkitUserDrag: string;
2121
MozUserSelect: string; // For some reason the Firefox property is in PascalCase.
22+
msScrollSnapType: string;
23+
scrollSnapType: string;
24+
msUserSelect: string;
2225
}
2326

2427
/**

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
isInsideClientRect,
2424
} from './client-rect';
2525
import {ParentPositionTracker} from './parent-position-tracker';
26+
import {DragCSSStyleDeclaration} from './drag-styling';
2627

2728
/**
2829
* Proximity, as a ratio to width/height, at which a
@@ -235,15 +236,15 @@ export class DropListRef<T = any> {
235236

236237
/** Starts dragging an item. */
237238
start(): void {
238-
const styles = coerceElement(this.element).style;
239+
const styles = coerceElement(this.element).style as DragCSSStyleDeclaration;
239240
this.beforeStarted.next();
240241
this._isDragging = true;
241242

242243
// We need to disable scroll snapping while the user is dragging, because it breaks automatic
243244
// scrolling. The browser seems to round the value based on the snapping points which means
244245
// that we can't increment/decrement the scroll position.
245-
this._initialScrollSnap = styles.msScrollSnapType || (styles as any).scrollSnapType || '';
246-
(styles as any).scrollSnapType = styles.msScrollSnapType = 'none';
246+
this._initialScrollSnap = styles.msScrollSnapType || styles.scrollSnapType || '';
247+
styles.scrollSnapType = styles.msScrollSnapType = 'none';
247248
this._cacheItems();
248249
this._siblings.forEach(sibling => sibling._startReceiving(this));
249250
this._viewportScrollSubscription.unsubscribe();
@@ -629,8 +630,8 @@ export class DropListRef<T = any> {
629630
private _reset() {
630631
this._isDragging = false;
631632

632-
const styles = coerceElement(this.element).style;
633-
(styles as any).scrollSnapType = styles.msScrollSnapType = this._initialScrollSnap;
633+
const styles = coerceElement(this.element).style as DragCSSStyleDeclaration;
634+
styles.scrollSnapType = styles.msScrollSnapType = this._initialScrollSnap;
634635

635636
// TODO(crisbeto): may have to wait for the animations to finish.
636637
this._activeDraggables.forEach(item => {

src/material/tooltip/tooltip.spec.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,12 +1018,12 @@ describe('MatTooltip', () => {
10181018

10191019
expect(inputStyle.userSelect).toBeFalsy();
10201020
expect(inputStyle.webkitUserSelect).toBeFalsy();
1021-
expect(inputStyle.msUserSelect).toBeFalsy();
1021+
expect((inputStyle as any).msUserSelect).toBeFalsy();
10221022
expect((inputStyle as any).MozUserSelect).toBeFalsy();
10231023

10241024
expect(textareaStyle.userSelect).toBeFalsy();
10251025
expect(textareaStyle.webkitUserSelect).toBeFalsy();
1026-
expect(textareaStyle.msUserSelect).toBeFalsy();
1026+
expect((textareaStyle as any).msUserSelect).toBeFalsy();
10271027
expect((textareaStyle as any).MozUserSelect).toBeFalsy();
10281028
});
10291029

@@ -1034,10 +1034,11 @@ describe('MatTooltip', () => {
10341034

10351035
const inputStyle = fixture.componentInstance.input.nativeElement.style;
10361036
const inputUserSelect = inputStyle.userSelect || inputStyle.webkitUserSelect ||
1037-
inputStyle.msUserSelect || (inputStyle as any).MozUserSelect;
1037+
(inputStyle as any).msUserSelect || (inputStyle as any).MozUserSelect;
10381038
const textareaStyle = fixture.componentInstance.textarea.nativeElement.style;
10391039
const textareaUserSelect = textareaStyle.userSelect || textareaStyle.webkitUserSelect ||
1040-
textareaStyle.msUserSelect || (textareaStyle as any).MozUserSelect;
1040+
(textareaStyle as any).msUserSelect ||
1041+
(textareaStyle as any).MozUserSelect;
10411042

10421043
expect(inputUserSelect).toBe('none');
10431044
expect(textareaUserSelect).toBe('none');

src/material/tooltip/tooltip.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ export class MatTooltip implements OnDestroy, OnInit {
589589
// If gestures are set to `auto`, we don't disable text selection on inputs and
590590
// textareas, because it prevents the user from typing into them on iOS Safari.
591591
if (gestures === 'on' || (element.nodeName !== 'INPUT' && element.nodeName !== 'TEXTAREA')) {
592-
style.userSelect = style.msUserSelect = style.webkitUserSelect =
592+
style.userSelect = (style as any).msUserSelect = style.webkitUserSelect =
593593
(style as any).MozUserSelect = 'none';
594594
}
595595

tools/tslint-rules/tsLoaderRule.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ const Lint = require('tslint');
33

44
// Custom rule that registers all of the custom rules, written in TypeScript, with ts-node.
55
// This is necessary, because `tslint` and IDEs won't execute any rules that aren't in a .js file.
6-
require('ts-node').register({
7-
project: path.join(__dirname, '../gulp/tsconfig.json')
8-
});
6+
require('ts-node').register({project: path.join(__dirname, './tsconfig.json')});
97

108
// Add a noop rule so tslint doesn't complain.
119
exports.Rule = class Rule extends Lint.Rules.AbstractRule {

tools/tslint-rules/tsconfig.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"compilerOptions": {
4+
"module": "commonjs",
5+
"baseUrl": ".",
6+
"paths": {
7+
// TODO(crisbeto): at the time of writing, tslint is locked to TS 3.8 which causes compilation
8+
// errors in our custom rules. We should remove this alias once tslint is updated to TS 3.9.
9+
"typescript": ["../../node_modules/typescript-3.8"]
10+
}
11+
}
12+
}

yarn.lock

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11725,11 +11725,16 @@ typedarray@^0.0.6:
1172511725
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.5.tgz#0692e21f65fd4108b9330238aac11dd2e177a1ae"
1172611726
integrity sha512-/P5lkRXkWHNAbcJIiHPfRoKqyd7bsyCma1hZNUGfn20qm64T6ZBlrzprymeu918H+mB/0rIg2gGK/BXkhhYgBw==
1172711727

11728-
typescript@3.8.3, typescript@^3.2.2, typescript@~3.8.3:
11728+
"typescript-3.8@npm:typescript@~3.8.0", typescript@3.8.3, typescript@^3.2.2:
1172911729
version "3.8.3"
1173011730
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.8.3.tgz#409eb8544ea0335711205869ec458ab109ee1061"
1173111731
integrity sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==
1173211732

11733+
11734+
version "3.9.1-rc"
11735+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.1-rc.tgz#81d5a5a0a597e224b6e2af8dffb46524b2eaf5f3"
11736+
integrity sha512-+cPv8L2Vd4KidCotqi2wjegBZ5n47CDRUu/QiLVu2YbeXAz78hIfcai9ziBiNI6JTGTVwUqXRug2UZxDcxhvFw==
11737+
1173311738
typescript@^3.0.3, typescript@^3.4.5, typescript@~3.5.3:
1173411739
version "3.5.3"
1173511740
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.5.3.tgz#c830f657f93f1ea846819e929092f5fe5983e977"

0 commit comments

Comments
 (0)