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", "shelljs": "^0.8.4",
"source-map-support": "^0.5.19", "source-map-support": "^0.5.19",
"tar-stream": "^2.1.3", "tar-stream": "^2.1.3",
"tslib": "^2.0.1" "tslib": "^2.1.0"
}, },
"devDependencies": { "devDependencies": {
"@types/body-parser": "^1.19.0", "@types/body-parser": "^1.19.0",
@ -49,6 +49,6 @@
"supertest": "^4.0.2", "supertest": "^4.0.2",
"tslint": "^6.1.3", "tslint": "^6.1.3",
"tslint-jasmine-noSkipOrFocus": "^1.0.9", "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" version "1.9.3"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286"
tslib@^2.0.1: tslib@^2.1.0:
version "2.0.1" version "2.1.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.0.1.tgz#410eb0d113e5b6356490eec749603725b021b43e" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.1.0.tgz#da60860f1c2ecaa5703ab7d39bc05b6bf988b97a"
integrity sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ== integrity sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==
tslint-jasmine-noSkipOrFocus@^1.0.9: tslint-jasmine-noSkipOrFocus@^1.0.9:
version "1.0.9" version "1.0.9"
@ -2563,10 +2563,10 @@ typedarray-to-buffer@^3.1.5:
dependencies: dependencies:
is-typedarray "^1.0.0" is-typedarray "^1.0.0"
typescript@^4.1.2: typescript@^4.2.3:
version "4.1.2" version "4.2.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.2.tgz#6369ef22516fe5e10304aae5a5c4862db55380e9" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.3.tgz#39062d8019912d43726298f09493d598048c1ce3"
integrity sha512-thGloWsGH3SOxv1SoY7QojKi0tc+8FnOmiarEGMbd/lar7QOEd3hvlx3Fp5y6FlDUGl9L+pd4n2e+oToGMmhRQ== integrity sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw==
undefsafe@^2.0.2: undefsafe@^2.0.2:
version "2.0.2" version "2.0.2"

View File

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

View File

@ -104,7 +104,7 @@
"@angular/service-worker": "11.2.3", "@angular/service-worker": "11.2.3",
"@webcomponents/custom-elements": "1.2.1", "@webcomponents/custom-elements": "1.2.1",
"rxjs": "^6.5.3", "rxjs": "^6.5.3",
"tslib": "^2.0.0", "tslib": "^2.1.0",
"zone.js": "~0.11.4" "zone.js": "~0.11.4"
}, },
"devDependencies": { "devDependencies": {
@ -170,7 +170,7 @@
"tree-kill": "^1.1.0", "tree-kill": "^1.1.0",
"ts-node": "^8.4.1", "ts-node": "^8.4.1",
"tslint": "~6.1.0", "tslint": "~6.1.0",
"typescript": "~4.1.2", "typescript": "~4.2.3",
"uglify-js": "^3.0.15", "uglify-js": "^3.0.15",
"unist-util-filter": "^0.2.1", "unist-util-filter": "^0.2.1",
"unist-util-source": "^1.0.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" resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.5.tgz#0692e21f65fd4108b9330238aac11dd2e177a1ae"
integrity sha512-/P5lkRXkWHNAbcJIiHPfRoKqyd7bsyCma1hZNUGfn20qm64T6ZBlrzprymeu918H+mB/0rIg2gGK/BXkhhYgBw== integrity sha512-/P5lkRXkWHNAbcJIiHPfRoKqyd7bsyCma1hZNUGfn20qm64T6ZBlrzprymeu918H+mB/0rIg2gGK/BXkhhYgBw==
typescript@~4.1.2: typescript@~4.2.3:
version "4.1.5" version "4.2.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.5.tgz#123a3b214aaff3be32926f0d8f1f6e704eb89a72" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.3.tgz#39062d8019912d43726298f09493d598048c1ce3"
integrity sha512-6OSu9PTIzmn9TCDiovULTnET6BgXtDYL4Gg4szY+cGsc3JP1dQL8qvE8kShTRx1NIw4Q9IBHlwODjkjWEtMUyA== integrity sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw==
ua-parser-js@^0.7.23: ua-parser-js@^0.7.23:
version "0.7.24" version "0.7.24"

View File

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

View File

@ -239,7 +239,7 @@ function promptAutocomplete(message, choices, noChoiceText) {
case 0: case 0:
prompt = inquirer.createPromptModule({}).registerPrompt('autocomplete', inquirerAutocomplete); prompt = inquirer.createPromptModule({}).registerPrompt('autocomplete', inquirerAutocomplete);
if (noChoiceText) { if (noChoiceText) {
choices = tslib.__spread([noChoiceText], choices); choices = tslib.__spreadArray([noChoiceText], tslib.__read(choices));
} }
return [4 /*yield*/, prompt({ return [4 /*yield*/, prompt({
type: 'autocomplete', type: 'autocomplete',
@ -313,7 +313,7 @@ function buildLogLevelFunction(loadCommand, level) {
for (var _i = 0; _i < arguments.length; _i++) { for (var _i = 0; _i < arguments.length; _i++) {
text[_i] = arguments[_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. */ /** Start a group at the LOG_LEVEL, optionally starting it as collapsed. */
loggingFunction.group = function (text, collapsed) { loggingFunction.group = function (text, collapsed) {
@ -342,9 +342,9 @@ function runConsoleCommand(loadCommand, logLevel) {
text[_i - 2] = arguments[_i]; text[_i - 2] = arguments[_i];
} }
if (getLogLevel() >= logLevel) { 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 * 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 diffFiles = gitOutputAsArray("git diff --name-only --diff-filter=d " + sha);
var untrackedFiles = gitOutputAsArray("git ls-files --others --exclude-standard"); 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. // 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. * A list of all staged files which have been modified.
@ -2947,7 +2947,7 @@ function getPr(prSchema, prNumber, git) {
PR_QUERY = typedGraphqlify.params({ PR_QUERY = typedGraphqlify.params({
$number: 'Int!', $number: 'Int!',
$owner: 'String!', $owner: 'String!',
$name: 'String!', $name: 'String!', // The organization to query for
}, { }, {
repository: typedGraphqlify.params({ owner: '$owner', name: '$name' }, { repository: typedGraphqlify.params({ owner: '$owner', name: '$name' }, {
pullRequest: typedGraphqlify.params({ number: '$number' }, prSchema), pullRequest: typedGraphqlify.params({ number: '$number' }, prSchema),
@ -2973,7 +2973,7 @@ function getPendingPrs(prSchema, git) {
$first: 'Int', $first: 'Int',
$after: 'String', $after: 'String',
$owner: 'String!', $owner: 'String!',
$name: 'String!', $name: 'String!', // The repository to query for
}, { }, {
repository: typedGraphqlify.params({ owner: '$owner', name: '$name' }, { repository: typedGraphqlify.params({ owner: '$owner', name: '$name' }, {
pullRequests: typedGraphqlify.params({ pullRequests: typedGraphqlify.params({
@ -3003,7 +3003,7 @@ function getPendingPrs(prSchema, git) {
return [4 /*yield*/, git.github.graphql.query(PRS_QUERY, params_1)]; return [4 /*yield*/, git.github.graphql.query(PRS_QUERY, params_1)];
case 2: case 2:
results = _b.sent(); 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; hasNextPage = results.repository.pullRequests.pageInfo.hasNextPage;
cursor = results.repository.pullRequests.pageInfo.endCursor; cursor = results.repository.pullRequests.pageInfo.endCursor;
return [3 /*break*/, 1]; return [3 /*break*/, 1];
@ -3598,7 +3598,7 @@ var MergeStrategy = /** @class */ (function () {
// Checkout the local target branch. // Checkout the local target branch.
this.git.run(['checkout', localTargetBranch]); this.git.run(['checkout', localTargetBranch]);
// Cherry-pick the refspec into the target branch. // 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 // Abort the failed cherry-pick. We do this because Git persists the failed
// cherry-pick state globally in the repository. This could prevent future // 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. // 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 // Fetch all target branches with a single command. We don't want to fetch them
// individually as that could cause an unnecessary slow-down. // 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. */ /** Pushes the given target branches upstream. */
MergeStrategy.prototype.pushTargetBranchesUpstream = function (names) { 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. // 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. // 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; return MergeStrategy;
}()); }());

View File

@ -97,6 +97,12 @@ INTEGRATION_TESTS = {
# root @npm//typescript package. # root @npm//typescript package.
"pinned_npm_packages": ["typescript"], "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", "systemjs": "0.18.10",
"terser": "^4.4.0", "terser": "^4.4.0",
"tsickle": "0.38.1", "tsickle": "0.38.1",
"tslib": "^2.0.0", "tslib": "^2.1.0",
"tslint": "6.1.3", "tslint": "6.1.3",
"typescript": "~4.1.2", "typescript": "~4.2.3",
"xhr2": "0.2.0", "xhr2": "0.2.0",
"yaml": "^1.10.0", "yaml": "^1.10.0",
"yargs": "^16.1.1" "yargs": "^16.1.1"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -60,7 +60,7 @@ describe('type check blocks', () => {
selector: '[dir]', selector: '[dir]',
inputs: {inputA: 'inputA'}, 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', () => { it('should handle multiple bindings to the same property', () => {
@ -135,7 +135,7 @@ describe('type check blocks', () => {
}]; }];
expect(tcb(TEMPLATE, DIRECTIVES)) expect(tcb(TEMPLATE, DIRECTIVES))
.toContain( .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', () => { it('should handle multiple bindings to the same property', () => {
@ -261,7 +261,7 @@ describe('type check blocks', () => {
}]; }];
expect(tcb(TEMPLATE, DIRECTIVES)) expect(tcb(TEMPLATE, DIRECTIVES))
.toContain( .toContain(
'var _t1: typeof Dir.ngAcceptInputType_fieldA = (null!); ' + 'var _t1: typeof Dir.ngAcceptInputType_fieldA = null!; ' +
'_t1 = (((ctx).foo));'); '_t1 = (((ctx).foo));');
}); });
}); });
@ -321,11 +321,11 @@ describe('type check blocks', () => {
}, },
]; ];
const block = tcb(TEMPLATE, DIRECTIVES); 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('_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('_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('var _t3 = _t4;');
expect(block).toContain('(_t3).a'); expect(block).toContain('(_t3).a');
expect(block).not.toContain('NoBindings'); expect(block).not.toContain('NoBindings');
@ -355,7 +355,7 @@ describe('type check blocks', () => {
}]; }];
expect(tcb(TEMPLATE, DIRECTIVES)) expect(tcb(TEMPLATE, DIRECTIVES))
.toContain( .toContain(
'var _t2: Dir = (null!); ' + 'var _t2: Dir = null!; ' +
'var _t1 = _t2; ' + 'var _t1 = _t2; ' +
'"" + (((_t1).value));'); '"" + (((_t1).value));');
}); });
@ -383,7 +383,7 @@ describe('type check blocks', () => {
inputs: {'color': 'color', 'strong': 'strong', 'enabled': 'enabled'}, inputs: {'color': 'color', 'strong': 'strong', 'enabled': 'enabled'},
}]; }];
const block = tcb(TEMPLATE, DIRECTIVES); 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('"color"');
expect(block).not.toContain('"strong"'); expect(block).not.toContain('"strong"');
expect(block).not.toContain('"enabled"'); expect(block).not.toContain('"enabled"');
@ -403,7 +403,7 @@ describe('type check blocks', () => {
}]; }];
expect(tcb(TEMPLATE, DIRECTIVES)) expect(tcb(TEMPLATE, DIRECTIVES))
.toContain( .toContain(
'var _t2: Dir = (null!); ' + 'var _t2: Dir = null!; ' +
'var _t1 = _t2; ' + 'var _t1 = _t2; ' +
'_t2.input = (_t1);'); '_t2.input = (_t1);');
}); });
@ -431,9 +431,9 @@ describe('type check blocks', () => {
]; ];
expect(tcb(TEMPLATE, DIRECTIVES)) expect(tcb(TEMPLATE, DIRECTIVES))
.toContain( .toContain(
'var _t2: DirB = (null!); ' + 'var _t2: DirB = null!; ' +
'var _t1 = _t2; ' + 'var _t1 = _t2; ' +
'var _t3: DirA = (null!); ' + 'var _t3: DirA = null!; ' +
'_t3.inputA = (_t1); ' + '_t3.inputA = (_t1); ' +
'var _t4 = _t3; ' + 'var _t4 = _t3; ' +
'_t2.inputA = (_t4);'); '_t2.inputA = (_t4);');
@ -451,7 +451,7 @@ describe('type check blocks', () => {
undeclaredInputFields: ['fieldA'] undeclaredInputFields: ['fieldA']
}]; }];
const block = tcb(TEMPLATE, DIRECTIVES); 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)); '); expect(block).toContain('(((ctx).foo)); ');
}); });
@ -468,8 +468,8 @@ describe('type check blocks', () => {
}]; }];
expect(tcb(TEMPLATE, DIRECTIVES)) expect(tcb(TEMPLATE, DIRECTIVES))
.toContain( .toContain(
'var _t1: Dir = (null!); ' + 'var _t1: Dir = null!; ' +
'var _t2: typeof _t1["fieldA"] = (null!); ' + 'var _t2: typeof _t1["fieldA"] = null!; ' +
'_t2 = (((ctx).foo)); '); '_t2 = (((ctx).foo)); ');
}); });
@ -487,7 +487,7 @@ describe('type check blocks', () => {
}]; }];
const block = tcb(TEMPLATE, DIRECTIVES); const block = tcb(TEMPLATE, DIRECTIVES);
expect(block).toContain( expect(block).toContain(
'var _t1: Dir = (null!); ' + 'var _t1: Dir = null!; ' +
'_t1["some-input.xs"] = (((ctx).foo)); '); '_t1["some-input.xs"] = (((ctx).foo)); ');
}); });
@ -504,7 +504,7 @@ describe('type check blocks', () => {
}]; }];
expect(tcb(TEMPLATE, DIRECTIVES)) expect(tcb(TEMPLATE, DIRECTIVES))
.toContain( .toContain(
'var _t1: Dir = (null!); ' + 'var _t1: Dir = null!; ' +
'_t1.field2 = _t1.field1 = (((ctx).foo));'); '_t1.field2 = _t1.field1 = (((ctx).foo));');
}); });
@ -523,8 +523,8 @@ describe('type check blocks', () => {
}]; }];
expect(tcb(TEMPLATE, DIRECTIVES)) expect(tcb(TEMPLATE, DIRECTIVES))
.toContain( .toContain(
'var _t1: typeof Dir.ngAcceptInputType_field1 = (null!); ' + 'var _t1: typeof Dir.ngAcceptInputType_field1 = null!; ' +
'var _t2: Dir = (null!); ' + 'var _t2: Dir = null!; ' +
'_t2.field2 = _t1 = (((ctx).foo));'); '_t2.field2 = _t1 = (((ctx).foo));');
}); });
@ -543,7 +543,7 @@ describe('type check blocks', () => {
}]; }];
expect(tcb(TEMPLATE, DIRECTIVES)) expect(tcb(TEMPLATE, DIRECTIVES))
.toContain( .toContain(
'var _t1: Dir = (null!); ' + 'var _t1: Dir = null!; ' +
'_t1.field2 = (((ctx).foo));'); '_t1.field2 = (((ctx).foo));');
}); });
@ -559,9 +559,9 @@ describe('type check blocks', () => {
coercedInputFields: ['fieldA'], coercedInputFields: ['fieldA'],
}]; }];
const block = tcb(TEMPLATE, DIRECTIVES); const block = tcb(TEMPLATE, DIRECTIVES);
expect(block).not.toContain('var _t1: Dir = (null!);'); expect(block).not.toContain('var _t1: Dir = null!;');
expect(block).toContain( expect(block).toContain(
'var _t1: typeof Dir.ngAcceptInputType_fieldA = (null!); ' + 'var _t1: typeof Dir.ngAcceptInputType_fieldA = null!; ' +
'_t1 = (((ctx).foo));'); '_t1 = (((ctx).foo));');
}); });
@ -578,9 +578,9 @@ describe('type check blocks', () => {
undeclaredInputFields: ['fieldA'], undeclaredInputFields: ['fieldA'],
}]; }];
const block = tcb(TEMPLATE, DIRECTIVES); const block = tcb(TEMPLATE, DIRECTIVES);
expect(block).not.toContain('var _t1: Dir = (null!);'); expect(block).not.toContain('var _t1: Dir = null!;');
expect(block).toContain( expect(block).toContain(
'var _t1: typeof Dir.ngAcceptInputType_fieldA = (null!); ' + 'var _t1: typeof Dir.ngAcceptInputType_fieldA = null!; ' +
'_t1 = (((ctx).foo));'); '_t1 = (((ctx).foo));');
}); });
@ -893,7 +893,7 @@ describe('type check blocks', () => {
TypeCheckingConfig = {...BASE_CONFIG, checkTypeOfDomReferences: false}; TypeCheckingConfig = {...BASE_CONFIG, checkTypeOfDomReferences: false};
const block = tcb(TEMPLATE, [], DISABLED_CONFIG); const block = tcb(TEMPLATE, [], DISABLED_CONFIG);
expect(block).toContain( expect(block).toContain(
'var _t1 = (_t2 as any); ' + 'var _t1 = _t2 as any; ' +
'"" + (((_t1).value));'); '"" + (((_t1).value));');
}); });
}); });
@ -928,7 +928,7 @@ describe('type check blocks', () => {
TypeCheckingConfig = {...BASE_CONFIG, checkTypeOfNonDomReferences: false}; TypeCheckingConfig = {...BASE_CONFIG, checkTypeOfNonDomReferences: false};
const block = tcb(TEMPLATE, DIRECTIVES, DISABLED_CONFIG); const block = tcb(TEMPLATE, DIRECTIVES, DISABLED_CONFIG);
expect(block).toContain( expect(block).toContain(
'var _t1 = (_t2 as any); ' + 'var _t1 = _t2 as any; ' +
'"" + (((_t1).value));'); '"" + (((_t1).value));');
}); });
}); });
@ -983,8 +983,8 @@ describe('type check blocks', () => {
it('should use undefined for safe navigation operations when enabled', () => { it('should use undefined for safe navigation operations when enabled', () => {
const block = tcb(TEMPLATE, DIRECTIVES); const block = tcb(TEMPLATE, DIRECTIVES);
expect(block).toContain('((null as any) ? (((ctx).a))!.method() : undefined)'); 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))!.b : undefined)');
}); });
it('should use an \'any\' type for safe navigation operations when disabled', () => { it('should use an \'any\' type for safe navigation operations when disabled', () => {
const DISABLED_CONFIG: const DISABLED_CONFIG:
@ -999,8 +999,8 @@ describe('type check blocks', () => {
const TEMPLATE = `{{a.method()?.b}} {{a()?.method()}}`; const TEMPLATE = `{{a.method()?.b}} {{a()?.method()}}`;
it('should check the presence of a property/method on the receiver when enabled', () => { it('should check the presence of a property/method on the receiver when enabled', () => {
const block = tcb(TEMPLATE, DIRECTIVES); 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())!.b : undefined)');
expect(block).toContain('((null as any) ? ((ctx).a())!.method() : 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', () => { it('should not check the presence of a property/method on the receiver when disabled', () => {
const DISABLED_CONFIG: const DISABLED_CONFIG:
@ -1045,7 +1045,7 @@ describe('type check blocks', () => {
TypeCheckingConfig = {...BASE_CONFIG, honorAccessModifiersForInputBindings: true}; TypeCheckingConfig = {...BASE_CONFIG, honorAccessModifiersForInputBindings: true};
const block = tcb(TEMPLATE, DIRECTIVES, enableChecks); const block = tcb(TEMPLATE, DIRECTIVES, enableChecks);
expect(block).toContain( expect(block).toContain(
'var _t1: Dir = (null!); ' + 'var _t1: Dir = null!; ' +
'_t1["some-input.xs"] = (((ctx).foo)); '); '_t1["some-input.xs"] = (((ctx).foo)); ');
}); });
@ -1063,7 +1063,7 @@ describe('type check blocks', () => {
TypeCheckingConfig = {...BASE_CONFIG, honorAccessModifiersForInputBindings: true}; TypeCheckingConfig = {...BASE_CONFIG, honorAccessModifiersForInputBindings: true};
const block = tcb(TEMPLATE, DIRECTIVES, enableChecks); const block = tcb(TEMPLATE, DIRECTIVES, enableChecks);
expect(block).toContain( expect(block).toContain(
'var _t1: Dir = (null!); ' + 'var _t1: Dir = null!; ' +
'_t1.fieldA = (((ctx).foo)); '); '_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 * Note: this check is disabled in g3, search for
* `angularCompilerOptions.disableTypeScriptVersionCheck` config param value in g3. * `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 * 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(); let diags = env.driveDiagnostics();
expect(diags.length).toBe(1); 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. // On a rebuild, the same errors should be present.
diags = env.driveDiagnostics(); diags = env.driveDiagnostics();
expect(diags.length).toBe(1); 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", "author": "angular",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"tslib": "^2.0.0" "tslib": "^2.1.0"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

View File

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

View File

@ -7,7 +7,7 @@
*/ */
import {Rule, SchematicsException, Tree} from '@angular-devkit/schematics'; import {Rule, SchematicsException, Tree} from '@angular-devkit/schematics';
import {relative} from 'path'; import {basename, join, relative} from 'path';
import * as ts from 'typescript'; import * as ts from 'typescript';
import {getProjectTsConfigPaths} from '../../utils/project_tsconfig_paths'; import {getProjectTsConfigPaths} from '../../utils/project_tsconfig_paths';
@ -43,11 +43,15 @@ export default function(): Rule {
} }
function runRendererToRenderer2Migration(tree: Tree, tsconfigPath: string, basePath: string) { 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 => { const {program} = createMigrationProgram(tree, tsconfigPath, basePath, fileName => {
// In case the module augmentation file has been requested, we return a source file that // 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 // 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. // 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 ` return `
import '@angular/core'; import '@angular/core';
declare module "@angular/core" { declare module "@angular/core" {
@ -55,8 +59,8 @@ function runRendererToRenderer2Migration(tree: Tree, tsconfigPath: string, baseP
} }
`; `;
} }
return null; return undefined;
}, [MODULE_AUGMENTATION_FILENAME]); }, [augmentedFilePath]);
const typeChecker = program.getTypeChecker(); const typeChecker = program.getTypeChecker();
const printer = ts.createPrinter(); const printer = ts.createPrinter();
const sourceFiles = const sourceFiles =

View File

@ -7,7 +7,7 @@
*/ */
import {Rule, SchematicsException, Tree} from '@angular-devkit/schematics'; import {Rule, SchematicsException, Tree} from '@angular-devkit/schematics';
import {relative} from 'path'; import {basename, join, relative} from 'path';
import * as ts from 'typescript'; import * as ts from 'typescript';
import {getProjectTsConfigPaths} from '../../utils/project_tsconfig_paths'; import {getProjectTsConfigPaths} from '../../utils/project_tsconfig_paths';
@ -38,11 +38,15 @@ export default function(): Rule {
} }
function runWaitForAsyncMigration(tree: Tree, tsconfigPath: string, basePath: string) { 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 => { const {program} = createMigrationProgram(tree, tsconfigPath, basePath, fileName => {
// In case the module augmentation file has been requested, we return a source file that // 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 // 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. // 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 ` return `
import '@angular/core/testing'; import '@angular/core/testing';
declare module "@angular/core/testing" { declare module "@angular/core/testing" {
@ -50,8 +54,8 @@ function runWaitForAsyncMigration(tree: Tree, tsconfigPath: string, basePath: st
} }
`; `;
} }
return null; return undefined;
}, [MODULE_AUGMENTATION_FILENAME]); }, [augmentedFilePath]);
const typeChecker = program.getTypeChecker(); const typeChecker = program.getTypeChecker();
const printer = ts.createPrinter(); const printer = ts.createPrinter();
const sourceFiles = 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 () => { it('should not mark queries used in promises as static', async () => {
writeFile('/es2015.dom.d.ts', ` writeFile('/es2015.dom.d.ts', `
interface PromiseConstructor { interface PromiseConstructor {
resolve(): Promise; resolve(): Promise<unknown>;
reject(): Promise; reject(): Promise<unknown>;
} }
interface Promise { interface Promise {
then(cb: Function): Promise; then(cb: Function): Promise<unknown>;
catch(cb: Function): Promise; catch(cb: Function): Promise<unknown>;
} }
declare var Promise: PromiseConstructor; declare var Promise: PromiseConstructor;

View File

@ -1484,7 +1484,10 @@ describe('Undecorated classes with DI migration', () => {
{flatModuleId: 'AUTOGENERATED', flatModuleOutFile: 'AUTOGENERATED'} {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', ` writeFile('/test.ts', `
import {Injectable, NgModule, NgZone} from '@angular/core'; 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 * as ts from 'typescript';
import {parseTsconfigFile} from './parse_tsconfig'; 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 * Creates a TypeScript program instance for a TypeScript project within
@ -40,6 +40,7 @@ export function createMigrationCompilerHost(
tree: Tree, options: ts.CompilerOptions, basePath: string, tree: Tree, options: ts.CompilerOptions, basePath: string,
fakeRead?: FakeReadFileFn): ts.CompilerHost { fakeRead?: FakeReadFileFn): ts.CompilerHost {
const host = ts.createCompilerHost(options, true); const host = ts.createCompilerHost(options, true);
const defaultReadFile = host.readFile;
// We need to overwrite the host "readFile" method, as we want the TypeScript // 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 // program to be based on the file contents in the virtual file tree. Otherwise
@ -47,12 +48,19 @@ export function createMigrationCompilerHost(
// source files. // source files.
host.readFile = fileName => { host.readFile = fileName => {
const treeRelativePath = relative(basePath, fileName); const treeRelativePath = relative(basePath, fileName);
const fakeOutput = fakeRead ? fakeRead(treeRelativePath) : null; let result: string|undefined = fakeRead?.(treeRelativePath);
const buffer = fakeOutput === null ? tree.read(treeRelativePath) : fakeOutput;
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, // Strip BOM as otherwise TSC methods (Ex: getWidth) will return an offset,
// which breaks the CLI UpdateRecorder. // which breaks the CLI UpdateRecorder.
// See: https://github.com/angular/angular/pull/30719 // See: https://github.com/angular/angular/pull/30719
return buffer ? buffer.toString().replace(/^\uFEFF/, '') : undefined; return result ? result.replace(/^\uFEFF/, '') : undefined;
}; };
return host; return host;

View File

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

View File

@ -5,7 +5,7 @@
"author": "angular", "author": "angular",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"tslib": "^2.0.0" "tslib": "^2.1.0"
}, },
"peerDependencies": { "peerDependencies": {
"@angular/core": "0.0.0-PLACEHOLDER", "@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>`, templateOverride: `<div *ngFor="let item o¦f heroes; trackBy: trackByFn;"></div>`,
expectedSpanText: 'of', expectedSpanText: 'of',
expectedDisplayString: 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); const tsDiags = tsLS.getSemanticDiagnostics(APP_COMPONENT);
expect(tsDiags.length).toBe(1); expect(tsDiags.length).toBe(1);
expect(tsDiags[0].messageText) expect(tsDiags[0].messageText)
.toBe( .toBe(`Module '"@angular/core"' has no exported member 'OpaqueToken'.`);
`Module '"../node_modules/@angular/core/core"' has no exported member 'OpaqueToken'.`);
}); });
describe('templates', () => { describe('templates', () => {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -8,7 +8,7 @@
"fesm2015": "./fesm2015/zone.js", "fesm2015": "./fesm2015/zone.js",
"typings": "./zone.d.ts", "typings": "./zone.d.ts",
"dependencies": { "dependencies": {
"tslib": "^2.0.0" "tslib": "^2.1.0"
}, },
"devDependencies": { "devDependencies": {
"@externs/nodejs": "^1.5.0", "@externs/nodejs": "^1.5.0",
@ -19,7 +19,7 @@
"mocha": "^3.1.2", "mocha": "^3.1.2",
"mock-require": "3.0.3", "mock-require": "3.0.3",
"promises-aplus-tests": "^2.1.2", "promises-aplus-tests": "^2.1.2",
"typescript": "4.1.2" "typescript": "4.2.3"
}, },
"scripts": { "scripts": {
"closuretest": "./scripts/closure/closure_compiler.sh", "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 // Android 4.3's native browser doesn't implement add/RemoveEventListener for FileReader
function supportsEventTargetFns() { function supportsEventTargetFns() {
return FileReader.prototype.addEventListener && return !!FileReader.prototype.addEventListener &&
FileReader.prototype.removeEventListener; !!FileReader.prototype.removeEventListener;
} }
(<any>supportsEventTargetFns).message = (<any>supportsEventTargetFns).message =
'FileReader#addEventListener and FileReader#removeEventListener'; 'FileReader#addEventListener and FileReader#removeEventListener';

View File

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

View File

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

View File

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

View File

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