Skip to content

Commit 29039fc

Browse files
crisbetodylhunn
authored andcommitted
feat(core): support TypeScript 4.7 (#45749)
Adds support for TypeScript 4.7. Changes include: * Bumping the TS version as well as some Bazel dependencies to include bazel-contrib/rules_nodejs#3420. * Adding a backwards-compatibility layer for calls to `updateTypeParameterDeclaration`. * Making `LView` generic in order to make it easier to type the context based on the usage. Currently the context can be 4 different types which coupled with stricter type checking would required a lot of extra casting all over `core`. * Fixing a bunch of miscellaneous type errors. * Removing assertions of `ReferenceEntry.isDefinition` in a few of the language service tests. The field isn't returned by TS anymore and we weren't using it for anything. * Resolving in error in the language service that was caused by TS attempting to parse HTML files when we try to open them. Previous TS was silently setting them as `ScriptKind.Unknown` and ignoring the errors, but now it throws. I've worked around it by setting them as `ScriptKind.JSX`. PR Close #45749
1 parent fcc548a commit 29039fc

File tree

48 files changed

+419
-176
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+419
-176
lines changed

devtools/projects/ng-devtools/src/lib/devtools-tabs/diffing/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ export const diff = <T>(differ: DefaultIterableDiffer<T>, a: T[], b: T[]):
4343
if (!alreadySet[record.previousIndex]) {
4444
a[record.currentIndex] = a[record.previousIndex];
4545
} else {
46-
a[record.currentIndex] = {} as T;
46+
a[record.currentIndex] = {} as unknown as T;
4747
}
48-
Object.keys(b[record.currentIndex]).forEach(prop => {
48+
Object.keys(b[record.currentIndex] as unknown as {}).forEach(prop => {
4949
// TypeScript's type inference didn't follow the check from above.
5050
if (record.currentIndex === null) {
5151
return;

devtools/projects/shell-browser/src/app/chrome-window-extensions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const initializeExtendedWindowOperations = () => {
1414
extendWindowOperations(window, {inspectedApplication: chromeWindowExtensions});
1515
};
1616

17-
const extendWindowOperations = <T>(target, classImpl: T) => {
17+
const extendWindowOperations = <T extends {}>(target, classImpl: T) => {
1818
for (const key of Object.keys(classImpl)) {
1919
if (target[key] != null) {
2020
console.warn(`A window function or object named ${key} would be overwritten`);

goldens/public-api/core/global_utils.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export interface DirectiveDebugMetadata {
2727
export function getComponent<T>(element: Element): T | null;
2828

2929
// @public
30-
export function getContext<T>(element: Element): T | null;
30+
export function getContext<T extends ({} | RootContext)>(element: Element): T | null;
3131

3232
// @public
3333
export function getDirectiveMetadata(directiveOrComponentInstance: any): ComponentDebugMetadata | DirectiveDebugMetadata | null;
@@ -59,7 +59,6 @@ export interface Listener {
5959
useCapture: boolean;
6060
}
6161

62-
6362
// (No @packageDocumentation comment for this package)
6463

6564
```

integration/bazel_workspace_tests/bazel_ngtsc_plugin/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
"@angular/compiler-cli": "file:../../../dist/packages-dist/compiler-cli",
2525
"@babel/core": "^7.16.0",
2626
"@bazel/bazelisk": "file:../../../node_modules/@bazel/bazelisk",
27-
"@bazel/concatjs": "5.4.0",
28-
"@bazel/esbuild": "5.4.0",
29-
"@bazel/protractor": "5.4.0",
30-
"@bazel/rollup": "5.4.0",
31-
"@bazel/terser": "5.4.0",
27+
"@bazel/concatjs": "5.4.1",
28+
"@bazel/esbuild": "5.4.1",
29+
"@bazel/protractor": "5.4.1",
30+
"@bazel/rollup": "5.4.1",
31+
"@bazel/terser": "5.4.1",
3232
"@rollup/plugin-commonjs": "file:../../../node_modules/@rollup/plugin-commonjs",
3333
"@rollup/plugin-node-resolve": "file:../../../node_modules/@rollup/plugin-node-resolve",
3434
"@types/jasmine": "2.8.8",

integration/bazel_workspace_tests/bazel_ngtsc_plugin/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,10 @@
265265
"@bazel/bazelisk@file:../../../node_modules/@bazel/bazelisk":
266266
version "1.11.0"
267267

268-
"@bazel/concatjs@5.4.0":
269-
version "5.4.0"
270-
resolved "https://registry.yarnpkg.com/@bazel/concatjs/-/concatjs-5.4.0.tgz#04e752a6ea3e684f00879e6683657c4ede72df6e"
271-
integrity sha512-jlupaDKxqFS3B1lttOIgkKxirP7v5Qx7KCFtOXO7JxtvYJD/qKtKXEQggTrGKJqLPyiZlNiYimHHGICLSWIZcQ==
268+
"@bazel/concatjs@5.4.1":
269+
version "5.4.1"
270+
resolved "https://registry.yarnpkg.com/@bazel/concatjs/-/concatjs-5.4.1.tgz#590b7944d89136863ba4e3e264c555b0efc815de"
271+
integrity sha512-E5lVBdJNeTcXgDM4phmY2JbHdwWIJZ61ls22McXpWhsDlfItURhNuzxbg/+8gDDX0AlMsJnBpAtFLNVH5c2xwA==
272272
dependencies:
273273
protobufjs "6.8.8"
274274
source-map-support "0.5.9"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
load("//integration:index.bzl", "ng_integration_test")
2+
3+
ng_integration_test(
4+
name = "test",
5+
)
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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+
11+
import * as animations from '@angular/animations';
12+
import * as animationsBrowser from '@angular/animations/browser';
13+
import * as animationsBrowserTesting from '@angular/animations/browser/testing';
14+
import * as common from '@angular/common';
15+
import * as commonHttp from '@angular/common/http';
16+
import * as commonTesting from '@angular/common/testing';
17+
import * as commonHttpTesting from '@angular/common/testing';
18+
import * as compiler from '@angular/compiler';
19+
import * as compilerCli from '@angular/compiler-cli';
20+
import * as compilerTesting from '@angular/compiler/testing';
21+
import * as core from '@angular/core';
22+
import * as coreTesting from '@angular/core/testing';
23+
import * as elements from '@angular/elements';
24+
import * as forms from '@angular/forms';
25+
import * as localize from '@angular/localize';
26+
import * as platformBrowser from '@angular/platform-browser';
27+
import * as platformBrowserDynamic from '@angular/platform-browser-dynamic';
28+
import * as platformBrowserDynamicTesting from '@angular/platform-browser-dynamic/testing';
29+
import * as platformBrowserAnimations from '@angular/platform-browser/animations';
30+
import * as platformBrowserTesting from '@angular/platform-browser/testing';
31+
import * as platformServer from '@angular/platform-server';
32+
import * as platformServerInit from '@angular/platform-server/init';
33+
import * as platformServerTesting from '@angular/platform-server/testing';
34+
import * as router from '@angular/router';
35+
import * as routerTesting from '@angular/router/testing';
36+
import * as routerUpgrade from '@angular/router/upgrade';
37+
import * as serviceWorker from '@angular/service-worker';
38+
import * as upgrade from '@angular/upgrade';
39+
import * as upgradeStatic from '@angular/upgrade/static';
40+
import * as upgradeTesting from '@angular/upgrade/static/testing';
41+
42+
export default {
43+
animations,
44+
animationsBrowser,
45+
animationsBrowserTesting,
46+
common,
47+
commonTesting,
48+
commonHttp,
49+
commonHttpTesting,
50+
compiler,
51+
compilerTesting,
52+
compilerCli,
53+
core,
54+
coreTesting,
55+
elements,
56+
forms,
57+
localize,
58+
platformBrowser,
59+
platformBrowserTesting,
60+
platformBrowserDynamic,
61+
platformBrowserDynamicTesting,
62+
platformBrowserAnimations,
63+
platformServer,
64+
platformServerInit,
65+
platformServerTesting,
66+
router,
67+
routerTesting,
68+
routerUpgrade,
69+
serviceWorker,
70+
upgrade,
71+
upgradeStatic,
72+
upgradeTesting,
73+
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "angular-integration",
3+
"description": "Assert that users with module: nodenext in their tsconfig can import our packages",
4+
"version": "0.0.0",
5+
"license": "MIT",
6+
"dependencies": {
7+
"@angular/animations": "file:../../dist/packages-dist/animations",
8+
"@angular/common": "file:../../dist/packages-dist/common",
9+
"@angular/compiler": "file:../../dist/packages-dist/compiler",
10+
"@angular/compiler-cli": "file:../../dist/packages-dist/compiler-cli",
11+
"@angular/core": "file:../../dist/packages-dist/core",
12+
"@angular/elements": "file:../../dist/packages-dist/elements",
13+
"@angular/forms": "file:../../dist/packages-dist/forms",
14+
"@angular/localize": "file:../../dist/packages-dist/localize",
15+
"@angular/platform-browser": "file:../../dist/packages-dist/platform-browser",
16+
"@angular/platform-browser-dynamic": "file:../../dist/packages-dist/platform-browser-dynamic",
17+
"@angular/platform-server": "file:../../dist/packages-dist/platform-server",
18+
"@angular/router": "file:../../dist/packages-dist/router",
19+
"@angular/service-worker": "file:../../dist/packages-dist/service-worker",
20+
"@angular/upgrade": "file:../../dist/packages-dist/upgrade",
21+
"@types/jasmine": "file:../../node_modules/@types/jasmine",
22+
"rxjs": "file:../../node_modules/rxjs",
23+
"typescript": "file:../../node_modules/typescript",
24+
"zone.js": "file:../../dist/zone.js-dist/archive/zone.js.tgz"
25+
},
26+
"scripts": {
27+
"test": "tsc"
28+
}
29+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"compilerOptions": {
3+
"forceConsistentCasingInFileNames": true,
4+
"strict": true,
5+
"noImplicitReturns": true,
6+
"noFallthroughCasesInSwitch": true,
7+
"experimentalDecorators": true,
8+
"module": "NodeNext",
9+
"moduleResolution": "node",
10+
"outDir": "./dist/out-tsc",
11+
"rootDir": ".",
12+
"target": "es5",
13+
"lib": [
14+
"es5",
15+
"dom",
16+
"es2015.collection",
17+
"es2015.iterable",
18+
"es2015.promise"
19+
],
20+
"types": [],
21+
},
22+
"files": [
23+
"include-all.ts",
24+
"node_modules/@types/jasmine/index.d.ts"
25+
]
26+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
load("//integration:index.bzl", "ng_integration_test")
2+
3+
ng_integration_test(
4+
name = "test",
5+
# Special case for `typings_test_ts47` test as we want to pin
6+
# `typescript` at version 4.7.x for that test and not link to the
7+
# root @npm//typescript package.
8+
pinned_npm_packages = ["typescript"],
9+
)

0 commit comments

Comments
 (0)