From ec9b0edadcdbffd948da6c1ccff8ea350ab43069 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Tue, 11 May 2021 21:27:57 +1200 Subject: [PATCH] Make VSCode type detection happier --- api/captions.js | 2 ++ api/thumbnails.js | 2 ++ api/video.js | 2 ++ background/feed-update.js | 2 ++ utils/converters.js | 2 +- utils/getuser.js | 2 ++ utils/request.js | 2 ++ 7 files changed, 13 insertions(+), 1 deletion(-) diff --git a/api/captions.js b/api/captions.js index 29611ef..f44b921 100644 --- a/api/captions.js +++ b/api/captions.js @@ -1,3 +1,5 @@ +/** @type {import("node-fetch").default} */ +// @ts-ignore const fetch = require("node-fetch") const {getUser} = require("../utils/getuser") const constants = require("../utils/constants.js") diff --git a/api/thumbnails.js b/api/thumbnails.js index e8b6cb4..4da9c6c 100644 --- a/api/thumbnails.js +++ b/api/thumbnails.js @@ -1,3 +1,5 @@ +/** @type {import("node-fetch").default} */ +// @ts-ignore const fetch = require("node-fetch") const constants = require("../utils/constants.js") diff --git a/api/video.js b/api/video.js index 9a27a26..37e344a 100644 --- a/api/video.js +++ b/api/video.js @@ -1,4 +1,6 @@ const {request} = require("../utils/request") +/** @type {import("node-fetch").default} */ +// @ts-ignore const fetch = require("node-fetch") const {render} = require("pinski/plugins") const db = require("../utils/db") diff --git a/background/feed-update.js b/background/feed-update.js index 917a86b..a94766e 100644 --- a/background/feed-update.js +++ b/background/feed-update.js @@ -1,4 +1,6 @@ const Denque = require("denque") +/** @type {import("node-fetch").default} */ +// @ts-ignore const fetch = require("node-fetch") const constants = require("../utils/constants") const db = require("../utils/db") diff --git a/utils/converters.js b/utils/converters.js index 54126d0..2b387f0 100644 --- a/utils/converters.js +++ b/utils/converters.js @@ -151,7 +151,7 @@ function preroundedCountToText(count) { for (const scale of [[1e9, "B"], [1e6, "M"], [1e3, "K"]]) { if (count >= scale[0]) { // YouTube returns 3 significant figures. At least it does for channels. - const rounded = (count/scale[0]).toPrecision(3) + const rounded = (count/+scale[0]).toPrecision(3) return `${rounded}${scale[1]}` } } diff --git a/utils/getuser.js b/utils/getuser.js index 4d50e80..ef6c8e3 100644 --- a/utils/getuser.js +++ b/utils/getuser.js @@ -31,6 +31,7 @@ class User { this.token = token } + /** @return {{instance?: string, save_history?: boolean, local?: boolean, quality?: number}} */ getSettings() { if (this.token) { return db.prepare("SELECT * FROM Settings WHERE token = ?").get(this.token) || {} @@ -39,6 +40,7 @@ class User { } } + /** @return {{instance?: string, save_history?: boolean, local?: boolean, quality?: number}} */ getSettingsOrDefaults() { const settings = this.getSettings() for (const key of Object.keys(constants.user_settings)) { diff --git a/utils/request.js b/utils/request.js index b08fe27..3b94c53 100644 --- a/utils/request.js +++ b/utils/request.js @@ -1,3 +1,5 @@ +/** @type {import("node-fetch").default} */ +// @ts-ignore const fetch = require("node-fetch") function request(url, options = {}) {