[ts-migrate][client] Init tsconfig.json file

Co-authored-by: ts-migrate <>
This commit is contained in:
Max Leiter 2022-05-02 21:16:01 -07:00
parent a799677c2a
commit a0c05b93d6
No known key found for this signature in database
GPG key ID: A3512F2F2F17EBDA
5 changed files with 34 additions and 7 deletions

View file

@ -3,6 +3,23 @@
import socket from "../socket";
import eventbus from "../eventbus";
type ContextMenuItem =
| ({
label: string;
type: string;
class: string;
} & (
| {
link?: string;
}
| {
action?: () => void;
}
))
| {
type: "divider";
};
export function generateChannelContextMenu($root, channel, network) {
const typeMap = {
lobby: "network",
@ -18,7 +35,7 @@ export function generateChannelContextMenu($root, channel, network) {
special: "Close",
};
let items = [
let items: ContextMenuItem[] = [
{
label: channel.name,
type: "item",

View file

@ -2,7 +2,7 @@
const sizes = ["Bytes", "KiB", "MiB", "GiB", "TiB", "PiB"];
export default (size) => {
export default (size: number) => {
// Loosely inspired from https://stackoverflow.com/a/18650828/1935861
const i = size > 0 ? Math.floor(Math.log(size) / Math.log(1024)) : 0;
const fixedSize = parseFloat((size / Math.pow(1024, i)).toFixed(1));

View file

@ -1,12 +1,15 @@
"use strict";
export default (event) => {
if (event.target.tagName !== "TEXTAREA" && event.target.tagName !== "INPUT") {
export default (event: MouseEvent) => {
if (
(event.target as HTMLElement).tagName !== "TEXTAREA" &&
(event.target as HTMLElement).tagName !== "INPUT"
) {
return false;
}
// If focus is in a textarea, do not handle keybinds if user has typed anything
// This is done to prevent keyboard layout binds conflicting with ours
// For example alt+shift+left on macos selects a word
return !!event.target.value;
return !!(event.target as any).value;
};

View file

@ -5,7 +5,10 @@ import distance from "./distance";
// onTwoFingerSwipe will be called with a cardinal direction ("n", "e", "s" or
// "w") as its only argument.
function listenForTwoFingerSwipes(onTwoFingerSwipe) {
let history = [];
let history: {
center: number[];
timestamp: number;
}[] = [];
document.body.addEventListener(
"touchmove",
@ -17,6 +20,10 @@ function listenForTwoFingerSwipes(onTwoFingerSwipe) {
const a = event.touches.item(0);
const b = event.touches.item(1);
if (!a || !b) {
return;
}
const timestamp = window.performance.now();
const center = [(a.screenX + b.screenX) / 2, (a.screenY + b.screenY) / 2];

View file

@ -2,4 +2,4 @@
import dayjs from "dayjs";
export default (time) => dayjs(time).format("D MMMM YYYY, HH:mm:ss");
export default (time: Date | number) => dayjs(time).format("D MMMM YYYY, HH:mm:ss");