Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 95c729f

Browse files
alxhubmatsko
authored andcommitted
build: typescript 3.8 support (#35864)
This commit adds support in the Angular monorepo and in the Angular compiler(s) for TypeScript 3.8. All packages can now compile with TS 3.8. For most of the repo, only a handful few typings adjustments were needed: * TS 3.8 has a new `CustomElementConstructor` DOM type, which enforces a zero-argument constructor. The `NgElementConstructor` type previously declared a required `injector` argument despite the fact that its implementation allowed `injector` to be optional. The interface type was updated to reflect the optionality of the argument. * Certain error messages were changed, and expectations in tests were updated as a result. * tsserver (part of language server) now returns performance information in responses, so test expectations were changed to only assert on the actual body content of responses. For compiler-cli and schematics (which use the TypeScript AST) a major breaking change was the introduction of the export form: ```typescript export * as foo from 'bar'; ``` This is a `ts.NamespaceExport`, and the `exportClause` of a `ts.ExportDeclaration` can now take this type as well as `ts.NamedExports`. This broke a lot of places where `exportClause` was assumed to be `ts.NamedExports`. For the most part these breakages were in cases where it is not necessary to handle the new `ts.NamedExports` anyway. ngtsc's design uses the `ts.TypeChecker` APIs to understand syntax and so automatically supports the new form of exports. The View Engine compiler on the other hand extracts TS structures into metadata.json files, and that format was not designed for namespaced exports. As a result it will take a nontrivial amount of work if we want to support such exports in View Engine. For now, these new exports are not accounted for in metadata.json, and so using them in "folded" Angular expressions will result in errors (probably claiming that the referenced exported namespace doesn't exist). Care was taken to only use TS APIs which are present in 3.7/3.6, as Angular needs to remain compatible with these for the time being. This commit does not update angular.io. PR Close #35864
1 parent c98c6e8 commit 95c729f

File tree

21 files changed

+845
-37
lines changed

21 files changed

+845
-37
lines changed

‎integration/language_service_plugin/matcher.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@ const goldens: string[] = process.argv.slice(2);
55
export const goldenMatcher: jasmine.CustomMatcherFactories = {
66
toMatchGolden(util: jasmine.MatchersUtil): jasmine.CustomMatcher {
77
return {
8-
compare(actual: {command: string}, golden: string): jasmine.CustomMatcherResult {
8+
compare(actual: {body?: {}}, golden: string): jasmine.CustomMatcherResult {
99
if (goldens.includes(golden)) {
1010
console.error(`Writing golden file ${golden}`);
1111
writeFileSync(`./goldens/${golden}`, JSON.stringify(actual, null, 2));
1212
return { pass : true };
1313
}
1414
const content = readFileSync(`./goldens/${golden}`, 'utf-8');
1515
const expected = JSON.parse(content.replace("${PWD}", process.env.PWD!));
16-
const pass = util.equals(actual, expected);
16+
const hasBody = Object.hasOwnProperty.call(expected, 'body');
17+
const pass = hasBody ? util.equals(actual.body, expected.body) : util.equals(actual, expected);
1718
return {
1819
pass,
1920
message: `Expected ${JSON.stringify(actual, null, 2)} to match golden ` +
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. 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 compilerTesting from '@angular/compiler/testing';
20+
import * as core from '@angular/core';
21+
import * as coreTesting from '@angular/core/testing';
22+
import * as elements from '@angular/elements';
23+
import * as forms from '@angular/forms';
24+
// Current plan for Angular 8 is to stop building the @angular/http package
25+
// import * as http from '@angular/http';
26+
// import * as httpTesting from '@angular/http/testing';
27+
import * as platformBrowser from '@angular/platform-browser';
28+
import * as platformBrowserDynamic from '@angular/platform-browser-dynamic';
29+
import * as platformBrowserDynamicTesting from '@angular/platform-browser-dynamic/testing';
30+
import * as platformBrowserAnimations from '@angular/platform-browser/animations';
31+
import * as platformBrowserTesting from '@angular/platform-browser/testing';
32+
import * as platformServer from '@angular/platform-server';
33+
import * as platformServerTesting from '@angular/platform-server/testing';
34+
import * as platformWebworker from '@angular/platform-webworker';
35+
import * as platformWebworkerDynamic from '@angular/platform-webworker-dynamic';
36+
import * as router from '@angular/router';
37+
import * as routerTesting from '@angular/router/testing';
38+
import * as routerUpgrade from '@angular/router/upgrade';
39+
import * as serviceWorker from '@angular/service-worker';
40+
import * as upgrade from '@angular/upgrade';
41+
import * as upgradeStatic from '@angular/upgrade/static';
42+
import * as upgradeTesting from '@angular/upgrade/static/testing';
43+
44+
export default {
45+
animations,
46+
animationsBrowser,
47+
animationsBrowserTesting,
48+
common,
49+
commonTesting,
50+
commonHttp,
51+
commonHttpTesting,
52+
compiler,
53+
compilerTesting,
54+
core,
55+
coreTesting,
56+
elements,
57+
forms,
58+
// See above
59+
// http,
60+
// httpTesting,
61+
platformBrowser,
62+
platformBrowserTesting,
63+
platformBrowserDynamic,
64+
platformBrowserDynamicTesting,
65+
platformBrowserAnimations,
66+
platformServer,
67+
platformServerTesting,
68+
platformWebworker,
69+
platformWebworkerDynamic,
70+
router,
71+
routerTesting,
72+
routerUpgrade,
73+
serviceWorker,
74+
upgrade,
75+
upgradeStatic,
76+
upgradeTesting,
77+
};
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "angular-integration",
3+
"description": "Assert that users with TypeScript 3.8 can type-check an Angular application",
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/platform-browser": "file:../../dist/packages-dist/platform-browser",
15+
"@angular/platform-browser-dynamic": "file:../../dist/packages-dist/platform-browser-dynamic",
16+
"@angular/platform-server": "file:../../dist/packages-dist/platform-server",
17+
"@angular/platform-webworker": "file:../../dist/packages-dist/platform-webworker",
18+
"@angular/platform-webworker-dynamic": "file:../../dist/packages-dist/platform-webworker-dynamic",
19+
"@angular/router": "file:../../dist/packages-dist/router",
20+
"@angular/service-worker": "file:../../dist/packages-dist/service-worker",
21+
"@angular/upgrade": "file:../../dist/packages-dist/upgrade",
22+
"@types/jasmine": "file:../../node_modules/@types/jasmine",
23+
"rxjs": "file:../../node_modules/rxjs",
24+
"typescript": "3.8.3",
25+
"zone.js": "file:../../dist/zone.js-dist/zone.js"
26+
},
27+
"scripts": {
28+
"test": "tsc"
29+
}
30+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"compilerOptions": {
3+
"strict": true,
4+
"skipLibCheck": false,
5+
"emitDecoratorMetadata": true,
6+
"experimentalDecorators": true,
7+
"module": "commonjs",
8+
"moduleResolution": "node",
9+
"outDir": "./dist/out-tsc",
10+
"rootDir": ".",
11+
"target": "es5",
12+
"lib": [
13+
"es5",
14+
"dom",
15+
"es2015.collection",
16+
"es2015.iterable",
17+
"es2015.promise"
18+
],
19+
"types": [],
20+
},
21+
"files": [
22+
"include-all.ts",
23+
"node_modules/@types/jasmine/index.d.ts"
24+
]
25+
}

0 commit comments

Comments
 (0)