Skip to content

Commit

Permalink
refactor(common): ensure compatibility with typescript strict flag (#…
Browse files Browse the repository at this point in the history
…30993)

As part of FW-1265, the `@angular/common` package is made compatible
with the TypeScript `--strict` flag. Read more about the strict flag [here](https://www.typescriptlang.org/docs/handbook/compiler-options.html)

PR Close #30993
  • Loading branch information
devversion authored and mhevery committed Jul 18, 2019
1 parent e061e63 commit 0139b11
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/common/http/src/xhr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export class HttpXhrBackend implements HttpBackend {
// The onError callback is called when something goes wrong at the network level.
// Connection timeout, DNS error, offline, etc. These are actual errors, and are
// transmitted on the error channel.
const onError = (error: ErrorEvent) => {
const onError = (error: ProgressEvent) => {
const {url} = partialFromXhr();
const res = new HttpErrorResponse({
error,
Expand Down
11 changes: 7 additions & 4 deletions packages/common/src/directives/ng_for_of.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,18 @@ export class NgForOf<T> implements DoCheck {
private _applyChanges(changes: IterableChanges<T>) {
const insertTuples: RecordViewTuple<T>[] = [];
changes.forEachOperation(
(item: IterableChangeRecord<any>, adjustedPreviousIndex: number, currentIndex: number) => {
(item: IterableChangeRecord<any>, adjustedPreviousIndex: number | null,
currentIndex: number | null) => {
if (item.previousIndex == null) {
const view = this._viewContainer.createEmbeddedView(
this._template, new NgForOfContext<T>(null !, this._ngForOf, -1, -1), currentIndex);
this._template, new NgForOfContext<T>(null !, this._ngForOf, -1, -1),
currentIndex === null ? undefined : currentIndex);
const tuple = new RecordViewTuple<T>(item, view);
insertTuples.push(tuple);
} else if (currentIndex == null) {
this._viewContainer.remove(adjustedPreviousIndex);
} else {
this._viewContainer.remove(
adjustedPreviousIndex === null ? undefined : adjustedPreviousIndex);
} else if (adjustedPreviousIndex !== null) {
const view = this._viewContainer.get(adjustedPreviousIndex) !;
this._viewContainer.move(view, currentIndex);
const tuple = new RecordViewTuple(item, <EmbeddedViewRef<NgForOfContext<T>>>view);
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/i18n/format_date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ function weekGetter(size: number, monthBased = false): DateFormatter {
};
}

type DateFormatter = (date: Date, locale: string, offset?: number) => string;
type DateFormatter = (date: Date, locale: string, offset: number) => string;

const DATE_FORMATS: {[format: string]: DateFormatter} = {};

Expand Down
3 changes: 1 addition & 2 deletions packages/upgrade/src/common/src/angular1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ export interface ITranscludeFunction {
(cloneAttachFn?: ICloneAttachFunction): IAugmentedJQuery;
}
export interface ICloneAttachFunction {
// Let's hint but not force cloneAttachFn's signature
(clonedElement?: IAugmentedJQuery, scope?: IScope): any;
(clonedElement: IAugmentedJQuery, scope: IScope): any;
}
export type IAugmentedJQuery = Node[] & {
on?: (name: string, fn: () => void) => void;
Expand Down

0 comments on commit 0139b11

Please sign in to comment.