1
0
Fork 0

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
This commit is contained in:
BO41 2018-10-18 09:08:59 +02:00 committed by Rigel Kent
parent 28e51e831b
commit 244b4ae397
64 changed files with 181 additions and 174 deletions

View File

@ -62,7 +62,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
}
ngOnInit () {
const formGroupData = {
const formGroupData: any = {
instanceName: this.customConfigValidatorsService.INSTANCE_NAME,
instanceShortDescription: this.customConfigValidatorsService.INSTANCE_SHORT_DESCRIPTION,
instanceDescription: null,
@ -202,7 +202,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
}
private updateForm () {
const data = {
const data: any = {
instanceName: this.customConfig.instance.name,
instanceShortDescription: this.customConfig.instance.shortDescription,
instanceDescription: this.customConfig.instance.description,

View File

@ -7,7 +7,7 @@ export abstract class UserEdit extends FormReactive {
videoQuotaOptions: { value: string, label: string }[] = []
videoQuotaDailyOptions: { value: string, label: string }[] = []
roles = Object.keys(USER_ROLE_LABELS).map(key => ({ value: key.toString(), label: USER_ROLE_LABELS[key] }))
roles = Object.keys(USER_ROLE_LABELS).map((key: any) => ({ value: key.toString(), label: USER_ROLE_LABELS[key] }))
protected abstract serverService: ServerService
protected abstract configService: ConfigService

View File

@ -45,12 +45,12 @@ export class UserListComponent extends RestTable implements OnInit {
{
label: this.i18n('Ban'),
handler: users => this.openBanUserModal(users),
isDisplayed: users => users.every(u => u.blocked === false)
isDisplayed: users => users.every((u: any) => u.blocked === false)
},
{
label: this.i18n('Unban'),
handler: users => this.unbanUsers(users),
isDisplayed: users => users.every(u => u.blocked === true)
isDisplayed: users => users.every((u: any) => u.blocked === true)
}
]
}

View File

@ -17,7 +17,7 @@ import { VideoChannelValidatorsService } from '@app/shared/forms/form-validators
styleUrls: [ './my-account-video-channel-edit.component.scss' ]
})
export class MyAccountVideoChannelUpdateComponent extends MyAccountVideoChannelEdit implements OnInit, OnDestroy {
@ViewChild('avatarfileInput') avatarfileInput
@ViewChild('avatarfileInput') avatarfileInput: any
error: string

View File

@ -66,7 +66,7 @@ export class MyAccountVideosComponent extends AbstractVideoList implements OnIni
}
isInSelectionMode () {
return Object.keys(this.checkedVideos).some(k => this.checkedVideos[ k ] === true)
return Object.keys(this.checkedVideos).some((k: any) => this.checkedVideos[ k ] === true)
}
getVideosObservable (page: number) {
@ -81,7 +81,7 @@ export class MyAccountVideosComponent extends AbstractVideoList implements OnIni
async deleteSelectedVideos () {
const toDeleteVideosIds = Object.keys(this.checkedVideos)
.filter(k => this.checkedVideos[ k ] === true)
.filter((k: any) => this.checkedVideos[ k ] === true)
.map(k => parseInt(k, 10))
const res = await this.confirmService.confirm(
@ -168,9 +168,10 @@ export class MyAccountVideosComponent extends AbstractVideoList implements OnIni
}
private spliceVideosById (id: number) {
for (const key of Object.keys(this.loadedPages)) {
let key: any
for (key of Object.keys(this.loadedPages)) {
const videos = this.loadedPages[ key ]
const index = videos.findIndex(v => v.id === id)
const index = videos.findIndex((v: any) => v.id === id)
if (index !== -1) {
videos.splice(index, 1)

View File

@ -49,7 +49,8 @@ export class VideoChangeOwnershipComponent extends FormReactive implements OnIni
.catch((_) => _) // Called when closing (cancel) the modal without validating, do nothing
}
search (event) {
// TODO: typing
search (event: any) {
const query = event.query
this.userService.autocomplete(query)
.subscribe(

View File

@ -10,7 +10,7 @@ import { Account } from '@app/shared/account/account.model'
styleUrls: [ './actor-avatar-info.component.scss' ]
})
export class ActorAvatarInfoComponent {
@ViewChild('avatarfileInput') avatarfileInput
@ViewChild('avatarfileInput') avatarfileInput: any
@Input() actor: VideoChannel | Account

View File

@ -69,7 +69,7 @@ export function metaFactory (serverService: ServerService): MetaLoader {
providers: [
{
provide: TRANSLATIONS,
useFactory: (locale) => {
useFactory: (locale: string) => {
// On dev mode, test localization
if (isOnDevLocale()) {
locale = buildFileLocale(getDevLocale())

View File

@ -221,7 +221,7 @@ export class AuthService {
}
refreshUserInformation () {
const obj = {
const obj: any = {
access_token: this.user.getAccessToken(),
refresh_token: null,
token_type: this.user.getTokenType(),

View File

@ -155,7 +155,7 @@ export class ServerService {
.pipe(
switchMap(translations => {
return this.http.get(ServerService.BASE_VIDEO_URL + attributeName)
.pipe(map(data => ({ data, translations })))
.pipe(map((data: any) => ({ data, translations })))
})
)
.subscribe(({ data, translations }) => {

View File

@ -5,7 +5,7 @@ import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage'
export class ThemeService {
private theme = document.querySelector('body')
private darkTheme = false
private previousTheme = {}
private previousTheme: { [ id: string ]: string } = {}
constructor () {
// initialise the alternative theme with dark theme colors
@ -33,7 +33,7 @@ export class ThemeService {
}
}
private switchProperty (property, newValue?) {
private switchProperty (property: string, newValue?: string) {
const propertyOldvalue = window.getComputedStyle(this.theme).getPropertyValue('--' + property)
this.theme.style.setProperty('--' + property, (newValue) ? newValue : this.previousTheme[property])
this.previousTheme[property] = propertyOldvalue

View File

@ -18,7 +18,7 @@ export class MenuComponent implements OnInit {
userHasAdminAccess = false
helpVisible = false
private routesPerRight = {
private routesPerRight: any = {
[UserRight.MANAGE_USERS]: '/admin/users',
[UserRight.MANAGE_SERVER_FOLLOW]: '/admin/friends',
[UserRight.MANAGE_VIDEO_ABUSES]: '/admin/moderation/video-abuses',

View File

@ -53,7 +53,7 @@ export class AdvancedSearch {
}
containsValues () {
const obj = this.toUrlObject()
const obj: any = this.toUrlObject()
for (const k of Object.keys(obj)) {
if (k === 'sort') continue // Exception
@ -113,7 +113,7 @@ export class AdvancedSearch {
size () {
let acc = 0
const obj = this.toUrlObject()
const obj: any = this.toUrlObject()
for (const k of Object.keys(obj)) {
if (k === 'sort') continue // Exception

View File

@ -2,9 +2,9 @@ import { Component, Input } from '@angular/core'
export type DropdownAction<T> = {
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({

View File

@ -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

View File

@ -8,5 +8,5 @@ import { Component, Input } from '@angular/core'
export class EditButtonComponent {
@Input() label: string
@Input() routerLink = []
@Input() routerLink: any = []
}

View File

@ -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'),

View File

@ -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)
}

View File

@ -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, '<br />')
})

View File

@ -16,4 +16,5 @@ export class VideosOverview implements VideosOverviewServer {
tag: string
videos: Video[]
}[]
[key: string]: any
}

View File

@ -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

View File

@ -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

View File

@ -43,6 +43,7 @@ export class User implements UserServerModel {
blocked: boolean
blockedReason?: string
[key: string]: any
constructor (hash: UserConstructorHash) {
this.id = hash.id

View File

@ -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)

View File

@ -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 ]
})

View File

@ -6,5 +6,5 @@ import { Component, Input } from '@angular/core'
templateUrl: './video-feed.component.html'
})
export class VideoFeedComponent {
@Input() syndicationItems
@Input() syndicationItems: any
}

View File

@ -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))
)
}

View File

@ -19,7 +19,7 @@ export class VideoCaptionAddModalComponent extends FormReactive implements OnIni
@ViewChild('modal') modal: ElementRef
videoCaptionLanguages = []
videoCaptionLanguages: any = []
private openedModal: NgbModalRef
private closingModal = false
@ -73,7 +73,7 @@ export class VideoCaptionAddModalComponent extends FormReactive implements OnIni
this.hide()
const languageId = this.form.value[ 'language' ]
const languageObject = this.videoCaptionLanguages.find(l => l.id === languageId)
const languageObject = this.videoCaptionLanguages.find((l: any) => l.id === languageId)
this.captionAdded.emit({
language: languageObject,

View File

@ -48,7 +48,7 @@ export class VideoEditComponent implements OnInit, OnDestroy {
calendarTimezone: string
calendarDateFormat: string
private schedulerInterval
private schedulerInterval: any
private firstPatchDone = false
private initialVideoCaptions: string[] = []
@ -77,13 +77,13 @@ export class VideoEditComponent implements OnInit, OnDestroy {
}
updateForm () {
const defaultValues = {
const defaultValues: any = {
nsfw: 'false',
commentsEnabled: 'true',
waitTranscoding: 'true',
tags: []
}
const obj = {
const obj: any = {
name: this.videoValidatorsService.VIDEO_NAME,
privacy: this.videoValidatorsService.VIDEO_PRIVACY,
channelId: this.videoValidatorsService.VIDEO_CHANNEL,

View File

@ -23,7 +23,7 @@ import { VideoImportService } from '@app/shared/video-import'
})
export class VideoImportTorrentComponent extends VideoSend implements OnInit, CanComponentDeactivate {
@Output() firstStepDone = new EventEmitter<string>()
@ViewChild('torrentfileInput') torrentfileInput
@ViewChild('torrentfileInput') torrentfileInput: any
videoFileName: string
magnetUri = ''

View File

@ -30,7 +30,7 @@ export abstract class VideoSend extends FormReactive implements OnInit, CanCompo
protected videoService: VideoService
protected videoCaptionService: VideoCaptionService
abstract canDeactivate ()
abstract canDeactivate (): any
ngOnInit () {
this.buildForm({})

View File

@ -25,7 +25,7 @@ import { VideoCaptionService } from '@app/shared/video-caption'
})
export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy, CanComponentDeactivate {
@Output() firstStepDone = new EventEmitter<string>()
@ViewChild('videofileInput') videofileInput
@ViewChild('videofileInput') videofileInput: any
// So that it can be accessed in the template
readonly SPECIAL_SCHEDULED_PRIVACY = VideoEdit.SPECIAL_SCHEDULED_PRIVACY

View File

@ -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
}

View File

@ -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()

View File

@ -26,7 +26,7 @@ export class VideoCommentComponent implements OnInit, OnChanges {
@Output() resetReply = new EventEmitter()
sanitizedCommentHTML = ''
newParentComments = []
newParentComments: any = []
constructor (
private linkifierService: LinkifierService,

View File

@ -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

View File

@ -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))
)
}

View File

@ -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

View File

@ -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)
)
}

View File

@ -40,15 +40,15 @@ export class PeertubeChunkStore extends EventEmitter {
// If the store is full
private memoryChunks: { [ id: number ]: Buffer | true } = {}
private databaseName: string
private putBulkTimeout
private cleanerInterval
private putBulkTimeout: any
private cleanerInterval: any
private db: ChunkDatabase
private expirationDB: ExpirationDatabase
private readonly length: number
private readonly lastChunkLength: number
private readonly lastChunkIndex: number
constructor (chunkLength: number, opts) {
constructor (chunkLength: number, opts: any) {
super()
this.databaseName = 'webtorrent-chunks-'
@ -113,13 +113,13 @@ export class PeertubeChunkStore extends EventEmitter {
}, PeertubeChunkStore.BUFFERING_PUT_MS)
}
get (index: number, opts, cb) {
get (index: number, opts: any, cb: any): any {
if (typeof opts === 'function') return this.get(index, null, opts)
// IndexDB could be slow, use our memory index first
const memoryChunk = this.memoryChunks[index]
if (memoryChunk === undefined) {
const err = new Error('Chunk not found')
const err = new Error('Chunk not found') as any
err['notFound'] = true
return process.nextTick(() => cb(err))
@ -146,11 +146,11 @@ export class PeertubeChunkStore extends EventEmitter {
})
}
close (db) {
close (db: any) {
return this.destroy(db)
}
async destroy (cb) {
async destroy (cb: any) {
try {
if (this.pendingPut) {
clearTimeout(this.putBulkTimeout)
@ -225,7 +225,7 @@ export class PeertubeChunkStore extends EventEmitter {
}
}
private nextTick (cb, err, val?) {
private nextTick (cb: any, err: Error, val?: any) {
process.nextTick(() => cb(err, val), undefined)
}
}

View File

@ -1,11 +1,10 @@
import * as videojs from 'video.js'
import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings'
import { buildVideoLink } from './utils'
const Button: VideoJSComponentInterface = videojsUntyped.getComponent('Button')
class PeerTubeLinkButton extends Button {
constructor (player: videojs.Player, options) {
constructor (player: any, options: any) {
super(player, options)
}

View File

@ -4,7 +4,7 @@ const Component: VideoJSComponentInterface = videojsUntyped.getComponent('Compon
class PeerTubeLoadProgressBar extends Component {
constructor (player, options) {
constructor (player: any, options: any) {
super(player, options)
this.partEls_ = []
this.on(player, 'progress', this.update)

View File

@ -75,12 +75,12 @@ function getVideojsOptions (options: {
enableVolumeScroll: false,
enableModifiersForNumbers: false,
fullscreenKey: function (event) {
fullscreenKey: function (event: any) {
// fullscreen with the f key or Ctrl+Enter
return event.key === 'f' || (event.ctrlKey && event.key === 'Enter')
},
seekStep: function (event) {
seekStep: function (event: any) {
// mimic VLC seek behavior, and default to 5 (original value is 5).
if (event.ctrlKey && event.altKey) {
return 5 * 60
@ -95,26 +95,26 @@ function getVideojsOptions (options: {
customKeys: {
increasePlaybackRateKey: {
key: function (event) {
key: function (event: any) {
return event.key === '>'
},
handler: function (player) {
handler: function (player: any) {
player.playbackRate((player.playbackRate() + 0.1).toFixed(2))
}
},
decreasePlaybackRateKey: {
key: function (event) {
key: function (event: any) {
return event.key === '<'
},
handler: function (player) {
handler: function (player: any) {
player.playbackRate((player.playbackRate() - 0.1).toFixed(2))
}
},
frameByFrame: {
key: function (event) {
key: function (event: any) {
return event.key === '.'
},
handler: function (player, options, event) {
handler: function (player: any) {
player.pause()
// Calculate movement distance (assuming 30 fps)
const dist = 1 / 30

View File

@ -1,11 +1,11 @@
import * as videojs from 'video.js'
const videojs = require('video.js')
import * as WebTorrent from 'webtorrent'
import { VideoFile } from '../../../../shared/models/videos/video.model'
import { renderVideo } from './video-renderer'
import './settings-menu-button'
import { PeertubePluginOptions, UserWatching, VideoJSCaption, VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings'
import { isMobile, timeToInt, videoFileMaxByResolution, videoFileMinByResolution } from './utils'
import * as CacheChunkStore from 'cache-chunk-store'
const CacheChunkStore = require('cache-chunk-store')
import { PeertubeChunkStore } from './peertube-chunk-store'
import {
getAverageBandwidthInStore,
@ -61,11 +61,11 @@ class PeerTubePlugin extends Plugin {
private player: any
private currentVideoFile: VideoFile
private torrent: WebTorrent.Torrent
private torrent: any
private videoCaptions: VideoJSCaption[]
private renderer
private fakeRenderer
private renderer: any
private fakeRenderer: any
private destoyingFakeRenderer = false
private autoResolution = true
@ -73,17 +73,17 @@ class PeerTubePlugin extends Plugin {
private isAutoResolutionObservation = false
private playerRefusedP2P = false
private videoViewInterval
private torrentInfoInterval
private autoQualityInterval
private userWatchingVideoInterval
private addTorrentDelay
private qualityObservationTimer
private runAutoQualitySchedulerTimer
private videoViewInterval: any
private torrentInfoInterval: any
private autoQualityInterval: any
private userWatchingVideoInterval: any
private addTorrentDelay: any
private qualityObservationTimer: any
private runAutoQualitySchedulerTimer: any
private downloadSpeeds: number[] = []
constructor (player: videojs.Player, options: PeertubePluginOptions) {
constructor (player: any, options: PeertubePluginOptions) {
super(player, options)
// Disable auto play on iOS
@ -273,7 +273,7 @@ class PeerTubePlugin extends Plugin {
const oldTorrent = this.torrent
const torrentOptions = {
store: (chunkLength, storeOpts) => new CacheChunkStore(new PeertubeChunkStore(chunkLength, storeOpts), {
store: (chunkLength: any, storeOpts: any) => new CacheChunkStore(new PeertubeChunkStore(chunkLength, storeOpts), {
max: 100
})
}
@ -304,7 +304,7 @@ class PeerTubePlugin extends Plugin {
if (err) return this.fallbackToHttp(options, done)
return this.tryToPlay(err => {
return this.tryToPlay((err: Error) => {
if (err) return done(err)
if (options.seek) this.seek(options.seek)
@ -316,7 +316,7 @@ class PeerTubePlugin extends Plugin {
}, options.delay || 0)
})
this.torrent.on('error', err => console.error(err))
this.torrent.on('error', (err: any) => console.error(err))
this.torrent.on('warning', (err: any) => {
// We don't support HTTP tracker but we don't care -> we use the web socket tracker
@ -350,7 +350,7 @@ class PeerTubePlugin extends Plugin {
const playPromise = this.player.play()
if (playPromise !== undefined) {
return playPromise.then(done)
.catch(err => {
.catch((err: Error) => {
if (err.message.indexOf('The play() request was interrupted by a call to pause()') !== -1) {
return
}
@ -627,7 +627,7 @@ class PeerTubePlugin extends Plugin {
this.player.options_.inactivityTimeout = saveInactivityTimeout
}
const settingsDialog = this.player.children_.find(c => c.name_ === 'SettingsDialog')
const settingsDialog = this.player.children_.find((c: any) => c.name_ === 'SettingsDialog')
this.player.controlBar.on('mouseenter', () => disableInactivity())
settingsDialog.on('mouseenter', () => disableInactivity())
@ -641,7 +641,7 @@ class PeerTubePlugin extends Plugin {
return this.videoFiles[Math.floor(this.videoFiles.length / 2)]
}
private stopTorrent (torrent: WebTorrent.Torrent) {
private stopTorrent (torrent: any) {
torrent.pause()
// Pause does not remove actual peers (in particular the webseed peer)
torrent.removePeer(torrent[ 'ws' ])
@ -703,7 +703,7 @@ class PeerTubePlugin extends Plugin {
const percent = time / this.player_.duration()
return percent >= 1 ? 1 : percent
}
SeekBar.prototype.handleMouseMove = function handleMouseMove (event) {
SeekBar.prototype.handleMouseMove = function handleMouseMove (event: any) {
let newTime = this.calculateDistance(event) * this.player_.duration()
if (newTime === this.player_.duration()) {
newTime = newTime - 0.1

View File

@ -1,4 +1,4 @@
import * as videojs from 'video.js'
const videojs = require('video.js')
import { VideoFile } from '../../../../shared/models/videos/video.model'
import { PeerTubePlugin } from './peertube-videojs-plugin'
@ -11,9 +11,9 @@ declare namespace videojs {
interface VideoJSComponentInterface {
_player: videojs.Player
new (player: videojs.Player, options?: any)
new (player: videojs.Player, options?: any): any
registerComponent (name: string, obj: any)
registerComponent (name: string, obj: any): any
}
type VideoJSCaption = {

View File

@ -1,4 +1,3 @@
import * as videojs from 'video.js'
import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings'
import { ResolutionMenuItem } from './resolution-menu-item'
@ -7,7 +6,7 @@ const MenuButton: VideoJSComponentInterface = videojsUntyped.getComponent('MenuB
class ResolutionMenuButton extends MenuButton {
label: HTMLElement
constructor (player: videojs.Player, options) {
constructor (player: any, options: any) {
super(player, options)
this.player = player

View File

@ -1,10 +1,9 @@
import * as videojs from 'video.js'
import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings'
const MenuItem: VideoJSComponentInterface = videojsUntyped.getComponent('MenuItem')
class ResolutionMenuItem extends MenuItem {
constructor (player: videojs.Player, options) {
constructor (player: any, options: any) {
const currentResolutionId = player.peertube().getCurrentResolutionId()
options.selectable = true
options.selected = options.id === currentResolutionId
@ -18,7 +17,7 @@ class ResolutionMenuItem extends MenuItem {
player.peertube().on('autoResolutionUpdate', () => this.updateSelection())
}
handleClick (event) {
handleClick (event: any) {
if (this.id === -1 && this.player_.peertube().isAutoResolutionForbidden()) return
super.handleClick(event)

View File

@ -1,7 +1,7 @@
// Author: Yanko Shterev
// Thanks https://github.com/yshterev/videojs-settings-menu
import * as videojs from 'video.js'
const videojs = require('video.js')
import { SettingsMenuItem } from './settings-menu-item'
import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings'
import { toTitleCase } from './utils'
@ -11,7 +11,7 @@ const Menu: VideoJSComponentInterface = videojsUntyped.getComponent('Menu')
const Component: VideoJSComponentInterface = videojsUntyped.getComponent('Component')
class SettingsButton extends Button {
constructor (player: videojs.Player, options) {
constructor (player: any, options: any) {
super(player, options)
this.playerComponent = player
@ -48,7 +48,7 @@ class SettingsButton extends Button {
}
}
onDisposeSettingsItem (event, name: string) {
onDisposeSettingsItem (name: string) {
if (name === undefined) {
let children = this.menu.children()
@ -74,7 +74,7 @@ class SettingsButton extends Button {
}
}
onAddSettingsItem (event, data) {
onAddSettingsItem (data: any) {
const [ entry, options ] = data
this.addMenuItem(entry, options)
@ -120,7 +120,7 @@ class SettingsButton extends Button {
this.resetChildren()
}
getComponentSize (element) {
getComponentSize (element: any) {
let width: number = null
let height: number = null
@ -178,7 +178,7 @@ class SettingsButton extends Button {
this.panelChild.addChild(this.menu)
}
addMenuItem (entry, options) {
addMenuItem (entry: any, options: any) {
const openSubMenu = function () {
if (videojsUntyped.dom.hasClass(this.el_, 'open')) {
videojsUntyped.dom.removeClass(this.el_, 'open')
@ -218,7 +218,7 @@ class SettingsButton extends Button {
}
class SettingsPanel extends Component {
constructor (player: videojs.Player, options) {
constructor (player: any, options: any) {
super(player, options)
}
@ -232,7 +232,7 @@ class SettingsPanel extends Component {
}
class SettingsPanelChild extends Component {
constructor (player: videojs.Player, options) {
constructor (player: any, options: any) {
super(player, options)
}
@ -246,7 +246,7 @@ class SettingsPanelChild extends Component {
}
class SettingsDialog extends Component {
constructor (player: videojs.Player, options) {
constructor (player: any, options: any) {
super(player, options)
this.hide()
}

View File

@ -1,7 +1,6 @@
// Author: Yanko Shterev
// Thanks https://github.com/yshterev/videojs-settings-menu
import * as videojs from 'video.js'
import { toTitleCase } from './utils'
import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings'
@ -10,7 +9,7 @@ const component: VideoJSComponentInterface = videojsUntyped.getComponent('Compon
class SettingsMenuItem extends MenuItem {
constructor (player: videojs.Player, options, entry: string, menuButton: VideoJSComponentInterface) {
constructor (player: any, options: any, entry: string, menuButton: VideoJSComponentInterface) {
super(player, options)
this.settingsButton = menuButton
@ -55,7 +54,7 @@ class SettingsMenuItem extends MenuItem {
this.transitionEndHandler = this.onTransitionEnd.bind(this)
}
onSubmenuClick (event) {
onSubmenuClick (event: any) {
let target = null
if (event.type === 'tap') {
@ -150,7 +149,7 @@ class SettingsMenuItem extends MenuItem {
*
* @method PrefixedEvent
*/
PrefixedEvent (element, type, callback, action = 'addEvent') {
PrefixedEvent (element: any, type: any, callback: any, action = 'addEvent') {
let prefix = ['webkit', 'moz', 'MS', 'o', '']
for (let p = 0; p < prefix.length; p++) {
@ -166,7 +165,7 @@ class SettingsMenuItem extends MenuItem {
}
}
onTransitionEnd (event) {
onTransitionEnd (event: any) {
if (event.propertyName !== 'margin-right') {
return
}
@ -229,7 +228,7 @@ class SettingsMenuItem extends MenuItem {
)
}
update (event?: Event) {
update (event?: any) {
let target = null
let subMenu = this.subMenu.name()

View File

@ -6,7 +6,7 @@ class TheaterButton extends Button {
private static readonly THEATER_MODE_CLASS = 'vjs-theater-enabled'
constructor (player, options) {
constructor (player: any, options: any) {
super(player, options)
const enabled = getStoredTheater()

View File

@ -12,7 +12,7 @@ const dictionaryBytes: Array<{max: number, type: string}> = [
{ max: 1073741824, type: 'MB' },
{ max: 1.0995116e12, type: 'GB' }
]
function bytes (value) {
function bytes (value: any) {
const format = dictionaryBytes.find(d => value < d.max) || dictionaryBytes[dictionaryBytes.length - 1]
const calc = Math.floor(value / (format.max / 1024)).toString()

View File

@ -1,9 +1,9 @@
// Thanks: https://github.com/feross/render-media
// TODO: use render-media once https://github.com/feross/render-media/issues/32 is fixed
import * as MediaElementWrapper from 'mediasource'
const MediaElementWrapper = require('mediasource')
import { extname } from 'path'
import * as videostream from 'videostream'
const videostream = require('videostream')
const VIDEOSTREAM_EXTS = [
'.m4a',
@ -17,7 +17,7 @@ type RenderMediaOptions = {
}
function renderVideo (
file,
file: any,
elem: HTMLVideoElement,
opts: RenderMediaOptions,
callback: (err: Error, renderer: any) => void
@ -27,11 +27,11 @@ function renderVideo (
return renderMedia(file, elem, opts, callback)
}
function renderMedia (file, elem: HTMLVideoElement, opts: RenderMediaOptions, callback: (err: Error, renderer?: any) => void) {
function renderMedia (file: any, elem: HTMLVideoElement, opts: RenderMediaOptions, callback: (err: Error, renderer?: any) => void) {
const extension = extname(file.name).toLowerCase()
let preparedElem = undefined
let preparedElem: any = undefined
let currentTime = 0
let renderer
let renderer: any
try {
if (VIDEOSTREAM_EXTS.indexOf(extension) >= 0) {
@ -45,7 +45,7 @@ function renderMedia (file, elem: HTMLVideoElement, opts: RenderMediaOptions, ca
function useVideostream () {
prepareElem()
preparedElem.addEventListener('error', function onError (err) {
preparedElem.addEventListener('error', function onError (err: Error) {
preparedElem.removeEventListener('error', onError)
return callback(err)
@ -58,7 +58,7 @@ function renderMedia (file, elem: HTMLVideoElement, opts: RenderMediaOptions, ca
const codecs = getCodec(file.name, useVP9)
prepareElem()
preparedElem.addEventListener('error', function onError (err) {
preparedElem.addEventListener('error', function onError (err: Error) {
preparedElem.removeEventListener('error', onError)
// Try with vp9 before returning an error
@ -102,7 +102,7 @@ function renderMedia (file, elem: HTMLVideoElement, opts: RenderMediaOptions, ca
}
}
function validateFile (file) {
function validateFile (file: any) {
if (file == null) {
throw new Error('file cannot be null or undefined')
}

View File

@ -65,7 +65,7 @@ class WebtorrentInfoButton extends Button {
subDivHttp.appendChild(subDivHttpText)
div.appendChild(subDivHttp)
this.player_.peertube().on('torrentInfo', (event, data) => {
this.player_.peertube().on('torrentInfo', (data: any) => {
// We are in HTTP fallback
if (!data) {
subDivHttp.className = 'vjs-peertube-displayed'

View File

@ -8,7 +8,7 @@ import { hmrBootstrap } from './hmr'
import { getDevLocale, isOnDevLocale } from '@app/shared/i18n/i18n-utils'
import { buildFileLocale } from '../../shared'
let providers = []
let providers: any[] = []
if (environment.production) {
enableProdMode()
}

View File

@ -18,24 +18,26 @@
* BROWSER POLYFILLS
*/
/** IE9, IE10 and IE11 requires all of the following polyfills. **/
/**
* IE9, IE10 and IE11 requires all of the following polyfills.
*/
// For Google Bot
import 'core-js/es6/symbol';
import 'core-js/es6/object';
import 'core-js/es6/function';
import 'core-js/es6/parse-int';
import 'core-js/es6/parse-float';
import 'core-js/es6/number';
import 'core-js/es6/math';
import 'core-js/es6/string';
import 'core-js/es6/date';
import 'core-js/es6/array';
import 'core-js/es6/regexp';
import 'core-js/es6/map';
import 'core-js/es6/weak-map';
import 'core-js/es6/set';
import 'core-js/es7/object';
import 'core-js/es6/symbol'
import 'core-js/es6/object'
import 'core-js/es6/function'
import 'core-js/es6/parse-int'
import 'core-js/es6/parse-float'
import 'core-js/es6/number'
import 'core-js/es6/math'
import 'core-js/es6/string'
import 'core-js/es6/date'
import 'core-js/es6/array'
import 'core-js/es6/regexp'
import 'core-js/es6/map'
import 'core-js/es6/weak-map'
import 'core-js/es6/set'
import 'core-js/es7/object'
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
// import 'classlist.js'; // Run `npm install --save classlist.js`.
@ -43,17 +45,18 @@ import 'core-js/es7/object';
/** IE10 and IE11 requires the following for the Reflect API. */
// For Google Bot
import 'core-js/es6/reflect';
import 'core-js/es6/reflect'
/** Evergreen browsers require these. **/
/**
* Evergreen browsers require these.
*/
// Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove.
import 'core-js/es7/reflect'
/**
* Required to support Web Animations `@angular/platform-browser/animations`.
* Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation
**/
*/
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
/**
@ -70,19 +73,17 @@ import 'core-js/es7/reflect'
*/
// (window as any).__Zone_enable_cross_context_check = true;
/***************************************************************************************************
* Zone JS is required by default for Angular itself.
*/
import 'zone.js/dist/zone' // Included with Angular CLI.
/***************************************************************************************************
* APPLICATION IMPORTS
*/
// global/process polyfills
;(window as any).global = window;
;(window as any).process = require('process/');
;(window as any).Buffer = require('buffer/').Buffer;
;(window as any).global = window
;(window as any).process = require('process/')
;(window as any).Buffer = require('buffer/').Buffer

View File

@ -1,3 +1,3 @@
// Does nothing. Used to shim out node.js modules
// which are no-ops in the browser.
export const NOOP = 0
export const NOOP = 0

View File

@ -17,7 +17,7 @@ import 'core-js/es6/set'
// For google bot that uses Chrome 41 and does not understand fetch
import 'whatwg-fetch'
import * as vjs from 'video.js'
const vjs = require('video.js')
import * as Channel from 'jschannel'
import { peertubeTranslate, ResultList, VideoDetails } from '../../../../shared'
@ -304,7 +304,7 @@ class PeerTubeEmbed {
this.playerOptions = videojsOptions
this.player = vjs(this.videoContainerId, videojsOptions, () => {
this.player.on('customError', (event, data) => this.handleError(data.err))
this.player.on('customError', (data: any) => this.handleError(data.err))
window[ 'videojsPlayer' ] = this.player

View File

@ -66,11 +66,11 @@ window.addEventListener('load', async () => {
updateRates()
})
let updateResolutions = resolutions => {
let updateResolutions = ((resolutions: any) => {
let resolutionListEl = document.querySelector('#resolution-list')
resolutionListEl.innerHTML = ''
resolutions.forEach(resolution => {
resolutions.forEach((resolution: any) => {
if (resolution.active) {
let itemEl = document.createElement('strong')
itemEl.innerText = `${resolution.label} (active)`
@ -87,7 +87,7 @@ window.addEventListener('load', async () => {
resolutionListEl.appendChild(itemEl)
}
})
}
})
player.getResolutions().then(
resolutions => updateResolutions(resolutions))

View File

@ -2,4 +2,5 @@
declare var module: NodeModule;
interface NodeModule {
id: string;
[key: string]: any
}

View File

@ -7,7 +7,8 @@
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"noImplicitAny": false,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors":true,
"alwaysStrict": true,
"target": "es5",
"typeRoots": [

View File

@ -1,6 +1,6 @@
export const LOCALE_FILES = [ 'player', 'server' ]
export const I18N_LOCALES = {
export const I18N_LOCALES: any = {
'en-US': 'English',
'fr-FR': 'Français',
'eu-ES': 'Euskara',
@ -17,7 +17,7 @@ export const I18N_LOCALES = {
'zh-Hans-CN': '简体中文(中国)'
}
const I18N_LOCALE_ALIAS = {
const I18N_LOCALE_ALIAS: any = {
'en': 'en-US',
'fr': 'fr-FR',
'eu': 'eu-ES',

View File

@ -15,4 +15,5 @@ export interface VideosOverview {
tag: string
videos: Video[]
}[]
[key: string]: any
}

View File

@ -55,6 +55,7 @@ export interface CustomConfig {
'480p': boolean
'720p': boolean
'1080p': boolean
[key: string]: boolean
}
}

View File

@ -20,4 +20,5 @@ export interface User {
blockedReason?: string
videoQuotaUsed?: number
[key: string]: any
}