From 5cf82f8f3fef4dbeb00c63a328334a167d129344 Mon Sep 17 00:00:00 2001 From: Lucas Sloan Date: Tue, 8 May 2018 13:37:54 -0700 Subject: [PATCH] build: upgrade to TypeScript 2.8 (#23782) PR Close #23782 --- integration/typings_test_ts27/package.json | 2 +- integration/typings_test_ts28/include-all.ts | 47 +++++++++++++++++++ integration/typings_test_ts28/package.json | 30 ++++++++++++ integration/typings_test_ts28/tsconfig.json | 24 ++++++++++ package.json | 4 +- packages/bazel/package.json | 2 +- packages/compiler-cli/package.json | 2 +- .../compiler-cli/src/transformers/program.ts | 2 +- .../core/src/sanitization/html_sanitizer.ts | 4 +- packages/core/src/sanitization/inert_body.ts | 2 +- packages/language-service/src/ts_plugin.ts | 11 +++-- .../service-worker/worker/testing/cache.ts | 3 +- .../src/common/downgrade_component_adapter.ts | 2 +- packages/upgrade/src/common/util.ts | 13 ----- yarn.lock | 12 ++--- 15 files changed, 127 insertions(+), 33 deletions(-) create mode 100644 integration/typings_test_ts28/include-all.ts create mode 100644 integration/typings_test_ts28/package.json create mode 100644 integration/typings_test_ts28/tsconfig.json diff --git a/integration/typings_test_ts27/package.json b/integration/typings_test_ts27/package.json index 766ba3fec9..cfacf41182 100644 --- a/integration/typings_test_ts27/package.json +++ b/integration/typings_test_ts27/package.json @@ -1,6 +1,6 @@ { "name": "angular-integration", - "description": "Assert that users with TypeScript 2.6 can type-check an Angular application", + "description": "Assert that users with TypeScript 2.7 can type-check an Angular application", "version": "0.0.0", "license": "MIT", "dependencies": { diff --git a/integration/typings_test_ts28/include-all.ts b/integration/typings_test_ts28/include-all.ts new file mode 100644 index 0000000000..78cefe0030 --- /dev/null +++ b/integration/typings_test_ts28/include-all.ts @@ -0,0 +1,47 @@ +/** + * @license + * Copyright Google Inc. 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 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 forms from '@angular/forms'; +import * as http from '@angular/http'; +import * as httpTesting from '@angular/http/testing'; +import * as platformBrowser from '@angular/platform-browser'; +import * as platformBrowserTesting from '@angular/platform-browser/testing'; +import * as platformBrowserDynamic from '@angular/platform-browser-dynamic'; +import * as platformServer from '@angular/platform-server'; +import * as platformServerTesting from '@angular/platform-server/testing'; +import * as platformWebworker from '@angular/platform-webworker'; +import * as platformWebworkerDynamic from '@angular/platform-webworker-dynamic'; +import * as router from '@angular/router'; +import * as routerTesting from '@angular/router/testing'; +import * as serviceWorker from '@angular/service-worker'; +import * as upgrade from '@angular/upgrade'; + +export default { + compiler, + compilerTesting, + core, + coreTesting, + forms, + http, + httpTesting, + platformBrowser, + platformBrowserTesting, + platformBrowserDynamic, + platformServer, + platformServerTesting, + platformWebworker, + platformWebworkerDynamic, + router, + routerTesting, + serviceWorker, + upgrade, +}; diff --git a/integration/typings_test_ts28/package.json b/integration/typings_test_ts28/package.json new file mode 100644 index 0000000000..8c3ddac65e --- /dev/null +++ b/integration/typings_test_ts28/package.json @@ -0,0 +1,30 @@ +{ + "name": "angular-integration", + "description": "Assert that users with TypeScript 2.8 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/forms": "file:../../dist/packages-dist/forms", + "@angular/http": "file:../../dist/packages-dist/http", + "@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/platform-webworker": "file:../../dist/packages-dist/platform-webworker", + "@angular/platform-webworker-dynamic": "file:../../dist/packages-dist/platform-webworker-dynamic", + "@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": "2.5.41", + "rxjs": "file:../../node_modules/rxjs", + "typescript": "2.8.x", + "zone.js": "file:../../node_modules/zone.js" + }, + "scripts": { + "test": "tsc" + } +} diff --git a/integration/typings_test_ts28/tsconfig.json b/integration/typings_test_ts28/tsconfig.json new file mode 100644 index 0000000000..165bd7a957 --- /dev/null +++ b/integration/typings_test_ts28/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "module": "commonjs", + "moduleResolution": "node", + "outDir": "../../dist/typings_test_ts28/", + "rootDir": ".", + "target": "es5", + "lib": [ + "es5", + "dom", + "es2015.collection", + "es2015.iterable", + "es2015.promise" + ], + "types": [], + "strictNullChecks": true + }, + "files": [ + "include-all.ts", + "node_modules/@types/jasmine/index.d.ts" + ] +} diff --git a/package.json b/package.json index 8da8259111..b38d5d6dbf 100644 --- a/package.json +++ b/package.json @@ -110,11 +110,11 @@ "source-map": "0.5.7", "source-map-support": "0.4.18", "systemjs": "0.18.10", - "tsickle": "^0.27.2", + "tsickle": "^0.28.0", "tslint": "5.7.0", "tslint-eslint-rules": "4.1.1", "tsutils": "2.20.0", - "typescript": "2.7.x", + "typescript": "2.8.x", "uglify-es": "^3.3.9", "universal-analytics": "0.4.15", "vlq": "0.2.2", diff --git a/packages/bazel/package.json b/packages/bazel/package.json index 19d1fde5c6..820bddaf98 100644 --- a/packages/bazel/package.json +++ b/packages/bazel/package.json @@ -13,7 +13,7 @@ }, "peerDependencies": { "@angular/compiler-cli": "0.0.0-PLACEHOLDER", - "typescript": ">=2.7.2 <2.8" + "typescript": ">=2.7.2 <2.9" }, "repository": { "type": "git", diff --git a/packages/compiler-cli/package.json b/packages/compiler-cli/package.json index 25f420400f..8249b66deb 100644 --- a/packages/compiler-cli/package.json +++ b/packages/compiler-cli/package.json @@ -15,7 +15,7 @@ "chokidar": "^1.4.2" }, "peerDependencies": { - "typescript": ">=2.7.2 <2.8", + "typescript": ">=2.7.2 <2.9", "@angular/compiler": "0.0.0-PLACEHOLDER" }, "engines" : { diff --git a/packages/compiler-cli/src/transformers/program.ts b/packages/compiler-cli/src/transformers/program.ts index f58dd7d465..78764efca3 100644 --- a/packages/compiler-cli/src/transformers/program.ts +++ b/packages/compiler-cli/src/transformers/program.ts @@ -108,7 +108,7 @@ const MIN_TS_VERSION = '2.7.2'; * ∀ supported typescript version v, v < MAX_TS_VERSION * MAX_TS_VERSION is not considered as a supported TypeScript version */ -const MAX_TS_VERSION = '2.8.0'; +const MAX_TS_VERSION = '2.9.0'; class AngularCompilerProgram implements Program { private rootNames: string[]; diff --git a/packages/core/src/sanitization/html_sanitizer.ts b/packages/core/src/sanitization/html_sanitizer.ts index dc49a6d073..cfa7e58035 100644 --- a/packages/core/src/sanitization/html_sanitizer.ts +++ b/packages/core/src/sanitization/html_sanitizer.ts @@ -141,13 +141,13 @@ class SanitizingHtmlSerializer { const elAttrs = element.attributes; for (let i = 0; i < elAttrs.length; i++) { const elAttr = elAttrs.item(i); - const attrName = elAttr.name; + const attrName = elAttr !.name; const lower = attrName.toLowerCase(); if (!VALID_ATTRS.hasOwnProperty(lower)) { this.sanitizedSomething = true; continue; } - let value = elAttr.value; + let value = elAttr !.value; // TODO(martinprobst): Special case image URIs for data:image/... if (URI_ATTRS[lower]) value = _sanitizeUrl(value); if (SRCSET_ATTRS[lower]) value = sanitizeSrcset(value); diff --git a/packages/core/src/sanitization/inert_body.ts b/packages/core/src/sanitization/inert_body.ts index 85463c7c9d..fb90f71a54 100644 --- a/packages/core/src/sanitization/inert_body.ts +++ b/packages/core/src/sanitization/inert_body.ts @@ -146,7 +146,7 @@ export class InertBodyHelper { // loop backwards so that we can support removals. for (let i = elAttrs.length - 1; 0 < i; i--) { const attrib = elAttrs.item(i); - const attrName = attrib.name; + const attrName = attrib !.name; if (attrName === 'xmlns:ns1' || attrName.indexOf('ns1:') === 0) { el.removeAttribute(attrName); } diff --git a/packages/language-service/src/ts_plugin.ts b/packages/language-service/src/ts_plugin.ts index b7336d9bbd..6457c4ef52 100644 --- a/packages/language-service/src/ts_plugin.ts +++ b/packages/language-service/src/ts_plugin.ts @@ -64,7 +64,7 @@ export function create(info: any /* ts.server.PluginCreateInfo */): ts.LanguageS } function typescriptOnly(ls: ts.LanguageService): ts.LanguageService { - return { + const languageService: ts.LanguageService = { cleanupSemanticCache: () => ls.cleanupSemanticCache(), getSyntacticDiagnostics: tryFilenameCall(ls.getSyntacticDiagnostics), getSemanticDiagnostics: tryFilenameCall(ls.getSemanticDiagnostics), @@ -117,8 +117,13 @@ export function create(info: any /* ts.server.PluginCreateInfo */): ts.LanguageS getDefinitionAndBoundSpan: tryFilenameOneCall(ls.getDefinitionAndBoundSpan), getCombinedCodeFix: (scope: ts.CombinedCodeFixScope, fixId: {}, formatOptions: ts.FormatCodeSettings) => - tryCall(undefined, () => ls.getCombinedCodeFix(scope, fixId, formatOptions)) - }; + tryCall(undefined, () => ls.getCombinedCodeFix(scope, fixId, formatOptions)), + // TODO(kyliau): dummy implementation to compile with ts 2.8, create real one + getSuggestionDiagnostics: (fileName: string) => [], + // TODO(kyliau): dummy implementation to compile with ts 2.8, create real one + organizeImports: (scope: ts.CombinedCodeFixScope, formatOptions: ts.FormatCodeSettings) => [], + } as ts.LanguageService; + return languageService; } oldLS = typescriptOnly(oldLS); diff --git a/packages/service-worker/worker/testing/cache.ts b/packages/service-worker/worker/testing/cache.ts index e56c43410a..b24147e2f6 100644 --- a/packages/service-worker/worker/testing/cache.ts +++ b/packages/service-worker/worker/testing/cache.ts @@ -156,7 +156,8 @@ export class MockCache { headers: {}, } as DehydratedResponse; - resp.headers.forEach((value, name) => { dehydratedResp.headers[name] = value; }); + resp.headers.forEach( + (value: string, name: string) => { dehydratedResp.headers[name] = value; }); dehydrated[url] = dehydratedResp; }); diff --git a/packages/upgrade/src/common/downgrade_component_adapter.ts b/packages/upgrade/src/common/downgrade_component_adapter.ts index 7d15d0c4a5..fd20b79e0a 100644 --- a/packages/upgrade/src/common/downgrade_component_adapter.ts +++ b/packages/upgrade/src/common/downgrade_component_adapter.ts @@ -11,7 +11,7 @@ import {ApplicationRef, ChangeDetectorRef, ComponentFactory, ComponentRef, Event import * as angular from './angular1'; import {PropertyBinding} from './component_info'; import {$SCOPE} from './constants'; -import {getAttributesAsArray, getComponentName, hookupNgModel, strictEquals} from './util'; +import {getComponentName, hookupNgModel, strictEquals} from './util'; const INITIAL_VALUE = { __UNINITIALIZED__: true diff --git a/packages/upgrade/src/common/util.ts b/packages/upgrade/src/common/util.ts index 15213dd986..0407753b10 100644 --- a/packages/upgrade/src/common/util.ts +++ b/packages/upgrade/src/common/util.ts @@ -32,19 +32,6 @@ export function directiveNormalize(name: string): string { .replace(DIRECTIVE_SPECIAL_CHARS_REGEXP, (_, letter) => letter.toUpperCase()); } -export function getAttributesAsArray(node: Node): [string, string][] { - const attributes = node.attributes; - let asArray: [string, string][] = undefined !; - if (attributes) { - let attrLen = attributes.length; - asArray = new Array(attrLen); - for (let i = 0; i < attrLen; i++) { - asArray[i] = [attributes[i].nodeName, attributes[i].nodeValue !]; - } - } - return asArray || []; -} - export function getComponentName(component: Type): string { // Return the name of the component or the first line of its stringified version. return (component as any).overriddenName || component.name || component.toString().split('\n')[0]; diff --git a/yarn.lock b/yarn.lock index 5b87332be0..a04ffc296d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5886,9 +5886,9 @@ trim-off-newlines@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/trim-off-newlines/-/trim-off-newlines-1.0.1.tgz#9f9ba9d9efa8764c387698bcbfeb2c848f11adb3" -tsickle@^0.27.2: - version "0.27.2" - resolved "https://registry.yarnpkg.com/tsickle/-/tsickle-0.27.2.tgz#f33d46d046f73dd5c155a37922e422816e878736" +tsickle@^0.28.0: + version "0.28.0" + resolved "https://registry.yarnpkg.com/tsickle/-/tsickle-0.28.0.tgz#6cd6fa004766c6ad9261b599c83866ee97cc7875" dependencies: minimist "^1.2.0" mkdirp "^0.5.1" @@ -5989,9 +5989,9 @@ typedarray@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" -typescript@2.7.x: - version "2.7.2" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.7.2.tgz#2d615a1ef4aee4f574425cdff7026edf81919836" +typescript@2.8.x: + version "2.8.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.8.3.tgz#5d817f9b6f31bb871835f4edf0089f21abe6c170" typescript@~2.6.2: version "2.6.2"