Skip to content

Commit 9d49f50

Browse files
committed
Merge remote-tracking branch 'upstream/master' into deps
2 parents fa1a3d6 + 63151d5 commit 9d49f50

File tree

10 files changed

+89
-25
lines changed

10 files changed

+89
-25
lines changed

packages/@angular/cli/blueprints/ng2/files/__path__/tsconfig.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
"declaration": false,
55
"emitDecoratorMetadata": true,
66
"experimentalDecorators": true,
7-
"lib": ["es6", "dom"],
7+
"lib": [
8+
"es2015",
9+
"dom"
10+
],
811
"mapRoot": "./",
9-
"module": "es6",
12+
"module": "es2015",
1013
"moduleResolution": "node",
1114
"outDir": "<%= relativeRootPath %>/dist/out-tsc",
1215
"sourceMap": true,

packages/@angular/cli/blueprints/ng2/files/e2e/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
"declaration": false,
55
"emitDecoratorMetadata": true,
66
"experimentalDecorators": true,
7+
"lib": [
8+
"es2016"
9+
],
710
"module": "commonjs",
811
"moduleResolution": "node",
912
"outDir": "../dist/out-tsc-e2e",

packages/@angular/cli/lib/ast-tools/ast-utils.ts

Lines changed: 61 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import * as ts from 'typescript';
22
import * as fs from 'fs';
3-
import {Symbols} from '@angular/tsc-wrapped/src/symbols';
4-
import {
5-
isMetadataImportedSymbolReferenceExpression,
6-
isMetadataModuleReferenceExpression
7-
} from '@angular/tsc-wrapped';
83
import {Change, InsertChange, NoopChange, MultiChange} from './change';
94
import {findNodes} from './node';
105
import {insertImport} from './route-utils';
@@ -105,9 +100,64 @@ export function getContentOfKeyLiteral(source: ts.SourceFile, node: ts.Node): st
105100
}
106101

107102

