Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aio/aio-builds-setup/dockerbuild/scripts-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@
"supertest": "^4.0.2",
"tslint": "^6.1.3",
"tslint-jasmine-noSkipOrFocus": "^1.0.9",
"typescript": "^4.0.2"
"typescript": "^4.1.2"
}
}
8 changes: 4 additions & 4 deletions aio/aio-builds-setup/dockerbuild/scripts-js/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2563,10 +2563,10 @@ typedarray-to-buffer@^3.1.5:
dependencies:
is-typedarray "^1.0.0"

typescript@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.2.tgz#7ea7c88777c723c681e33bf7988be5d008d05ac2"
integrity sha512-e4ERvRV2wb+rRZ/IQeb3jm2VxBsirQLpQhdxplZ2MEzGvDkkMmPglecnNDfSUBivMjP93vRbngYYDQqQ/78bcQ==
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==

undefsafe@^2.0.2:
version "2.0.2"
Expand Down
2 changes: 1 addition & 1 deletion aio/src/app/custom-elements/elements-loader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,6 @@ class FakeModuleFactory extends NgModuleFactory<any> {

function returnPromisesFromSpy(spy: jasmine.Spy): Deferred[] {
const deferreds: Deferred[] = [];
spy.and.callFake(() => new Promise((resolve, reject) => deferreds.push({resolve, reject})));
spy.and.callFake(() => new Promise<void>((resolve, reject) => deferreds.push({resolve, reject})));
return deferreds;
}
7 changes: 1 addition & 6 deletions aio/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13658,7 +13658,7 @@ typedarray@^0.0.6:
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=

typescript@4.0.5:
typescript@4.0.5, typescript@~4.0.2:
version "4.0.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.5.tgz#ae9dddfd1069f1cb5beb3ef3b2170dd7c1332389"
integrity sha512-ywmr/VrTVCmNTJ6iV2LwIrfG1P+lv6luD8sUJs+2eI9NLGigaN+nUQc13iHqisq7bra9lnmUSYqbJvegraBOPQ==
Expand All @@ -13668,11 +13668,6 @@ typescript@^3.2.2:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.5.tgz#0692e21f65fd4108b9330238aac11dd2e177a1ae"
integrity sha512-/P5lkRXkWHNAbcJIiHPfRoKqyd7bsyCma1hZNUGfn20qm64T6ZBlrzprymeu918H+mB/0rIg2gGK/BXkhhYgBw==

typescript@~4.0.2:
version "4.0.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.3.tgz#153bbd468ef07725c1df9c77e8b453f8d36abba5"
integrity sha512-tEu6DGxGgRJPb/mVPIZ48e69xCn2yRmCgYmDugAVwmJ6o+0u1RI18eO7E7WBTLYLaEVVOhwQmcdhQHweux/WPg==

ua-parser-js@0.7.21:
version "0.7.21"
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.21.tgz#853cf9ce93f642f67174273cc34565ae6f308777"
Expand Down
4 changes: 2 additions & 2 deletions dev-infra/caretaker/check/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export abstract class BaseModule<Data> {
protected git: GitClient, protected config: NgDevConfig<{caretaker: CaretakerConfig}>) {}

/** Asyncronously retrieve data for the module. */
protected abstract async retrieveData(): Promise<Data>;
protected abstract retrieveData(): Promise<Data>;

/** Print the information discovered for the module to the terminal. */
abstract async printToTerminal(): Promise<void>;
abstract printToTerminal(): Promise<void>;
}
6 changes: 6 additions & 0 deletions integration/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ INTEGRATION_TESTS = {
# root @npm//typescript package.
"pinned_npm_packages": ["typescript"],
},
"typings_test_ts41": {
# Special case for `typings_test_ts41` test as we want to pin
# `typescript` at version 4.1.x for that test and not link to the
# root @npm//typescript package.
"pinned_npm_packages": ["typescript"],
},
}

[
Expand Down
67 changes: 67 additions & 0 deletions integration/typings_test_ts41/include-all.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* @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 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,
platformServerTesting,
router,
routerTesting,
routerUpgrade,
serviceWorker,
upgrade,
upgradeStatic,
upgradeTesting,
};
28 changes: 28 additions & 0 deletions integration/typings_test_ts41/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "angular-integration",
"description": "Assert that users with TypeScript 4.1 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.1.2",
"zone.js": "file:../../dist/zone.js-dist/archive/zone.js.tgz"
},
"scripts": {
"test": "tsc"
}
}
26 changes: 26 additions & 0 deletions integration/typings_test_ts41/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
2 changes: 1 addition & 1 deletion modules/benchmarks/src/expanding_rows/benchmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export async function execTimed(description: string, func: () => Promise<void>)
}

