feat(core): support TypeScript 4.2 (#41158)

Updates the repo to TypeScript 4.2 and tslib 2.1.0.

PR Close #41158
This commit is contained in:
Kristiyan Kostadinov 2021-03-16 20:10:32 +01:00 committed by Jessica Janiuk
parent eb74a96935
commit 59ef40988e
44 changed files with 283 additions and 134 deletions

View File

@ -33,7 +33,7 @@
"shelljs": "^0.8.4",
"source-map-support": "^0.5.19",
"tar-stream": "^2.1.3",
"tslib": "^2.0.1"
"tslib": "^2.1.0"
},
"devDependencies": {
"@types/body-parser": "^1.19.0",
@ -49,6 +49,6 @@
"supertest": "^4.0.2",
"tslint": "^6.1.3",
"tslint-jasmine-noSkipOrFocus": "^1.0.9",
"typescript": "^4.1.2"
"typescript": "^4.2.3"
}
}

View File

@ -2505,10 +2505,10 @@ tslib@^1.8.1:
version "1.9.3"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286"
tslib@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.0.1.tgz#410eb0d113e5b6356490eec749603725b021b43e"
integrity sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ==
tslib@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.1.0.tgz#da60860f1c2ecaa5703ab7d39bc05b6bf988b97a"
integrity sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==
tslint-jasmine-noSkipOrFocus@^1.0.9:
version "1.0.9"
@ -2563,10 +2563,10 @@ typedarray-to-buffer@^3.1.5:
dependencies:
is-typedarray "^1.0.0"
typescript@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.2.tgz#6369ef22516fe5e10304aae5a5c4862db55380e9"
integrity sha512-thGloWsGH3SOxv1SoY7QojKi0tc+8FnOmiarEGMbd/lar7QOEd3hvlx3Fp5y6FlDUGl9L+pd4n2e+oToGMmhRQ==
typescript@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.3.tgz#39062d8019912d43726298f09493d598048c1ce3"
integrity sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw==
undefsafe@^2.0.2:
version "2.0.2"

View File

