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 3c808c6 commit 2885a93
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 32 deletions.
2 changes: 1 addition & 1 deletion packages/angular_devkit/build_optimizer/package.json
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"
}
}
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
29 changes: 15 additions & 14 deletions tests/legacy-cli/e2e/ng-snapshot/package.json
Expand Up @@ -2,19 +2,20 @@
"description": "snapshot versions of Angular for e2e testing",
"private": true,
"dependencies": {
"@angular/animations": "github:angular/animations-builds#9fe8b543b33f555fabc1606876cc4ec363da4537",
"@angular/cdk": "github:angular/cdk-builds#9f8f26403874e3bd1bd48122e22cdb2912930071",
"@angular/common": "github:angular/common-builds#7d19e430b47efd687b35b6789674b92334d397a7",
"@angular/compiler": "github:angular/compiler-builds#60996e104d5efd02bfef34d2cea5f7cd7b6924a1",
"@angular/compiler-cli": "github:angular/compiler-cli-builds#f397a99462f689ab0fa6251221e44138ea8d12c5",
"@angular/core": "github:angular/core-builds#e77932ea8853947401a4d12fee4f37f36f5e0688",
"@angular/forms": "github:angular/forms-builds#ab32de290377792cf1a8dc83a5d081db613c845f",
"@angular/language-service": "github:angular/language-service-builds#70cdb38917ac2ddcc83a198484c0406b98fc45db",
"@angular/localize": "github:angular/localize-builds#898fdff51f203b0ce635f8b362ec286acdbe5c1a",
"@angular/material": "github:angular/material2-builds#c13d96c97b1d3ce2ac06a4d0cc25e9e27ba071ad",
"@angular/platform-browser": "github:angular/platform-browser-builds#4bef44058b37f5457ff3b08ee5f65c8e8848ad56",
"@angular/platform-browser-dynamic": "github:angular/platform-browser-dynamic-builds#ad30c159864814f9fcf8589ba255450a4fadf92d",
"@angular/platform-server": "github:angular/platform-server-builds#0010a319bb54a9dc620463f935b762bc1b666e8c",
"@angular/router": "github:angular/router-builds#73578d4471f1a31bf7ea921475aed8962909ae7c"
"@angular/animations": "github:angular/animations-builds#83ac2e068b436216f77de3fae86ae651b8102c2b",
"@angular/cdk": "github:angular/cdk-builds#d8905b3e70eb0df8b9790ca664432a363cc431a9",
"@angular/common": "github:angular/common-builds#1e65621763a7794475dfc82034c7a1d5626e431c",
"@angular/compiler": "github:angular/compiler-builds#6bdc2b5f3483be31ca223229dcf98bc0ebdc1732",
"@angular/compiler-cli": "github:angular/compiler-cli-builds#1336ad7aff4e4a7a7ce3b549e0cc577527e0f14b",
"@angular/core": "github:angular/core-builds#ab7a963a273606aab4bd3fd33d41affd3e1c4368",
"@angular/forms": "github:angular/forms-builds#796e46075c82c315d6dd7c5e517e873f7929d50d",
"@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",
"@angular/router": "github:angular/router-builds#3dea8bb66e4c05e729b35ff9d8f4335c0c719e50"
}
}
80 changes: 64 additions & 16 deletions tests/legacy-cli/e2e/tests/build/material.ts
@@ -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
Expand Up @@ -11501,6 +11501,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 2885a93

Please sign in to comment.