export async function nextTick(delay = 1) {
return new Promise((res, rej) => {
return new Promise<void>((res, rej) => {
setTimeout(() => {
res();
}, delay);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
"tsickle": "0.38.1",
"tslib": "^2.0.0",
"tslint": "6.1.3",
"typescript": "~4.0.2",
"typescript": "~4.1.2",
"xhr2": "0.2.0",
"yaml": "^1.10.0",
"yargs": "^16.1.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ export class TransitionAnimationEngine {
}

whenRenderingDone(): Promise<any> {
return new Promise(resolve => {
return new Promise<void>(resolve => {
if (this.players.length) {
return optimizeGroupPlayer(this.players).onDone(() => resolve());
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/bazel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@angular/compiler-cli": "0.0.0-PLACEHOLDER",
"@bazel/typescript": ">=1.0.0",
"terser": "^4.3.1",
"typescript": ">=4.0 <4.1",
"typescript": ">=4.0 <4.2",
"rollup": ">=1.20.0",
"rollup-plugin-commonjs": ">=9.0.0",
"rollup-plugin-node-resolve": ">=4.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/benchpress/src/common_options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class Options {
}

function writeFile(filename: string, content: string): Promise<any> {
return new Promise(function(resolve, reject) {
return new Promise<void>(function(resolve, reject) {
fs.writeFile(filename, content, (error) => {
if (error) {
reject(error);
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-cli/ngcc/src/host/commonjs_umd_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export function findNamespaceOfIdentifier(id: ts.Identifier): ts.Identifier|null
export function findRequireCallReference(id: ts.Identifier, checker: ts.TypeChecker): RequireCall|
null {
const symbol = checker.getSymbolAtLocation(id) || null;
const declaration = symbol && symbol.valueDeclaration;
const declaration = symbol?.valueDeclaration ?? symbol?.declarations?.[0];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change seems to have been due to microsoft/TypeScript#39770, where the variable declaration is now treated as an alias declaration which no longer has a value declaration.

const initializer =
declaration && ts.isVariableDeclaration(declaration) && declaration.initializer || null;
return initializer && isRequireCall(initializer) ? initializer : null;
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"peerDependencies": {
"@angular/compiler": "0.0.0-PLACEHOLDER",
"typescript": ">=4.0 <4.1"
"typescript": ">=4.0 <4.2"
},
"engines": {
"node": ">=10.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/compiler-cli/src/ngtsc/testing/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ enum TsStructureIsReused {
Completely = 2,
}

export function expectCompleteReuse(oldProgram: ts.Program): void {
export function expectCompleteReuse(program: ts.Program): void {
// Assert complete reuse using TypeScript's private API.
expect((oldProgram as any).structureIsReused)
expect((program as any).structureIsReused)
.toBe(TsStructureIsReused.Completely, COMPLETE_REUSE_FAILURE_MESSAGE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ runInEachFileSystem(() => {
programStrategy.updateFiles(
new Map([[typecheckPath, 'export const VERSION = 2;']]), UpdateMode.Complete);

expectCompleteReuse(program);
expectCompleteReuse(programStrategy.getProgram());
});

it('should have complete reuse if no structural changes are made to input files', () => {
Expand All @@ -56,7 +56,7 @@ runInEachFileSystem(() => {
programStrategy.updateFiles(
new Map([[mainPath, 'export const STILL_NOT_A_COMPONENT = true;']]), UpdateMode.Complete);

expectCompleteReuse(program);
expectCompleteReuse(programStrategy.getProgram());
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-cli/src/perform_watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export function performWatchCompilation(host: PerformWatchHost):

// Watch basePath, ignoring .dotfiles
let resolveReadyPromise: () => void;
const readyPromise = new Promise(resolve => resolveReadyPromise = resolve);
const readyPromise = new Promise<void>(resolve => resolveReadyPromise = resolve);
// Note: ! is ok as options are filled after the first compilation
// Note: ! is ok as resolvedReadyPromise is filled by the previous call
const fileWatcher =
Expand Down
19 changes: 18 additions & 1 deletion packages/compiler-cli/src/transformers/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ const LOWER_FIELDS = ['useValue', 'useFactory', 'data', 'id', 'loadChildren'];
*/
const R3_LOWER_FIELDS = [...LOWER_FIELDS, 'providers', 'imports', 'exports'];

/**
* Installs a handler for testing purposes to allow inspection of the temporary program.
*/
let tempProgramHandlerForTest: ((program: ts.Program) => void)|null = null;
export function setTempProgramHandlerForTest(handler: (program: ts.Program) => void): void {
tempProgramHandlerForTest = handler;
}
export function resetTempProgramHandlerForTest(): void {
tempProgramHandlerForTest = null;
}

const emptyModules: NgAnalyzedModules = {
ngModules: [],
ngModuleByPipeOrDirective: new Map(),
Expand Down Expand Up @@ -618,6 +629,9 @@ class AngularCompilerProgram implements Program {
}

const tmpProgram = ts.createProgram(rootNames, this.options, this.hostAdapter, oldTsProgram);
if (tempProgramHandlerForTest !== null) {
tempProgramHandlerForTest(tmpProgram);
}
const sourceFiles: string[] = [];
const tsFiles: string[] = [];
tmpProgram.getSourceFiles().forEach(sf => {
Expand Down Expand Up @@ -654,7 +668,10 @@ class AngularCompilerProgram implements Program {
// - we cache all the files in the hostAdapter
// - new new stubs use the exactly same imports/exports as the old once (we assert that in
// hostAdapter.updateGeneratedFile).
if (tsStructureIsReused(tmpProgram) !== StructureIsReused.Completely) {
// TS 4.1+ stores the reuse state in the new program
const checkReuseProgram =
(ts.versionMajorMinor as string) === '4.0' ? tmpProgram : this._tsProgram;
if (tsStructureIsReused(checkReuseProgram) !== StructureIsReused.Completely) {
throw new Error(`Internal Error: The structure of the program changed during codegen.`);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-cli/src/typescript_support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.1.0';
const MAX_TS_VERSION = '4.2.0';

/**
* The currently used version of TypeScript, which can be adjusted for testing purposes using
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-cli/test/ngc_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1671,7 +1671,7 @@ describe('ngc transformer command-line', () => {
const config = readCommandLineAndConfiguration(['-p', basePath]);
const compile = watchMode(config.project, config.options, errorSpy);

return new Promise(resolve => {
return new Promise<void>(resolve => {
compile.ready(() => {
cb();

Expand Down
Loading