Skip to content

Commit

Permalink
fix(@angular-devkit/build-optimizer): use TypeScript 3.6
Browse files Browse the repository at this point in the history
Fixes: #17320
  • Loading branch information
clydin authored and mgechev committed Apr 6, 2020
1 parent 142099e commit 4509d3c
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 18 deletions.
2 changes: 1 addition & 1 deletion packages/angular_devkit/build_optimizer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"loader-utils": "2.0.0",
"source-map": "0.7.3",
"tslib": "1.11.1",
"typescript": "3.8.3",
"typescript": "3.6.5",
"webpack-sources": "1.4.3"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ function isTslibHelper(
checker: ts.TypeChecker,
) {

let callExprIdent = callExpr.expression as ts.Identifier | ts.PrivateIdentifier;
let callExprIdent = callExpr.expression as ts.Identifier;

if (callExpr.expression.kind !== ts.SyntaxKind.Identifier) {
if (callExpr.expression.kind === ts.SyntaxKind.PropertyAccessExpression) {
Expand Down
1 change: 1 addition & 0 deletions tests/legacy-cli/e2e/ng-snapshot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@angular/language-service": "github:angular/language-service-builds#e4c45a027958642903873913bdeb5a321b1a2220",
"@angular/localize": "github:angular/localize-builds#00aca0caa37113b01dd270c31fcb1c3009807539",
"@angular/material": "github:angular/material2-builds#261ff75b8acdbfda3d69c65a30898df029816f32",
"@angular/material-moment-adapter": "github:angular/material-moment-adapter-builds#93f405e88f0360127bf2419941ec133dac84b4a5",
"@angular/platform-browser": "github:angular/platform-browser-builds#2f6d4dd67601a7589783a226b8145837dd3c963c",
"@angular/platform-browser-dynamic": "github:angular/platform-browser-dynamic-builds#609599de331caf8bc05f6e522823c2f07162772d",
"@angular/platform-server": "github:angular/platform-server-builds#f4b83463f893b894a9984446782086f9bde8b240",
Expand Down
80 changes: 64 additions & 16 deletions tests/legacy-cli/e2e/tests/build/material.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,74 @@
import { getGlobalVariable } from '../../utils/env';
import { replaceInFile } from '../../utils/fs';
import { ng, silentNpm } from '../../utils/process';
import { updateJsonFile } from '../../utils/project';

const snapshots = require('../../ng-snapshot/package.json');

export default async function () {
await ng('add', '@angular/material');

const isSnapshotBuild = getGlobalVariable('argv')['ng-snapshots'];
if (isSnapshotBuild) {
await updateJsonFile('package.json', packageJson => {
const dependencies = packageJson['dependencies'];
// Angular material adds dependencies on other Angular packages
// Iterate over all of the packages to update them to the snapshot version.
for (const [name, version] of Object.entries(snapshots.dependencies)) {
if (name in dependencies) {
dependencies[name] = version;
}
}
});
}
await ng('add', '@angular/material');

const isSnapshotBuild = getGlobalVariable('argv')['ng-snapshots'];
if (isSnapshotBuild) {
await updateJsonFile('package.json', (packageJson) => {
const dependencies = packageJson['dependencies'];
// Angular material adds dependencies on other Angular packages
// Iterate over all of the packages to update them to the snapshot version.
for (const [name, version] of Object.entries(snapshots.dependencies)) {
if (name in dependencies) {
dependencies[name] = version;
}
}

dependencies['@angular/material-moment-adapter'] =
snapshots.dependencies['@angular/material-moment-adapter'];
});

await silentNpm('install');
await ng('build', '--prod');
} else {
await silentNpm('install', '@angular/material-moment-adapter');
}

await silentNpm('install', 'moment');

await ng('build', '--prod');

// Ensure moment adapter works (uses unique importing mechanism for moment)
// Issue: https://github.com/angular/angular-cli/issues/17320
await replaceInFile(
'src/app/app.module.ts',
`import { AppComponent } from './app.component';`,
`
import { AppComponent } from './app.component';
import {
MomentDateAdapter,
MAT_MOMENT_DATE_FORMATS
} from '@angular/material-moment-adapter';
import {
DateAdapter,
MAT_DATE_LOCALE,
MAT_DATE_FORMATS
} from '@angular/material/core';
`,
);

await replaceInFile(
'src/app/app.module.ts',
`providers: []`,
`
providers: [
{
provide: DateAdapter,
useClass: MomentDateAdapter,
deps: [MAT_DATE_LOCALE]
},
{
provide: MAT_DATE_FORMATS,
useValue: MAT_MOMENT_DATE_FORMATS
}
]
`,
);

await ng('e2e', '--prod');
}
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11560,6 +11560,11 @@ typedarray@^0.0.6:
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=

typescript@3.6.5:
version "3.6.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.6.5.tgz#dae20114a7b4ff4bd642db9c8c699f2953e8bbdb"
integrity sha512-BEjlc0Z06ORZKbtcxGrIvvwYs5hAnuo6TKdNFL55frVDlB+na3z5bsLhFaIxmT+dPWgBIjMo6aNnTOgHHmHgiQ==

typescript@3.8.3:
version "3.8.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.8.3.tgz#409eb8544ea0335711205869ec458ab109ee1061"
Expand Down

0 comments on commit 4509d3c

Please sign in to comment.