From d74f0eea1b5d4c87f904fb69e36aa78d2ee85084 Mon Sep 17 00:00:00 2001 From: Juan Valencia Calvellido Date: Fri, 29 Sep 2017 11:41:58 +0200 Subject: [PATCH] Bump TypeScript version to 2.4.2 * This is due to a bug about spread operator usage fixed on TypeScript 2.4.0 (Microsoft/TypeScript#5296) * With this change now a warning will be given about the TS version used. This is expected, you see the discussion about it on angular/angular-cli#7625 --- package.json | 2 +- src/app/shared/metric.model.ts | 23 ++++++++++++++++------- src/app/ws-viewer/ws-viewer.component.ts | 2 +- yarn.lock | 6 +++--- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 1f37e39..a08c0ea 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,6 @@ "protractor": "~5.1.2", "ts-node": "~3.2.0", "tslint": "~5.3.2", - "typescript": "2.3.4" + "typescript": "2.4.2" } } diff --git a/src/app/shared/metric.model.ts b/src/app/shared/metric.model.ts index b532f23..66ca2f8 100644 --- a/src/app/shared/metric.model.ts +++ b/src/app/shared/metric.model.ts @@ -16,14 +16,23 @@ export class Metric { * parameters and/or using interfaces. * * For the sake of brevity and simplicity of this model we are gonna - * assume only one single constructor right now (being a single string array - * with all data), and depending on the mileage we might take another route. + * assume only one single constructor right now + * (̶b̶e̶i̶n̶g̶ ̶a̶ ̶s̶i̶n̶g̶l̶e̶ ̶s̶t̶r̶i̶n̶g̶ ̶a̶r̶r̶a̶y̶ ̶w̶i̶t̶h̶ ̶a̶l̶l̶ ̶d̶a̶t̶a̶)̶, + * (being the four parameters of the model), + * and depending on the mileage we might take another route. */ - constructor(metricData: Array) { - this.microservice = metricData[0]; - this.date = new Date(+metricData[1]); - this.metric = metricData[2]; - this.value = +metricData[3]; + // constructor(metricData: Array) { + // this.microservice = metricData[0]; + // this.date = new Date(+metricData[1]); + // this.metric = metricData[2]; + // this.value = +metricData[3]; + // } + + constructor(microservice?: string, date?: string, metric?: string, value?: string) { + this.microservice = microservice; + this.date = new Date(+date); + this.metric = metric; + this.value = +value; } } diff --git a/src/app/ws-viewer/ws-viewer.component.ts b/src/app/ws-viewer/ws-viewer.component.ts index 2ea1ebd..4db6a11 100644 --- a/src/app/ws-viewer/ws-viewer.component.ts +++ b/src/app/ws-viewer/ws-viewer.component.ts @@ -25,7 +25,7 @@ export class WsViewerComponent implements OnInit { // this.subscription = this.wsService.getSubject('handshake') this.subscription = this.wsService.getSubject() .subscribe( - async (msg) => this.metric = new Metric((await msg).split(' ')) + async (msg) => this.metric = new Metric(...(await msg).split(' ')) ); } diff --git a/yarn.lock b/yarn.lock index 697cf29..1d85ed5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5274,9 +5274,9 @@ type-is@~1.6.15: media-typer "0.3.0" mime-types "~2.1.15" -typescript@2.3.4: - version "2.3.4" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.3.4.tgz#3d38321828231e434f287514959c37a82b629f42" +typescript@2.4.2: + version "2.4.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.4.2.tgz#f8395f85d459276067c988aa41837a8f82870844" "typescript@>=2.0.0 <2.6.0", typescript@^2.3.3: version "2.5.2"