Skip to content

Commit

Permalink
feat: add support for typescript 3.2 (#27536)
Browse files Browse the repository at this point in the history
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-2.html
https://blogs.msdn.microsoft.com/typescript/2018/11/29/announcing-typescript-3-2/

Any application using tsickle for closure compatibility will need to update it's tsickle
dependency to 0.34

PR Close #27536
  • Loading branch information
IgorMinar authored and mhevery committed Dec 18, 2018
1 parent b04bc5d commit 17e702b
Show file tree
Hide file tree
Showing 13 changed files with 200 additions and 34 deletions.
26 changes: 25 additions & 1 deletion integration/typings_test_ts31/include-all.ts
Expand Up @@ -6,6 +6,15 @@
* found in the LICENSE file at https://angular.io/license * 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 compiler from '@angular/compiler';
import * as compilerTesting from '@angular/compiler/testing'; import * as compilerTesting from '@angular/compiler/testing';
import * as core from '@angular/core'; import * as core from '@angular/core';
Expand All @@ -15,18 +24,29 @@ import * as forms from '@angular/forms';
import * as http from '@angular/http'; import * as http from '@angular/http';
import * as httpTesting from '@angular/http/testing'; import * as httpTesting from '@angular/http/testing';
import * as platformBrowser from '@angular/platform-browser'; 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 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 platformServer from '@angular/platform-server';
import * as platformServerTesting from '@angular/platform-server/testing'; import * as platformServerTesting from '@angular/platform-server/testing';
import * as platformWebworker from '@angular/platform-webworker'; import * as platformWebworker from '@angular/platform-webworker';
import * as platformWebworkerDynamic from '@angular/platform-webworker-dynamic'; import * as platformWebworkerDynamic from '@angular/platform-webworker-dynamic';
import * as router from '@angular/router'; import * as router from '@angular/router';
import * as routerTesting from '@angular/router/testing'; import * as routerTesting from '@angular/router/testing';
import * as routerUpgrade from '@angular/router/upgrade';
import * as serviceWorker from '@angular/service-worker'; import * as serviceWorker from '@angular/service-worker';
import * as upgrade from '@angular/upgrade'; import * as upgrade from '@angular/upgrade';
import * as upgradeStatic from '@angular/upgrade/static';


export default { export default {
animations,
animationsBrowser,
animationsBrowserTesting,
common,
commonTesting,
commonHttp,
commonHttpTesting,
compiler, compiler,
compilerTesting, compilerTesting,
core, core,
Expand All @@ -38,12 +58,16 @@ export default {
platformBrowser, platformBrowser,
platformBrowserTesting, platformBrowserTesting,
platformBrowserDynamic, platformBrowserDynamic,
platformBrowserDynamicTesting,
platformBrowserAnimations,
platformServer, platformServer,
platformServerTesting, platformServerTesting,
platformWebworker, platformWebworker,
platformWebworkerDynamic, platformWebworkerDynamic,
router, router,
routerTesting, routerTesting,
routerUpgrade,
serviceWorker, serviceWorker,
upgrade, upgrade,
upgradeStatic
}; };
73 changes: 73 additions & 0 deletions integration/typings_test_ts32/include-all.ts
@@ -0,0 +1,73 @@
/**
* @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 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 http from '@angular/http';
import * as httpTesting from '@angular/http/testing';
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 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 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';

export default {
animations,
animationsBrowser,
animationsBrowserTesting,
common,
commonTesting,
commonHttp,
commonHttpTesting,
compiler,
compilerTesting,
core,
coreTesting,
elements,
forms,
http,
httpTesting,
platformBrowser,
platformBrowserTesting,
platformBrowserDynamic,
platformBrowserDynamicTesting,
platformBrowserAnimations,
platformServer,
platformServerTesting,
platformWebworker,
platformWebworkerDynamic,
router,
routerTesting,
routerUpgrade,
serviceWorker,
upgrade,
upgradeStatic
};
31 changes: 31 additions & 0 deletions integration/typings_test_ts32/package.json
@@ -0,0 +1,31 @@
{
"name": "angular-integration",
"description": "Assert that users with TypeScript 3.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/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": "3.2.x",
"zone.js": "file:../../node_modules/zone.js"
},
"scripts": {
"test": "tsc"
}
}
24 changes: 24 additions & 0 deletions integration/typings_test_ts32/tsconfig.json
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"module": "commonjs",
"moduleResolution": "node",
"outDir": "../../dist/typings_test_ts31/",
"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"
]
}
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -76,9 +76,9 @@
"shelljs": "^0.8.1", "shelljs": "^0.8.1",
"source-map": "^0.6.1", "source-map": "^0.6.1",
"source-map-support": "0.5.9", "source-map-support": "0.5.9",
"tsickle": "0.33.1", "tsickle": "0.34.0",
"tslib": "^1.7.1", "tslib": "^1.9.0",
"typescript": "~3.1.1", "typescript": "~3.2.2",
"xhr2": "0.1.4", "xhr2": "0.1.4",
"yargs": "9.0.1", "yargs": "9.0.1",
"zone.js": "^0.8.26" "zone.js": "^0.8.26"
Expand Down
4 changes: 2 additions & 2 deletions packages/bazel/package.json
Expand Up @@ -24,7 +24,7 @@
}, },
"peerDependencies": { "peerDependencies": {
"@angular/compiler-cli": "0.0.0-PLACEHOLDER", "@angular/compiler-cli": "0.0.0-PLACEHOLDER",
"typescript": ">=3.1.1 <3.2" "typescript": ">=3.1.1 <3.3"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
Expand All @@ -38,4 +38,4 @@
"scripts": { "scripts": {
"postinstall": "node ./check_version.js" "postinstall": "node ./check_version.js"
} }
} }
8 changes: 4 additions & 4 deletions packages/compiler-cli/package.json
Expand Up @@ -24,10 +24,10 @@
}, },
"peerDependencies": { "peerDependencies": {
"@angular/compiler": "0.0.0-PLACEHOLDER", "@angular/compiler": "0.0.0-PLACEHOLDER",
"typescript": ">=3.1.1 <3.2" "typescript": ">=3.1.1 <3.3"
}, },
"engines" : { "engines": {
"node" : ">=8.0" "node": ">=8.0"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
Expand All @@ -49,4 +49,4 @@
"ng-update": { "ng-update": {
"packageGroup": "NG_UPDATE_PACKAGE_GROUP" "packageGroup": "NG_UPDATE_PACKAGE_GROUP"
} }
} }
18 changes: 14 additions & 4 deletions packages/compiler-cli/src/ngcc/src/packages/transformer.ts
Expand Up @@ -8,11 +8,12 @@
import {dirname} from 'canonical-path'; import {dirname} from 'canonical-path';
import {existsSync, writeFileSync} from 'fs'; import {existsSync, writeFileSync} from 'fs';
import {mkdir, mv} from 'shelljs'; import {mkdir, mv} from 'shelljs';
import * as ts from 'typescript';


import {DecorationAnalyzer} from '../analysis/decoration_analyzer'; import {CompiledFile, DecorationAnalyzer} from '../analysis/decoration_analyzer';
import {NgccReferencesRegistry} from '../analysis/ngcc_references_registry'; import {NgccReferencesRegistry} from '../analysis/ngcc_references_registry';
import {PrivateDeclarationsAnalyzer} from '../analysis/private_declarations_analyzer'; import {ExportInfo, PrivateDeclarationsAnalyzer} from '../analysis/private_declarations_analyzer';
import {SwitchMarkerAnalyzer} from '../analysis/switch_marker_analyzer'; import {SwitchMarkerAnalyses, SwitchMarkerAnalyzer} from '../analysis/switch_marker_analyzer';
import {Esm2015ReflectionHost} from '../host/esm2015_host'; import {Esm2015ReflectionHost} from '../host/esm2015_host';
import {Esm5ReflectionHost} from '../host/esm5_host'; import {Esm5ReflectionHost} from '../host/esm5_host';
import {NgccReflectionHost} from '../host/ngcc_host'; import {NgccReflectionHost} from '../host/ngcc_host';
Expand All @@ -23,6 +24,7 @@ import {FileInfo, Renderer} from '../rendering/renderer';
import {EntryPoint} from './entry_point'; import {EntryPoint} from './entry_point';
import {EntryPointBundle} from './entry_point_bundle'; import {EntryPointBundle} from './entry_point_bundle';



/** /**
* A Package is stored in a directory on disk and that directory can contain one or more package * A Package is stored in a directory on disk and that directory can contain one or more package
* formats - e.g. fesm2015, UMD, etc. Additionally, each package provides typings (`.d.ts` files). * formats - e.g. fesm2015, UMD, etc. Additionally, each package provides typings (`.d.ts` files).
Expand Down Expand Up @@ -96,7 +98,8 @@ export class Transformer {
} }
} }


analyzeProgram(reflectionHost: NgccReflectionHost, isCore: boolean, bundle: EntryPointBundle) { analyzeProgram(reflectionHost: NgccReflectionHost, isCore: boolean, bundle: EntryPointBundle):
ProgramAnalyses {
const typeChecker = bundle.src.program.getTypeChecker(); const typeChecker = bundle.src.program.getTypeChecker();
const referencesRegistry = new NgccReferencesRegistry(reflectionHost); const referencesRegistry = new NgccReferencesRegistry(reflectionHost);
const decorationAnalyzer = new DecorationAnalyzer( const decorationAnalyzer = new DecorationAnalyzer(
Expand All @@ -120,3 +123,10 @@ export class Transformer {
writeFileSync(file.path, file.contents, 'utf8'); writeFileSync(file.path, file.contents, 'utf8');
} }
} }


interface ProgramAnalyses {
decorationAnalyses: Map<ts.SourceFile, CompiledFile>;
switchMarkerAnalyses: SwitchMarkerAnalyses;
privateDeclarationsAnalyses: ExportInfo[];
}
2 changes: 1 addition & 1 deletion packages/compiler-cli/src/transformers/program.ts
Expand Up @@ -79,7 +79,7 @@ const MIN_TS_VERSION = '3.1.1';
* ∀ supported typescript version v, v < MAX_TS_VERSION * ∀ supported typescript version v, v < MAX_TS_VERSION
* MAX_TS_VERSION is not considered as a supported TypeScript version * MAX_TS_VERSION is not considered as a supported TypeScript version
*/ */
const MAX_TS_VERSION = '3.2.0'; const MAX_TS_VERSION = '3.3.0';


class AngularCompilerProgram implements Program { class AngularCompilerProgram implements Program {
private rootNames: string[]; private rootNames: string[];
Expand Down
12 changes: 8 additions & 4 deletions packages/language-service/src/ts_plugin.ts
Expand Up @@ -275,18 +275,20 @@ export function create(info: any /* ts.server.PluginCreateInfo */): ts.LanguageS
}; };


proxy.getDefinitionAtPosition = function( proxy.getDefinitionAtPosition = function(
fileName: string, position: number): ts.DefinitionInfo[] { fileName: string, position: number): ReadonlyArray<ts.DefinitionInfo> {
let base = oldLS.getDefinitionAtPosition(fileName, position); let base = oldLS.getDefinitionAtPosition(fileName, position);
if (base && base.length) { if (base && base.length) {
return base; return base;
} }


return tryOperation('get definition', () => { return tryOperation('get definition', () => {
const ours = ls.getDefinitionAt(fileName, position); const ours = ls.getDefinitionAt(fileName, position);
let combined;

if (ours && ours.length) { if (ours && ours.length) {
base = base || []; combined = base && base.concat([]) || [];
for (const loc of ours) { for (const loc of ours) {
base.push({ combined.push({
fileName: loc.fileName, fileName: loc.fileName,
textSpan: {start: loc.span.start, length: loc.span.end - loc.span.start}, textSpan: {start: loc.span.start, length: loc.span.end - loc.span.start},
name: '', name: '',
Expand All @@ -296,8 +298,10 @@ export function create(info: any /* ts.server.PluginCreateInfo */): ts.LanguageS
containerKind: 'file' as any, containerKind: 'file' as any,
}); });
} }
} else {
combined = base;
} }
return base; return combined;
}) || []; }) || [];
}; };


Expand Down
6 changes: 3 additions & 3 deletions tools/ts-api-guardian/package.json
Expand Up @@ -11,7 +11,7 @@
"test": "test" "test": "test"
}, },
"peerDependencies": { "peerDependencies": {
"typescript": "~3.1.1" "typescript": "~3.2.2"
}, },
"dependencies": { "dependencies": {
"chalk": "^2.3.1", "chalk": "^2.3.1",
Expand All @@ -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": "~3.1.1" "typescript": "~3.2.2"
}, },
"repository": {}, "repository": {},
"keywords": [ "keywords": [
Expand All @@ -45,4 +45,4 @@
"url": "https://github.com/angular/angular/issues" "url": "https://github.com/angular/angular/issues"
}, },
"homepage": "https://github.com/angular/angular/tools/ts-api-guardian" "homepage": "https://github.com/angular/angular/tools/ts-api-guardian"
} }
8 changes: 4 additions & 4 deletions tools/ts-api-guardian/yarn.lock
Expand Up @@ -224,10 +224,10 @@ type-detect@^4.0.0:
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c"
integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g== integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==


typescript@~3.1.1: typescript@~3.2.2:
version "3.1.1" version "3.2.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.1.1.tgz#3362ba9dd1e482ebb2355b02dfe8bcd19a2c7c96" resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.2.2.tgz#fe8101c46aa123f8353523ebdcf5730c2ae493e5"
integrity sha512-Veu0w4dTc/9wlWNf2jeRInNodKlcdLgemvPsrNpfu5Pq39sgfFjvIIgTsvUHCoLBnMhPoUA+tFxsXjU6VexVRQ== integrity sha512-VCj5UiSyHBjwfYacmDuc/NOk4QQixbE+Wn7MFJuS0nRuPQbof132Pw4u53dm264O8LPc2MVsc7RJNml5szurkg==


wrappy@1: wrappy@1:
version "1.0.2" version "1.0.2"
Expand Down

0 comments on commit 17e702b

Please sign in to comment.