103+
104+
function _angularImportsFromNode(node: ts.ImportDeclaration,
105+
sourceFile: ts.SourceFile): {[name: string]: string} {
106+
const ms = node.moduleSpecifier;
107+
let modulePath: string | null = null;
108+
switch (ms.kind) {
109+
case ts.SyntaxKind.StringLiteral:
110+
modulePath = (ms as ts.StringLiteral).text;
111+
break;
112+
default:
113+
return [];
114+
}
115+
116+
if (!modulePath.startsWith('@angular/')) {
117+
return {};
118+
}
119+
120+
if (node.importClause) {
121+
if (node.importClause.name) {
122+
// This is of the form `import Name from 'path'`. Ignore.
123+
return {};
124+
} else if (node.importClause.namedBindings) {
125+
const nb = node.importClause.namedBindings;
126+
if (nb.kind == ts.SyntaxKind.NamespaceImport) {
127+
// This is of the form `import * as name from 'path'`. Return `name.`.
128+
return {
129+
[(nb as ts.NamespaceImport).name.text + '.']: modulePath
130+
};
131+
} else {
132+
// This is of the form `import {a,b,c} from 'path'`
133+
const namedImports = nb as ts.NamedImports;
134+
135+
return namedImports.elements
136+
.map((is: ts.ImportSpecifier) => is.propertyName ? is.propertyName.text : is.name.text)
137+
.reduce((acc: {[name: string]: string}, curr: string) => {
138+
acc[curr] = modulePath;
139+
return acc;
140+
}, {});
141+
}
142+
}
143+
} else {
144+
// This is of the form `import 'path';`. Nothing to do.
145+
return [];
146+
}
147+
}
148+
149+
108150
export function getDecoratorMetadata(source: ts.SourceFile, identifier: string,
109151
module: string): Observable<ts.Node> {
110-
const symbols = new Symbols(source as any);
152+
const angularImports: {[name: string]: string}
153+
= findNodes(source, ts.SyntaxKind.ImportDeclaration)
154+
.map((node: ts.ImportDeclaration) => _angularImportsFromNode(node, source))
155+
.reduce((acc: {[name: string]: string}, current: {[name: string]: string}) => {
156+
for (const key of Object.keys(current)) {
157+
acc[key] = current[key];
158+
}
159+
return acc;
160+
}, {});
111161

112162
return getSourceNodes(source)
113163
.filter(node => {
@@ -118,10 +168,8 @@ export function getDecoratorMetadata(source: ts.SourceFile, identifier: string,
118168
.filter(expr => {
119169
if (expr.expression.kind == ts.SyntaxKind.Identifier) {
120170
const id = <ts.Identifier>expr.expression;
121-
const metaData = symbols.resolve(id.getFullText(source));
122-
if (isMetadataImportedSymbolReferenceExpression(metaData)) {
123-
return metaData.name == identifier && metaData.module == module;
124-
}
171+
return id.getFullText(source) == identifier
172+
&& angularImports[id.getFullText(source)] === module;
125173
} else if (expr.expression.kind == ts.SyntaxKind.PropertyAccessExpression) {
126174
// This covers foo.NgModule when importing * as foo.
127175
const paExpr = <ts.PropertyAccessExpression>expr.expression;
@@ -130,12 +178,9 @@ export function getDecoratorMetadata(source: ts.SourceFile, identifier: string,
130178
return false;
131179
}
132180

133-
const id = paExpr.name;
134-
const moduleId = <ts.Identifier>paExpr.expression;
135-
const moduleMetaData = symbols.resolve(moduleId.getFullText(source));
136-
if (isMetadataModuleReferenceExpression(moduleMetaData)) {
137-
return moduleMetaData.module == module && id.getFullText(source) == identifier;
138-
}
181+
const id = paExpr.name.text;
182+
const moduleId = (<ts.Identifier>paExpr.expression).getText(source);
183+
return id === identifier && (angularImports[moduleId + '.'] === module);
139184
}
140185
return false;
141186
})

packages/@angular/cli/tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
"sourceMap": true,
1414
"sourceRoot": "/",
1515
"target": "es5",
16-
"lib": ["es6"],
16+
"lib": [
17+
"es2016"
18+
],
1719
"skipLibCheck": true,
1820
"typeRoots": [
1921
"../../../node_modules/@types"

packages/@ngtools/json-schema/tsconfig.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
"noImplicitAny": true,
1010
"outDir": "../../../dist/@ngtools/json-schema",
1111
"rootDir": ".",
12-
"lib": ["es2015", "es6", "dom"],
12+
"lib": [
13+
"es2016",
14+
"dom"
15+
],
1316
"target": "es5",
1417
"sourceMap": true,
1518
"sourceRoot": "/",

packages/@ngtools/logger/tsconfig.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
"noImplicitAny": true,
1010
"outDir": "../../../dist/@ngtools/logger",
1111
"rootDir": ".",
12-
"lib": ["es2015", "es6", "dom"],
12+
"lib": [
13+
"es2016",
14+
"dom"
15+
],
1316
"target": "es5",
1417
"sourceMap": true,
1518
"sourceRoot": "/",

packages/@ngtools/webpack/tsconfig.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
"noImplicitAny": true,
1010
"outDir": "../../../dist/@ngtools/webpack",
1111
"rootDir": ".",
12-
"lib": ["es2015", "es6", "dom"],
12+
"lib": [
13+
"es2016",
14+
"dom"
15+
],
1316
"target": "es5",
1417
"sourceMap": true,
1518
"sourceRoot": "/",

tests/e2e/assets/webpack/test-app-weird/not/so/source/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"emitDecoratorMetadata": true,
1010
"experimentalDecorators": true,
1111
"lib": [
12-
"es2015",
12+
"es2016",
1313
"dom"
1414
],
1515
"outDir": "lib",

tests/e2e/assets/webpack/test-app/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"emitDecoratorMetadata": true,
1111
"experimentalDecorators": true,
1212
"lib": [
13-
"es2015",
13+
"es2016",
1414
"dom"
1515
],
1616
"outDir": "lib",

tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
"sourceRoot": "",
1515
"inlineSourceMap": true,
1616
"target": "es5",
17-
"lib": ["es6"],
17+
"lib": [
18+
"es2016"
19+
],
1820
"baseUrl": "",
1921
"typeRoots": [
2022
"./node_modules/@types"

0 commit comments

Comments
 (0)