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 --- .../app/videos/+video-watch/comment/linkifier.service.ts | 6 +++--- .../+video-watch/comment/video-comment-add.component.ts | 2 +- .../videos/+video-watch/comment/video-comment.component.ts | 2 +- .../app/videos/+video-watch/comment/video-comment.model.ts | 2 +- .../videos/+video-watch/comment/video-comment.service.ts | 4 ++-- .../+video-watch/comment/video-comments.component.ts | 2 +- .../src/app/videos/+video-watch/video-watch.component.ts | 14 +++++++------- 7 files changed, 16 insertions(+), 16 deletions(-) (limited to 'client/src/app/videos/+video-watch') diff --git a/client/src/app/videos/+video-watch/comment/linkifier.service.ts b/client/src/app/videos/+video-watch/comment/linkifier.service.ts index 3f4072efd..9ad419a69 100644 --- a/client/src/app/videos/+video-watch/comment/linkifier.service.ts +++ b/client/src/app/videos/+video-watch/comment/linkifier.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core' import { getAbsoluteAPIUrl } from '@app/shared/misc/utils' -import * as linkify from 'linkifyjs' -import * as linkifyHtml from 'linkifyjs/html' +const linkify = require('linkifyjs') +const linkifyHtml = require('linkifyjs/html') @Injectable() export class LinkifierService { @@ -40,7 +40,7 @@ export class LinkifierService { const TT_UNDERSCORE = TT.UNDERSCORE const TT_DOT = TT.DOT - function MENTION (value) { + function MENTION (value: any) { this.v = value } diff --git a/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts b/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts index fb7de0e04..ba3c0398e 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts +++ b/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts @@ -76,7 +76,7 @@ export class VideoCommentAddComponent extends FormReactive implements OnInit { this.formValidated() } - openVisitorModal (event) { + openVisitorModal (event: any) { if (this.user === null) { // we only open it for visitors // fixing ng-bootstrap ModalService and the "Expression Changed After It Has Been Checked" Error event.srcElement.blur() diff --git a/client/src/app/videos/+video-watch/comment/video-comment.component.ts b/client/src/app/videos/+video-watch/comment/video-comment.component.ts index e90008de9..982470786 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment.component.ts +++ b/client/src/app/videos/+video-watch/comment/video-comment.component.ts @@ -26,7 +26,7 @@ export class VideoCommentComponent implements OnInit, OnChanges { @Output() resetReply = new EventEmitter() sanitizedCommentHTML = '' - newParentComments = [] + newParentComments: any = [] constructor ( private linkifierService: LinkifierService, diff --git a/client/src/app/videos/+video-watch/comment/video-comment.model.ts b/client/src/app/videos/+video-watch/comment/video-comment.model.ts index fe591811e..824fb24c3 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment.model.ts +++ b/client/src/app/videos/+video-watch/comment/video-comment.model.ts @@ -14,7 +14,7 @@ export class VideoComment implements VideoCommentServerModel { account: AccountInterface totalReplies: number by: string - accountAvatarUrl + accountAvatarUrl: string constructor (hash: VideoCommentServerModel) { this.id = hash.id diff --git a/client/src/app/videos/+video-watch/comment/video-comment.service.ts b/client/src/app/videos/+video-watch/comment/video-comment.service.ts index 9bcb4b7de..7d9c2d0ad 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment.service.ts +++ b/client/src/app/videos/+video-watch/comment/video-comment.service.ts @@ -32,7 +32,7 @@ export class VideoCommentService { return this.authHttp.post(url, normalizedComment) .pipe( - map(data => this.extractVideoComment(data['comment'])), + map((data: any) => this.extractVideoComment(data['comment'])), catchError(err => this.restExtractor.handleError(err)) ) } @@ -43,7 +43,7 @@ export class VideoCommentService { return this.authHttp.post(url, normalizedComment) .pipe( - map(data => this.extractVideoComment(data[ 'comment' ])), + map((data: any) => this.extractVideoComment(data[ 'comment' ])), catchError(err => this.restExtractor.handleError(err)) ) } diff --git a/client/src/app/videos/+video-watch/comment/video-comments.component.ts b/client/src/app/videos/+video-watch/comment/video-comments.component.ts index c864d82b7..4c1bdf2dd 100644 --- a/client/src/app/videos/+video-watch/comment/video-comments.component.ts +++ b/client/src/app/videos/+video-watch/comment/video-comments.component.ts @@ -35,7 +35,7 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { threadComments: { [ id: number ]: VideoCommentThreadTree } = {} threadLoading: { [ id: number ]: boolean } = {} - syndicationItems = [] + syndicationItems: any = [] private sub: Subscription diff --git a/client/src/app/videos/+video-watch/video-watch.component.ts b/client/src/app/videos/+video-watch/video-watch.component.ts index c5deddf05..ed5e723c9 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.ts +++ b/client/src/app/videos/+video-watch/video-watch.component.ts @@ -7,7 +7,7 @@ import { VideoSupportComponent } from '@app/videos/+video-watch/modal/video-supp import { MetaService } from '@ngx-meta/core' import { NotificationsService } from 'angular2-notifications' import { forkJoin, Subscription } from 'rxjs' -import * as videojs from 'video.js' +const videojs = require('video.js') import 'videojs-hotkeys' import { Hotkey, HotkeysService } from 'angular2-hotkeys' import * as WebTorrent from 'webtorrent' @@ -45,7 +45,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { @ViewChild('videoBlacklistModal') videoBlacklistModal: VideoBlacklistComponent @ViewChild('subscribeButton') subscribeButton: SubscribeButtonComponent - player: videojs.Player + player: any playerElement: HTMLVideoElement userRating: UserVideoRateType = null video: VideoDetails = null @@ -435,7 +435,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { this.zone.runOutsideAngular(async () => { videojs(this.playerElement, videojsOptions, function () { self.player = this - this.on('customError', (event, data) => self.handleError(data.err)) + this.on('customError', (data: any) => self.handleError(data.err)) addContextMenu(self.player, self.video.embedUrl) }) @@ -448,7 +448,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { this.checkUserRating() } - private setRating (nextRating) { + private setRating (nextRating: string) { let method switch (nextRating) { case 'like': @@ -466,11 +466,11 @@ export class VideoWatchComponent implements OnInit, OnDestroy { .subscribe( () => { // Update the video like attribute - this.updateVideoRating(this.userRating, nextRating) - this.userRating = nextRating + this.updateVideoRating(this.userRating, nextRating as VideoRateType) + this.userRating = nextRating as UserVideoRateType }, - err => this.notificationsService.error(this.i18n('Error'), err.message) + (err: any) => this.notificationsService.error(this.i18n('Error'), err.message) ) } -- cgit v1.2.3 From c199c427d4ae586339822320f20f512a7a19dc3f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 18 Oct 2018 14:35:31 +0200 Subject: Better typings --- .../app/videos/+video-watch/comment/linkifier.service.ts | 1 + .../+video-watch/comment/video-comment.component.ts | 2 +- .../videos/+video-watch/comment/video-comment.service.ts | 8 ++++---- .../+video-watch/comment/video-comments.component.html | 2 +- .../+video-watch/comment/video-comments.component.scss | 2 +- .../+video-watch/comment/video-comments.component.ts | 3 ++- .../app/videos/+video-watch/video-watch.component.scss | 2 +- .../src/app/videos/+video-watch/video-watch.component.ts | 16 +++++++++------- 8 files changed, 20 insertions(+), 16 deletions(-) (limited to 'client/src/app/videos/+video-watch') diff --git a/client/src/app/videos/+video-watch/comment/linkifier.service.ts b/client/src/app/videos/+video-watch/comment/linkifier.service.ts index 9ad419a69..4f4ec1e5d 100644 --- a/client/src/app/videos/+video-watch/comment/linkifier.service.ts +++ b/client/src/app/videos/+video-watch/comment/linkifier.service.ts @@ -1,5 +1,6 @@ import { Injectable } from '@angular/core' import { getAbsoluteAPIUrl } from '@app/shared/misc/utils' +// FIXME: use @types/linkify when https://github.com/DefinitelyTyped/DefinitelyTyped/pull/29682/files is merged? const linkify = require('linkifyjs') const linkifyHtml = require('linkifyjs/html') diff --git a/client/src/app/videos/+video-watch/comment/video-comment.component.ts b/client/src/app/videos/+video-watch/comment/video-comment.component.ts index 982470786..00f0460a1 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment.component.ts +++ b/client/src/app/videos/+video-watch/comment/video-comment.component.ts @@ -26,7 +26,7 @@ export class VideoCommentComponent implements OnInit, OnChanges { @Output() resetReply = new EventEmitter() sanitizedCommentHTML = '' - newParentComments: any = [] + newParentComments: VideoComment[] = [] constructor ( private linkifierService: LinkifierService, diff --git a/client/src/app/videos/+video-watch/comment/video-comment.service.ts b/client/src/app/videos/+video-watch/comment/video-comment.service.ts index 7d9c2d0ad..921447d5b 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment.service.ts +++ b/client/src/app/videos/+video-watch/comment/video-comment.service.ts @@ -30,9 +30,9 @@ export class VideoCommentService { const url = VideoCommentService.BASE_VIDEO_URL + videoId + '/comment-threads' const normalizedComment = lineFeedToHtml(comment, 'text') - return this.authHttp.post(url, normalizedComment) + return this.authHttp.post<{ comment: VideoCommentServerModel }>(url, normalizedComment) .pipe( - map((data: any) => this.extractVideoComment(data['comment'])), + map(data => this.extractVideoComment(data.comment)), catchError(err => this.restExtractor.handleError(err)) ) } @@ -41,9 +41,9 @@ export class VideoCommentService { const url = VideoCommentService.BASE_VIDEO_URL + videoId + '/comments/' + inReplyToCommentId const normalizedComment = lineFeedToHtml(comment, 'text') - return this.authHttp.post(url, normalizedComment) + return this.authHttp.post<{ comment: VideoCommentServerModel }>(url, normalizedComment) .pipe( - map((data: any) => this.extractVideoComment(data[ 'comment' ])), + map(data => this.extractVideoComment(data.comment)), catchError(err => this.restExtractor.handleError(err)) ) } diff --git a/client/src/app/videos/+video-watch/comment/video-comments.component.html b/client/src/app/videos/+video-watch/comment/video-comments.component.html index 42e129d65..44016d8ad 100644 --- a/client/src/app/videos/+video-watch/comment/video-comments.component.html +++ b/client/src/app/videos/+video-watch/comment/video-comments.component.html @@ -4,7 +4,7 @@ Comments - + diff --git a/client/src/app/videos/+video-watch/comment/video-comments.component.scss b/client/src/app/videos/+video-watch/comment/video-comments.component.scss index dbb44c66c..575e331e4 100644 --- a/client/src/app/videos/+video-watch/comment/video-comments.component.scss +++ b/client/src/app/videos/+video-watch/comment/video-comments.component.scss @@ -23,7 +23,7 @@ margin-right: 0; } -my-video-feed { +my-feed { display: inline-block; margin-left: 5px; } diff --git a/client/src/app/videos/+video-watch/comment/video-comments.component.ts b/client/src/app/videos/+video-watch/comment/video-comments.component.ts index 4c1bdf2dd..8850eccd8 100644 --- a/client/src/app/videos/+video-watch/comment/video-comments.component.ts +++ b/client/src/app/videos/+video-watch/comment/video-comments.component.ts @@ -12,6 +12,7 @@ import { VideoDetails } from '../../../shared/video/video-details.model' import { VideoComment } from './video-comment.model' import { VideoCommentService } from './video-comment.service' import { I18n } from '@ngx-translate/i18n-polyfill' +import { Syndication } from '@app/shared/video/syndication.model' @Component({ selector: 'my-video-comments', @@ -35,7 +36,7 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { threadComments: { [ id: number ]: VideoCommentThreadTree } = {} threadLoading: { [ id: number ]: boolean } = {} - syndicationItems: any = [] + syndicationItems: Syndication[] = [] private sub: Subscription diff --git a/client/src/app/videos/+video-watch/video-watch.component.scss b/client/src/app/videos/+video-watch/video-watch.component.scss index f31e4694a..2586a2204 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.scss +++ b/client/src/app/videos/+video-watch/video-watch.component.scss @@ -162,7 +162,7 @@ $other-videos-width: 260px; } } - my-video-feed { + my-feed { margin-left: 5px; margin-top: 1px; } diff --git a/client/src/app/videos/+video-watch/video-watch.component.ts b/client/src/app/videos/+video-watch/video-watch.component.ts index ed5e723c9..65b974037 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.ts +++ b/client/src/app/videos/+video-watch/video-watch.component.ts @@ -7,7 +7,9 @@ import { VideoSupportComponent } from '@app/videos/+video-watch/modal/video-supp import { MetaService } from '@ngx-meta/core' import { NotificationsService } from 'angular2-notifications' import { forkJoin, Subscription } from 'rxjs' -const videojs = require('video.js') +// FIXME: something weird with our path definition in tsconfig and typings +// @ts-ignore +import videojs from 'video.js' import 'videojs-hotkeys' import { Hotkey, HotkeysService } from 'angular2-hotkeys' import * as WebTorrent from 'webtorrent' @@ -45,7 +47,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { @ViewChild('videoBlacklistModal') videoBlacklistModal: VideoBlacklistComponent @ViewChild('subscribeButton') subscribeButton: SubscribeButtonComponent - player: any + player: videojs.Player playerElement: HTMLVideoElement userRating: UserVideoRateType = null video: VideoDetails = null @@ -435,7 +437,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { this.zone.runOutsideAngular(async () => { videojs(this.playerElement, videojsOptions, function () { self.player = this - this.on('customError', (data: any) => self.handleError(data.err)) + this.on('customError', ({ err }: { err: any }) => self.handleError(err)) addContextMenu(self.player, self.video.embedUrl) }) @@ -448,7 +450,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { this.checkUserRating() } - private setRating (nextRating: string) { + private setRating (nextRating: VideoRateType) { let method switch (nextRating) { case 'like': @@ -466,11 +468,11 @@ export class VideoWatchComponent implements OnInit, OnDestroy { .subscribe( () => { // Update the video like attribute - this.updateVideoRating(this.userRating, nextRating as VideoRateType) - this.userRating = nextRating as UserVideoRateType + this.updateVideoRating(this.userRating, nextRating) + this.userRating = nextRating }, - (err: any) => this.notificationsService.error(this.i18n('Error'), err.message) + (err: { message: string }) => this.notificationsService.error(this.i18n('Error'), err.message) ) } -- cgit v1.2.3 From 951ef8294e9eae8f0b42292059daf0c972dbc48f Mon Sep 17 00:00:00 2001 From: BO41 Date: Wed, 24 Oct 2018 21:50:18 +0200 Subject: add noImplicitThis flag (#1324) --- client/src/app/videos/+video-watch/comment/linkifier.service.ts | 2 +- client/src/app/videos/+video-watch/video-watch.component.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'client/src/app/videos/+video-watch') diff --git a/client/src/app/videos/+video-watch/comment/linkifier.service.ts b/client/src/app/videos/+video-watch/comment/linkifier.service.ts index 4f4ec1e5d..2529c9eaf 100644 --- a/client/src/app/videos/+video-watch/comment/linkifier.service.ts +++ b/client/src/app/videos/+video-watch/comment/linkifier.service.ts @@ -41,7 +41,7 @@ export class LinkifierService { const TT_UNDERSCORE = TT.UNDERSCORE const TT_DOT = TT.DOT - function MENTION (value: any) { + function MENTION (this: any, value: any) { this.v = value } diff --git a/client/src/app/videos/+video-watch/video-watch.component.ts b/client/src/app/videos/+video-watch/video-watch.component.ts index 65b974037..dda870905 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.ts +++ b/client/src/app/videos/+video-watch/video-watch.component.ts @@ -435,7 +435,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { const self = this this.zone.runOutsideAngular(async () => { - videojs(this.playerElement, videojsOptions, function () { + videojs(this.playerElement, videojsOptions, function (this: videojs.Player) { self.player = this this.on('customError', ({ err }: { err: any }) => self.handleError(err)) -- cgit v1.2.3 From 5c6d985faeef1d6793d3f44ca6374f1a9b722806 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 14 Nov 2018 15:01:28 +0100 Subject: Check activities host --- client/src/app/videos/+video-watch/video-watch.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'client/src/app/videos/+video-watch') diff --git a/client/src/app/videos/+video-watch/video-watch.component.ts b/client/src/app/videos/+video-watch/video-watch.component.ts index dda870905..d0151ceb1 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.ts +++ b/client/src/app/videos/+video-watch/video-watch.component.ts @@ -450,7 +450,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { this.checkUserRating() } - private setRating (nextRating: VideoRateType) { + private setRating (nextRating: UserVideoRateType) { let method switch (nextRating) { case 'like': @@ -476,7 +476,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { ) } - private updateVideoRating (oldRating: UserVideoRateType, newRating: VideoRateType) { + private updateVideoRating (oldRating: UserVideoRateType, newRating: UserVideoRateType) { let likesToIncrement = 0 let dislikesToIncrement = 0 -- cgit v1.2.3 From 2fbe7f1933f4bd5de96e6428234e56965616120e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 15 Nov 2018 09:24:56 +0100 Subject: Fix new Angular 7 issues --- .../app/videos/+video-watch/comment/video-comment-add.component.html | 2 +- .../src/app/videos/+video-watch/comment/video-comment-add.component.ts | 2 +- client/src/app/videos/+video-watch/video-watch.module.ts | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) (limited to 'client/src/app/videos/+video-watch') diff --git a/client/src/app/videos/+video-watch/comment/video-comment-add.component.html b/client/src/app/videos/+video-watch/comment/video-comment-add.component.html index b58a56596..d8a7a78c4 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment-add.component.html +++ b/client/src/app/videos/+video-watch/comment/video-comment-add.component.html @@ -3,7 +3,7 @@ Avatar
-