feat(core): support TypeScript 4.4 (#43281)

Adds support for TypeScript 4.4. High-level overview of the changes made in this PR:

* Bumps the various packages to `typescript@4.4.2` and `tslib@2.3.0`.
* The `useUnknownInCatchVariables` compiler option has been disabled so that we don't have to cast error objects explicitly everywhere.
* TS now passes in a third argument to the `__spreadArray` call inside child class constructors. I had to update a couple of places in the runtime and ngcc to be able to pick up the calls correctly.
* TS now generates code like `(0, foo)(arg1, arg2)` for imported function calls. I had to update a few of our tests to account for it. See https://github.com/microsoft/TypeScript/pull/44624.
* Our `ngtsc` test setup calls the private `matchFiles` function from TS. I had to update our usage, because a new parameter was added.
* There was one place where we were setting the readonly `hasTrailingComma` property. I updated the usage to pass in the value when constructing the object instead.
* Some browser types were updated which meant that I had to resolve some trivial type errors.
* The downlevel decorators tranform was running into an issue where the Closure synthetic comments were being emitted twice. I've worked around it by recreating the class declaration node instead of cloning it.

PR Close #43281
This commit is contained in:
Kristiyan Kostadinov
2021-09-22 20:50:59 +02:00
committed by Alex Rickabaugh
parent cc427d18c4
commit ea61ec2562
55 changed files with 250 additions and 126 deletions
+1 -1
View File
@@ -8,7 +8,7 @@
"node": "^12.14.1 || >=14.0.0"
},
"dependencies": {
"tslib": "^2.2.0"
"tslib": "^2.3.0"
},
"repository": {
"type": "git",
@@ -260,9 +260,9 @@ export class Binary extends AST {
export class Unary extends Binary {
// Redeclare the properties that are inherited from `Binary` as `never`, as consumers should not
// depend on these fields when operating on `Unary`.
override left: never;
override right: never;
override operation: never;
override left: never = null as never;
override right: never = null as never;
override operation: never = null as never;
/**
* Creates a unary minus expression "-x", represented as `Binary` using "0 - x".
+1 -1
View File
@@ -381,7 +381,7 @@ class _TreeBuilder {
// `_peek.type` from TS. Otherwise TS will narrow the type of `_peek.type` preventing it from
// being able to consider `ATTR_VALUE_INTERPOLATION` as an option. This is because TS is not
// able to see that `_advance()` will actually mutate `_peek`.
const nextTokenType = this._peek.type;
const nextTokenType = this._peek.type as TokenType;
if (nextTokenType === TokenType.ATTR_VALUE_TEXT) {
valueStartSpan = this._peek.sourceSpan;
valueEnd = this._peek.sourceSpan.end;