@ -1,7 +1,7 @@
// tslint:disable-next-line:no-unused-variable
import { fakeAsync, tick, waitForAsync } from '@angular/core/testing';
import { interval, of } from 'rxjs';
import { delay, take } from 'rxjs/operators';
import {fakeAsync, tick, waitForAsync} from '@angular/core/testing';
import {interval, of} from 'rxjs';
import {delay, take} from 'rxjs/operators';
describe('Angular async helper', () => {
describe('async', () => {
@ -183,7 +183,7 @@ describe('Angular async helper', () => {
// before loading zone.js/testing
it('should wait until promise.then is called', waitForAsync(() => {
let finished = false;
new Promise((res, rej) => {
new Promise<void>(res => {
jsonp('localhost:8080/jsonp', () => {
// success callback and resolve the promise
finished = true;

View File

@ -104,7 +104,7 @@
"@angular/service-worker": "11.2.3",
"@webcomponents/custom-elements": "1.2.1",
"rxjs": "^6.5.3",
"tslib": "^2.0.0",
"tslib": "^2.1.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
@ -170,7 +170,7 @@
"tree-kill": "^1.1.0",
"ts-node": "^8.4.1",
"tslint": "~6.1.0",
"typescript": "~4.1.2",
"typescript": "~4.2.3",
"uglify-js": "^3.0.15",
"unist-util-filter": "^0.2.1",
"unist-util-source": "^1.0.1",

View File

@ -13722,10 +13722,10 @@ typescript@^3.2.2:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.5.tgz#0692e21f65fd4108b9330238aac11dd2e177a1ae"
integrity sha512-/P5lkRXkWHNAbcJIiHPfRoKqyd7bsyCma1hZNUGfn20qm64T6ZBlrzprymeu918H+mB/0rIg2gGK/BXkhhYgBw==
typescript@~4.1.2:
version "4.1.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.5.tgz#123a3b214aaff3be32926f0d8f1f6e704eb89a72"
integrity sha512-6OSu9PTIzmn9TCDiovULTnET6BgXtDYL4Gg4szY+cGsc3JP1dQL8qvE8kShTRx1NIw4Q9IBHlwODjkjWEtMUyA==
typescript@~4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.3.tgz#39062d8019912d43726298f09493d598048c1ce3"
integrity sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw==
ua-parser-js@^0.7.23:
version "0.7.24"

View File

@ -58,7 +58,7 @@ function buildLogLevelFunction(loadCommand, level) {
for (var _i = 0; _i < arguments.length; _i++) {
text[_i] = arguments[_i];
}
runConsoleCommand.apply(void 0, tslib.__spread([loadCommand, level], text));
runConsoleCommand.apply(void 0, tslib.__spreadArray([loadCommand, level], tslib.__read(text)));
};
/** Start a group at the LOG_LEVEL, optionally starting it as collapsed. */
loggingFunction.group = function (text, collapsed) {
@ -87,9 +87,9 @@ function runConsoleCommand(loadCommand, logLevel) {
text[_i - 2] = arguments[_i];
}
if (getLogLevel() >= logLevel) {
loadCommand().apply(void 0, tslib.__spread(text));
loadCommand().apply(void 0, tslib.__spreadArray([], tslib.__read(text)));
}
printToLogFile.apply(void 0, tslib.__spread([logLevel], text));
printToLogFile.apply(void 0, tslib.__spreadArray([logLevel], tslib.__read(text)));
}
/**
* Retrieve the log level from environment variables, if the value found

View File

@ -239,7 +239,7 @@ function promptAutocomplete(message, choices, noChoiceText) {
case 0:
prompt = inquirer.createPromptModule({}).registerPrompt('autocomplete', inquirerAutocomplete);
if (noChoiceText) {
choices = tslib.__spread([noChoiceText], choices);
choices = tslib.__spreadArray([noChoiceText], tslib.__read(choices));
}
return [4 /*yield*/, prompt({
type: 'autocomplete',
@ -313,7 +313,7 @@ function buildLogLevelFunction(loadCommand, level) {
for (var _i = 0; _i < arguments.length; _i++) {
text[_i] = arguments[_i];
}
runConsoleCommand.apply(void 0, tslib.__spread([loadCommand, level], text));
runConsoleCommand.apply(void 0, tslib.__spreadArray([loadCommand, level], tslib.__read(text)));
};
/** Start a group at the LOG_LEVEL, optionally starting it as collapsed. */
loggingFunction.group = function (text, collapsed) {
@ -342,9 +342,9 @@ function runConsoleCommand(loadCommand, logLevel) {
text[_i - 2] = arguments[_i];
}
if (getLogLevel() >= logLevel) {
loadCommand().apply(void 0, tslib.__spread(text));
loadCommand().apply(void 0, tslib.__spreadArray([], tslib.__read(text)));
}
printToLogFile.apply(void 0, tslib.__spread([logLevel], text));
printToLogFile.apply(void 0, tslib.__spreadArray([logLevel], tslib.__read(text)));
}
/**
* Retrieve the log level from environment variables, if the value found
@ -2254,7 +2254,7 @@ function allChangedFilesSince(sha) {
var diffFiles = gitOutputAsArray("git diff --name-only --diff-filter=d " + sha);
var untrackedFiles = gitOutputAsArray("git ls-files --others --exclude-standard");
// Use a set to deduplicate the list as its possible for a file to show up in both lists.
return Array.from(new Set(tslib.__spread(diffFiles, untrackedFiles)));
return Array.from(new Set(tslib.__spreadArray(tslib.__spreadArray([], tslib.__read(diffFiles)), tslib.__read(untrackedFiles))));
}
/**
* A list of all staged files which have been modified.
@ -2947,7 +2947,7 @@ function getPr(prSchema, prNumber, git) {
PR_QUERY = typedGraphqlify.params({
$number: 'Int!',
$owner: 'String!',
$name: 'String!',
$name: 'String!', // The organization to query for
}, {
repository: typedGraphqlify.params({ owner: '$owner', name: '$name' }, {
pullRequest: typedGraphqlify.params({ number: '$number' }, prSchema),
@ -2973,7 +2973,7 @@ function getPendingPrs(prSchema, git) {
$first: 'Int',
$after: 'String',
$owner: 'String!',
$name: 'String!',
$name: 'String!', // The repository to query for
}, {
repository: typedGraphqlify.params({ owner: '$owner', name: '$name' }, {
pullRequests: typedGraphqlify.params({
@ -3003,7 +3003,7 @@ function getPendingPrs(prSchema, git) {
return [4 /*yield*/, git.github.graphql.query(PRS_QUERY, params_1)];
case 2:
results = _b.sent();
prs.push.apply(prs, tslib.__spread(results.repository.pullRequests.nodes));
prs.push.apply(prs, tslib.__spreadArray([], tslib.__read(results.repository.pullRequests.nodes)));
hasNextPage = results.repository.pullRequests.pageInfo.hasNextPage;
cursor = results.repository.pullRequests.pageInfo.endCursor;
return [3 /*break*/, 1];
@ -3598,7 +3598,7 @@ var MergeStrategy = /** @class */ (function () {
// Checkout the local target branch.
this.git.run(['checkout', localTargetBranch]);
// Cherry-pick the refspec into the target branch.
if (this.git.runGraceful(tslib.__spread(['cherry-pick'], cherryPickArgs)).status !== 0) {
if (this.git.runGraceful(tslib.__spreadArray(['cherry-pick'], tslib.__read(cherryPickArgs))).status !== 0) {
// Abort the failed cherry-pick. We do this because Git persists the failed
// cherry-pick state globally in the repository. This could prevent future
// pull request merges as a Git thinks a cherry-pick is still in progress.
@ -3637,7 +3637,7 @@ var MergeStrategy = /** @class */ (function () {
});
// Fetch all target branches with a single command. We don't want to fetch them
// individually as that could cause an unnecessary slow-down.
this.git.run(tslib.__spread(['fetch', '-q', '-f', this.git.repoGitUrl], fetchRefspecs, extraRefspecs));
this.git.run(tslib.__spreadArray(tslib.__spreadArray(['fetch', '-q', '-f', this.git.repoGitUrl], tslib.__read(fetchRefspecs)), tslib.__read(extraRefspecs)));
};
/** Pushes the given target branches upstream. */
MergeStrategy.prototype.pushTargetBranchesUpstream = function (names) {
@ -3648,7 +3648,7 @@ var MergeStrategy = /** @class */ (function () {
});
// Push all target branches with a single command if we don't run in dry-run mode.
// We don't want to push them individually as that could cause an unnecessary slow-down.
this.git.run(tslib.__spread(['push', this.git.repoGitUrl], pushRefspecs));
this.git.run(tslib.__spreadArray(['push', this.git.repoGitUrl], tslib.__read(pushRefspecs)));
};
return MergeStrategy;
}());

View File

@ -97,6 +97,12 @@ INTEGRATION_TESTS = {
# root @npm//typescript package.
"pinned_npm_packages": ["typescript"],
},
"typings_test_ts42": {
# Special case for `typings_test_ts42` test as we want to pin
# `typescript` at version 4.2.x for that test and not link to the
# root @npm//typescript package.
"pinned_npm_packages": ["typescript"],
},
}
[

View File

@ -0,0 +1,69 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import * as animations from '@angular/animations';
import * as animationsBrowser from '@angular/animations/browser';
import * as animationsBrowserTesting from '@angular/animations/browser/testing';
import * as common from '@angular/common';
import * as commonHttp from '@angular/common/http';
import * as commonTesting from '@angular/common/testing';
import * as commonHttpTesting from '@angular/common/testing';
import * as compiler from '@angular/compiler';
import * as compilerTesting from '@angular/compiler/testing';
import * as core from '@angular/core';
import * as coreTesting from '@angular/core/testing';
import * as elements from '@angular/elements';
import * as forms from '@angular/forms';
import * as platformBrowser from '@angular/platform-browser';
import * as platformBrowserDynamic from '@angular/platform-browser-dynamic';
import * as platformBrowserDynamicTesting from '@angular/platform-browser-dynamic/testing';
import * as platformBrowserAnimations from '@angular/platform-browser/animations';
import * as platformBrowserTesting from '@angular/platform-browser/testing';
import * as platformServer from '@angular/platform-server';
import * as platformServerInit from '@angular/platform-server/init';
import * as platformServerTesting from '@angular/platform-server/testing';
import * as router from '@angular/router';
import * as routerTesting from '@angular/router/testing';
import * as routerUpgrade from '@angular/router/upgrade';
import * as serviceWorker from '@angular/service-worker';
import * as upgrade from '@angular/upgrade';
import * as upgradeStatic from '@angular/upgrade/static';
import * as upgradeTesting from '@angular/upgrade/static/testing';
export default {
animations,
animationsBrowser,
animationsBrowserTesting,
common,
commonTesting,
commonHttp,
commonHttpTesting,
compiler,
compilerTesting,
core,
coreTesting,
elements,
forms,
platformBrowser,
platformBrowserTesting,
platformBrowserDynamic,
platformBrowserDynamicTesting,
platformBrowserAnimations,
platformServer,
platformServerInit,
platformServerTesting,
router,
routerTesting,
routerUpgrade,
serviceWorker,
upgrade,
upgradeStatic,
upgradeTesting,
};

View File

@ -0,0 +1,28 @@
{
"name": "angular-integration",
"description": "Assert that users with TypeScript 4.2 can type-check an Angular application",
"version": "0.0.0",
"license": "MIT",
"dependencies": {
"@angular/animations": "file:../../dist/packages-dist/animations",
"@angular/common": "file:../../dist/packages-dist/common",
"@angular/compiler": "file:../../dist/packages-dist/compiler",
"@angular/compiler-cli": "file:../../dist/packages-dist/compiler-cli",
"@angular/core": "file:../../dist/packages-dist/core",
"@angular/elements": "file:../../dist/packages-dist/elements",
"@angular/forms": "file:../../dist/packages-dist/forms",
"@angular/platform-browser": "file:../../dist/packages-dist/platform-browser",
"@angular/platform-browser-dynamic": "file:../../dist/packages-dist/platform-browser-dynamic",
"@angular/platform-server": "file:../../dist/packages-dist/platform-server",
"@angular/router": "file:../../dist/packages-dist/router",
"@angular/service-worker": "file:../../dist/packages-dist/service-worker",
"@angular/upgrade": "file:../../dist/packages-dist/upgrade",
"@types/jasmine": "file:../../node_modules/@types/jasmine",
"rxjs": "file:../../node_modules/rxjs",
"typescript": "4.2.3",
"zone.js": "file:../../dist/zone.js-dist/archive/zone.js.tgz"
},
"scripts": {
"test": "tsc"
}
}

View File

@ -0,0 +1,26 @@
{
"compilerOptions": {
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"experimentalDecorators": true,
"module": "commonjs",
"moduleResolution": "node",
"outDir": "./dist/out-tsc",
"rootDir": ".",
"target": "es5",
"lib": [
"es5",
"dom",
"es2015.collection",
"es2015.iterable",
"es2015.promise"
],
"types": [],
},
"files": [
"include-all.ts",
"node_modules/@types/jasmine/index.d.ts"
]
}

View File

@ -152,9 +152,9 @@
"systemjs": "0.18.10",
"terser": "^4.4.0",
"tsickle": "0.38.1",
"tslib": "^2.0.0",
"tslib": "^2.1.0",
"tslint": "6.1.3",
"typescript": "~4.1.2",
"typescript": "~4.2.3",
"xhr2": "0.2.0",
"yaml": "^1.10.0",
"yargs": "^16.1.1"

View File

@ -5,7 +5,7 @@
"author": "angular",
"license": "MIT",
"dependencies": {
"tslib": "^2.0.0"
"tslib": "^2.1.0"
},
"peerDependencies": {
"@angular/core": "0.0.0-PLACEHOLDER"

View File

@ -28,7 +28,7 @@
"@angular/compiler-cli": "0.0.0-PLACEHOLDER",
"@bazel/typescript": ">=1.0.0",
"terser": "^4.3.1",
"typescript": ">=4.0 <4.2",
"typescript": ">=4.0 <4.3",
"rollup": ">=1.20.0",
"rollup-plugin-commonjs": ">=9.0.0",
"rollup-plugin-node-resolve": ">=4.2.0",

View File

@ -6,7 +6,7 @@
"license": "MIT",
"locales": "locales",
"dependencies": {
"tslib": "^2.0.0"
"tslib": "^2.1.0"
},
"peerDependencies": {
"@angular/core": "0.0.0-PLACEHOLDER",

View File

@ -24,12 +24,12 @@
"semver": "^6.3.0",
"source-map": "^0.6.1",
"sourcemap-codec": "^1.4.8",
"tslib": "^2.0.0",
"tslib": "^2.1.0",
"yargs": "^16.1.1"
},
"peerDependencies": {
"@angular/compiler": "0.0.0-PLACEHOLDER",
"typescript": ">=4.0 <4.2"
"typescript": ">=4.0 <4.3"
},
"engines": {
"node": ">=10.0"

View File

@ -116,15 +116,14 @@ describe('type check blocks diagnostics', () => {
it('should annotate safe property access', () => {
const TEMPLATE = `{{ a?.b }}`;
expect(tcbWithSpans(TEMPLATE))
.toContain(
'((null as any) ? (((ctx).a /*3,4*/) /*3,4*/)!.b /*6,7*/ : undefined) /*3,7*/');
.toContain('(null as any ? (((ctx).a /*3,4*/) /*3,4*/)!.b /*6,7*/ : undefined) /*3,7*/');
});
it('should annotate safe method calls', () => {
const TEMPLATE = `{{ a?.method(b) }}`;
expect(tcbWithSpans(TEMPLATE))
.toContain(
'((null as any) ? (((ctx).a /*3,4*/) /*3,4*/)!.method /*6,12*/(((ctx).b /*13,14*/) /*13,14*/) : undefined) /*3,15*/');
'(null as any ? (((ctx).a /*3,4*/) /*3,4*/)!.method /*6,12*/(((ctx).b /*13,14*/) /*13,14*/) : undefined) /*3,15*/');
});
it('should annotate $any casts', () => {

View File

@ -60,7 +60,7 @@ describe('type check blocks', () => {
selector: '[dir]',
inputs: {inputA: 'inputA'},
}];
expect(tcb(TEMPLATE, DIRECTIVES)).toContain('_t1: DirA = (null!); _t1.inputA = ("value");');
expect(tcb(TEMPLATE, DIRECTIVES)).toContain('_t1: DirA = null!; _t1.inputA = ("value");');
});
it('should handle multiple bindings to the same property', () => {
@ -135,7 +135,7 @@ describe('type check blocks', () => {
}];
expect(tcb(TEMPLATE, DIRECTIVES))
.toContain(
'var _t1 = Dir.ngTypeCtor({ "fieldA": (((ctx).foo)), "fieldB": (null as any) });');
'var _t1 = Dir.ngTypeCtor({ "fieldA": (((ctx).foo)), "fieldB": null as any });');
});
it('should handle multiple bindings to the same property', () => {
@ -261,7 +261,7 @@ describe('type check blocks', () => {
}];
expect(tcb(TEMPLATE, DIRECTIVES))
.toContain(
'var _t1: typeof Dir.ngAcceptInputType_fieldA = (null!); ' +
'var _t1: typeof Dir.ngAcceptInputType_fieldA = null!; ' +
'_t1 = (((ctx).foo));');
});
});
@ -321,11 +321,11 @@ describe('type check blocks', () => {
},
];
const block = tcb(TEMPLATE, DIRECTIVES);
expect(block).toContain('var _t1: HasInput = (null!)');
expect(block).toContain('var _t1: HasInput = null!');
expect(block).toContain('_t1.input = (((ctx).value));');
expect(block).toContain('var _t2: HasOutput = (null!)');
expect(block).toContain('var _t2: HasOutput = null!');
expect(block).toContain('_t2["output"]');
expect(block).toContain('var _t4: HasReference = (null!)');
expect(block).toContain('var _t4: HasReference = null!');
expect(block).toContain('var _t3 = _t4;');
expect(block).toContain('(_t3).a');
expect(block).not.toContain('NoBindings');
@ -355,7 +355,7 @@ describe('type check blocks', () => {
}];
expect(tcb(TEMPLATE, DIRECTIVES))
.toContain(
'var _t2: Dir = (null!); ' +
'var _t2: Dir = null!; ' +
'var _t1 = _t2; ' +
'"" + (((_t1).value));');
});
@ -383,7 +383,7 @@ describe('type check blocks', () => {
inputs: {'color': 'color', 'strong': 'strong', 'enabled': 'enabled'},
}];
const block = tcb(TEMPLATE, DIRECTIVES);
expect(block).not.toContain('var _t1: Dir = (null!);');
expect(block).not.toContain('var _t1: Dir = null!;');
expect(block).not.toContain('"color"');
expect(block).not.toContain('"strong"');
expect(block).not.toContain('"enabled"');
@ -403,7 +403,7 @@ describe('type check blocks', () => {
}];
expect(tcb(TEMPLATE, DIRECTIVES))
.toContain(
'var _t2: Dir = (null!); ' +
'var _t2: Dir = null!; ' +
'var _t1 = _t2; ' +
'_t2.input = (_t1);');
});
@ -431,9 +431,9 @@ describe('type check blocks', () => {
];
expect(tcb(TEMPLATE, DIRECTIVES))
.toContain(
'var _t2: DirB = (null!); ' +
'var _t2: DirB = null!; ' +
'var _t1 = _t2; ' +
'var _t3: DirA = (null!); ' +
'var _t3: DirA = null!; ' +
'_t3.inputA = (_t1); ' +
'var _t4 = _t3; ' +
'_t2.inputA = (_t4);');
@ -451,7 +451,7 @@ describe('type check blocks', () => {
undeclaredInputFields: ['fieldA']
}];
const block = tcb(TEMPLATE, DIRECTIVES);
expect(block).not.toContain('var _t1: Dir = (null!);');
expect(block).not.toContain('var _t1: Dir = null!;');
expect(block).toContain('(((ctx).foo)); ');
});
@ -468,8 +468,8 @@ describe('type check blocks', () => {
}];
expect(tcb(TEMPLATE, DIRECTIVES))
.toContain(
'var _t1: Dir = (null!); ' +
'var _t2: typeof _t1["fieldA"] = (null!); ' +
'var _t1: Dir = null!; ' +
'var _t2: typeof _t1["fieldA"] = null!; ' +
'_t2 = (((ctx).foo)); ');
});
@ -487,7 +487,7 @@ describe('type check blocks', () => {
}];
const block = tcb(TEMPLATE, DIRECTIVES);
expect(block).toContain(
'var _t1: Dir = (null!); ' +
'var _t1: Dir = null!; ' +
'_t1["some-input.xs"] = (((ctx).foo)); ');
});
@ -504,7 +504,7 @@ describe('type check blocks', () => {
}];
expect(tcb(TEMPLATE, DIRECTIVES))
.toContain(
'var _t1: Dir = (null!); ' +
'var _t1: Dir = null!; ' +
'_t1.field2 = _t1.field1 = (((ctx).foo));');
});
@ -523,8 +523,8 @@ describe('type check blocks', () => {
}];
expect(tcb(TEMPLATE, DIRECTIVES))
.toContain(
'var _t1: typeof Dir.ngAcceptInputType_field1 = (null!); ' +
'var _t2: Dir = (null!); ' +
'var _t1: typeof Dir.ngAcceptInputType_field1 = null!; ' +
'var _t2: Dir = null!; ' +
'_t2.field2 = _t1 = (((ctx).foo));');
});
@ -543,7 +543,7 @@ describe('type check blocks', () => {
}];
expect(tcb(TEMPLATE, DIRECTIVES))
.toContain(
'var _t1: Dir = (null!); ' +
'var _t1: Dir = null!; ' +
'_t1.field2 = (((ctx).foo));');
});
@ -559,9 +559,9 @@ describe('type check blocks', () => {
coercedInputFields: ['fieldA'],
}];
const block = tcb(TEMPLATE, DIRECTIVES);
expect(block).not.toContain('var _t1: Dir = (null!);');
expect(block).not.toContain('var _t1: Dir = null!;');
expect(block).toContain(
'var _t1: typeof Dir.ngAcceptInputType_fieldA = (null!); ' +
'var _t1: typeof Dir.ngAcceptInputType_fieldA = null!; ' +
'_t1 = (((ctx).foo));');
});
@ -578,9 +578,9 @@ describe('type check blocks', () => {
undeclaredInputFields: ['fieldA'],
}];
const block = tcb(TEMPLATE, DIRECTIVES);
expect(block).not.toContain('var _t1: Dir = (null!);');
expect(block).not.toContain('var _t1: Dir = null!;');
expect(block).toContain(
'var _t1: typeof Dir.ngAcceptInputType_fieldA = (null!); ' +
'var _t1: typeof Dir.ngAcceptInputType_fieldA = null!; ' +
'_t1 = (((ctx).foo));');
});
@ -893,7 +893,7 @@ describe('type check blocks', () => {
TypeCheckingConfig = {...BASE_CONFIG, checkTypeOfDomReferences: false};
const block = tcb(TEMPLATE, [], DISABLED_CONFIG);
expect(block).toContain(
'var _t1 = (_t2 as any); ' +
'var _t1 = _t2 as any; ' +
'"" + (((_t1).value));');
});
});
@ -928,7 +928,7 @@ describe('type check blocks', () => {
TypeCheckingConfig = {...BASE_CONFIG, checkTypeOfNonDomReferences: false};
const block = tcb(TEMPLATE, DIRECTIVES, DISABLED_CONFIG);
expect(block).toContain(
'var _t1 = (_t2 as any); ' +
'var _t1 = _t2 as any; ' +
'"" + (((_t1).value));');
});
});
@ -983,8 +983,8 @@ describe('type check blocks', () => {
it('should use undefined for safe navigation operations when enabled', () => {
const block = tcb(TEMPLATE, DIRECTIVES);
expect(block).toContain('((null as any) ? (((ctx).a))!.method() : undefined)');
expect(block).toContain('((null as any) ? (((ctx).a))!.b : undefined)');
expect(block).toContain('(null as any ? (((ctx).a))!.method() : undefined)');
expect(block).toContain('(null as any ? (((ctx).a))!.b : undefined)');
});
it('should use an \'any\' type for safe navigation operations when disabled', () => {
const DISABLED_CONFIG:
@ -999,8 +999,8 @@ describe('type check blocks', () => {
const TEMPLATE = `{{a.method()?.b}} {{a()?.method()}}`;
it('should check the presence of a property/method on the receiver when enabled', () => {
const block = tcb(TEMPLATE, DIRECTIVES);
expect(block).toContain('((null as any) ? ((((ctx).a)).method())!.b : undefined)');
expect(block).toContain('((null as any) ? ((ctx).a())!.method() : undefined)');
expect(block).toContain('(null as any ? ((((ctx).a)).method())!.b : undefined)');
expect(block).toContain('(null as any ? ((ctx).a())!.method() : undefined)');
});
it('should not check the presence of a property/method on the receiver when disabled', () => {
const DISABLED_CONFIG:
@ -1045,7 +1045,7 @@ describe('type check blocks', () => {
TypeCheckingConfig = {...BASE_CONFIG, honorAccessModifiersForInputBindings: true};
const block = tcb(TEMPLATE, DIRECTIVES, enableChecks);
expect(block).toContain(
'var _t1: Dir = (null!); ' +
'var _t1: Dir = null!; ' +
'_t1["some-input.xs"] = (((ctx).foo)); ');
});
@ -1063,7 +1063,7 @@ describe('type check blocks', () => {
TypeCheckingConfig = {...BASE_CONFIG, honorAccessModifiersForInputBindings: true};
const block = tcb(TEMPLATE, DIRECTIVES, enableChecks);
expect(block).toContain(
'var _t1: Dir = (null!); ' +
'var _t1: Dir = null!; ' +
'_t1.fieldA = (((ctx).foo)); ');
});
});

View File

@ -25,7 +25,7 @@ const MIN_TS_VERSION = '4.0.0';
* Note: this check is disabled in g3, search for
* `angularCompilerOptions.disableTypeScriptVersionCheck` config param value in g3.
*/
const MAX_TS_VERSION = '4.2.0';
const MAX_TS_VERSION = '4.3.0';
/**
* The currently used version of TypeScript, which can be adjusted for testing purposes using

View File

@ -769,12 +769,14 @@ runInEachFileSystem(() => {
let diags = env.driveDiagnostics();
expect(diags.length).toBe(1);
expect(diags[0].messageText).toContain('"alpha" | "beta"');
expect(diags[0].messageText)
.toContain(`Type '"gamma"' is not assignable to type 'keyof Keys'.`);
// On a rebuild, the same errors should be present.
diags = env.driveDiagnostics();
expect(diags.length).toBe(1);
expect(diags[0].messageText).toContain('"alpha" | "beta"');
expect(diags[0].messageText)
.toContain(`Type '"gamma"' is not assignable to type 'keyof Keys'.`);
});
});
});

View File

@ -5,7 +5,7 @@
"author": "angular",
"license": "MIT",
"dependencies": {
"tslib": "^2.0.0"
"tslib": "^2.1.0"
},
"repository": {
"type": "git",

View File

@ -5,7 +5,7 @@
"author": "angular",
"license": "MIT",
"dependencies": {
"tslib": "^2.0.0"
"tslib": "^2.1.0"
},
"peerDependencies": {
"rxjs": "^6.5.3",

View File

@ -7,7 +7,7 @@
*/
import {Rule, SchematicsException, Tree} from '@angular-devkit/schematics';
import {relative} from 'path';
import {basename, join, relative} from 'path';
import * as ts from 'typescript';
import {getProjectTsConfigPaths} from '../../utils/project_tsconfig_paths';
@ -43,11 +43,15 @@ export default function(): Rule {
}
function runRendererToRenderer2Migration(tree: Tree, tsconfigPath: string, basePath: string) {
// Technically we can get away with using `MODULE_AUGMENTATION_FILENAME` as the path, but as of
// TS 4.2, the module resolution caching seems to be more aggressive which causes the file to be
// retained between test runs. We can avoid it by using the full path.
const augmentedFilePath = join(basePath, MODULE_AUGMENTATION_FILENAME);
const {program} = createMigrationProgram(tree, tsconfigPath, basePath, fileName => {
// In case the module augmentation file has been requested, we return a source file that
// augments "@angular/core" to include a named export called "Renderer". This ensures that
// we can rely on the type checker for this migration in v9 where "Renderer" has been removed.
if (fileName === MODULE_AUGMENTATION_FILENAME) {
if (basename(fileName) === MODULE_AUGMENTATION_FILENAME) {
return `
import '@angular/core';
declare module "@angular/core" {
@ -55,8 +59,8 @@ function runRendererToRenderer2Migration(tree: Tree, tsconfigPath: string, baseP
}
`;
}
return null;
}, [MODULE_AUGMENTATION_FILENAME]);
return undefined;
}, [augmentedFilePath]);
const typeChecker = program.getTypeChecker();
const printer = ts.createPrinter();
const sourceFiles =

View File

@ -7,7 +7,7 @@
*/
import {Rule, SchematicsException, Tree} from '@angular-devkit/schematics';
import {relative} from 'path';
import {basename, join, relative} from 'path';
import * as ts from 'typescript';
import {getProjectTsConfigPaths} from '../../utils/project_tsconfig_paths';
@ -38,11 +38,15 @@ export default function(): Rule {
}
function runWaitForAsyncMigration(tree: Tree, tsconfigPath: string, basePath: string) {
// Technically we can get away with using `MODULE_AUGMENTATION_FILENAME` as the path, but as of
// TS 4.2, the module resolution caching seems to be more aggressive which causes the file to be
// retained between test runs. We can avoid it by using the full path.
const augmentedFilePath = join(basePath, MODULE_AUGMENTATION_FILENAME);
const {program} = createMigrationProgram(tree, tsconfigPath, basePath, fileName => {
// In case the module augmentation file has been requested, we return a source file that
// augments "@angular/core/testing" to include a named export called "async". This ensures that
// we can rely on the type checker for this migration after `async` has been removed.
if (fileName === MODULE_AUGMENTATION_FILENAME) {
if (basename(fileName) === MODULE_AUGMENTATION_FILENAME) {
return `
import '@angular/core/testing';
declare module "@angular/core/testing" {
@ -50,8 +54,8 @@ function runWaitForAsyncMigration(tree: Tree, tsconfigPath: string, basePath: st
}
`;
}
return null;
}, [MODULE_AUGMENTATION_FILENAME]);
return undefined;
}, [augmentedFilePath]);
const typeChecker = program.getTypeChecker();
const printer = ts.createPrinter();
const sourceFiles =

View File

@ -683,13 +683,13 @@ describe('static-queries migration with usage strategy', () => {
it('should not mark queries used in promises as static', async () => {
writeFile('/es2015.dom.d.ts', `
interface PromiseConstructor {
resolve(): Promise;
reject(): Promise;
resolve(): Promise<unknown>;
reject(): Promise<unknown>;
}
interface Promise {
then(cb: Function): Promise;
catch(cb: Function): Promise;
then(cb: Function): Promise<unknown>;
catch(cb: Function): Promise<unknown>;
}
declare var Promise: PromiseConstructor;

View File

@ -1484,7 +1484,10 @@ describe('Undecorated classes with DI migration', () => {
{flatModuleId: 'AUTOGENERATED', flatModuleOutFile: 'AUTOGENERATED'}
}));
writeFile('/second.ts', ``);
// This file doesn't do anything, but it's necessary in order to hit the code path for
// the assertion. As of TS 4.2 it needs to have _some_ kind of content, otherwise the
// compiler will throw an error.
writeFile('/second.ts', `export const foo = 1;`);
writeFile('/test.ts', `
import {Injectable, NgModule, NgZone} from '@angular/core';

View File

@ -10,7 +10,7 @@ import {dirname, relative, resolve} from 'path';
import * as ts from 'typescript';
import {parseTsconfigFile} from './parse_tsconfig';
export type FakeReadFileFn = (fileName: string) => string|null;
export type FakeReadFileFn = (fileName: string) => string|undefined;
/**
* Creates a TypeScript program instance for a TypeScript project within
@ -40,6 +40,7 @@ export function createMigrationCompilerHost(
tree: Tree, options: ts.CompilerOptions, basePath: string,
fakeRead?: FakeReadFileFn): ts.CompilerHost {
const host = ts.createCompilerHost(options, true);
const defaultReadFile = host.readFile;
// We need to overwrite the host "readFile" method, as we want the TypeScript
// program to be based on the file contents in the virtual file tree. Otherwise
@ -47,12 +48,19 @@ export function createMigrationCompilerHost(
// source files.
host.readFile = fileName => {
const treeRelativePath = relative(basePath, fileName);
const fakeOutput = fakeRead ? fakeRead(treeRelativePath) : null;
const buffer = fakeOutput === null ? tree.read(treeRelativePath) : fakeOutput;
let result: string|undefined = fakeRead?.(treeRelativePath);
if (result === undefined) {
// If the relative path resolved to somewhere outside of the tree, fall back to
// TypeScript's default file reading function since the `tree` will throw an error.
result = treeRelativePath.startsWith('..') ? defaultReadFile.call(host, fileName) :
tree.read(treeRelativePath)?.toString();
}
// Strip BOM as otherwise TSC methods (Ex: getWidth) will return an offset,
// which breaks the CLI UpdateRecorder.
// See: https://github.com/angular/angular/pull/30719
return buffer ? buffer.toString().replace(/^\uFEFF/, '') : undefined;
return result ? result.replace(/^\uFEFF/, '') : undefined;
};
return host;

View File

@ -5,7 +5,7 @@
"author": "angular",
"license": "MIT",
"dependencies": {
"tslib": "^2.0.0"
"tslib": "^2.1.0"
},
"peerDependencies": {
"@angular/core": "0.0.0-PLACEHOLDER",

View File

@ -5,7 +5,7 @@
"author": "angular",
"license": "MIT",
"dependencies": {
"tslib": "^2.0.0"
"tslib": "^2.1.0"
},
"peerDependencies": {
"@angular/core": "0.0.0-PLACEHOLDER",

View File

@ -216,7 +216,7 @@ describe('quick info', () => {
templateOverride: `<div *ngFor="let item o¦f heroes; trackBy: trackByFn;"></div>`,
expectedSpanText: 'of',
expectedDisplayString:
'(property) NgForOf<Hero, Hero[]>.ngForOf: Hero[] | (Hero[] & Iterable<Hero>) | null | undefined'
'(property) NgForOf<Hero, Hero[]>.ngForOf: (Hero[] & NgIterable<Hero>) | null | undefined'
});
});

View File

@ -830,8 +830,7 @@ describe('diagnostics', () => {
const tsDiags = tsLS.getSemanticDiagnostics(APP_COMPONENT);
expect(tsDiags.length).toBe(1);
expect(tsDiags[0].messageText)
.toBe(
`Module '"../node_modules/@angular/core/core"' has no exported member 'OpaqueToken'.`);
.toBe(`Module '"@angular/core"' has no exported member 'OpaqueToken'.`);
});
describe('templates', () => {

View File

@ -5,7 +5,7 @@
"author": "angular",
"license": "MIT",
"dependencies": {
"tslib": "^2.0.0"
"tslib": "^2.1.0"
},
"peerDependencies": {
"@angular/core": "0.0.0-PLACEHOLDER",

View File

@ -5,7 +5,7 @@
"author": "angular",
"license": "MIT",
"dependencies": {
"tslib": "^2.0.0"
"tslib": "^2.1.0"
},
"peerDependencies": {
"@angular/animations": "0.0.0-PLACEHOLDER",

View File

@ -9,7 +9,7 @@
import {DOCUMENT} from '@angular/common';
import {TestBed} from '@angular/core/testing';
import {BrowserModule, BrowserTransferStateModule, TransferState} from '@angular/platform-browser';
import {escapeHtml, makeStateKey, StateKey, unescapeHtml} from '@angular/platform-browser/src/browser/transfer_state';
import {escapeHtml, makeStateKey, unescapeHtml} from '@angular/platform-browser/src/browser/transfer_state';
(function() {
function removeScriptTag(doc: Document, id: string) {
@ -37,6 +37,7 @@ describe('TransferState', () => {
let doc: Document;
const TEST_KEY = makeStateKey<number>('test');
const BOOLEAN_KEY = makeStateKey<boolean>('boolean');
const DELAYED_KEY = makeStateKey<string>('delayed');
beforeEach(() => {
@ -80,9 +81,9 @@ describe('TransferState', () => {
it('supports setting and accessing value \'false\' via get', () => {
const transferState: TransferState = TestBed.inject(TransferState);
transferState.set(TEST_KEY, false);
expect(transferState.get(TEST_KEY, true)).toBe(false);
expect(transferState.hasKey(TEST_KEY)).toBe(true);
transferState.set(BOOLEAN_KEY, false);
expect(transferState.get(BOOLEAN_KEY, true)).toBe(false);
expect(transferState.hasKey(BOOLEAN_KEY)).toBe(true);
});
it('supports setting and accessing value \'null\' via get', () => {

View File

@ -14,7 +14,7 @@
},
"dependencies": {
"domino": "^2.1.2",
"tslib": "^2.0.0",
"tslib": "^2.1.0",
"xhr2": "^0.2.0"
},
"repository": {

View File

@ -18,7 +18,7 @@
},
"homepage": "https://github.com/angular/angular/tree/master/packages/router",
"dependencies": {
"tslib": "^2.0.0"
"tslib": "^2.1.0"
},
"peerDependencies": {
"@angular/core": "0.0.0-PLACEHOLDER",

View File

@ -5,7 +5,7 @@
"author": "angular",
"license": "MIT",
"dependencies": {
"tslib": "^2.0.0"
"tslib": "^2.1.0"
},
"peerDependencies": {
"@angular/core": "0.0.0-PLACEHOLDER",

View File

@ -5,7 +5,7 @@
"author": "angular",
"license": "MIT",
"dependencies": {
"tslib": "^2.0.0"
"tslib": "^2.1.0"
},
"peerDependencies": {
"@angular/core": "0.0.0-PLACEHOLDER",

View File

@ -8,7 +8,7 @@
"fesm2015": "./fesm2015/zone.js",
"typings": "./zone.d.ts",
"dependencies": {
"tslib": "^2.0.0"
"tslib": "^2.1.0"
},
"devDependencies": {
"@externs/nodejs": "^1.5.0",
@ -19,7 +19,7 @@
"mocha": "^3.1.2",
"mock-require": "3.0.3",
"promises-aplus-tests": "^2.1.2",
"typescript": "4.1.2"
"typescript": "4.2.3"
},
"scripts": {
"closuretest": "./scripts/closure/closure_compiler.sh",

View File

@ -17,8 +17,8 @@ describe('FileReader', ifEnvSupports('FileReader', function() {
// Android 4.3's native browser doesn't implement add/RemoveEventListener for FileReader
function supportsEventTargetFns() {
return FileReader.prototype.addEventListener &&
FileReader.prototype.removeEventListener;
return !!FileReader.prototype.addEventListener &&
!!FileReader.prototype.removeEventListener;
}
(<any>supportsEventTargetFns).message =
'FileReader#addEventListener and FileReader#removeEventListener';

View File

@ -14,6 +14,6 @@
"zone.js": "file:../../../../dist/bin/packages/zone.js/npm_package"
},
"devDependencies": {
"typescript": "~4.1.2"
"typescript": "~4.2.3"
}
}

View File

@ -3745,10 +3745,10 @@ tr46@^2.0.2:
dependencies:
punycode "^2.1.1"
tslib@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.0.1.tgz#410eb0d113e5b6356490eec749603725b021b43e"
integrity sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ==
tslib@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.1.0.tgz#da60860f1c2ecaa5703ab7d39bc05b6bf988b97a"
integrity sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==
tunnel-agent@^0.6.0:
version "0.6.0"
@ -3786,10 +3786,10 @@ typedarray-to-buffer@^3.1.5:
dependencies:
is-typedarray "^1.0.0"
typescript@4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.2.tgz#6369ef22516fe5e10304aae5a5c4862db55380e9"
integrity sha512-thGloWsGH3SOxv1SoY7QojKi0tc+8FnOmiarEGMbd/lar7QOEd3hvlx3Fp5y6FlDUGl9L+pd4n2e+oToGMmhRQ==
typescript@4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.3.tgz#39062d8019912d43726298f09493d598048c1ce3"
integrity sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw==
underscore@~1.8.3:
version "1.8.3"

View File

@ -27,7 +27,7 @@
"chai": "^4.1.2",
"jasmine": "^3.1.0",
"source-map-support": "^0.5.9",
"typescript": "4.1.2"
"typescript": "4.2.3"
},
"keywords": [
"typescript"

View File

@ -15262,10 +15262,10 @@ tslib@^1.13.0:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.13.0.tgz#c881e13cc7015894ed914862d276436fa9a47043"
integrity sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==
tslib@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.0.0.tgz#18d13fc2dce04051e20f074cc8387fd8089ce4f3"
integrity sha512-lTqkx847PI7xEDYJntxZH89L2/aXInsyF2luSafe/+0fHOMjlBNXdH6th7f70qxLDhul7KZK0zC8V5ZIyHl0/g==
tslib@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.1.0.tgz#da60860f1c2ecaa5703ab7d39bc05b6bf988b97a"
integrity sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==
tslint-eslint-rules@5.4.0:
version "5.4.0"
@ -15445,10 +15445,10 @@ typescript@~3.7.2:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.5.tgz#0692e21f65fd4108b9330238aac11dd2e177a1ae"
integrity sha512-/P5lkRXkWHNAbcJIiHPfRoKqyd7bsyCma1hZNUGfn20qm64T6ZBlrzprymeu918H+mB/0rIg2gGK/BXkhhYgBw==
typescript@~4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.2.tgz#6369ef22516fe5e10304aae5a5c4862db55380e9"
integrity sha512-thGloWsGH3SOxv1SoY7QojKi0tc+8FnOmiarEGMbd/lar7QOEd3hvlx3Fp5y6FlDUGl9L+pd4n2e+oToGMmhRQ==
typescript@~4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.3.tgz#39062d8019912d43726298f09493d598048c1ce3"
integrity sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw==
uglify-js@^1.3.3:
version "1.3.5"