From 4ba9e18c23c22fece18eb899aedc796b00ab4bdd Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Sun, 26 Nov 2017 11:41:53 -0500 Subject: [PATCH] build: support building with TS 2.6 --- WORKSPACE | 11 +- package-lock.json | 124 +++--------------- package.json | 5 +- .../src/helpers/transform-javascript.ts | 2 +- .../src/transforms/class-fold.ts | 7 +- .../src/transforms/scrub-file.ts | 7 +- packages/angular_devkit/schematics/BUILD | 2 + .../schematics/src/rules/template.ts | 2 +- .../schematics/src/sink/dryrun.ts | 5 +- .../tools/file-system-engine-host-base.ts | 2 +- .../schematics/angular/application/index.ts | 2 +- packages/schematics/angular/class/index.ts | 2 +- .../schematics/angular/component/index.ts | 2 +- .../schematics/angular/directive/index.ts | 2 +- packages/schematics/angular/enum/index.ts | 2 +- packages/schematics/angular/guard/index.ts | 2 +- .../schematics/angular/interface/index.ts | 2 +- packages/schematics/angular/module/index.ts | 2 +- packages/schematics/angular/pipe/index.ts | 2 +- packages/schematics/angular/service/index.ts | 2 +- 20 files changed, 45 insertions(+), 142 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 2ed858c60a..37b9166f05 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,13 +1,18 @@ git_repository( name = "build_bazel_rules_nodejs", remote = "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/bazelbuild/rules_nodejs.git", - tag = "0.1.0", + tag = "0.3.1", ) load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories") node_repositories(package_json = ["//:package.json"]) -local_repository( +git_repository( name = "build_bazel_rules_typescript", - path = "node_modules/@bazel/typescript", + remote = "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/bazelbuild/rules_typescript.git", + tag = "0.6.0", ) + +load("@build_bazel_rules_typescript//:defs.bzl", "ts_repositories") + +ts_repositories() diff --git a/package-lock.json b/package-lock.json index 2206879003..1f42bfb7f4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,32 +4,6 @@ "lockfileVersion": 1, "requires": true, "dependencies": { - "@bazel/typescript": { - "version": "0.0.10", - "resolved": "https://registry.npmjs.org/@bazel/typescript/-/typescript-0.0.10.tgz", - "integrity": "sha1-SbU1d7/VrWLGu6Ox68LggQtKYVI=", - "dev": true, - "requires": { - "@types/node": "7.0.18", - "protobufjs": "5.0.0", - "tsickle": "0.23.6", - "typescript": "2.3.4" - }, - "dependencies": { - "@types/node": { - "version": "7.0.18", - "resolved": "https://registry.npmjs.org/@types/node/-/node-7.0.18.tgz", - "integrity": "sha1-zWfyfT3Az7dG8L3V4IbExdVb4XM=", - "dev": true - }, - "typescript": { - "version": "2.3.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.3.4.tgz", - "integrity": "sha1-PTgyGCgjHkNPKHUUlZw3qCtin0I=", - "dev": true - } - } - }, "@ngtools/json-schema": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@ngtools/json-schema/-/json-schema-1.1.0.tgz", @@ -220,16 +194,6 @@ "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=" }, - "ascli": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/ascli/-/ascli-1.0.1.tgz", - "integrity": "sha1-vPpZdKYvGOgcq660lzKrSoj5Brw=", - "dev": true, - "requires": { - "colour": "0.7.1", - "optjs": "3.2.2" - } - }, "asn1": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", @@ -343,15 +307,6 @@ "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=" }, - "bytebuffer": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/bytebuffer/-/bytebuffer-5.0.1.tgz", - "integrity": "sha1-WC7qSxqHO20CCkjVjfhfC7ps/d0=", - "dev": true, - "requires": { - "long": "3.2.0" - } - }, "camelcase": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz", @@ -375,6 +330,7 @@ "version": "0.1.3", "resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz", "integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=", + "optional": true, "requires": { "align-text": "0.1.4", "lazy-cache": "1.0.4" @@ -414,6 +370,7 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=", + "optional": true, "requires": { "center-align": "0.1.3", "right-align": "0.1.3", @@ -423,7 +380,8 @@ "wordwrap": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", - "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=" + "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=", + "optional": true } } }, @@ -455,12 +413,6 @@ "resolved": "https://registry.npmjs.org/colors/-/colors-1.1.2.tgz", "integrity": "sha1-FopHAXVran9RoSzgyXv6KMCE7WM=" }, - "colour": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/colour/-/colour-0.7.1.tgz", - "integrity": "sha1-nLFpkX7F0SwHNtPoaFdG3xyt93g=", - "dev": true - }, "combined-stream": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", @@ -1437,7 +1389,8 @@ "lazy-cache": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz", - "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=" + "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=", + "optional": true }, "levn": { "version": "0.3.0", @@ -1497,12 +1450,6 @@ "lodash._reinterpolate": "3.0.0" } }, - "long": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/long/-/long-3.2.0.tgz", - "integrity": "sha1-2CG3E4yhy1gcFymQ7xTbIAtcR0s=", - "dev": true - }, "longest": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", @@ -5207,12 +5154,6 @@ } } }, - "optjs": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/optjs/-/optjs-3.2.2.tgz", - "integrity": "sha1-aabOicRCpEQDFBrS+bNwvVu29O4=", - "dev": true - }, "os-homedir": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", @@ -5314,33 +5255,6 @@ "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=" }, - "protobufjs": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-5.0.0.tgz", - "integrity": "sha1-QiMGMjPqlqwGPKK1VANSBNtST6E=", - "dev": true, - "requires": { - "ascli": "1.0.1", - "bytebuffer": "5.0.1", - "glob": "5.0.15", - "yargs": "3.10.0" - }, - "dependencies": { - "glob": { - "version": "5.0.15", - "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz", - "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", - "dev": true, - "requires": { - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" - } - } - } - }, "protochain": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/protochain/-/protochain-1.0.5.tgz", @@ -5478,6 +5392,7 @@ "version": "0.1.3", "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", "integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=", + "optional": true, "requires": { "align-text": "0.1.4" } @@ -5881,18 +5796,6 @@ } } }, - "tsickle": { - "version": "0.23.6", - "resolved": "https://registry.npmjs.org/tsickle/-/tsickle-0.23.6.tgz", - "integrity": "sha1-/O5Xpct/kqjDqeV47gooZCfc+s0=", - "dev": true, - "requires": { - "minimist": "1.2.0", - "mkdirp": "0.5.1", - "source-map": "0.5.7", - "source-map-support": "0.4.18" - } - }, "tslib": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.8.0.tgz", @@ -5957,9 +5860,9 @@ } }, "typescript": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.4.2.tgz", - "integrity": "sha1-+DlfhdRZJ2BnyYiqQYN6j4KHCEQ=" + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.6.1.tgz", + "integrity": "sha1-7znN6ierrAtQAkLWcmq5DgyEZjE=" }, "uglify-js": { "version": "2.8.29", @@ -6069,7 +5972,8 @@ "window-size": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", - "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=" + "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=", + "optional": true }, "wordwrap": { "version": "0.0.3", @@ -6095,6 +5999,7 @@ "version": "3.10.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=", + "optional": true, "requires": { "camelcase": "1.2.1", "cliui": "2.1.0", @@ -6105,7 +6010,8 @@ "camelcase": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", - "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=" + "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=", + "optional": true } } }, diff --git a/package.json b/package.json index 2888f4eeae..0c27d3b460 100644 --- a/package.json +++ b/package.json @@ -72,11 +72,8 @@ "temp": "^0.8.3", "ts-node": "^2.0.0", "tslint": "^5.5.0", - "typescript": "~2.4.0", + "typescript": "~2.6.1", "v8-profiler": "^5.7.0", "webpack-sources": "^1.0.1" - }, - "devDependencies": { - "@bazel/typescript": "0.0.10" } } diff --git a/packages/angular_devkit/build_optimizer/src/helpers/transform-javascript.ts b/packages/angular_devkit/build_optimizer/src/helpers/transform-javascript.ts index 08e16b8709..e7adc84a5b 100644 --- a/packages/angular_devkit/build_optimizer/src/helpers/transform-javascript.ts +++ b/packages/angular_devkit/build_optimizer/src/helpers/transform-javascript.ts @@ -47,7 +47,7 @@ export function transformJavascript( } // Print error diagnostics. - const checkDiagnostics = (diagnostics: ts.Diagnostic[]) => { + const checkDiagnostics = (diagnostics: ReadonlyArray) => { if (diagnostics && diagnostics.length > 0) { let errors = ''; errors = errors + '\n' + ts.formatDiagnostics(diagnostics, { diff --git a/packages/angular_devkit/build_optimizer/src/transforms/class-fold.ts b/packages/angular_devkit/build_optimizer/src/transforms/class-fold.ts index 55002df6e9..3dd0a82471 100644 --- a/packages/angular_devkit/build_optimizer/src/transforms/class-fold.ts +++ b/packages/angular_devkit/build_optimizer/src/transforms/class-fold.ts @@ -29,13 +29,10 @@ export function getFoldFileTransformer(program: ts.Program): ts.TransformerFacto const classes = findClassDeclarations(sf); const statements = findClassStaticPropertyAssignments(sf, checker, classes); - const visitor: ts.Visitor = (node: ts.Node): ts.Node => { + const visitor: ts.Visitor = (node: ts.Node): ts.VisitResult => { // Check if node is a statement to be dropped. if (statements.find((st) => st.expressionStatement === node)) { - // According to @mhegazy returning undefined is supported. - // https://github.com/Microsoft/TypeScript/pull/17044 - // tslint:disable-next-line:no-any - return undefined as any; + return undefined; } // Check if node is a class to add statements to. diff --git a/packages/angular_devkit/build_optimizer/src/transforms/scrub-file.ts b/packages/angular_devkit/build_optimizer/src/transforms/scrub-file.ts index 2af38ec80f..620b4815ff 100644 --- a/packages/angular_devkit/build_optimizer/src/transforms/scrub-file.ts +++ b/packages/angular_devkit/build_optimizer/src/transforms/scrub-file.ts @@ -85,13 +85,10 @@ export function getScrubFileTransformer(program: ts.Program): ts.TransformerFact } } - const visitor: ts.Visitor = (node: ts.Node): ts.Node => { + const visitor: ts.Visitor = (node: ts.Node): ts.VisitResult => { // Check if node is a statement to be dropped. if (nodes.find((n) => n === node)) { - // According to @mhegazy returning undefined is supported. - // https://github.com/Microsoft/TypeScript/pull/17044 - // tslint:disable-next-line:no-any - return undefined as any; + return undefined; } // Otherwise return node as is. diff --git a/packages/angular_devkit/schematics/BUILD b/packages/angular_devkit/schematics/BUILD index bda638e786..515c2dc6c7 100644 --- a/packages/angular_devkit/schematics/BUILD +++ b/packages/angular_devkit/schematics/BUILD @@ -63,6 +63,7 @@ ts_library( ), deps = [ ":schematics", + "//packages/angular_devkit/core", # @deps: rxjs # @typings: jasmine ], @@ -75,6 +76,7 @@ ts_library( include = ["tools/**/*_spec.ts"], ), deps = [ + ":schematics", ":tools", # @deps: rxjs # @typings: jasmine diff --git a/packages/angular_devkit/schematics/src/rules/template.ts b/packages/angular_devkit/schematics/src/rules/template.ts index d630a3b125..cd950cf513 100644 --- a/packages/angular_devkit/schematics/src/rules/template.ts +++ b/packages/angular_devkit/schematics/src/rules/template.ts @@ -31,7 +31,7 @@ export const kPathTemplateComponentRE = /__(.+?)__/g; export const kPathTemplatePipeRE = /@([^@]+)/; -export type TemplateValue = boolean | string | number; +export type TemplateValue = boolean | string | number | undefined; export type TemplatePipeFunction = (x: string) => TemplateValue; export type TemplateOptions = { [key: string]: TemplateValue | TemplateOptions | TemplatePipeFunction, diff --git a/packages/angular_devkit/schematics/src/sink/dryrun.ts b/packages/angular_devkit/schematics/src/sink/dryrun.ts index fb6add4998..b29c4dae6b 100644 --- a/packages/angular_devkit/schematics/src/sink/dryrun.ts +++ b/packages/angular_devkit/schematics/src/sink/dryrun.ts @@ -84,8 +84,7 @@ export class DryRunSink extends FileSystemSink { } } - const content = null; - this._subject.next({ kind: 'delete', path, content }); + this._subject.next({ kind: 'delete', path }); }); this._filesToCreate.forEach((content, path) => { // Check if this is a renaming. @@ -106,7 +105,7 @@ export class DryRunSink extends FileSystemSink { this._subject.next({ kind: 'update', path, content: content.generate() }); }); this._filesToRename.forEach(([path, to]) => { - this._subject.next({ kind: 'rename', path, to, content: null }); + this._subject.next({ kind: 'rename', path, to }); }); this._subject.complete(); diff --git a/packages/angular_devkit/schematics/tools/file-system-engine-host-base.ts b/packages/angular_devkit/schematics/tools/file-system-engine-host-base.ts index 6ec6a9d16c..1a21a4b1e7 100644 --- a/packages/angular_devkit/schematics/tools/file-system-engine-host-base.ts +++ b/packages/angular_devkit/schematics/tools/file-system-engine-host-base.ts @@ -118,7 +118,7 @@ export abstract class FileSystemEngineHostBase implements createCollectionDescription(name: string): FileSystemCollectionDesc { const path = this._resolveCollectionPath(name); const jsonValue = readJsonFile(path); - if (!jsonValue || typeof jsonValue != 'object') { + if (!jsonValue || typeof jsonValue != 'object' || Array.isArray(jsonValue)) { throw new InvalidCollectionJsonException(name, path); } diff --git a/packages/schematics/angular/application/index.ts b/packages/schematics/angular/application/index.ts index db762a8ecf..d5108e49a1 100644 --- a/packages/schematics/angular/application/index.ts +++ b/packages/schematics/angular/application/index.ts @@ -98,7 +98,7 @@ export default function (options: ApplicationOptions): Rule { options.serviceWorker ? noop() : filter(path => !path.endsWith('/ngsw-config.json')), template({ utils: stringUtils, - ...options as object, + ...options, 'dot': '.', sourcedir: sourceDir, }), diff --git a/packages/schematics/angular/class/index.ts b/packages/schematics/angular/class/index.ts index f07335365c..aa2c8296d0 100644 --- a/packages/schematics/angular/class/index.ts +++ b/packages/schematics/angular/class/index.ts @@ -35,7 +35,7 @@ export default function (options: ClassOptions): Rule { options.spec ? noop() : filter(path => !path.endsWith('.spec.ts')), template({ ...stringUtils, - ...options as object, + ...options, }), move(sourceDir), ]); diff --git a/packages/schematics/angular/component/index.ts b/packages/schematics/angular/component/index.ts index a67bf613cc..02e1bf7c86 100644 --- a/packages/schematics/angular/component/index.ts +++ b/packages/schematics/angular/component/index.ts @@ -119,7 +119,7 @@ export default function(options: ComponentOptions): Rule { template({ ...stringUtils, 'if-flat': (s: string) => options.flat ? '' : s, - ...options as object, + ...options, }), move(sourceDir), ]); diff --git a/packages/schematics/angular/directive/index.ts b/packages/schematics/angular/directive/index.ts index a043661c29..8ade528a88 100644 --- a/packages/schematics/angular/directive/index.ts +++ b/packages/schematics/angular/directive/index.ts @@ -113,7 +113,7 @@ export default function (options: DirectiveOptions): Rule { template({ ...stringUtils, 'if-flat': (s: string) => options.flat ? '' : s, - ...options as object, + ...options, }), move(sourceDir), ]); diff --git a/packages/schematics/angular/enum/index.ts b/packages/schematics/angular/enum/index.ts index 5f46c1dd41..e5cfb2b87b 100644 --- a/packages/schematics/angular/enum/index.ts +++ b/packages/schematics/angular/enum/index.ts @@ -31,7 +31,7 @@ export default function (options: EnumOptions): Rule { const templateSource = apply(url('./files'), [ template({ ...stringUtils, - ...options as object, + ...options, }), move(sourceDir), ]); diff --git a/packages/schematics/angular/guard/index.ts b/packages/schematics/angular/guard/index.ts index cd1c3634ae..a1c76119ab 100644 --- a/packages/schematics/angular/guard/index.ts +++ b/packages/schematics/angular/guard/index.ts @@ -81,7 +81,7 @@ export default function (options: GuardOptions): Rule { options.spec ? noop() : filter(path => !path.endsWith('.spec.ts')), template({ ...stringUtils, - ...options as object, + ...options, }), move(sourceDir), ]); diff --git a/packages/schematics/angular/interface/index.ts b/packages/schematics/angular/interface/index.ts index c1e466d205..100d281ff4 100644 --- a/packages/schematics/angular/interface/index.ts +++ b/packages/schematics/angular/interface/index.ts @@ -33,7 +33,7 @@ export default function (options: InterfaceOptions): Rule { const templateSource = apply(url('./files'), [ template({ ...stringUtils, - ...options as object, + ...options, }), move(sourceDir), ]); diff --git a/packages/schematics/angular/module/index.ts b/packages/schematics/angular/module/index.ts index 3dcc550df8..2a2a956887 100644 --- a/packages/schematics/angular/module/index.ts +++ b/packages/schematics/angular/module/index.ts @@ -87,7 +87,7 @@ export default function (options: ModuleOptions): Rule { template({ ...stringUtils, 'if-flat': (s: string) => options.flat ? '' : s, - ...options as object, + ...options, }), move(sourceDir), ]); diff --git a/packages/schematics/angular/pipe/index.ts b/packages/schematics/angular/pipe/index.ts index 37af3b5b28..3b442f2534 100644 --- a/packages/schematics/angular/pipe/index.ts +++ b/packages/schematics/angular/pipe/index.ts @@ -100,7 +100,7 @@ export default function (options: PipeOptions): Rule { template({ ...stringUtils, 'if-flat': (s: string) => options.flat ? '' : s, - ...options as object, + ...options, }), move(sourceDir), ]); diff --git a/packages/schematics/angular/service/index.ts b/packages/schematics/angular/service/index.ts index b8800f9905..cc98ea0409 100644 --- a/packages/schematics/angular/service/index.ts +++ b/packages/schematics/angular/service/index.ts @@ -86,7 +86,7 @@ export default function (options: ServiceOptions): Rule { template({ ...stringUtils, 'if-flat': (s: string) => options.flat ? '' : s, - ...options as object, + ...options, }), move(sourceDir), ]);