Skip to content

Commit

Permalink
feat(stark-all): upgrade to TypeScript 3.2 (latest version supported …
Browse files Browse the repository at this point in the history
…in Angular 7.2)

ISSUES CLOSED: #1234
  • Loading branch information
christophercr committed Apr 9, 2019
1 parent 8bae536 commit 600f88e
Show file tree
Hide file tree
Showing 18 changed files with 58 additions and 53 deletions.
2 changes: 1 addition & 1 deletion greenkeeper.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
"packages": ["showcase/package.json", "starter/package.json"]
}
},
"ignore": ["@angular/flex-layout", "@compodoc/compodoc", "@types/node", "typescript"]
"ignore": ["@compodoc/compodoc", "@types/node", "typescript"]
}
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.17.0",
"tslint-sonarts": "^1.8.0",
"typescript": "~3.1.6",
"typescript": "~3.2.4",
"uglify-es": "^3.3.9",
"zone.js": "~0.8.26"
},
Expand Down Expand Up @@ -154,7 +154,7 @@
"test:showcase:e2e:browserstack": "cd showcase && npm run e2e:browserstack && cd ../..",
"test:starter": "cd starter && npm run test-fast && cd ../..",
"test:starter:e2e": "cd starter && npm run e2e && cd ../..",
"test:ci:all": "npm run test:ci:stark-core && npm run test:ci:stark-ui && npm run test:ci:starter && npm run test:ci:showcase",
"test:ci:all": "npm run test:ci:stark-core && npm run test:ci:stark-ui && npm run test:ci:stark-rbac && npm run test:ci:starter && npm run test:ci:showcase",
"test:ci:stark-core": "cd packages/stark-core && npm run test-fast:ci && cd ../..",
"test:ci:stark-rbac": "cd packages/stark-rbac && npm run test-fast:ci && cd ../..",
"test:ci:stark-ui": "cd packages/stark-ui && npm run test-fast:ci && cd ../..",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const deepFreeze: Function = require("deep-freeze-strict");
const resourcePath = "/something/:somethingId/else/:elseId/next";
const resourceUuid = "dummyUUID";
const resourceEtag = "123456789";
const mockDate: Date = new Date();
const mockDate = new Date();
const mockFrozenPathParamsWithoutUUID: StarkHttpRequestParams = deepFreeze({
pathParameters: { someId: "1234" }
});
Expand Down
14 changes: 7 additions & 7 deletions packages/stark-core/src/util/date.util.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe("Util: DateUtil", () => {

describe("parseDateWithFormat", () => {
it("should return a valid Date when different valid dateStrings are provided using the same format", () => {
const expectedDate: Date = new Date();
const expectedDate = new Date();

// full date-time
expectedDate.setFullYear(2016, 2, 18);
Expand Down Expand Up @@ -60,7 +60,7 @@ describe("Util: DateUtil", () => {
});

it("should return a valid Date when the same dateString is used and passing different formats", () => {
const expectedDate: Date = new Date();
const expectedDate = new Date();

// full date-time (UTC format and including milliseconds)
expectedDate.setUTCFullYear(2016, 2, 18);
Expand Down Expand Up @@ -124,7 +124,7 @@ describe("Util: DateUtil", () => {
});

it("should return a valid Date when the same date is represented in different formats", () => {
const expectedDate: Date = new Date();
const expectedDate = new Date();
expectedDate.setUTCFullYear(2016, 2, 18);
expectedDate.setUTCHours(17, 25, 43, 511);

Expand Down Expand Up @@ -185,10 +185,10 @@ describe("Util: DateUtil", () => {
it("should return the date in a formatted string based on the given format", () => {
// IMPORTANT: in case the date string has a timezone, it should have a ':' between the hours and the minutes
// otherwise IE will fail to parse it returning "Invalid Date"
const mockDate: Date = new Date("2016-03-18T10:25:43.511+01:00");
const mockDate = new Date("2016-03-18T10:25:43.511+01:00");

// another way to create a date
// const mockDate: Date = new Date();
// const mockDate = new Date();
// mockDate.setFullYear(2016, 2, 18);
// mockDate.setHours(10, 25, 43, 511);

Expand Down Expand Up @@ -222,7 +222,7 @@ describe("Util: DateUtil", () => {
});

it("should return the date in a formatted string based on the default format if no format is defined", () => {
const mockDate: Date = new Date();
const mockDate = new Date();
mockDate.setFullYear(2016, 2, 18);
mockDate.setHours(10, 25, 43, 511);

Expand All @@ -231,7 +231,7 @@ describe("Util: DateUtil", () => {
});

it("should return 'invalid format' when the given format is invalid", () => {
const mockDate: Date = new Date();
const mockDate = new Date();
mockDate.setFullYear(2016, 2, 18);
mockDate.setHours(10, 25, 43, 511);

Expand Down
5 changes: 3 additions & 2 deletions packages/stark-rbac/base.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ if (window.NodeList && !NodeList.prototype.forEach) {
}

/* tslint:disable:no-import-side-effect */
// FIXME: change when https://github.com/monounity/karma-typescript/issues/320 is resolved
// tslint:disable-next-line:import-blacklist
import "lodash-es"; // see https://github.com/monounity/karma-typescript/issues/150#issuecomment-318620280
import "zone.js/dist/zone";
import "zone.js/dist/long-stack-trace-zone";
import "zone.js/dist/proxy"; // since zone.js 0.6.15
import "zone.js/dist/sync-test";
import "zone.js/dist/jasmine-patch"; // put here since zone.js 0.6.14
import "zone.js/dist/async-test";
import "zone.js/dist/fake-async-test";
import "zone.js/dist/zone-patch-rxjs";
import "zone.js/dist/zone-patch-rxjs-fake-async";
/* tslint:enable:no-import-side-effect */

import { TestBed } from "@angular/core/testing";
Expand Down
10 changes: 8 additions & 2 deletions packages/stark-rbac/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@ const karmaTypescriptBundlerAliasResolution = {
cerialize: "../stark-core/node_modules/cerialize/index.js",
"class-validator": "../stark-core/node_modules/class-validator/index.js",
"deep-freeze-strict": "../stark-core/node_modules/deep-freeze-strict/index.js",
moment: "../stark-core/node_modules/moment/moment.js",
ibantools: "../stark-core/node_modules/ibantools/build/ibantools.js"
ibantools: "../stark-core/node_modules/ibantools/build/ibantools.js",
"lodash-es": "../stark-core/node_modules/lodash-es/lodash.js",
"lodash-es/cloneDeep": "../stark-core/node_modules/lodash-es/cloneDeep.js",
"lodash-es/floor": "../stark-core/node_modules/lodash-es/floor.js",
"lodash-es/isEmpty": "../stark-core/node_modules/lodash-es/isEmpty.js",
"lodash-es/noop": "../stark-core/node_modules/lodash-es/noop.js",
"lodash-es/reduce": "../stark-core/node_modules/lodash-es/reduce.js",
moment: "../stark-core/node_modules/moment/moment.js"
}
}
};
Expand Down
4 changes: 2 additions & 2 deletions packages/stark-ui/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const karmaTypescriptBundlerAlias = {
cerialize: "../stark-core/node_modules/cerialize/index.js",
"class-validator": "../stark-core/node_modules/class-validator/index.js",
"deep-freeze-strict": "../stark-core/node_modules/deep-freeze-strict/index.js",
moment: "../stark-core/node_modules/moment/moment.js",
ibantools: "../stark-core/node_modules/ibantools/build/ibantools.js",
"lodash-es": "../stark-core/node_modules/lodash-es/lodash.js",
"lodash-es/cloneDeep": "../stark-core/node_modules/lodash-es/cloneDeep.js",
"lodash-es/findIndex": "../stark-core/node_modules/lodash-es/findIndex.js",
Expand All @@ -39,7 +39,7 @@ const karmaTypescriptBundlerAlias = {
"lodash-es/reduce": "../stark-core/node_modules/lodash-es/reduce.js",
"lodash-es/startCase": "../stark-core/node_modules/lodash-es/startCase.js",
"lodash-es/uniqueId": "../stark-core/node_modules/lodash-es/uniqueId.js",
ibantools: "../stark-core/node_modules/ibantools/build/ibantools.js"
moment: "../stark-core/node_modules/moment/moment.js"
};

// start customizing the KarmaCI configuration from stark-testing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,23 +174,23 @@ describe("DatePickerComponent", () => {
});

it("the MatDatepickerInput min date should be minDate", () => {
const minDate: Date = new Date(2018, 6, 1);
const minDate = new Date(2018, 6, 1);
component.min = minDate;
hostFixture.detectChanges();
expect(component.pickerInput.min).not.toBeNull();
expect((<moment.Moment>component.pickerInput.min).toDate()).toEqual(minDate);
});

it("the MatDatepickerInput max date should be maxDate", () => {
const maxDate: Date = new Date(2018, 6, 2);
const maxDate = new Date(2018, 6, 2);
component.max = maxDate;
hostFixture.detectChanges();
expect(component.pickerInput.max).not.toBeNull();
expect((<moment.Moment>component.pickerInput.max).toDate()).toEqual(maxDate);
});

it("the MatDatepickerInput value should be date", () => {
const date: Date = new Date(2018, 6, 3);
const date = new Date(2018, 6, 3);
hostComponent.formControl.setValue(date);
hostFixture.detectChanges();
expect(component.pickerInput.value).not.toBeNull();
Expand Down Expand Up @@ -341,23 +341,23 @@ describe("DatePickerComponent", () => {
});

it("the MatDatepickerInput min date should be minDate", () => {
const minDate: Date = new Date(2018, 6, 1);
const minDate = new Date(2018, 6, 1);
component.min = minDate;
hostFixture.detectChanges();
expect(component.pickerInput.min).not.toBeNull();
expect((<moment.Moment>component.pickerInput.min).toDate()).toEqual(minDate);
});

it("the MatDatepickerInput max date should be maxDate", () => {
const maxDate: Date = new Date(2018, 6, 2);
const maxDate = new Date(2018, 6, 2);
component.max = maxDate;
hostFixture.detectChanges();
expect(component.pickerInput.max).not.toBeNull();
expect((<moment.Moment>component.pickerInput.max).toDate()).toEqual(maxDate);
});

it("the MatDatepickerInput value should be date", () => {
const date: Date = new Date(2018, 6, 3);
const date = new Date(2018, 6, 3);
hostComponent.value = date;
hostFixture.detectChanges();
expect(component.pickerInput.value).not.toBeNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ describe("DateRangePickerComponent", () => {
});

it("the datepickers min date should be set correctly", () => {
const minDate: Date = new Date(2018, 6, 1);
const minDate = new Date(2018, 6, 1);
component.startMinDate = minDate;
component.endMinDate = minDate;
fixture.detectChanges();
Expand All @@ -121,7 +121,7 @@ describe("DateRangePickerComponent", () => {
});

it("the datepickers max date should be set correctly", () => {
const maxDate: Date = new Date(2018, 6, 2);
const maxDate = new Date(2018, 6, 2);
component.startMaxDate = maxDate;
component.endMaxDate = maxDate;
fixture.detectChanges();
Expand All @@ -132,7 +132,7 @@ describe("DateRangePickerComponent", () => {
});

it("the datepickers value should be set correctly", () => {
const date: Date = new Date(2018, 6, 3);
const date = new Date(2018, 6, 3);
component.startDate = date;
component.endDate = date;
fixture.detectChanges();
Expand All @@ -153,7 +153,7 @@ describe("DateRangePickerComponent", () => {
});

it("the end date should be correctly set if after the start date", () => {
const endDate: Date = new Date(2018, 6, 7);
const endDate = new Date(2018, 6, 7);
component.startDate = new Date(2018, 6, 6);
component.endDate = endDate;
fixture.detectChanges();
Expand All @@ -162,7 +162,7 @@ describe("DateRangePickerComponent", () => {
});

it("the end date should be correctly set if after the start date is undefined", () => {
const endDate: Date = new Date(2018, 6, 8);
const endDate = new Date(2018, 6, 8);
component.startDate = undefined;
component.endDate = endDate;
fixture.detectChanges();
Expand Down
12 changes: 6 additions & 6 deletions showcase/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions showcase/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
"@angular/compiler": "~7.2.2",
"@angular/compiler-cli": "~7.2.2",
"@angular/core": "~7.2.2",
"@angular/flex-layout": "7.0.0-beta.22",
"@angular/flex-layout": "7.0.0-beta.24",
"@angular/forms": "~7.2.2",
"@angular/material": "~7.3.0",
"@angular/platform-browser": "~7.2.2",
Expand Down Expand Up @@ -157,6 +157,6 @@
"parse5": "~5.1.0",
"ts-node": "~8.0.2",
"tslib": "~1.9.3",
"typescript": "~3.1.6"
"typescript": "~3.2.4"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class DemoDatePickerPageComponent implements OnDestroy {
public minDate = new Date();
public maxDate = new Date(Date.now() + 30 * DAY_IN_MILLISECONDS);

public ngModelDate: Date = new Date();
public ngModelDate = new Date();
public formControl = new FormControl(new Date(), Validators.required);

public disabled = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class DemoInputMaskDirectivesPageComponent {
}

public logChange(event: Event): void {
this.logger.debug("input value changed", (<HTMLInputElement>event.srcElement).value);
this.logger.debug("input value changed", (<HTMLInputElement>event.target).value);
}

public logModelChange(model: any): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export class InMemoryDataHttpInterceptor implements HttpInterceptor {
// .add(40, "m")
// .toDate()
// .toUTCString(); // 40 minutes from now
const expirationDate: Date = new Date();
const expirationDate = new Date();
expirationDate.setTime(new Date().getTime() + 2400000); // 40 minutes from now
const cookieExpiration: string = expirationDate.toUTCString();
const cookieAttributes: string[] = [`${this.xsrfCookieName}=${xsrfToken}`, `path='/'`, `expires=${cookieExpiration}`];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { TableOfContentLink } from "./table-of-content-link.intf";
templateUrl: "./table-of-contents.component.html"
})
/**
* The table of contents component, freely inspired from :
* The table of contents component, freely inspired from:
* @link https://github.com/angular/material.angular.io/tree/master/src/app/shared/table-of-contents
*/
export class TableOfContentsComponent implements OnInit, AfterViewInit, OnDestroy {
Expand Down Expand Up @@ -67,7 +67,7 @@ export class TableOfContentsComponent implements OnInit, AfterViewInit, OnDestro
}

/**
* Gets the scrolloffset of the container.
* Gets the scrollOffset of the container.
* Basically, this will return the position on the screen where the user is located.
*/
private getScrollOffset(): number {
Expand Down Expand Up @@ -118,10 +118,8 @@ export class TableOfContentsComponent implements OnInit, AfterViewInit, OnDestro
*/
private onScroll(): void {
const linksCounter: number = this.links.length - 1;
const max: number = (<HTMLElement>document.documentElement).scrollHeight;
const pos: number =
((<HTMLElement>document.documentElement).scrollTop || document.body.scrollTop) +
(<HTMLElement>document.documentElement).offsetHeight;
const max: number = document.documentElement.scrollHeight;
const pos: number = (document.documentElement.scrollTop || document.body.scrollTop) + document.documentElement.offsetHeight;
if (pos === max) {
this.links[linksCounter].active = true;
for (let i = 0; i < linksCounter; i++) {
Expand All @@ -137,8 +135,8 @@ export class TableOfContentsComponent implements OnInit, AfterViewInit, OnDestro

/**
* This method will check, thanks to the user's position on a screen, if a link is active or not.
* If the value of scrolloffset is higher than the top of the currentlink (so, below the currentLink)
* and lower than the top of tne nextlinkg (so, above the nextLink), it means that the link is active.
* If the value of scrollOffset is higher than the top of the current link (so, below the current link)
* and lower than the top of tne next link (so, above the next link), it means that the link is active.
* @param currentLink - the Link we are analysing
* @param nextLink - the Link that follows the currentLink
* @returns - if the link is active (true) or not (false)
Expand Down
2 changes: 1 addition & 1 deletion showcase/src/assets/examples/date-picker/ng-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class DemoDatePickerComponent {
public minDate = new Date();
public maxDate = new Date(Date.now() + 30 * DAY_IN_MILLISECONDS);

public date: Date = new Date();
public date = new Date();
public disabled = false;

public maskConfig: StarkTimestampMaskConfig = { format: "DD-MM-YYYY" };
Expand Down
4 changes: 2 additions & 2 deletions starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"@angular/compiler": "~7.2.2",
"@angular/compiler-cli": "~7.2.2",
"@angular/core": "~7.2.2",
"@angular/flex-layout": "7.0.0-beta.22",
"@angular/flex-layout": "7.0.0-beta.24",
"@angular/forms": "~7.2.2",
"@angular/material": "~7.3.0",
"@angular/platform-browser": "~7.2.2",
Expand Down Expand Up @@ -160,6 +160,6 @@
"parse5": "~5.1.0",
"ts-node": "~8.0.2",
"tslib": "~1.9.3",
"typescript": "~3.1.6"
"typescript": "~3.2.4"
}
}

0 comments on commit 600f88e

Please sign in to comment.