Add more type definitions to reduce implicit any

Problem: We still have heaps of implicit 'any' types that our linters
can't make sense of.

Solution: Keep on adding type documentation! Slowly but surely I'm
hoping we can reduce the amount of untyped JavaScript in the repo.
This commit is contained in:
Christian Bundy 2020-03-27 08:21:40 -07:00
parent defb57321e
commit fb23d25217
4 changed files with 19 additions and 1 deletions

View File

@ -3,6 +3,10 @@
const yargs = require("yargs");
const _ = require("lodash");
/**
* @param {object} presets
* @param {string} defaultConfigFile
*/
module.exports = (presets, defaultConfigFile) =>
yargs
.scriptName("oasis")

View File

@ -530,7 +530,7 @@ router
peers: peersWithNames,
theme,
themeNames,
version: config.version,
version: config.version.toString(),
});
};
ctx.body = await getMeta({ theme });

View File

@ -23,6 +23,10 @@ ssbConfig.connections.incoming.unix = [
{ scope: "device", transform: "noauth" },
];
/**
* @param formatter {string} input
* @param args {any[]} input
*/
const log = (formatter, ...args) => {
const isDebugEnabled = debug.enabled;
debug.enabled = true;

View File

@ -69,6 +69,9 @@ const toAttributes = (obj) =>
// non-breaking space
const nbsp = "\xa0";
/**
* @param {{href: string, emoji: string, text: string }} input
*/
const navLink = ({ href, emoji, text }) =>
li(a({ href }, span({ class: "emoji" }, emoji), nbsp, text));
@ -846,6 +849,9 @@ exports.publishView = () => {
);
};
/**
* @param {{status: object, peers: any[], theme: string, themeNames: string[], version: string }} input
*/
exports.settingsView = ({ status, peers, theme, themeNames, version }) => {
const max = status.sync.since;
@ -969,6 +975,7 @@ exports.settingsView = ({ status, peers, theme, themeNames, version }) => {
);
};
/** @param {{ viewTitle: string, viewDescription: string }} input */
const viewInfoBox = ({ viewTitle = null, viewDescription = null }) => {
if (!viewTitle && !viewDescription) {
return null;
@ -989,6 +996,8 @@ exports.likesView = async ({ messages, feed, name }) => {
return template(
viewInfoBox({
viewTitle: span(authorLink, i18n.likedBy),
// TODO: i18n
viewDescription: "List of messages liked by this author.",
}),
messages.map((msg) => post({ msg }))
);
@ -1144,6 +1153,7 @@ exports.hashtagView = ({ messages, hashtag }) => {
);
};
/** @param {{percent: number}} input */
exports.indexingView = ({ percent }) => {
// TODO: i18n
const message = `Oasis has only processed ${percent}% of the messages and needs to catch up. This page will refresh every 10 seconds. Thanks for your patience! ❤`;