From 244b4ae3973bc1511464a08158a123767f83179c Mon Sep 17 00:00:00 2001 From: BO41 Date: Thu, 18 Oct 2018 09:08:59 +0200 Subject: NoImplicitAny flag true (#1157) this enables the `noImplicitAny` flag in the Typescript compiler > When the noImplicitAny flag is true and the TypeScript compiler cannot infer the type, it still generates the JavaScript files, but it also reports an error. Many seasoned developers prefer this stricter setting because type checking catches more unintentional errors at compile time. closes: #1131 replaces #1137 --- client/src/app/shared/buttons/action-dropdown.component.ts | 6 +++--- client/src/app/shared/buttons/button.component.ts | 6 +++--- client/src/app/shared/buttons/edit-button.component.ts | 2 +- client/src/app/shared/misc/help.component.ts | 2 +- client/src/app/shared/misc/peertube-local-storage.ts | 6 +++--- client/src/app/shared/misc/utils.ts | 2 +- client/src/app/shared/overview/videos-overview.model.ts | 1 + client/src/app/shared/rest/rest-extractor.service.ts | 4 ++-- client/src/app/shared/rest/rest.service.ts | 2 +- client/src/app/shared/users/user.model.ts | 1 + client/src/app/shared/video/abstract-video-list.ts | 6 +++--- client/src/app/shared/video/video-edit.model.ts | 3 ++- client/src/app/shared/video/video-feed.component.ts | 2 +- client/src/app/shared/video/video.service.ts | 2 +- 14 files changed, 24 insertions(+), 21 deletions(-) (limited to 'client/src/app/shared') diff --git a/client/src/app/shared/buttons/action-dropdown.component.ts b/client/src/app/shared/buttons/action-dropdown.component.ts index 022ab5ee8..9877f639d 100644 --- a/client/src/app/shared/buttons/action-dropdown.component.ts +++ b/client/src/app/shared/buttons/action-dropdown.component.ts @@ -2,9 +2,9 @@ import { Component, Input } from '@angular/core' export type DropdownAction = { label?: string - handler?: (T) => any - linkBuilder?: (T) => (string | number)[] - isDisplayed?: (T) => boolean + handler?: (T: any) => any + linkBuilder?: (T: any) => (string | number)[] + isDisplayed?: (T: any) => boolean } @Component({ diff --git a/client/src/app/shared/buttons/button.component.ts b/client/src/app/shared/buttons/button.component.ts index 967cb1409..cccf98bc3 100644 --- a/client/src/app/shared/buttons/button.component.ts +++ b/client/src/app/shared/buttons/button.component.ts @@ -8,9 +8,9 @@ import { Component, Input } from '@angular/core' export class ButtonComponent { @Input() label = '' - @Input() className = undefined - @Input() icon = undefined - @Input() title = undefined + @Input() className: any = undefined + @Input() icon: any = undefined + @Input() title: any = undefined getTitle () { return this.title || this.label diff --git a/client/src/app/shared/buttons/edit-button.component.ts b/client/src/app/shared/buttons/edit-button.component.ts index 7abaacc26..ea552663a 100644 --- a/client/src/app/shared/buttons/edit-button.component.ts +++ b/client/src/app/shared/buttons/edit-button.component.ts @@ -8,5 +8,5 @@ import { Component, Input } from '@angular/core' export class EditButtonComponent { @Input() label: string - @Input() routerLink = [] + @Input() routerLink: any = [] } diff --git a/client/src/app/shared/misc/help.component.ts b/client/src/app/shared/misc/help.component.ts index ba0452e77..ccce1ccfa 100644 --- a/client/src/app/shared/misc/help.component.ts +++ b/client/src/app/shared/misc/help.component.ts @@ -60,7 +60,7 @@ export class HelpComponent implements OnInit, OnChanges { } private createMarkdownList (rules: string[]) { - const rulesToText = { + const rulesToText: any = { 'emphasis': this.i18n('Emphasis'), 'link': this.i18n('Links'), 'newline': this.i18n('New lines'), diff --git a/client/src/app/shared/misc/peertube-local-storage.ts b/client/src/app/shared/misc/peertube-local-storage.ts index 260f994b6..fb5c45acf 100644 --- a/client/src/app/shared/misc/peertube-local-storage.ts +++ b/client/src/app/shared/misc/peertube-local-storage.ts @@ -6,7 +6,7 @@ class MemoryStorage { [key: string]: any [index: number]: string - getItem (key) { + getItem (key: any) { const stringKey = String(key) if (valuesMap.has(key)) { return String(valuesMap.get(stringKey)) @@ -15,11 +15,11 @@ class MemoryStorage { return null } - setItem (key, val) { + setItem (key: any, val: any) { valuesMap.set(String(key), String(val)) } - removeItem (key) { + removeItem (key: any) { valuesMap.delete(key) } diff --git a/client/src/app/shared/misc/utils.ts b/client/src/app/shared/misc/utils.ts index c8b7ebc67..78be2e5dd 100644 --- a/client/src/app/shared/misc/utils.ts +++ b/client/src/app/shared/misc/utils.ts @@ -102,7 +102,7 @@ function objectToFormData (obj: any, form?: FormData, namespace?: string) { return fd } -function lineFeedToHtml (obj: object, keyToNormalize: string) { +function lineFeedToHtml (obj: any, keyToNormalize: string) { return immutableAssign(obj, { [keyToNormalize]: obj[keyToNormalize].replace(/\r?\n|\r/g, '
') }) diff --git a/client/src/app/shared/overview/videos-overview.model.ts b/client/src/app/shared/overview/videos-overview.model.ts index cf02bdb3d..c8eafc8e8 100644 --- a/client/src/app/shared/overview/videos-overview.model.ts +++ b/client/src/app/shared/overview/videos-overview.model.ts @@ -16,4 +16,5 @@ export class VideosOverview implements VideosOverviewServer { tag: string videos: Video[] }[] + [key: string]: any } diff --git a/client/src/app/shared/rest/rest-extractor.service.ts b/client/src/app/shared/rest/rest-extractor.service.ts index 6492aa66d..934f6c618 100644 --- a/client/src/app/shared/rest/rest-extractor.service.ts +++ b/client/src/app/shared/rest/rest-extractor.service.ts @@ -33,7 +33,7 @@ export class RestExtractor { return this.applyToResultListData(result, this.convertDateToHuman, [ fieldsToConvert ]) } - convertDateToHuman (target: object, fieldsToConvert: string[]) { + convertDateToHuman (target: any, fieldsToConvert: string[]) { fieldsToConvert.forEach(field => target[field] = dateToHuman(target[field])) return target @@ -83,7 +83,7 @@ export class RestExtractor { errorMessage = err } - const errorObj = { + const errorObj: any = { message: errorMessage, status: undefined, body: undefined diff --git a/client/src/app/shared/rest/rest.service.ts b/client/src/app/shared/rest/rest.service.ts index 4560c2024..41824a18f 100644 --- a/client/src/app/shared/rest/rest.service.ts +++ b/client/src/app/shared/rest/rest.service.ts @@ -32,7 +32,7 @@ export class RestService { return newParams } - addObjectParams (params: HttpParams, object: object) { + addObjectParams (params: HttpParams, object: any) { for (const name of Object.keys(object)) { const value = object[name] if (!value) continue diff --git a/client/src/app/shared/users/user.model.ts b/client/src/app/shared/users/user.model.ts index 7c840ffa7..e6b612054 100644 --- a/client/src/app/shared/users/user.model.ts +++ b/client/src/app/shared/users/user.model.ts @@ -43,6 +43,7 @@ export class User implements UserServerModel { blocked: boolean blockedReason?: string + [key: string]: any constructor (hash: UserConstructorHash) { this.id = hash.id diff --git a/client/src/app/shared/video/abstract-video-list.ts b/client/src/app/shared/video/abstract-video-list.ts index 1f43f974c..87814d4ba 100644 --- a/client/src/app/shared/video/abstract-video-list.ts +++ b/client/src/app/shared/video/abstract-video-list.ts @@ -27,7 +27,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy { sort: VideoSortField = '-publishedAt' categoryOneOf?: number defaultSort: VideoSortField = '-publishedAt' - syndicationItems = [] + syndicationItems: any = [] loadOnInit = true marginContent = true @@ -59,7 +59,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy { private resizeSubscription: Subscription abstract getVideosObservable (page: number): Observable<{ videos: Video[], totalVideos: number}> - abstract generateSyndicationList () + abstract generateSyndicationList (): any get user () { return this.authService.getUser() @@ -209,7 +209,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy { } protected setNewRouteParams () { - const paramsObject = this.buildRouteParams() + const paramsObject: any = this.buildRouteParams() const queryParams = Object.keys(paramsObject).map(p => p + '=' + paramsObject[p]).join('&') this.location.replaceState(this.currentRoute, queryParams) diff --git a/client/src/app/shared/video/video-edit.model.ts b/client/src/app/shared/video/video-edit.model.ts index 0046be964..a62277e04 100644 --- a/client/src/app/shared/video/video-edit.model.ts +++ b/client/src/app/shared/video/video-edit.model.ts @@ -25,6 +25,7 @@ export class VideoEdit implements VideoUpdate { uuid?: string id?: number scheduleUpdate?: VideoScheduleUpdate + [key: string]: any constructor (video?: Video & { tags: string[], commentsEnabled: boolean, support: string, thumbnailUrl: string, previewUrl: string }) { if (video) { @@ -49,7 +50,7 @@ export class VideoEdit implements VideoUpdate { } } - patch (values: Object) { + patch (values: any) { Object.keys(values).forEach((key) => { this[ key ] = values[ key ] }) diff --git a/client/src/app/shared/video/video-feed.component.ts b/client/src/app/shared/video/video-feed.component.ts index 6922153c0..be6c80c3f 100644 --- a/client/src/app/shared/video/video-feed.component.ts +++ b/client/src/app/shared/video/video-feed.component.ts @@ -6,5 +6,5 @@ import { Component, Input } from '@angular/core' templateUrl: './video-feed.component.html' }) export class VideoFeedComponent { - @Input() syndicationItems + @Input() syndicationItems: any } diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts index 724a0bde9..6283cf84d 100644 --- a/client/src/app/shared/video/video.service.ts +++ b/client/src/app/shared/video/video.service.ts @@ -276,7 +276,7 @@ export class VideoService implements VideosProvider { return this.authHttp .get(environment.apiUrl + descriptionPath) .pipe( - map(res => res[ 'description' ]), + map((res: any) => res[ 'description' ]), catchError(err => this.restExtractor.handleError(err)) ) } -- cgit v1.2.3