diff --git a/.eslintrc b/.eslintrc index 8eeaa95b1d..ce786e01de 100644 --- a/.eslintrc +++ b/.eslintrc @@ -4,12 +4,10 @@ "react-app", "plugin:import/errors", "plugin:import/warnings", - "plugin:flowtype/recommended", "plugin:react-hooks/recommended" ], "plugins": [ - "prettier", - "flowtype" + "prettier" ], "rules": { "eqeqeq": 2, @@ -55,21 +53,6 @@ ] } ], - "flowtype/require-valid-file-annotation": [ - 2, - "always", - { - "annotationStyle": "line" - } - ], - "flowtype/space-after-type-colon": [ - 2, - "always" - ], - "flowtype/space-before-type-colon": [ - 2, - "never" - ], "prettier/prettier": [ "error", { @@ -91,9 +74,6 @@ "." ] } - }, - "flowtype": { - "onlyFilesWithFlowAnnotation": false } }, "env": { diff --git a/app/components/Actions.js b/app/components/Actions.ts similarity index 99% rename from app/components/Actions.js rename to app/components/Actions.ts index 444ce49688..a9252dd98a 100644 --- a/app/components/Actions.js +++ b/app/components/Actions.ts @@ -1,4 +1,3 @@ -// @flow import styled from "styled-components"; import breakpoint from "styled-components-breakpoint"; import Flex from "components/Flex"; diff --git a/app/components/Analytics.js b/app/components/Analytics.ts similarity index 96% rename from app/components/Analytics.js rename to app/components/Analytics.ts index ef9e0f154f..47508ddb56 100644 --- a/app/components/Analytics.js +++ b/app/components/Analytics.ts @@ -1,10 +1,9 @@ -// @flow /* global ga */ import * as React from "react"; import env from "env"; type Props = { - children?: React.Node, + children?: React.ReactNode; }; export default class Analytics extends React.Component { diff --git a/app/components/Arrow.js b/app/components/Arrow.tsx similarity index 98% rename from app/components/Arrow.js rename to app/components/Arrow.tsx index 2b6ade160a..ba462d5774 100644 --- a/app/components/Arrow.js +++ b/app/components/Arrow.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; export default function Arrow() { diff --git a/app/components/AuthLogo/GoogleLogo.js b/app/components/AuthLogo/GoogleLogo.tsx similarity index 93% rename from app/components/AuthLogo/GoogleLogo.js rename to app/components/AuthLogo/GoogleLogo.tsx index b4132b7a69..4854512b96 100644 --- a/app/components/AuthLogo/GoogleLogo.js +++ b/app/components/AuthLogo/GoogleLogo.tsx @@ -1,10 +1,9 @@ -// @flow import * as React from "react"; type Props = { - size?: number, - fill?: string, - className?: string, + size?: number; + fill?: string; + className?: string; }; function GoogleLogo({ size = 34, fill = "#FFF", className }: Props) { diff --git a/app/components/AuthLogo/MicrosoftLogo.js b/app/components/AuthLogo/MicrosoftLogo.tsx similarity index 94% rename from app/components/AuthLogo/MicrosoftLogo.js rename to app/components/AuthLogo/MicrosoftLogo.tsx index a73c5b84f4..393b524883 100644 --- a/app/components/AuthLogo/MicrosoftLogo.js +++ b/app/components/AuthLogo/MicrosoftLogo.tsx @@ -1,10 +1,9 @@ -// @flow import * as React from "react"; type Props = { - size?: number, - fill?: string, - className?: string, + size?: number; + fill?: string; + className?: string; }; function MicrosoftLogo({ size = 34, fill = "#FFF", className }: Props) { diff --git a/app/components/AuthLogo/SlackLogo.js b/app/components/AuthLogo/SlackLogo.tsx similarity index 98% rename from app/components/AuthLogo/SlackLogo.js rename to app/components/AuthLogo/SlackLogo.tsx index 69388b9217..1d19f5b8bb 100644 --- a/app/components/AuthLogo/SlackLogo.js +++ b/app/components/AuthLogo/SlackLogo.tsx @@ -1,10 +1,9 @@ -// @flow import * as React from "react"; type Props = { - size?: number, - fill?: string, - className?: string, + size?: number; + fill?: string; + className?: string; }; function SlackLogo({ size = 34, fill = "#FFF", className }: Props) { diff --git a/app/components/AuthLogo/index.js b/app/components/AuthLogo/index.tsx similarity index 91% rename from app/components/AuthLogo/index.js rename to app/components/AuthLogo/index.tsx index d2b444f2a2..87e0fe42d4 100644 --- a/app/components/AuthLogo/index.js +++ b/app/components/AuthLogo/index.tsx @@ -1,14 +1,13 @@ -// @flow import * as React from "react"; import styled from "styled-components"; import GoogleLogo from "./GoogleLogo"; import MicrosoftLogo from "./MicrosoftLogo"; import SlackLogo from "./SlackLogo"; -type Props = {| - providerName: string, - size?: number, -|}; +type Props = { + providerName: string; + size?: number; +}; function AuthLogo({ providerName, size = 16 }: Props) { switch (providerName) { diff --git a/app/components/Authenticated.js b/app/components/Authenticated.tsx similarity index 98% rename from app/components/Authenticated.js rename to app/components/Authenticated.tsx index 86b43ef510..080c3c48b8 100644 --- a/app/components/Authenticated.js +++ b/app/components/Authenticated.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import * as React from "react"; import { useTranslation } from "react-i18next"; @@ -9,7 +8,7 @@ import useStores from "../hooks/useStores"; import env from "env"; type Props = { - children: React.Node, + children: React.ReactNode; }; const Authenticated = ({ children }: Props) => { diff --git a/app/components/Avatar/Avatar.js b/app/components/Avatar/Avatar.tsx similarity index 88% rename from app/components/Avatar/Avatar.js rename to app/components/Avatar/Avatar.tsx index 38cfe6829d..03310c3da1 100644 --- a/app/components/Avatar/Avatar.js +++ b/app/components/Avatar/Avatar.tsx @@ -1,4 +1,3 @@ -// @flow import { observable } from "mobx"; import { observer } from "mobx-react"; import * as React from "react"; @@ -6,18 +5,19 @@ import styled from "styled-components"; import User from "models/User"; import placeholder from "./placeholder.png"; -type Props = {| - src: string, - size: number, - icon?: React.Node, - user?: User, - onClick?: () => void, - className?: string, -|}; +type Props = { + src: string; + size: number; + icon?: React.ReactNode; + user?: User; + onClick?: () => void; + className?: string; +}; @observer class Avatar extends React.Component { - @observable error: boolean; + @observable + error: boolean; static defaultProps = { size: 24, diff --git a/app/components/Avatar/AvatarWithPresence.js b/app/components/Avatar/AvatarWithPresence.tsx similarity index 88% rename from app/components/Avatar/AvatarWithPresence.js rename to app/components/Avatar/AvatarWithPresence.tsx index 300da5eccf..d33429cd37 100644 --- a/app/components/Avatar/AvatarWithPresence.js +++ b/app/components/Avatar/AvatarWithPresence.tsx @@ -1,9 +1,9 @@ -// @flow import { observable } from "mobx"; import { observer } from "mobx-react"; import { EditIcon } from "outline-icons"; import * as React from "react"; -import { withTranslation, type TFunction } from "react-i18next"; +import { withTranslation } from "react-i18next"; +import type { TFunction } from "react-i18next"; import styled from "styled-components"; import User from "models/User"; import UserProfile from "scenes/UserProfile"; @@ -11,17 +11,18 @@ import Avatar from "components/Avatar"; import Tooltip from "components/Tooltip"; type Props = { - user: User, - isPresent: boolean, - isEditing: boolean, - isCurrentUser: boolean, - profileOnClick: boolean, - t: TFunction, + user: User; + isPresent: boolean; + isEditing: boolean; + isCurrentUser: boolean; + profileOnClick: boolean; + t: TFunction; }; @observer class AvatarWithPresence extends React.Component { - @observable isOpen: boolean = false; + @observable + isOpen: boolean = false; handleOpenProfile = () => { this.isOpen = true; diff --git a/app/components/Avatar/index.js b/app/components/Avatar/index.ts similarity index 94% rename from app/components/Avatar/index.js rename to app/components/Avatar/index.ts index 0106b24db4..321d85d9e0 100644 --- a/app/components/Avatar/index.js +++ b/app/components/Avatar/index.ts @@ -1,4 +1,3 @@ -// @flow import Avatar from "./Avatar"; import AvatarWithPresence from "./AvatarWithPresence"; diff --git a/app/components/Badge.js b/app/components/Badge.ts similarity index 98% rename from app/components/Badge.js rename to app/components/Badge.ts index 04d564b84f..9842b1044e 100644 --- a/app/components/Badge.js +++ b/app/components/Badge.ts @@ -1,4 +1,3 @@ -// @flow import styled from "styled-components"; const Badge = styled.span` diff --git a/app/components/Branding.js b/app/components/Branding.tsx similarity index 96% rename from app/components/Branding.js rename to app/components/Branding.tsx index 38a90a3406..1cc6598ef1 100644 --- a/app/components/Branding.js +++ b/app/components/Branding.tsx @@ -1,11 +1,10 @@ -// @flow import * as React from "react"; import styled from "styled-components"; import OutlineLogo from "./OutlineLogo"; import env from "env"; type Props = { - href?: string, + href?: string; }; function Branding({ href = env.URL }: Props) { diff --git a/app/components/Breadcrumb.js b/app/components/Breadcrumb.tsx similarity index 90% rename from app/components/Breadcrumb.js rename to app/components/Breadcrumb.tsx index 350e20ad95..c9c656c3e1 100644 --- a/app/components/Breadcrumb.js +++ b/app/components/Breadcrumb.tsx @@ -1,4 +1,3 @@ -// @flow import { GoToIcon } from "outline-icons"; import * as React from "react"; import { Link } from "react-router-dom"; @@ -6,18 +5,18 @@ import styled from "styled-components"; import Flex from "components/Flex"; import BreadcrumbMenu from "menus/BreadcrumbMenu"; -type MenuItem = {| - icon?: React.Node, - title: React.Node, - to?: string, -|}; +type MenuItem = { + icon?: React.ReactNode; + title: React.ReactNode; + to?: string; +}; -type Props = {| - items: MenuItem[], - max?: number, - children?: React.Node, - highlightFirstItem?: boolean, -|}; +type Props = { + items: MenuItem[]; + max?: number; + children?: React.ReactNode; + highlightFirstItem?: boolean; +}; function Breadcrumb({ items, highlightFirstItem, children, max = 2 }: Props) { const totalItems = items.length; diff --git a/app/components/Bubble.js b/app/components/Bubble.tsx similarity index 94% rename from app/components/Bubble.js rename to app/components/Bubble.tsx index 2bfd3dc2b0..5f6410b4d4 100644 --- a/app/components/Bubble.js +++ b/app/components/Bubble.tsx @@ -1,11 +1,10 @@ -// @flow import * as React from "react"; import styled from "styled-components"; import { bounceIn } from "shared/styles/animations"; -type Props = {| - count: number, -|}; +type Props = { + count: number; +}; const Bubble = ({ count }: Props) => { if (!count) { diff --git a/app/components/Button.js b/app/components/Button.tsx similarity index 82% rename from app/components/Button.js rename to app/components/Button.tsx index 6ba2b8b559..ee134ee9b3 100644 --- a/app/components/Button.js +++ b/app/components/Button.tsx @@ -1,9 +1,10 @@ -// @flow import { ExpandedIcon } from "outline-icons"; import { darken } from "polished"; import * as React from "react"; import styled from "styled-components"; +import type { SyntheticEvent } from "react"; + const RealButton = styled.button` display: ${(props) => (props.fullwidth ? "block" : "inline-block")}; width: ${(props) => (props.fullwidth ? "100%" : "auto")}; @@ -108,33 +109,32 @@ export const Inner = styled.span` ${(props) => props.hasIcon && !props.hasText && "padding: 0 4px;"}; `; -export type Props = {| - type?: "button" | "submit", - value?: string, - icon?: React.Node, - iconColor?: string, - className?: string, - children?: React.Node, - innerRef?: React.ElementRef, - disclosure?: boolean, - neutral?: boolean, - danger?: boolean, - primary?: boolean, - disabled?: boolean, - fullwidth?: boolean, - autoFocus?: boolean, - style?: Object, - as?: React.ComponentType, - to?: string, - onClick?: (event: SyntheticEvent<>) => mixed, - borderOnHover?: boolean, +export type Props = { + type?: "button" | "submit"; + value?: string; + icon?: React.ReactNode; + iconColor?: string; + className?: string; + children?: React.ReactNode; + innerRef?: React.RefObject; + disclosure?: boolean; + neutral?: boolean; + danger?: boolean; + primary?: boolean; + disabled?: boolean; + fullwidth?: boolean; + autoFocus?: boolean; + style?: any; + as?: React.ComponentType; + to?: string; + onClick?: (event: SyntheticEvent) => unknown; + borderOnHover?: boolean; + "data-on"?: string; + "data-event-category"?: string; + "data-event-action"?: string; +}; - "data-on"?: string, - "data-event-category"?: string, - "data-event-action"?: string, -|}; - -const Button = React.forwardRef( +const Button = React.forwardRef( ( { type = "text", diff --git a/app/components/ButtonLarge.js b/app/components/ButtonLarge.ts similarity index 95% rename from app/components/ButtonLarge.js rename to app/components/ButtonLarge.ts index f3611bbd8a..24e28947d7 100644 --- a/app/components/ButtonLarge.js +++ b/app/components/ButtonLarge.ts @@ -1,4 +1,3 @@ -// @flow import styled from "styled-components"; import Button, { Inner } from "./Button"; diff --git a/app/components/ButtonLink.js b/app/components/ButtonLink.tsx similarity index 76% rename from app/components/ButtonLink.js rename to app/components/ButtonLink.tsx index b42e1efdca..3b892e3e17 100644 --- a/app/components/ButtonLink.js +++ b/app/components/ButtonLink.tsx @@ -1,10 +1,11 @@ -// @flow import * as React from "react"; import styled from "styled-components"; +import type { SyntheticEvent } from "react"; + type Props = { - onClick: (ev: SyntheticEvent<>) => void, - children: React.Node, + onClick: (ev: SyntheticEvent) => void; + children: React.ReactNode; }; export default function ButtonLink(props: Props) { diff --git a/app/components/CenteredContent.js b/app/components/CenteredContent.tsx similarity index 89% rename from app/components/CenteredContent.js rename to app/components/CenteredContent.tsx index 3f3685cdd5..a0a32e90c9 100644 --- a/app/components/CenteredContent.js +++ b/app/components/CenteredContent.tsx @@ -1,12 +1,11 @@ -// @flow import * as React from "react"; import styled from "styled-components"; import breakpoint from "styled-components-breakpoint"; -type Props = {| - children?: React.Node, - withStickyHeader?: boolean, -|}; +type Props = { + children?: React.ReactNode; + withStickyHeader?: boolean; +}; const Container = styled.div` width: 100%; diff --git a/app/components/Checkbox.js b/app/components/Checkbox.tsx similarity index 78% rename from app/components/Checkbox.js rename to app/components/Checkbox.tsx index 281e5764f8..25684ef187 100644 --- a/app/components/Checkbox.js +++ b/app/components/Checkbox.tsx @@ -1,21 +1,22 @@ -// @flow import * as React from "react"; import { VisuallyHidden } from "reakit/VisuallyHidden"; import styled from "styled-components"; import HelpText from "components/HelpText"; -export type Props = {| - checked?: boolean, - label?: React.Node, - labelHidden?: boolean, - className?: string, - name?: string, - disabled?: boolean, - onChange: (event: SyntheticInputEvent) => mixed, - note?: string, - short?: boolean, - small?: boolean, -|}; +import type { ChangeEvent } from "react"; + +export type Props = { + checked?: boolean; + label?: React.ReactNode; + labelHidden?: boolean; + className?: string; + name?: string; + disabled?: boolean; + onChange: (event: ChangeEvent) => unknown; + note?: string; + short?: boolean; + small?: boolean; +}; const LabelText = styled.span` font-weight: 500; diff --git a/app/components/ClickablePadding.js b/app/components/ClickablePadding.ts similarity index 96% rename from app/components/ClickablePadding.js rename to app/components/ClickablePadding.ts index 04ed7b510f..7bfb7f2c4e 100644 --- a/app/components/ClickablePadding.js +++ b/app/components/ClickablePadding.ts @@ -1,4 +1,3 @@ -// @flow import styled from "styled-components"; const ClickablePadding = styled.div` diff --git a/app/components/Collaborators.js b/app/components/Collaborators.tsx similarity index 97% rename from app/components/Collaborators.js rename to app/components/Collaborators.tsx index 384e20f815..319200e15f 100644 --- a/app/components/Collaborators.js +++ b/app/components/Collaborators.tsx @@ -1,4 +1,3 @@ -// @flow import { sortBy, filter, uniq } from "lodash"; import { observer } from "mobx-react"; import * as React from "react"; @@ -14,10 +13,10 @@ import NudeButton from "components/NudeButton"; import Popover from "components/Popover"; import useStores from "hooks/useStores"; -type Props = {| - document: Document, - currentUserId: string, -|}; +type Props = { + document: Document; + currentUserId: string; +}; function Collaborators(props: Props) { const { t } = useTranslation(); diff --git a/app/components/CollectionDescription.js b/app/components/CollectionDescription.tsx similarity index 98% rename from app/components/CollectionDescription.js rename to app/components/CollectionDescription.tsx index d8928491f0..90e9539222 100644 --- a/app/components/CollectionDescription.js +++ b/app/components/CollectionDescription.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import { transparentize } from "polished"; import * as React from "react"; @@ -13,9 +12,9 @@ import NudeButton from "components/NudeButton"; import useDebouncedCallback from "hooks/useDebouncedCallback"; import useStores from "hooks/useStores"; -type Props = {| - collection: Collection, -|}; +type Props = { + collection: Collection; +}; function CollectionDescription({ collection }: Props) { const { collections, ui, policies } = useStores(); diff --git a/app/components/CollectionIcon.js b/app/components/CollectionIcon.tsx similarity index 94% rename from app/components/CollectionIcon.js rename to app/components/CollectionIcon.tsx index 87e7a3b229..5fc89374e6 100644 --- a/app/components/CollectionIcon.js +++ b/app/components/CollectionIcon.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import { CollectionIcon } from "outline-icons"; import { getLuminance } from "polished"; @@ -8,9 +7,9 @@ import { icons } from "components/IconPicker"; import useStores from "hooks/useStores"; type Props = { - collection: Collection, - expanded?: boolean, - size?: number, + collection: Collection; + expanded?: boolean; + size?: number; }; function ResolvedCollectionIcon({ collection, expanded, size }: Props) { diff --git a/app/components/ContextMenu/Header.js b/app/components/ContextMenu/Header.ts similarity index 96% rename from app/components/ContextMenu/Header.js rename to app/components/ContextMenu/Header.ts index 775991eb85..d824c85c60 100644 --- a/app/components/ContextMenu/Header.js +++ b/app/components/ContextMenu/Header.ts @@ -1,4 +1,3 @@ -// @flow import styled from "styled-components"; const Header = styled.h3` diff --git a/app/components/ContextMenu/MenuItem.js b/app/components/ContextMenu/MenuItem.tsx similarity index 88% rename from app/components/ContextMenu/MenuItem.js rename to app/components/ContextMenu/MenuItem.tsx index e841949dd8..baf50653c2 100644 --- a/app/components/ContextMenu/MenuItem.js +++ b/app/components/ContextMenu/MenuItem.tsx @@ -1,21 +1,22 @@ -// @flow import { CheckmarkIcon } from "outline-icons"; import * as React from "react"; import { MenuItem as BaseMenuItem } from "reakit/Menu"; import styled from "styled-components"; import breakpoint from "styled-components-breakpoint"; -type Props = {| - onClick?: (SyntheticEvent<>) => void | Promise, - children?: React.Node, - selected?: boolean, - disabled?: boolean, - to?: string, - href?: string, - target?: "_blank", - as?: string | React.ComponentType<*>, - hide?: () => void, -|}; +import type { SyntheticEvent } from "react"; + +type Props = { + onClick?: (a: SyntheticEvent) => void | Promise; + children?: React.ReactNode; + selected?: boolean; + disabled?: boolean; + to?: string; + href?: string; + target?: "_blank"; + as?: string | React.ComponentType; + hide?: () => void; +}; const MenuItem = ({ onClick, diff --git a/app/components/ContextMenu/OverflowMenuButton.js b/app/components/ContextMenu/OverflowMenuButton.tsx similarity index 98% rename from app/components/ContextMenu/OverflowMenuButton.js rename to app/components/ContextMenu/OverflowMenuButton.tsx index 419b63b590..08d2660f46 100644 --- a/app/components/ContextMenu/OverflowMenuButton.js +++ b/app/components/ContextMenu/OverflowMenuButton.tsx @@ -1,4 +1,3 @@ -// @flow import { MoreIcon } from "outline-icons"; import * as React from "react"; import { MenuButton } from "reakit/Menu"; diff --git a/app/components/ContextMenu/Separator.js b/app/components/ContextMenu/Separator.tsx similarity index 97% rename from app/components/ContextMenu/Separator.js rename to app/components/ContextMenu/Separator.tsx index 5dbc29c5c2..cd921ce435 100644 --- a/app/components/ContextMenu/Separator.js +++ b/app/components/ContextMenu/Separator.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import { MenuSeparator } from "reakit/Menu"; import styled from "styled-components"; diff --git a/app/components/ContextMenu/Template.js b/app/components/ContextMenu/Template.tsx similarity index 76% rename from app/components/ContextMenu/Template.js rename to app/components/ContextMenu/Template.tsx index 697dabc505..d6ec7c546b 100644 --- a/app/components/ContextMenu/Template.js +++ b/app/components/ContextMenu/Template.tsx @@ -1,4 +1,3 @@ -// @flow import { ExpandedIcon } from "outline-icons"; import * as React from "react"; import { useTranslation } from "react-i18next"; @@ -13,49 +12,51 @@ import MenuItem, { MenuAnchor } from "./MenuItem"; import Separator from "./Separator"; import ContextMenu from "."; -type TMenuItem = - | {| - title: React.Node, - to: string, - visible?: boolean, - selected?: boolean, - disabled?: boolean, - |} - | {| - title: React.Node, - onClick: (event: SyntheticEvent<>) => void | Promise, - visible?: boolean, - selected?: boolean, - disabled?: boolean, - |} - | {| - title: React.Node, - href: string, - visible?: boolean, - selected?: boolean, - disabled?: boolean, - |} - | {| - title: React.Node, - visible?: boolean, - disabled?: boolean, - style?: Object, - hover?: boolean, - items: TMenuItem[], - |} - | {| - type: "separator", - visible?: boolean, - |} - | {| - type: "heading", - visible?: boolean, - title: React.Node, - |}; +import type { SyntheticEvent } from "react"; -type Props = {| - items: TMenuItem[], -|}; +type TMenuItem = + | { + title: React.ReactNode; + to: string; + visible?: boolean; + selected?: boolean; + disabled?: boolean; + } + | { + title: React.ReactNode; + onClick: (event: SyntheticEvent) => void | Promise; + visible?: boolean; + selected?: boolean; + disabled?: boolean; + } + | { + title: React.ReactNode; + href: string; + visible?: boolean; + selected?: boolean; + disabled?: boolean; + } + | { + title: React.ReactNode; + visible?: boolean; + disabled?: boolean; + style?: any; + hover?: boolean; + items: TMenuItem[]; + } + | { + type: "separator"; + visible?: boolean; + } + | { + type: "heading"; + visible?: boolean; + title: React.ReactNode; + }; + +type Props = { + items: TMenuItem[]; +}; const Disclosure = styled(ExpandedIcon)` transform: rotate(270deg); @@ -83,7 +84,7 @@ const Submenu = React.forwardRef(({ templateItems, title, ...rest }, ref) => { ); }); -function Template({ items, ...menu }: Props): React.Node { +function Template({ items, ...menu }: Props): React.ReactNode { let filtered = items.filter((item) => item.visible !== false); // this block literally just trims unneccessary separators diff --git a/app/components/ContextMenu/index.js b/app/components/ContextMenu/index.tsx similarity index 93% rename from app/components/ContextMenu/index.js rename to app/components/ContextMenu/index.tsx index 70c31c5597..a7738fa3da 100644 --- a/app/components/ContextMenu/index.js +++ b/app/components/ContextMenu/index.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import { Portal } from "react-portal"; import { Menu } from "reakit/Menu"; @@ -11,14 +10,14 @@ import { } from "shared/styles/animations"; import usePrevious from "hooks/usePrevious"; -type Props = {| - "aria-label": string, - visible?: boolean, - animating?: boolean, - children: React.Node, - onOpen?: () => void, - onClose?: () => void, -|}; +type Props = { + "aria-label": string; + visible?: boolean; + animating?: boolean; + children: React.ReactNode; + onOpen?: () => void; + onClose?: () => void; +}; export default function ContextMenu({ children, diff --git a/app/components/CopyToClipboard.js b/app/components/CopyToClipboard.ts similarity index 80% rename from app/components/CopyToClipboard.js rename to app/components/CopyToClipboard.ts index c25b4bbc09..58e416b0d0 100644 --- a/app/components/CopyToClipboard.js +++ b/app/components/CopyToClipboard.ts @@ -1,16 +1,17 @@ -// @flow import copy from "copy-to-clipboard"; import * as React from "react"; +import type { SyntheticEvent } from "react"; + type Props = { - text: string, - children?: React.Node, - onClick?: () => void, - onCopy: () => void, + text: string; + children?: React.ReactNode; + onClick?: () => void; + onCopy: () => void; }; class CopyToClipboard extends React.PureComponent { - onClick = (ev: SyntheticEvent<>) => { + onClick = (ev: SyntheticEvent) => { const { text, onCopy, children } = this.props; const elem = React.Children.only(children); copy(text, { diff --git a/app/components/DelayedMount.js b/app/components/DelayedMount.ts similarity index 88% rename from app/components/DelayedMount.js rename to app/components/DelayedMount.ts index e127456c98..ef7b73c041 100644 --- a/app/components/DelayedMount.js +++ b/app/components/DelayedMount.ts @@ -1,9 +1,8 @@ -// @flow import * as React from "react"; type Props = { - delay?: number, - children: React.Node, + delay?: number; + children: React.ReactNode; }; export default function DelayedMount({ delay = 250, children }: Props) { diff --git a/app/components/Divider.js b/app/components/Divider.ts similarity index 95% rename from app/components/Divider.js rename to app/components/Divider.ts index 9b4561c0fe..a9d3b469fd 100644 --- a/app/components/Divider.js +++ b/app/components/Divider.ts @@ -1,4 +1,3 @@ -// @flow import styled from "styled-components"; const Divider = styled.hr` diff --git a/app/components/DocumentBreadcrumb.js b/app/components/DocumentBreadcrumb.tsx similarity index 96% rename from app/components/DocumentBreadcrumb.js rename to app/components/DocumentBreadcrumb.tsx index fa669f82a5..68219bebb4 100644 --- a/app/components/DocumentBreadcrumb.js +++ b/app/components/DocumentBreadcrumb.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import { ArchiveIcon, @@ -16,11 +15,11 @@ import CollectionIcon from "components/CollectionIcon"; import useStores from "hooks/useStores"; import { collectionUrl } from "utils/routeHelpers"; -type Props = {| - document: Document, - children?: React.Node, - onlyText: boolean, -|}; +type Props = { + document: Document; + children?: React.ReactNode; + onlyText: boolean; +}; function useCategory(document) { const { t } = useTranslation(); diff --git a/app/components/DocumentHistory/DocumentHistory.js b/app/components/DocumentHistory/DocumentHistory.tsx similarity index 91% rename from app/components/DocumentHistory/DocumentHistory.js rename to app/components/DocumentHistory/DocumentHistory.tsx index 1f1e6e2435..7230520a90 100644 --- a/app/components/DocumentHistory/DocumentHistory.js +++ b/app/components/DocumentHistory/DocumentHistory.tsx @@ -1,10 +1,10 @@ -// @flow import ArrowKeyNavigation from "boundless-arrow-key-navigation"; import { action, observable } from "mobx"; import { inject, observer } from "mobx-react"; import { CloseIcon } from "outline-icons"; import * as React from "react"; -import { type Match, Redirect, type RouterHistory } from "react-router-dom"; +import { Redirect } from "react-router-dom"; +import type { Match, RouterHistory } from "react-router-dom"; import { Waypoint } from "react-waypoint"; import styled from "styled-components"; @@ -20,19 +20,24 @@ import Revision from "./components/Revision"; import { documentHistoryUrl, documentUrl } from "utils/routeHelpers"; type Props = { - match: Match, - documents: DocumentsStore, - revisions: RevisionsStore, - history: RouterHistory, + match: Match; + documents: DocumentsStore; + revisions: RevisionsStore; + history: RouterHistory; }; @observer class DocumentHistory extends React.Component { - @observable isLoaded: boolean = false; - @observable isFetching: boolean = false; - @observable offset: number = 0; - @observable allowLoadMore: boolean = true; - @observable redirectTo: ?string; + @observable + isLoaded: boolean = false; + @observable + isFetching: boolean = false; + @observable + offset: number = 0; + @observable + allowLoadMore: boolean = true; + @observable + redirectTo: string | undefined | null; async componentDidMount() { await this.loadMoreResults(); diff --git a/app/components/DocumentHistory/components/Revision.js b/app/components/DocumentHistory/components/Revision.tsx similarity index 92% rename from app/components/DocumentHistory/components/Revision.js rename to app/components/DocumentHistory/components/Revision.tsx index f1469f89b0..79add47e43 100644 --- a/app/components/DocumentHistory/components/Revision.js +++ b/app/components/DocumentHistory/components/Revision.tsx @@ -1,4 +1,3 @@ -// @flow import { format } from "date-fns"; import * as React from "react"; import { NavLink } from "react-router-dom"; @@ -10,16 +9,16 @@ import Avatar from "components/Avatar"; import Flex from "components/Flex"; import Time from "components/Time"; import RevisionMenu from "menus/RevisionMenu"; -import { type Theme } from "types"; +import type { Theme } from "types"; import { documentHistoryUrl } from "utils/routeHelpers"; type Props = { - theme: Theme, - showMenu: boolean, - selected: boolean, - document: Document, - revision: Revision, + theme: Theme; + showMenu: boolean; + selected: boolean; + document: Document; + revision: Revision; }; class RevisionListItem extends React.Component { diff --git a/app/components/DocumentHistory/index.js b/app/components/DocumentHistory/index.ts similarity index 90% rename from app/components/DocumentHistory/index.js rename to app/components/DocumentHistory/index.ts index 7d566709c2..d84c5ced61 100644 --- a/app/components/DocumentHistory/index.js +++ b/app/components/DocumentHistory/index.ts @@ -1,3 +1,2 @@ -// @flow import DocumentHistory from "./DocumentHistory"; export default DocumentHistory; diff --git a/app/components/DocumentList.js b/app/components/DocumentList.tsx similarity index 75% rename from app/components/DocumentList.js rename to app/components/DocumentList.tsx index 00ec5945d9..e57ba81fcc 100644 --- a/app/components/DocumentList.js +++ b/app/components/DocumentList.tsx @@ -1,18 +1,17 @@ -// @flow import ArrowKeyNavigation from "boundless-arrow-key-navigation"; import * as React from "react"; import Document from "models/Document"; import DocumentListItem from "components/DocumentListItem"; -type Props = {| - documents: Document[], - limit?: number, - showCollection?: boolean, - showPublished?: boolean, - showPin?: boolean, - showDraft?: boolean, - showTemplate?: boolean, -|}; +type Props = { + documents: Document[]; + limit?: number; + showCollection?: boolean; + showPublished?: boolean; + showPin?: boolean; + showDraft?: boolean; + showTemplate?: boolean; +}; export default function DocumentList({ limit, documents, ...rest }: Props) { const items = limit ? documents.splice(0, limit) : documents; diff --git a/app/components/DocumentListItem.js b/app/components/DocumentListItem.tsx similarity index 96% rename from app/components/DocumentListItem.js rename to app/components/DocumentListItem.tsx index 5e0b8a6f72..3fc2c20ac4 100644 --- a/app/components/DocumentListItem.js +++ b/app/components/DocumentListItem.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import { PlusIcon } from "outline-icons"; import * as React from "react"; @@ -21,17 +20,17 @@ import useStores from "hooks/useStores"; import DocumentMenu from "menus/DocumentMenu"; import { newDocumentUrl } from "utils/routeHelpers"; -type Props = {| - document: Document, - highlight?: ?string, - context?: ?string, - showNestedDocuments?: boolean, - showCollection?: boolean, - showPublished?: boolean, - showPin?: boolean, - showDraft?: boolean, - showTemplate?: boolean, -|}; +type Props = { + document: Document; + highlight?: string | null; + context?: string | null; + showNestedDocuments?: boolean; + showCollection?: boolean; + showPublished?: boolean; + showPin?: boolean; + showDraft?: boolean; + showTemplate?: boolean; +}; const SEARCH_RESULT_REGEX = /]*>(.*?)<\/b>/gi; diff --git a/app/components/DocumentMeta.js b/app/components/DocumentMeta.tsx similarity index 94% rename from app/components/DocumentMeta.js rename to app/components/DocumentMeta.tsx index b5af26a55a..9876354900 100644 --- a/app/components/DocumentMeta.js +++ b/app/components/DocumentMeta.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import * as React from "react"; import { useTranslation } from "react-i18next"; @@ -29,15 +28,15 @@ const Modified = styled.span` font-weight: ${(props) => (props.highlight ? "600" : "400")}; `; -type Props = {| - showCollection?: boolean, - showPublished?: boolean, - showLastViewed?: boolean, - showNestedDocuments?: boolean, - document: Document, - children: React.Node, - to?: string, -|}; +type Props = { + showCollection?: boolean; + showPublished?: boolean; + showLastViewed?: boolean; + showNestedDocuments?: boolean; + document: Document; + children: React.ReactNode; + to?: string; +}; function DocumentMeta({ showPublished, diff --git a/app/components/DocumentMetaWithViews.js b/app/components/DocumentMetaWithViews.tsx similarity index 95% rename from app/components/DocumentMetaWithViews.js rename to app/components/DocumentMetaWithViews.tsx index 6964b391ca..79be155217 100644 --- a/app/components/DocumentMetaWithViews.js +++ b/app/components/DocumentMetaWithViews.tsx @@ -1,4 +1,3 @@ -// @flow import { useObserver } from "mobx-react"; import * as React from "react"; import { useTranslation } from "react-i18next"; @@ -10,12 +9,12 @@ import DocumentViews from "components/DocumentViews"; import Popover from "components/Popover"; import useStores from "../hooks/useStores"; -type Props = {| - document: Document, - isDraft: boolean, - to?: string, - rtl?: boolean, -|}; +type Props = { + document: Document; + isDraft: boolean; + to?: string; + rtl?: boolean; +}; function DocumentMetaWithViews({ to, isDraft, document, ...rest }: Props) { const { views } = useStores(); diff --git a/app/components/DocumentViews.js b/app/components/DocumentViews.tsx similarity index 92% rename from app/components/DocumentViews.js rename to app/components/DocumentViews.tsx index 8f14164dc3..8aaf2a11e6 100644 --- a/app/components/DocumentViews.js +++ b/app/components/DocumentViews.tsx @@ -1,4 +1,3 @@ -// @flow import { formatDistanceToNow } from "date-fns"; import { sortBy } from "lodash"; import { observer } from "mobx-react"; @@ -10,10 +9,10 @@ import ListItem from "components/List/Item"; import PaginatedList from "components/PaginatedList"; import useStores from "hooks/useStores"; -type Props = {| - document: Document, - isOpen?: boolean, -|}; +type Props = { + document: Document; + isOpen?: boolean; +}; function DocumentViews({ document, isOpen }: Props) { const { t } = useTranslation(); @@ -36,9 +35,10 @@ function DocumentViews({ document, isOpen }: Props) { (view) => !presentIds.includes(view.user.id) ); - const users = React.useMemo(() => sortedViews.map((v) => v.user), [ - sortedViews, - ]); + const users = React.useMemo( + () => sortedViews.map((v) => v.user), + [sortedViews] + ); return ( <> diff --git a/app/components/Editor.js b/app/components/Editor.tsx similarity index 83% rename from app/components/Editor.js rename to app/components/Editor.tsx index eb7898c2b0..dab6e60237 100644 --- a/app/components/Editor.js +++ b/app/components/Editor.tsx @@ -1,8 +1,8 @@ -// @flow import { lighten } from "polished"; import * as React from "react"; import { useTranslation } from "react-i18next"; -import { withRouter, type RouterHistory } from "react-router-dom"; +import { withRouter } from "react-router-dom"; +import type { RouterHistory } from "react-router-dom"; import styled, { withTheme } from "styled-components"; import { light } from "shared/styles/theme"; import UiStore from "stores/UiStore"; @@ -10,51 +10,57 @@ import ErrorBoundary from "components/ErrorBoundary"; import Tooltip from "components/Tooltip"; import embeds from "../embeds"; import useMediaQuery from "hooks/useMediaQuery"; -import { type Theme } from "types"; +import type { Theme } from "types"; import { isModKey } from "utils/keyboard"; import { uploadFile } from "utils/uploadFile"; import { isInternalUrl } from "utils/urls"; +import type { SyntheticEvent } from "react"; + const RichMarkdownEditor = React.lazy(() => import(/* webpackChunkName: "rich-markdown-editor" */ "rich-markdown-editor") ); const EMPTY_ARRAY = []; -export type Props = {| - id?: string, - value?: string, - defaultValue?: string, - readOnly?: boolean, - grow?: boolean, - disableEmbeds?: boolean, - ui?: UiStore, - shareId?: ?string, - autoFocus?: boolean, - template?: boolean, - placeholder?: string, - maxLength?: number, - scrollTo?: string, - theme?: Theme, - handleDOMEvents?: Object, - readOnlyWriteCheckboxes?: boolean, - onBlur?: (event: SyntheticEvent<>) => any, - onFocus?: (event: SyntheticEvent<>) => any, - onPublish?: (event: SyntheticEvent<>) => any, - onSave?: ({ done?: boolean, autosave?: boolean, publish?: boolean }) => any, - onCancel?: () => any, - onDoubleClick?: () => any, - onChange?: (getValue: () => string) => any, - onSearchLink?: (title: string) => any, - onHoverLink?: (event: MouseEvent) => any, - onCreateLink?: (title: string) => Promise, - onImageUploadStart?: () => any, - onImageUploadStop?: () => any, -|}; +export type Props = { + id?: string; + value?: string; + defaultValue?: string; + readOnly?: boolean; + grow?: boolean; + disableEmbeds?: boolean; + ui?: UiStore; + shareId?: string | null; + autoFocus?: boolean; + template?: boolean; + placeholder?: string; + maxLength?: number; + scrollTo?: string; + theme?: Theme; + handleDOMEvents?: any; + readOnlyWriteCheckboxes?: boolean; + onBlur?: (event: SyntheticEvent) => any; + onFocus?: (event: SyntheticEvent) => any; + onPublish?: (event: SyntheticEvent) => any; + onSave?: (a: { + done?: boolean; + autosave?: boolean; + publish?: boolean; + }) => any; + onCancel?: () => any; + onDoubleClick?: () => any; + onChange?: (getValue: () => string) => any; + onSearchLink?: (title: string) => any; + onHoverLink?: (event: MouseEvent) => any; + onCreateLink?: (title: string) => Promise; + onImageUploadStart?: () => any; + onImageUploadStop?: () => any; +}; type PropsWithRef = Props & { - forwardedRef: React.Ref, - history: RouterHistory, + forwardedRef: React.Ref; + history: RouterHistory; }; function Editor(props: PropsWithRef) { @@ -259,6 +265,6 @@ const Span = styled.span` const EditorWithRouterAndTheme = withRouter(withTheme(Editor)); -export default React.forwardRef((props, ref) => ( +export default React.forwardRef((props, ref) => ( )); diff --git a/app/components/Empty.js b/app/components/Empty.ts similarity index 93% rename from app/components/Empty.js rename to app/components/Empty.ts index b7a603c41c..3e294fe3cd 100644 --- a/app/components/Empty.js +++ b/app/components/Empty.ts @@ -1,4 +1,3 @@ -// @flow import styled from "styled-components"; const Empty = styled.p` diff --git a/app/components/ErrorBoundary.js b/app/components/ErrorBoundary.tsx similarity index 93% rename from app/components/ErrorBoundary.js rename to app/components/ErrorBoundary.tsx index e3a077e335..a02d2282fa 100644 --- a/app/components/ErrorBoundary.js +++ b/app/components/ErrorBoundary.tsx @@ -1,4 +1,3 @@ -// @flow import * as Sentry from "@sentry/react"; import { observable } from "mobx"; import { observer } from "mobx-react"; @@ -12,16 +11,18 @@ import { githubIssuesUrl } from "../../shared/utils/routeHelpers"; import env from "env"; type Props = { - children: React.Node, - reloadOnChunkMissing?: boolean, + children: React.ReactNode; + reloadOnChunkMissing?: boolean; }; @observer class ErrorBoundary extends React.Component { - @observable error: ?Error; - @observable showDetails: boolean = false; + @observable + error: Error | undefined | null; + @observable + showDetails: boolean = false; - componentDidCatch(error: Error, info: Object) { + componentDidCatch(error: Error, info: any) { this.error = error; console.error(error); diff --git a/app/components/EventBoundary.js b/app/components/EventBoundary.tsx similarity index 64% rename from app/components/EventBoundary.js rename to app/components/EventBoundary.tsx index bbe28f46d2..eeb7fdcb61 100644 --- a/app/components/EventBoundary.js +++ b/app/components/EventBoundary.tsx @@ -1,14 +1,14 @@ -// @flow - import * as React from "react"; +import type { SyntheticEvent } from "react"; + type Props = { - children: React.Node, - className?: string, + children: React.ReactNode; + className?: string; }; export default function EventBoundary({ children, className }: Props) { - const handleClick = React.useCallback((event: SyntheticEvent<>) => { + const handleClick = React.useCallback((event: SyntheticEvent) => { event.preventDefault(); event.stopPropagation(); }, []); diff --git a/app/components/Facepile.js b/app/components/Facepile.tsx similarity index 86% rename from app/components/Facepile.js rename to app/components/Facepile.tsx index cf7a942942..b875595111 100644 --- a/app/components/Facepile.js +++ b/app/components/Facepile.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import * as React from "react"; import styled from "styled-components"; @@ -6,13 +5,15 @@ import User from "models/User"; import Avatar from "components/Avatar"; import Flex from "components/Flex"; -type Props = {| - users: User[], - size?: number, - overflow: number, - onClick?: (event: SyntheticEvent<>) => mixed, - renderAvatar?: (user: User) => React.Node, -|}; +import type { SyntheticEvent } from "react"; + +type Props = { + users: User[]; + size?: number; + overflow: number; + onClick?: (event: SyntheticEvent) => unknown; + renderAvatar?: (user: User) => React.ReactNode; +}; function Facepile({ users, diff --git a/app/components/Fade.js b/app/components/Fade.ts similarity index 96% rename from app/components/Fade.js rename to app/components/Fade.ts index f649bc8f7b..56ac1c8ba0 100644 --- a/app/components/Fade.js +++ b/app/components/Fade.ts @@ -1,4 +1,3 @@ -// @flow import styled from "styled-components"; import { fadeIn } from "shared/styles/animations"; diff --git a/app/components/FilterOptions.js b/app/components/FilterOptions.tsx similarity index 88% rename from app/components/FilterOptions.js rename to app/components/FilterOptions.tsx index 9221dda626..7712985da1 100644 --- a/app/components/FilterOptions.js +++ b/app/components/FilterOptions.tsx @@ -1,4 +1,3 @@ -// @flow import { find } from "lodash"; import * as React from "react"; import { useMenuState, MenuButton } from "reakit/Menu"; @@ -8,20 +7,20 @@ import ContextMenu from "components/ContextMenu"; import MenuItem from "components/ContextMenu/MenuItem"; import HelpText from "components/HelpText"; -type TFilterOption = {| - key: string, - label: string, - note?: string, -|}; +type TFilterOption = { + key: string; + label: string; + note?: string; +}; -type Props = {| - options: TFilterOption[], - activeKey: ?string, - defaultLabel?: string, - selectedPrefix?: string, - className?: string, - onSelect: (key: ?string) => void, -|}; +type Props = { + options: TFilterOption[]; + activeKey: string | undefined | null; + defaultLabel?: string; + selectedPrefix?: string; + className?: string; + onSelect: (key?: string | null) => void; +}; const FilterOptions = ({ options, diff --git a/app/components/Flex.js b/app/components/Flex.tsx similarity index 74% rename from app/components/Flex.js rename to app/components/Flex.tsx index ca93ad23c6..9a1aac09de 100644 --- a/app/components/Flex.js +++ b/app/components/Flex.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import styled from "styled-components"; @@ -8,7 +7,6 @@ type JustifyValues = | "space-between" | "flex-start" | "flex-end"; - type AlignValues = | "stretch" | "center" @@ -16,19 +14,19 @@ type AlignValues = | "flex-start" | "flex-end"; -type Props = {| - column?: ?boolean, - shrink?: ?boolean, - align?: AlignValues, - justify?: JustifyValues, - auto?: ?boolean, - className?: string, - children?: React.Node, - role?: string, - gap?: number, -|}; +type Props = { + column?: boolean | null; + shrink?: boolean | null; + align?: AlignValues; + justify?: JustifyValues; + auto?: boolean | null; + className?: string; + children?: React.ReactNode; + role?: string; + gap?: number; +}; -const Flex = React.forwardRef((props: Props, ref) => { +const Flex = React.forwardRef((props: Props, ref) => { const { children, ...restProps } = props; return ( diff --git a/app/components/FullscreenLoading.js b/app/components/FullscreenLoading.tsx similarity index 98% rename from app/components/FullscreenLoading.js rename to app/components/FullscreenLoading.tsx index d645361a18..2a2ba99d88 100644 --- a/app/components/FullscreenLoading.js +++ b/app/components/FullscreenLoading.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import styled from "styled-components"; import Empty from "components/Empty"; diff --git a/app/components/GithubLogo.js b/app/components/GithubLogo.tsx similarity index 94% rename from app/components/GithubLogo.js rename to app/components/GithubLogo.tsx index 7b63aaf6e5..803277628c 100644 --- a/app/components/GithubLogo.js +++ b/app/components/GithubLogo.tsx @@ -1,10 +1,9 @@ -// @flow import * as React from "react"; type Props = { - size?: number, - fill?: string, - className?: string, + size?: number; + fill?: string; + className?: string; }; function GithubLogo({ size = 34, fill = "#FFF", className }: Props) { diff --git a/app/components/GroupListItem.js b/app/components/GroupListItem.tsx similarity index 90% rename from app/components/GroupListItem.js rename to app/components/GroupListItem.tsx index 249080eb31..284fb76fda 100644 --- a/app/components/GroupListItem.js +++ b/app/components/GroupListItem.tsx @@ -1,4 +1,3 @@ -// @flow import { observable } from "mobx"; import { observer, inject } from "mobx-react"; import { GroupIcon } from "outline-icons"; @@ -15,17 +14,18 @@ import ListItem from "components/List/Item"; import Modal from "components/Modal"; type Props = { - group: Group, - groupMemberships: GroupMembershipsStore, - membership?: CollectionGroupMembership, - showFacepile?: boolean, - showAvatar?: boolean, - renderActions: ({ openMembersModal: () => void }) => React.Node, + group: Group; + groupMemberships: GroupMembershipsStore; + membership?: CollectionGroupMembership; + showFacepile?: boolean; + showAvatar?: boolean; + renderActions: (a: { openMembersModal: () => void }) => React.ReactNode; }; @observer class GroupListItem extends React.Component { - @observable membersModalOpen: boolean = false; + @observable + membersModalOpen: boolean = false; handleMembersModalOpen = () => { this.membersModalOpen = true; diff --git a/app/components/Guide.js b/app/components/Guide.tsx similarity index 94% rename from app/components/Guide.js rename to app/components/Guide.tsx index fea2a7e216..39ecf3e072 100644 --- a/app/components/Guide.js +++ b/app/components/Guide.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import * as React from "react"; import { Dialog, DialogBackdrop, useDialogState } from "reakit/Dialog"; @@ -6,12 +5,12 @@ import styled from "styled-components"; import Scrollable from "components/Scrollable"; import usePrevious from "hooks/usePrevious"; -type Props = {| - children?: React.Node, - isOpen: boolean, - title?: string, - onRequestClose: () => void, -|}; +type Props = { + children?: React.ReactNode; + isOpen: boolean; + title?: string; + onRequestClose: () => void; +}; const Guide = ({ children, diff --git a/app/components/Header.js b/app/components/Header.tsx similarity index 96% rename from app/components/Header.js rename to app/components/Header.tsx index bcd1bb3fca..6785e94b1b 100644 --- a/app/components/Header.js +++ b/app/components/Header.tsx @@ -1,4 +1,3 @@ -// @flow import { throttle } from "lodash"; import { observer } from "mobx-react"; import { transparentize } from "polished"; @@ -8,11 +7,11 @@ import breakpoint from "styled-components-breakpoint"; import Fade from "components/Fade"; import Flex from "components/Flex"; -type Props = {| - breadcrumb?: React.Node, - title: React.Node, - actions?: React.Node, -|}; +type Props = { + breadcrumb?: React.ReactNode; + title: React.ReactNode; + actions?: React.ReactNode; +}; function Header({ breadcrumb, title, actions }: Props) { const [isScrolled, setScrolled] = React.useState(false); diff --git a/app/components/Heading.js b/app/components/Heading.ts similarity index 97% rename from app/components/Heading.js rename to app/components/Heading.ts index f625d43efb..d0ba12ca27 100644 --- a/app/components/Heading.js +++ b/app/components/Heading.ts @@ -1,4 +1,3 @@ -// @flow import styled from "styled-components"; const Heading = styled.h1` diff --git a/app/components/HelpText.js b/app/components/HelpText.ts similarity index 96% rename from app/components/HelpText.js rename to app/components/HelpText.ts index e9f6de9704..c17fb8bbdc 100644 --- a/app/components/HelpText.js +++ b/app/components/HelpText.ts @@ -1,4 +1,3 @@ -// @flow import styled from "styled-components"; const HelpText = styled.p` diff --git a/app/components/Highlight.js b/app/components/Highlight.tsx similarity index 86% rename from app/components/Highlight.js rename to app/components/Highlight.tsx index 85f0040bb2..09301af174 100644 --- a/app/components/Highlight.js +++ b/app/components/Highlight.tsx @@ -1,13 +1,12 @@ -// @flow import * as React from "react"; import replace from "string-replace-to-array"; import styled from "styled-components"; type Props = { - highlight: ?string | RegExp, - processResult?: (tag: string) => string, - text: string, - caseSensitive?: boolean, + highlight: string | undefined | null | RegExp; + processResult?: (tag: string) => string; + text: string; + caseSensitive?: boolean; }; function Highlight({ diff --git a/app/components/HoverPreview.js b/app/components/HoverPreview.tsx similarity index 97% rename from app/components/HoverPreview.js rename to app/components/HoverPreview.tsx index ff1df8bdf5..68328f7ea9 100644 --- a/app/components/HoverPreview.js +++ b/app/components/HoverPreview.tsx @@ -1,4 +1,3 @@ -// @flow import { inject } from "mobx-react"; import { transparentize } from "polished"; import * as React from "react"; @@ -14,10 +13,10 @@ const DELAY_OPEN = 300; const DELAY_CLOSE = 300; type Props = { - node: HTMLAnchorElement, - event: MouseEvent, - documents: DocumentsStore, - onClose: () => void, + node: HTMLAnchorElement; + event: MouseEvent; + documents: DocumentsStore; + onClose: () => void; }; function HoverPreviewInternal({ node, documents, onClose, event }: Props) { @@ -26,7 +25,7 @@ function HoverPreviewInternal({ node, documents, onClose, event }: Props) { const [isVisible, setVisible] = React.useState(false); const timerClose = React.useRef(); const timerOpen = React.useRef(); - const cardRef = React.useRef(); + const cardRef = React.useRef(); const startCloseTimer = () => { stopOpenTimer(); diff --git a/app/components/HoverPreviewDocument.js b/app/components/HoverPreviewDocument.tsx similarity index 95% rename from app/components/HoverPreviewDocument.js rename to app/components/HoverPreviewDocument.tsx index 2c38afa9d0..aa32108f2c 100644 --- a/app/components/HoverPreviewDocument.js +++ b/app/components/HoverPreviewDocument.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import * as React from "react"; import { Link } from "react-router-dom"; @@ -9,8 +8,8 @@ import Editor from "components/Editor"; import useStores from "hooks/useStores"; type Props = { - url: string, - children: (React.Node) => React.Node, + url: string; + children: (a: React.ReactNode) => React.ReactNode; }; function HoverPreviewDocument({ url, children }: Props) { diff --git a/app/components/IconPicker.js b/app/components/IconPicker.tsx similarity index 97% rename from app/components/IconPicker.js rename to app/components/IconPicker.tsx index b553c6f486..2baae752bd 100644 --- a/app/components/IconPicker.js +++ b/app/components/IconPicker.tsx @@ -1,4 +1,3 @@ -// @flow import { CollectionIcon, CoinsIcon, @@ -126,12 +125,12 @@ const colors = [ "#2F362F", ]; -type Props = {| - onOpen?: () => void, - onChange: (color: string, icon: string) => void, - icon: string, - color: string, -|}; +type Props = { + onOpen?: () => void; + onChange: (color: string, icon: string) => void; + icon: string; + color: string; +}; function IconPicker({ onOpen, icon, color, onChange }: Props) { const { t } = useTranslation(); diff --git a/app/components/Image.js b/app/components/Image.tsx similarity index 62% rename from app/components/Image.js rename to app/components/Image.tsx index a8bf88a80e..123a34bdb3 100644 --- a/app/components/Image.js +++ b/app/components/Image.tsx @@ -1,14 +1,13 @@ -// @flow import * as React from "react"; import { cdnPath } from "utils/urls"; -type Props = {| - alt: string, - src: string, - title?: string, - width?: number, - height?: number, -|}; +type Props = { + alt: string; + src: string; + title?: string; + width?: number; + height?: number; +}; export default function Image({ src, alt, ...rest }: Props) { return {alt}; diff --git a/app/components/Input.js b/app/components/Input.tsx similarity index 78% rename from app/components/Input.js rename to app/components/Input.tsx index 42668c20d2..749ec13449 100644 --- a/app/components/Input.js +++ b/app/components/Input.tsx @@ -1,4 +1,3 @@ -// @flow import { observable } from "mobx"; import { observer } from "mobx-react"; import * as React from "react"; @@ -7,6 +6,8 @@ import styled from "styled-components"; import breakpoint from "styled-components-breakpoint"; import Flex from "components/Flex"; +import type { SyntheticEvent, ChangeEvent, KeyboardEvent } from "react"; + const RealTextarea = styled.textarea` border: 0; flex: 1; @@ -84,46 +85,47 @@ export const LabelText = styled.div` display: inline-block; `; -export type Props = {| - type?: "text" | "email" | "checkbox" | "search" | "textarea", - value?: string, - label?: string, - className?: string, - labelHidden?: boolean, - flex?: boolean, - short?: boolean, - margin?: string | number, - icon?: React.Node, - name?: string, - minLength?: number, - maxLength?: number, - autoFocus?: boolean, - autoComplete?: boolean | string, - readOnly?: boolean, - required?: boolean, - disabled?: boolean, - placeholder?: string, +export type Props = { + type?: "text" | "email" | "checkbox" | "search" | "textarea"; + value?: string; + label?: string; + className?: string; + labelHidden?: boolean; + flex?: boolean; + short?: boolean; + margin?: string | number; + icon?: React.ReactNode; + name?: string; + minLength?: number; + maxLength?: number; + autoFocus?: boolean; + autoComplete?: boolean | string; + readOnly?: boolean; + required?: boolean; + disabled?: boolean; + placeholder?: string; onChange?: ( - ev: SyntheticInputEvent - ) => mixed, - onKeyDown?: (ev: SyntheticKeyboardEvent) => mixed, - onFocus?: (ev: SyntheticEvent<>) => mixed, - onBlur?: (ev: SyntheticEvent<>) => mixed, -|}; + ev: ChangeEvent + ) => unknown; + onKeyDown?: (ev: KeyboardEvent) => unknown; + onFocus?: (ev: SyntheticEvent) => unknown; + onBlur?: (ev: SyntheticEvent) => unknown; +}; @observer class Input extends React.Component { - input: ?HTMLInputElement; - @observable focused: boolean = false; + input: HTMLInputElement | undefined | null; + @observable + focused: boolean = false; - handleBlur = (ev: SyntheticEvent<>) => { + handleBlur = (ev: SyntheticEvent) => { this.focused = false; if (this.props.onBlur) { this.props.onBlur(ev); } }; - handleFocus = (ev: SyntheticEvent<>) => { + handleFocus = (ev: SyntheticEvent) => { this.focused = true; if (this.props.onFocus) { this.props.onFocus(ev); diff --git a/app/components/InputLarge.js b/app/components/InputLarge.ts similarity index 96% rename from app/components/InputLarge.js rename to app/components/InputLarge.ts index 68fc10333c..f56b76445c 100644 --- a/app/components/InputLarge.js +++ b/app/components/InputLarge.ts @@ -1,4 +1,3 @@ -// @flow import styled from "styled-components"; import Input from "./Input"; diff --git a/app/components/InputRich.js b/app/components/InputRich.tsx similarity index 86% rename from app/components/InputRich.js rename to app/components/InputRich.tsx index 5238537b72..d1d03ca05e 100644 --- a/app/components/InputRich.js +++ b/app/components/InputRich.tsx @@ -1,4 +1,3 @@ -// @flow import { observable } from "mobx"; import { observer, inject } from "mobx-react"; import * as React from "react"; @@ -8,18 +7,20 @@ import Editor from "components/Editor"; import HelpText from "components/HelpText"; import { LabelText, Outline } from "components/Input"; -type Props = {| - label: string, - minHeight?: number, - maxHeight?: number, - readOnly?: boolean, - ui: UiStore, -|}; +type Props = { + label: string; + minHeight?: number; + maxHeight?: number; + readOnly?: boolean; + ui: UiStore; +}; @observer class InputRich extends React.Component { - @observable editorComponent: React.ComponentType; - @observable focused: boolean = false; + @observable + editorComponent: React.ComponentType; + @observable + focused: boolean = false; handleBlur = () => { this.focused = false; diff --git a/app/components/InputSearch.js b/app/components/InputSearch.tsx similarity index 74% rename from app/components/InputSearch.js rename to app/components/InputSearch.tsx index 6c9180d3cc..30cb4b9ad8 100644 --- a/app/components/InputSearch.js +++ b/app/components/InputSearch.tsx @@ -1,17 +1,19 @@ -// @flow import { SearchIcon } from "outline-icons"; import * as React from "react"; import { useTranslation } from "react-i18next"; import { useTheme } from "styled-components"; -import Input, { type Props as InputProps } from "./Input"; +import Input from "./Input"; -type Props = {| - ...InputProps, - placeholder?: string, - value?: string, - onChange: (event: SyntheticInputEvent<>) => mixed, - onKeyDown?: (event: SyntheticKeyboardEvent) => mixed, -|}; +import type { Props as InputProps } from "./Input"; + +import type { ChangeEvent, KeyboardEvent } from "react"; + +type Props = { + placeholder?: string; + value?: string; + onChange: (event: ChangeEvent) => unknown; + onKeyDown?: (event: KeyboardEvent) => unknown; +} & InputProps; export default function InputSearch(props: Props) { const { t } = useTranslation(); diff --git a/app/components/InputSearchPage.js b/app/components/InputSearchPage.tsx similarity index 69% rename from app/components/InputSearchPage.js rename to app/components/InputSearchPage.tsx index 2dec1bffbf..5d8f31bea4 100644 --- a/app/components/InputSearchPage.js +++ b/app/components/InputSearchPage.tsx @@ -1,38 +1,42 @@ -// @flow import { observable } from "mobx"; import { observer } from "mobx-react"; import { SearchIcon } from "outline-icons"; import * as React from "react"; -import { withTranslation, type TFunction } from "react-i18next"; +import { withTranslation } from "react-i18next"; +import type { TFunction } from "react-i18next"; import keydown from "react-keydown"; -import { withRouter, type RouterHistory } from "react-router-dom"; +import { withRouter } from "react-router-dom"; +import type { RouterHistory } from "react-router-dom"; import styled, { withTheme } from "styled-components"; import Input from "./Input"; -import { type Theme } from "types"; +import type { Theme } from "types"; import { meta } from "utils/keyboard"; import { searchUrl } from "utils/routeHelpers"; +import type { SyntheticEvent, ChangeEvent, KeyboardEvent } from "react"; + type Props = { - history: RouterHistory, - theme: Theme, - source: string, - placeholder?: string, - label?: string, - labelHidden?: boolean, - collectionId?: string, - value: string, - onChange: (event: SyntheticInputEvent<>) => mixed, - onKeyDown: (event: SyntheticKeyboardEvent) => mixed, - t: TFunction, + history: RouterHistory; + theme: Theme; + source: string; + placeholder?: string; + label?: string; + labelHidden?: boolean; + collectionId?: string; + value: string; + onChange: (event: ChangeEvent) => unknown; + onKeyDown: (event: KeyboardEvent) => unknown; + t: TFunction; }; @observer class InputSearchPage extends React.Component { - input: ?Input; - @observable focused: boolean = false; + input: Input | undefined | null; + @observable + focused: boolean = false; @keydown(`${meta}+f`) - focus(ev: SyntheticEvent<>) { + focus(ev: SyntheticEvent) { ev.preventDefault(); if (this.input) { @@ -40,7 +44,7 @@ class InputSearchPage extends React.Component { } } - handleSearchInput = (ev: SyntheticInputEvent<>) => { + handleSearchInput = (ev: ChangeEvent) => { ev.preventDefault(); this.props.history.push( searchUrl(ev.target.value, { diff --git a/app/components/InputSelect.js b/app/components/InputSelect.tsx similarity index 80% rename from app/components/InputSelect.js rename to app/components/InputSelect.tsx index 840be39533..d9d2ea4754 100644 --- a/app/components/InputSelect.js +++ b/app/components/InputSelect.tsx @@ -1,4 +1,3 @@ -// @flow import { observable } from "mobx"; import { observer } from "mobx-react"; import * as React from "react"; @@ -31,22 +30,26 @@ const Wrapper = styled.label` max-width: ${(props) => (props.short ? "350px" : "100%")}; `; -export type Option = { label: string, value: string }; +export type Option = { + label: string; + value: string; +}; export type Props = { - value?: string, - label?: string, - short?: boolean, - className?: string, - labelHidden?: boolean, - options: Option[], - onBlur?: () => void, - onFocus?: () => void, + value?: string; + label?: string; + short?: boolean; + className?: string; + labelHidden?: boolean; + options: Option[]; + onBlur?: () => void; + onFocus?: () => void; }; @observer class InputSelect extends React.Component { - @observable focused: boolean = false; + @observable + focused: boolean = false; handleBlur = () => { this.focused = false; @@ -57,14 +60,8 @@ class InputSelect extends React.Component { }; render() { - const { - label, - className, - labelHidden, - options, - short, - ...rest - } = this.props; + const { label, className, labelHidden, options, short, ...rest } = + this.props; const wrappedLabel = {label}; diff --git a/app/components/InputSelectPermission.js b/app/components/InputSelectPermission.tsx similarity index 68% rename from app/components/InputSelectPermission.js rename to app/components/InputSelectPermission.tsx index f462408bdb..cc7811633d 100644 --- a/app/components/InputSelectPermission.js +++ b/app/components/InputSelectPermission.tsx @@ -1,11 +1,10 @@ -// @flow import * as React from "react"; import { useTranslation } from "react-i18next"; -import InputSelect, { type Props, type Option } from "./InputSelect"; +import InputSelect from "./InputSelect"; -export default function InputSelectPermission( - props: $Rest }> -) { +import type { Props, Option } from "./InputSelect"; + +export default function InputSelectPermission(props: Omit) { const { t } = useTranslation(); return ( diff --git a/app/components/Key.js b/app/components/Key.ts similarity index 98% rename from app/components/Key.js rename to app/components/Key.ts index 09891971b0..94526da5c7 100644 --- a/app/components/Key.js +++ b/app/components/Key.ts @@ -1,4 +1,3 @@ -// @flow import styled from "styled-components"; const Key = styled.kbd` diff --git a/app/components/Labeled.js b/app/components/Labeled.tsx similarity index 85% rename from app/components/Labeled.js rename to app/components/Labeled.tsx index 58194ef717..c8f15305e3 100644 --- a/app/components/Labeled.js +++ b/app/components/Labeled.tsx @@ -1,13 +1,12 @@ -// @flow import { observer } from "mobx-react"; import * as React from "react"; import styled from "styled-components"; import Flex from "components/Flex"; -type Props = {| - label: React.Node | string, - children: React.Node, -|}; +type Props = { + label: React.ReactNode | string; + children: React.ReactNode; +}; const Labeled = ({ label, children, ...props }: Props) => ( diff --git a/app/components/LanguagePrompt.js b/app/components/LanguagePrompt.tsx similarity index 99% rename from app/components/LanguagePrompt.js rename to app/components/LanguagePrompt.tsx index 46e61f64df..90461c0be6 100644 --- a/app/components/LanguagePrompt.js +++ b/app/components/LanguagePrompt.tsx @@ -1,4 +1,3 @@ -// @flow import { find } from "lodash"; import * as React from "react"; import { Trans, useTranslation } from "react-i18next"; diff --git a/app/components/Layout.js b/app/components/Layout.tsx similarity index 87% rename from app/components/Layout.js rename to app/components/Layout.tsx index 7fd9eafc8f..acf381357f 100644 --- a/app/components/Layout.js +++ b/app/components/Layout.tsx @@ -1,18 +1,13 @@ -// @flow import { observable } from "mobx"; import { observer, inject } from "mobx-react"; import { MenuIcon } from "outline-icons"; import * as React from "react"; import { Helmet } from "react-helmet"; -import { withTranslation, type TFunction } from "react-i18next"; +import { withTranslation } from "react-i18next"; +import type { TFunction } from "react-i18next"; import keydown from "react-keydown"; -import { - Switch, - Route, - Redirect, - withRouter, - type RouterHistory, -} from "react-router-dom"; +import { Switch, Route, Redirect, withRouter } from "react-router-dom"; +import type { RouterHistory } from "react-router-dom"; import styled from "styled-components"; import breakpoint from "styled-components-breakpoint"; import AuthStore from "stores/AuthStore"; @@ -38,25 +33,29 @@ import { newDocumentUrl, } from "utils/routeHelpers"; +import type { SyntheticEvent } from "react"; + type Props = { - documents: DocumentsStore, - children?: ?React.Node, - actions?: ?React.Node, - title?: ?React.Node, - auth: AuthStore, - ui: UiStore, - history: RouterHistory, - policies: PoliciesStore, - notifications?: React.Node, - i18n: Object, - t: TFunction, + documents: DocumentsStore; + children?: React.ReactNode | null; + actions?: React.ReactNode | null; + title?: React.ReactNode | null; + auth: AuthStore; + ui: UiStore; + history: RouterHistory; + policies: PoliciesStore; + notifications?: React.ReactNode; + i18n: any; + t: TFunction; }; @observer class Layout extends React.Component { - scrollable: ?HTMLDivElement; - @observable redirectTo: ?string; - @observable keyboardShortcutsOpen: boolean = false; + scrollable: HTMLDivElement | undefined | null; + @observable + redirectTo: string | undefined | null; + @observable + keyboardShortcutsOpen: boolean = false; componentDidUpdate() { if (this.redirectTo) { @@ -79,7 +78,7 @@ class Layout extends React.Component { }; @keydown(["t", "/", `${meta}+k`]) - goToSearch(ev: SyntheticEvent<>) { + goToSearch(ev: SyntheticEvent) { ev.preventDefault(); ev.stopPropagation(); this.redirectTo = searchUrl(); diff --git a/app/components/List/Item.js b/app/components/List/Item.tsx similarity index 91% rename from app/components/List/Item.js rename to app/components/List/Item.tsx index 29b300f8eb..9bfd399898 100644 --- a/app/components/List/Item.js +++ b/app/components/List/Item.tsx @@ -1,15 +1,14 @@ -// @flow import * as React from "react"; import styled from "styled-components"; import Flex from "components/Flex"; type Props = { - image?: React.Node, - title: React.Node, - subtitle?: React.Node, - actions?: React.Node, - border?: boolean, - small?: boolean, + image?: React.ReactNode; + title: React.ReactNode; + subtitle?: React.ReactNode; + actions?: React.ReactNode; + border?: boolean; + small?: boolean; }; const ListItem = ({ diff --git a/app/components/List/List.js b/app/components/List/List.ts similarity index 93% rename from app/components/List/List.js rename to app/components/List/List.ts index 33fb89e053..f5bba2ecec 100644 --- a/app/components/List/List.js +++ b/app/components/List/List.ts @@ -1,4 +1,3 @@ -// @flow import styled from "styled-components"; const List = styled.ol` diff --git a/app/components/List/Placeholder.js b/app/components/List/Placeholder.tsx similarity index 95% rename from app/components/List/Placeholder.js rename to app/components/List/Placeholder.tsx index 8e0a0c9a5a..4e2a8220c4 100644 --- a/app/components/List/Placeholder.js +++ b/app/components/List/Placeholder.tsx @@ -1,4 +1,3 @@ -// @flow import { times } from "lodash"; import * as React from "react"; import styled from "styled-components"; @@ -7,7 +6,7 @@ import Flex from "components/Flex"; import Mask from "components/Mask"; type Props = { - count?: number, + count?: number; }; const Placeholder = ({ count }: Props) => { diff --git a/app/components/List/index.js b/app/components/List/index.ts similarity index 84% rename from app/components/List/index.js rename to app/components/List/index.ts index d31f1b0479..677531d8bd 100644 --- a/app/components/List/index.js +++ b/app/components/List/index.ts @@ -1,3 +1,2 @@ -// @flow import List from "./List"; export default List; diff --git a/app/components/LoadingIndicator/LoadingIndicator.js b/app/components/LoadingIndicator/LoadingIndicator.ts similarity index 94% rename from app/components/LoadingIndicator/LoadingIndicator.js rename to app/components/LoadingIndicator/LoadingIndicator.ts index 3b25a80a83..8ca84e09ea 100644 --- a/app/components/LoadingIndicator/LoadingIndicator.js +++ b/app/components/LoadingIndicator/LoadingIndicator.ts @@ -1,10 +1,9 @@ -// @flow import { inject, observer } from "mobx-react"; import * as React from "react"; import UiStore from "stores/UiStore"; type Props = { - ui: UiStore, + ui: UiStore; }; @observer diff --git a/app/components/LoadingIndicator/LoadingIndicatorBar.js b/app/components/LoadingIndicator/LoadingIndicatorBar.tsx similarity index 98% rename from app/components/LoadingIndicator/LoadingIndicatorBar.js rename to app/components/LoadingIndicator/LoadingIndicatorBar.tsx index 87c2f7aa23..1b7fd5b2e2 100644 --- a/app/components/LoadingIndicator/LoadingIndicatorBar.js +++ b/app/components/LoadingIndicator/LoadingIndicatorBar.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import styled, { keyframes } from "styled-components"; diff --git a/app/components/LoadingIndicator/index.js b/app/components/LoadingIndicator/index.ts similarity index 95% rename from app/components/LoadingIndicator/index.js rename to app/components/LoadingIndicator/index.ts index f90b3ecbe3..857413a952 100644 --- a/app/components/LoadingIndicator/index.js +++ b/app/components/LoadingIndicator/index.ts @@ -1,4 +1,3 @@ -// @flow import LoadingIndicator from "./LoadingIndicator"; import LoadingIndicatorBar from "./LoadingIndicatorBar"; export default LoadingIndicator; diff --git a/app/components/LoadingPlaceholder/ListPlaceholder.js b/app/components/LoadingPlaceholder/ListPlaceholder.tsx similarity index 95% rename from app/components/LoadingPlaceholder/ListPlaceholder.js rename to app/components/LoadingPlaceholder/ListPlaceholder.tsx index 8492131da2..d694c1a2a3 100644 --- a/app/components/LoadingPlaceholder/ListPlaceholder.js +++ b/app/components/LoadingPlaceholder/ListPlaceholder.tsx @@ -1,4 +1,3 @@ -// @flow import { times } from "lodash"; import * as React from "react"; import styled from "styled-components"; @@ -7,7 +6,7 @@ import Flex from "components/Flex"; import Mask from "components/Mask"; type Props = { - count?: number, + count?: number; }; const ListPlaceHolder = ({ count }: Props) => { diff --git a/app/components/LoadingPlaceholder/LoadingPlaceholder.js b/app/components/LoadingPlaceholder/LoadingPlaceholder.tsx similarity index 88% rename from app/components/LoadingPlaceholder/LoadingPlaceholder.js rename to app/components/LoadingPlaceholder/LoadingPlaceholder.tsx index 3ab4465baa..00e4e69960 100644 --- a/app/components/LoadingPlaceholder/LoadingPlaceholder.js +++ b/app/components/LoadingPlaceholder/LoadingPlaceholder.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import styled from "styled-components"; import DelayedMount from "components/DelayedMount"; @@ -6,7 +5,7 @@ import Fade from "components/Fade"; import Flex from "components/Flex"; import Mask from "components/Mask"; -export default function LoadingPlaceholder(props: Object) { +export default function LoadingPlaceholder(props: any) { return ( diff --git a/app/components/LoadingPlaceholder/index.js b/app/components/LoadingPlaceholder/index.ts similarity index 94% rename from app/components/LoadingPlaceholder/index.js rename to app/components/LoadingPlaceholder/index.ts index f5e93ca050..e03658e22c 100644 --- a/app/components/LoadingPlaceholder/index.js +++ b/app/components/LoadingPlaceholder/index.ts @@ -1,4 +1,3 @@ -// @flow import ListPlaceholder from "./ListPlaceholder"; import LoadingPlaceholder from "./LoadingPlaceholder"; diff --git a/app/components/LocaleTime.js b/app/components/LocaleTime.tsx similarity index 93% rename from app/components/LocaleTime.js rename to app/components/LocaleTime.tsx index e0e4219ccd..5f5a217dfa 100644 --- a/app/components/LocaleTime.js +++ b/app/components/LocaleTime.tsx @@ -1,4 +1,3 @@ -// @flow import { format, formatDistanceToNow } from "date-fns"; import { enUS, @@ -48,11 +47,11 @@ function eachMinute(fn) { } type Props = { - dateTime: string, - children?: React.Node, - tooltipDelay?: number, - addSuffix?: boolean, - shorten?: boolean, + dateTime: string; + children?: React.ReactNode; + tooltipDelay?: number; + addSuffix?: boolean; + shorten?: boolean; }; function LocaleTime({ diff --git a/app/components/Mask.js b/app/components/Mask.tsx similarity index 89% rename from app/components/Mask.js rename to app/components/Mask.tsx index ce407c7414..8ff10225d8 100644 --- a/app/components/Mask.js +++ b/app/components/Mask.tsx @@ -1,16 +1,15 @@ -// @flow import * as React from "react"; import styled from "styled-components"; import { randomInteger } from "shared/random"; import { pulsate } from "shared/styles/animations"; import Flex from "components/Flex"; -type Props = {| - header?: boolean, - height?: number, - minWidth?: number, - maxWidth?: number, -|}; +type Props = { + header?: boolean; + height?: number; + minWidth?: number; + maxWidth?: number; +}; class Mask extends React.Component { width: number; diff --git a/app/components/Modal.js b/app/components/Modal.tsx similarity index 97% rename from app/components/Modal.js rename to app/components/Modal.tsx index 05caa8ca2f..4bb7f25cbe 100644 --- a/app/components/Modal.js +++ b/app/components/Modal.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import { CloseIcon, BackIcon } from "outline-icons"; import { transparentize } from "polished"; @@ -16,12 +15,12 @@ import useUnmount from "hooks/useUnmount"; let openModals = 0; -type Props = {| - children?: React.Node, - isOpen: boolean, - title?: string, - onRequestClose: () => void, -|}; +type Props = { + children?: React.ReactNode; + isOpen: boolean; + title?: string; + onRequestClose: () => void; +}; const Modal = ({ children, diff --git a/app/components/Notice.js b/app/components/Notice.ts similarity index 96% rename from app/components/Notice.js rename to app/components/Notice.ts index 7bd8048073..a0a4d1d7d1 100644 --- a/app/components/Notice.js +++ b/app/components/Notice.ts @@ -1,4 +1,3 @@ -// @flow import styled from "styled-components"; const Notice = styled.p` diff --git a/app/components/NoticeAlert.js b/app/components/NoticeAlert.tsx similarity index 92% rename from app/components/NoticeAlert.js rename to app/components/NoticeAlert.tsx index c10b768d90..b919c6e2db 100644 --- a/app/components/NoticeAlert.js +++ b/app/components/NoticeAlert.tsx @@ -1,8 +1,11 @@ -// @flow import * as React from "react"; import Notice from "components/Notice"; -export default function AlertNotice({ children }: { children: React.Node }) { +export default function AlertNotice({ + children, +}: { + children: React.ReactNode; +}) { return ( ( +export default React.forwardRef( ({ size = 24, ...props }, ref) => ); diff --git a/app/components/OutlineLogo.js b/app/components/OutlineLogo.tsx similarity index 96% rename from app/components/OutlineLogo.js rename to app/components/OutlineLogo.tsx index 79602477b6..81eb485518 100644 --- a/app/components/OutlineLogo.js +++ b/app/components/OutlineLogo.tsx @@ -1,10 +1,9 @@ -// @flow import * as React from "react"; type Props = { - size?: number, - fill?: string, - className?: string, + size?: number; + fill?: string; + className?: string; }; function OutlineLogo({ size = 32, fill = "#333", className }: Props) { diff --git a/app/components/PageTheme.js b/app/components/PageTheme.ts similarity index 98% rename from app/components/PageTheme.js rename to app/components/PageTheme.ts index f0f47ebfb5..2d6c89ff9d 100644 --- a/app/components/PageTheme.js +++ b/app/components/PageTheme.ts @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import { useTheme } from "styled-components"; import useStores from "hooks/useStores"; diff --git a/app/components/PageTitle.js b/app/components/PageTitle.tsx similarity index 92% rename from app/components/PageTitle.js rename to app/components/PageTitle.tsx index 435d1e5d95..722fc85b41 100644 --- a/app/components/PageTitle.js +++ b/app/components/PageTitle.tsx @@ -1,14 +1,13 @@ -// @flow import { observer } from "mobx-react"; import * as React from "react"; import { Helmet } from "react-helmet"; import useStores from "hooks/useStores"; import { cdnPath } from "utils/urls"; -type Props = {| - title: string, - favicon?: string, -|}; +type Props = { + title: string; + favicon?: string; +}; const PageTitle = ({ title, favicon }: Props) => { const { auth } = useStores(); diff --git a/app/components/PaginatedDocumentList.js b/app/components/PaginatedDocumentList.tsx similarity index 69% rename from app/components/PaginatedDocumentList.js rename to app/components/PaginatedDocumentList.tsx index f6fabd9a69..f0dfde782c 100644 --- a/app/components/PaginatedDocumentList.js +++ b/app/components/PaginatedDocumentList.tsx @@ -1,23 +1,22 @@ -// @flow import { observer } from "mobx-react"; import * as React from "react"; import Document from "models/Document"; import DocumentListItem from "components/DocumentListItem"; import PaginatedList from "components/PaginatedList"; -type Props = {| - documents: Document[], - fetch: (options: ?Object) => Promise, - options?: Object, - heading?: React.Node, - empty?: React.Node, - showNestedDocuments?: boolean, - showCollection?: boolean, - showPublished?: boolean, - showPin?: boolean, - showDraft?: boolean, - showTemplate?: boolean, -|}; +type Props = { + documents: Document[]; + fetch: (options?: any | null) => Promise; + options?: any; + heading?: React.ReactNode; + empty?: React.ReactNode; + showNestedDocuments?: boolean; + showCollection?: boolean; + showPublished?: boolean; + showPin?: boolean; + showDraft?: boolean; + showTemplate?: boolean; +}; @observer class PaginatedDocumentList extends React.Component { diff --git a/app/components/PaginatedList.test.js b/app/components/PaginatedList.test.tsx similarity index 99% rename from app/components/PaginatedList.test.js rename to app/components/PaginatedList.test.tsx index 506c9c5474..7b2c0ea8c5 100644 --- a/app/components/PaginatedList.test.js +++ b/app/components/PaginatedList.test.tsx @@ -1,4 +1,3 @@ -// @flow import "../stores"; import { shallow } from "enzyme"; import * as React from "react"; diff --git a/app/components/PaginatedList.js b/app/components/PaginatedList.tsx similarity index 87% rename from app/components/PaginatedList.js rename to app/components/PaginatedList.tsx index eb657c6804..762f05e0cb 100644 --- a/app/components/PaginatedList.js +++ b/app/components/PaginatedList.tsx @@ -1,4 +1,3 @@ -// @flow import ArrowKeyNavigation from "boundless-arrow-key-navigation"; import { isEqual } from "lodash"; import { observable, action } from "mobx"; @@ -10,23 +9,29 @@ import DelayedMount from "components/DelayedMount"; import { ListPlaceholder } from "components/LoadingPlaceholder"; type Props = { - fetch?: (options: ?Object) => Promise, - options?: Object, - heading?: React.Node, - empty?: React.Node, - items: any[], - renderItem: (any) => React.Node, + fetch?: (options?: any | null) => Promise; + options?: any; + heading?: React.ReactNode; + empty?: React.ReactNode; + items: any[]; + renderItem: (a: any) => React.ReactNode; }; @observer class PaginatedList extends React.Component { isInitiallyLoaded: boolean = false; - @observable isLoaded: boolean = false; - @observable isFetchingMore: boolean = false; - @observable isFetching: boolean = false; - @observable renderCount: number = DEFAULT_PAGINATION_LIMIT; - @observable offset: number = 0; - @observable allowLoadMore: boolean = true; + @observable + isLoaded: boolean = false; + @observable + isFetchingMore: boolean = false; + @observable + isFetching: boolean = false; + @observable + renderCount: number = DEFAULT_PAGINATION_LIMIT; + @observable + offset: number = 0; + @observable + allowLoadMore: boolean = true; constructor(props: Props) { super(props); diff --git a/app/components/PathToDocument.js b/app/components/PathToDocument.tsx similarity index 89% rename from app/components/PathToDocument.js rename to app/components/PathToDocument.tsx index f9995e79f9..ce588439c6 100644 --- a/app/components/PathToDocument.js +++ b/app/components/PathToDocument.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import { GoToIcon } from "outline-icons"; import * as React from "react"; @@ -9,18 +8,20 @@ import Document from "models/Document"; import CollectionIcon from "components/CollectionIcon"; import Flex from "components/Flex"; +import type { SyntheticEvent } from "react"; + type Props = { - result: DocumentPath, - document?: ?Document, - collection: ?Collection, - onSuccess?: () => void, - style?: Object, - ref?: (?React.ElementRef<"div">) => void, + result: DocumentPath; + document?: Document | null; + collection: Collection | undefined | null; + onSuccess?: () => void; + style?: any; + ref?: (a?: React.RefObject<"div"> | null) => void; }; @observer class PathToDocument extends React.Component { - handleClick = async (ev: SyntheticEvent<>) => { + handleClick = async (ev: SyntheticEvent) => { ev.preventDefault(); const { document, result, onSuccess } = this.props; if (!document) return; diff --git a/app/components/Popover.js b/app/components/Popover.tsx similarity index 94% rename from app/components/Popover.js rename to app/components/Popover.tsx index e1af37a75a..3da2040148 100644 --- a/app/components/Popover.js +++ b/app/components/Popover.tsx @@ -1,12 +1,11 @@ -// @flow import * as React from "react"; import { Popover as ReakitPopover } from "reakit/Popover"; import styled from "styled-components"; import { fadeAndScaleIn } from "shared/styles/animations"; type Props = { - children: React.Node, - width?: number, + children: React.ReactNode; + width?: number; }; function Popover({ children, width = 380, ...rest }: Props) { diff --git a/app/components/ProfiledRoute.js b/app/components/ProfiledRoute.ts similarity index 96% rename from app/components/ProfiledRoute.js rename to app/components/ProfiledRoute.ts index 2eef5bce35..ecdd684afa 100644 --- a/app/components/ProfiledRoute.js +++ b/app/components/ProfiledRoute.ts @@ -1,4 +1,3 @@ -// @flow import * as Sentry from "@sentry/react"; import { Route } from "react-router-dom"; import env from "env"; diff --git a/app/components/Scene.js b/app/components/Scene.tsx similarity index 81% rename from app/components/Scene.js rename to app/components/Scene.tsx index 6c2c5247de..704d7eb512 100644 --- a/app/components/Scene.js +++ b/app/components/Scene.tsx @@ -1,19 +1,18 @@ -// @flow import * as React from "react"; import styled from "styled-components"; import CenteredContent from "components/CenteredContent"; import Header from "components/Header"; import PageTitle from "components/PageTitle"; -type Props = {| - icon?: React.Node, - title: React.Node, - textTitle?: string, - children: React.Node, - breadcrumb?: React.Node, - actions?: React.Node, - centered?: boolean, -|}; +type Props = { + icon?: React.ReactNode; + title: React.ReactNode; + textTitle?: string; + children: React.ReactNode; + breadcrumb?: React.ReactNode; + actions?: React.ReactNode; + centered?: boolean; +}; function Scene({ title, diff --git a/app/components/ScrollToTop.js b/app/components/ScrollToTop.ts similarity index 93% rename from app/components/ScrollToTop.js rename to app/components/ScrollToTop.ts index 1129a34103..6d0855c6c4 100644 --- a/app/components/ScrollToTop.js +++ b/app/components/ScrollToTop.ts @@ -1,12 +1,11 @@ -// @flow // based on: https://reacttraining.com/react-router/web/guides/scroll-restoration import * as React from "react"; import { withRouter } from "react-router-dom"; import type { Location } from "react-router-dom"; type Props = { - location: Location, - children: React.Node, + location: Location; + children: React.ReactNode; }; class ScrollToTop extends React.Component { diff --git a/app/components/Scrollable.js b/app/components/Scrollable.tsx similarity index 91% rename from app/components/Scrollable.js rename to app/components/Scrollable.tsx index 2c686970f3..49cb5d1d98 100644 --- a/app/components/Scrollable.js +++ b/app/components/Scrollable.tsx @@ -1,18 +1,17 @@ -// @flow import { observer } from "mobx-react"; import * as React from "react"; import styled from "styled-components"; import useWindowSize from "hooks/useWindowSize"; -type Props = {| - shadow?: boolean, - topShadow?: boolean, - bottomShadow?: boolean, - flex?: boolean, -|}; +type Props = { + shadow?: boolean; + topShadow?: boolean; + bottomShadow?: boolean; + flex?: boolean; +}; function Scrollable({ shadow, topShadow, bottomShadow, flex, ...rest }: Props) { - const ref = React.useRef(); + const ref = React.useRef(); const [topShadowVisible, setTopShadow] = React.useState(false); const [bottomShadowVisible, setBottomShadow] = React.useState(false); const { height } = useWindowSize(); diff --git a/app/components/Sidebar/Main.js b/app/components/Sidebar/Main.tsx similarity index 95% rename from app/components/Sidebar/Main.js rename to app/components/Sidebar/Main.tsx index dd06a7b7fe..7a96cf4bab 100644 --- a/app/components/Sidebar/Main.js +++ b/app/components/Sidebar/Main.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import { ArchiveIcon, @@ -30,14 +29,14 @@ import TeamButton from "./components/TeamButton"; import useStores from "hooks/useStores"; import AccountMenu from "menus/AccountMenu"; +import type { SyntheticEvent } from "react"; + function MainSidebar() { const { t } = useTranslation(); const { policies, auth, documents } = useStores(); const [inviteModalOpen, setInviteModalOpen] = React.useState(false); - const [ - createCollectionModalOpen, - setCreateCollectionModalOpen, - ] = React.useState(false); + const [createCollectionModalOpen, setCreateCollectionModalOpen] = + React.useState(false); React.useEffect(() => { documents.fetchDrafts(); @@ -45,7 +44,7 @@ function MainSidebar() { }, [documents]); const handleCreateCollectionModalOpen = React.useCallback( - (ev: SyntheticEvent<>) => { + (ev: SyntheticEvent) => { ev.preventDefault(); setCreateCollectionModalOpen(true); }, @@ -56,7 +55,7 @@ function MainSidebar() { setCreateCollectionModalOpen(false); }, []); - const handleInviteModalOpen = React.useCallback((ev: SyntheticEvent<>) => { + const handleInviteModalOpen = React.useCallback((ev: SyntheticEvent) => { ev.preventDefault(); setInviteModalOpen(true); }, []); @@ -67,9 +66,10 @@ function MainSidebar() { const [dndArea, setDndArea] = React.useState(); const handleSidebarRef = React.useCallback((node) => setDndArea(node), []); - const html5Options = React.useMemo(() => ({ rootElement: dndArea }), [ - dndArea, - ]); + const html5Options = React.useMemo( + () => ({ rootElement: dndArea }), + [dndArea] + ); const { user, team } = auth; if (!user || !team) return null; diff --git a/app/components/Sidebar/Settings.js b/app/components/Sidebar/Settings.tsx similarity index 99% rename from app/components/Sidebar/Settings.js rename to app/components/Sidebar/Settings.tsx index 9d9ffa52cf..122f5ece47 100644 --- a/app/components/Sidebar/Settings.js +++ b/app/components/Sidebar/Settings.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import { DocumentIcon, diff --git a/app/components/Sidebar/Sidebar.js b/app/components/Sidebar/Sidebar.tsx similarity index 98% rename from app/components/Sidebar/Sidebar.js rename to app/components/Sidebar/Sidebar.tsx index f63b76275d..0c28bd71b3 100644 --- a/app/components/Sidebar/Sidebar.js +++ b/app/components/Sidebar/Sidebar.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import * as React from "react"; import { useTranslation } from "react-i18next"; @@ -17,11 +16,11 @@ import useStores from "hooks/useStores"; let ANIMATION_MS = 250; let isFirstRender = true; -type Props = {| - children: React.Node, -|}; +type Props = { + children: React.ReactNode; +}; -const Sidebar = React.forwardRef( +const Sidebar = React.forwardRef( ({ children }: Props, ref) => { const [isCollapsing, setCollapsing] = React.useState(false); const theme = useTheme(); diff --git a/app/components/Sidebar/components/CollectionLink.js b/app/components/Sidebar/components/CollectionLink.tsx similarity index 95% rename from app/components/Sidebar/components/CollectionLink.js rename to app/components/Sidebar/components/CollectionLink.tsx index 5366fcd512..a819bdfd04 100644 --- a/app/components/Sidebar/components/CollectionLink.js +++ b/app/components/Sidebar/components/CollectionLink.tsx @@ -1,4 +1,3 @@ -// @flow import fractionalIndex from "fractional-index"; import { observer } from "mobx-react"; import * as React from "react"; @@ -16,15 +15,15 @@ import useStores from "hooks/useStores"; import CollectionMenu from "menus/CollectionMenu"; import CollectionSortMenu from "menus/CollectionSortMenu"; -type Props = {| - collection: Collection, - canUpdate: boolean, - activeDocument: ?Document, - prefetchDocument: (id: string) => Promise, - belowCollection: Collection | void, - isDraggingAnyCollection: boolean, - onChangeDragging: (dragging: boolean) => void, -|}; +type Props = { + collection: Collection; + canUpdate: boolean; + activeDocument: Document | undefined | null; + prefetchDocument: (id: string) => Promise; + belowCollection: Collection | void; + isDraggingAnyCollection: boolean; + onChangeDragging: (dragging: boolean) => void; +}; function CollectionLink({ collection, diff --git a/app/components/Sidebar/components/Collections.js b/app/components/Sidebar/components/Collections.tsx similarity index 96% rename from app/components/Sidebar/components/Collections.js rename to app/components/Sidebar/components/Collections.tsx index b2ce303ab9..05f7839d65 100644 --- a/app/components/Sidebar/components/Collections.js +++ b/app/components/Sidebar/components/Collections.tsx @@ -1,4 +1,3 @@ -// @flow import fractionalIndex from "fractional-index"; import { observer } from "mobx-react"; import { PlusIcon } from "outline-icons"; @@ -14,8 +13,9 @@ import DropCursor from "./DropCursor"; import Header from "./Header"; import SidebarLink from "./SidebarLink"; import useCurrentTeam from "hooks/useCurrentTeam"; + type Props = { - onCreateCollection: () => void, + onCreateCollection: () => void; }; function Collections({ onCreateCollection }: Props) { @@ -27,9 +27,8 @@ function Collections({ onCreateCollection }: Props) { const team = useCurrentTeam(); const orderedCollections = collections.orderedData; const can = policies.abilities(team.id); - const [isDraggingAnyCollection, setIsDraggingAnyCollection] = React.useState( - false - ); + const [isDraggingAnyCollection, setIsDraggingAnyCollection] = + React.useState(false); React.useEffect(() => { async function load() { diff --git a/app/components/Sidebar/components/CollectionsLoading.js b/app/components/Sidebar/components/CollectionsLoading.tsx similarity index 97% rename from app/components/Sidebar/components/CollectionsLoading.js rename to app/components/Sidebar/components/CollectionsLoading.tsx index d2a9c995b0..5416ec8d9d 100644 --- a/app/components/Sidebar/components/CollectionsLoading.js +++ b/app/components/Sidebar/components/CollectionsLoading.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import styled from "styled-components"; import Mask from "components/Mask"; diff --git a/app/components/Sidebar/components/DocumentLink.js b/app/components/Sidebar/components/DocumentLink.tsx similarity index 95% rename from app/components/Sidebar/components/DocumentLink.js rename to app/components/Sidebar/components/DocumentLink.tsx index 689f04fc0a..01526b1a7c 100644 --- a/app/components/Sidebar/components/DocumentLink.js +++ b/app/components/Sidebar/components/DocumentLink.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import { CollapsedIcon } from "outline-icons"; import * as React from "react"; @@ -14,18 +13,20 @@ import EditableTitle from "./EditableTitle"; import SidebarLink from "./SidebarLink"; import useStores from "hooks/useStores"; import DocumentMenu from "menus/DocumentMenu"; -import { type NavigationNode } from "types"; +import type { NavigationNode } from "types"; -type Props = {| - node: NavigationNode, - canUpdate: boolean, - collection?: Collection, - activeDocument: ?Document, - prefetchDocument: (documentId: string) => Promise, - depth: number, - index: number, - parentId?: string, -|}; +import type { SyntheticEvent } from "react"; + +type Props = { + node: NavigationNode; + canUpdate: boolean; + collection?: Collection; + activeDocument: Document | undefined | null; + prefetchDocument: (documentId: string) => Promise; + depth: number; + index: number; + parentId?: string; +}; function DocumentLink( { @@ -91,7 +92,7 @@ function DocumentLink( }, [expanded, hasChildDocuments]); const handleDisclosureClick = React.useCallback( - (ev: SyntheticEvent<>) => { + (ev: SyntheticEvent) => { ev.preventDefault(); ev.stopPropagation(); setExpanded(!expanded); @@ -100,7 +101,7 @@ function DocumentLink( ); const handleMouseEnter = React.useCallback( - (ev: SyntheticEvent<>) => { + (ev: SyntheticEvent) => { prefetchDocument(node.id); }, [prefetchDocument, node] diff --git a/app/components/Sidebar/components/DropCursor.js b/app/components/Sidebar/components/DropCursor.tsx similarity index 86% rename from app/components/Sidebar/components/DropCursor.js rename to app/components/Sidebar/components/DropCursor.tsx index d25ac49dc9..d7530a430f 100644 --- a/app/components/Sidebar/components/DropCursor.js +++ b/app/components/Sidebar/components/DropCursor.tsx @@ -1,7 +1,6 @@ -// @flow import * as React from "react"; import styled, { withTheme } from "styled-components"; -import { type Theme } from "types"; +import type { Theme } from "types"; function DropCursor({ isActiveDrop, @@ -9,10 +8,10 @@ function DropCursor({ theme, from, }: { - isActiveDrop: boolean, - innerRef: React.Ref, - theme: Theme, - from: string, + isActiveDrop: boolean; + innerRef: React.Ref; + theme: Theme; + from: string; }) { return ; } diff --git a/app/components/Sidebar/components/DropToImport.js b/app/components/Sidebar/components/DropToImport.tsx similarity index 92% rename from app/components/Sidebar/components/DropToImport.js rename to app/components/Sidebar/components/DropToImport.tsx index a63342ccaf..7f06569a64 100644 --- a/app/components/Sidebar/components/DropToImport.js +++ b/app/components/Sidebar/components/DropToImport.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import * as React from "react"; import Dropzone from "react-dropzone"; @@ -8,13 +7,13 @@ import LoadingIndicator from "components/LoadingIndicator"; import useImportDocument from "hooks/useImportDocument"; import useStores from "hooks/useStores"; -type Props = {| - children: React.Node, - collectionId: string, - documentId?: string, - disabled: boolean, - staticContext: Object, -|}; +type Props = { + children: React.ReactNode; + collectionId: string; + documentId?: string; + disabled: boolean; + staticContext: any; +}; function DropToImport({ disabled, children, collectionId, documentId }: Props) { const { t } = useTranslation(); diff --git a/app/components/Sidebar/components/EditableTitle.js b/app/components/Sidebar/components/EditableTitle.tsx similarity index 95% rename from app/components/Sidebar/components/EditableTitle.js rename to app/components/Sidebar/components/EditableTitle.tsx index 057c908ef5..b3a119d8f3 100644 --- a/app/components/Sidebar/components/EditableTitle.js +++ b/app/components/Sidebar/components/EditableTitle.tsx @@ -1,13 +1,12 @@ -// @flow import * as React from "react"; import styled from "styled-components"; import useStores from "hooks/useStores"; -type Props = {| - onSubmit: (title: string) => Promise, - title: string, - canUpdate: boolean, -|}; +type Props = { + onSubmit: (title: string) => Promise; + title: string; + canUpdate: boolean; +}; function EditableTitle({ title, onSubmit, canUpdate }: Props) { const [isEditing, setIsEditing] = React.useState(false); diff --git a/app/components/Sidebar/components/Header.js b/app/components/Sidebar/components/Header.ts similarity index 97% rename from app/components/Sidebar/components/Header.js rename to app/components/Sidebar/components/Header.ts index dbc9ccd5de..562f444a96 100644 --- a/app/components/Sidebar/components/Header.js +++ b/app/components/Sidebar/components/Header.ts @@ -1,4 +1,3 @@ -// @flow import styled from "styled-components"; import Flex from "components/Flex"; diff --git a/app/components/Sidebar/components/NavLink.js b/app/components/Sidebar/components/NavLink.tsx similarity index 88% rename from app/components/Sidebar/components/NavLink.js rename to app/components/Sidebar/components/NavLink.tsx index c0b3003ac7..898eb23435 100644 --- a/app/components/Sidebar/components/NavLink.js +++ b/app/components/Sidebar/components/NavLink.tsx @@ -1,4 +1,3 @@ -// @flow // ref: https://github.com/ReactTraining/react-router/blob/master/packages/react-router-dom/modules/NavLink.js // This file is pulled almost 100% from react-router with the addition of one @@ -6,11 +5,8 @@ // it avoids recalculating the link match again. import { createLocation } from "history"; import * as React from "react"; -import { - __RouterContext as RouterContext, - matchPath, - type Location, -} from "react-router"; +import { __RouterContext as RouterContext, matchPath } from "react-router"; +import type { Location } from "react-router"; import { Link } from "react-router-dom"; import scrollIntoView from "smooth-scroll-into-view-if-needed"; @@ -27,17 +23,17 @@ const joinClassnames = (...classnames) => { return classnames.filter((i) => i).join(" "); }; -type Props = {| - activeClassName?: String, - activeStyle?: Object, - className?: string, - exact?: boolean, - isActive?: any, - location?: Location, - strict?: boolean, - style?: Object, - to: string, -|}; +type Props = { + activeClassName?: String; + activeStyle?: any; + className?: string; + exact?: boolean; + isActive?: any; + location?: Location; + strict?: boolean; + style?: any; + to: string; +}; /** * A wrapper that knows if it's "active" or not. diff --git a/app/components/Sidebar/components/ResizeBorder.js b/app/components/Sidebar/components/ResizeBorder.ts similarity index 95% rename from app/components/Sidebar/components/ResizeBorder.js rename to app/components/Sidebar/components/ResizeBorder.ts index fe39860295..067641dd49 100644 --- a/app/components/Sidebar/components/ResizeBorder.js +++ b/app/components/Sidebar/components/ResizeBorder.ts @@ -1,4 +1,3 @@ -// @flow import styled from "styled-components"; const ResizeBorder = styled.div` diff --git a/app/components/Sidebar/components/Section.js b/app/components/Sidebar/components/Section.ts similarity index 97% rename from app/components/Sidebar/components/Section.js rename to app/components/Sidebar/components/Section.ts index 2469fa9d3b..8a9d863b43 100644 --- a/app/components/Sidebar/components/Section.js +++ b/app/components/Sidebar/components/Section.ts @@ -1,4 +1,3 @@ -// @flow import styled from "styled-components"; import Flex from "components/Flex"; diff --git a/app/components/Sidebar/components/SidebarLink.js b/app/components/Sidebar/components/SidebarLink.tsx similarity index 82% rename from app/components/Sidebar/components/SidebarLink.js rename to app/components/Sidebar/components/SidebarLink.tsx index 43a3987823..19652f5c69 100644 --- a/app/components/Sidebar/components/SidebarLink.js +++ b/app/components/Sidebar/components/SidebarLink.tsx @@ -1,32 +1,34 @@ -// @flow import * as React from "react"; -import { withRouter, type RouterHistory, type Match } from "react-router-dom"; +import { withRouter } from "react-router-dom"; +import type { RouterHistory, Match } from "react-router-dom"; import styled, { withTheme } from "styled-components"; import breakpoint from "styled-components-breakpoint"; import EventBoundary from "components/EventBoundary"; import NavLink from "./NavLink"; -import { type Theme } from "types"; +import type { Theme } from "types"; + +import type { SyntheticEvent } from "react"; type Props = { - to?: string | Object, - href?: string | Object, - innerRef?: (?HTMLElement) => void, - onClick?: (SyntheticEvent<>) => void, - onMouseEnter?: (SyntheticEvent<>) => void, - className?: string, - children?: React.Node, - icon?: React.Node, - label?: React.Node, - menu?: React.Node, - showActions?: boolean, - iconColor?: string, - active?: boolean, - isActiveDrop?: boolean, - history: RouterHistory, - match: Match, - theme: Theme, - exact?: boolean, - depth?: number, + to?: string | any; + href?: string | any; + innerRef?: (a?: HTMLElement | null) => void; + onClick?: (a: SyntheticEvent) => void; + onMouseEnter?: (a: SyntheticEvent) => void; + className?: string; + children?: React.ReactNode; + icon?: React.ReactNode; + label?: React.ReactNode; + menu?: React.ReactNode; + showActions?: boolean; + iconColor?: string; + active?: boolean; + isActiveDrop?: boolean; + history: RouterHistory; + match: Match; + theme: Theme; + exact?: boolean; + depth?: number; }; function SidebarLink( diff --git a/app/components/Sidebar/components/TeamButton.js b/app/components/Sidebar/components/TeamButton.tsx similarity index 87% rename from app/components/Sidebar/components/TeamButton.js rename to app/components/Sidebar/components/TeamButton.tsx index 04738a477a..ad54943f7f 100644 --- a/app/components/Sidebar/components/TeamButton.js +++ b/app/components/Sidebar/components/TeamButton.tsx @@ -1,19 +1,20 @@ -// @flow import { ExpandedIcon } from "outline-icons"; import * as React from "react"; import styled from "styled-components"; import Flex from "components/Flex"; import TeamLogo from "components/TeamLogo"; -type Props = {| - teamName: string, - subheading: React.Node, - showDisclosure?: boolean, - onClick: (event: SyntheticEvent<>) => void, - logoUrl: string, -|}; +import type { SyntheticEvent } from "react"; -const TeamButton = React.forwardRef( +type Props = { + teamName: string; + subheading: React.ReactNode; + showDisclosure?: boolean; + onClick: (event: SyntheticEvent) => void; + logoUrl: string; +}; + +const TeamButton = React.forwardRef( ({ showDisclosure, teamName, subheading, logoUrl, ...rest }: Props, ref) => (
diff --git a/app/components/Sidebar/components/Toggle.js b/app/components/Sidebar/components/Toggle.tsx similarity index 89% rename from app/components/Sidebar/components/Toggle.js rename to app/components/Sidebar/components/Toggle.tsx index 4a563de672..08dc76624a 100644 --- a/app/components/Sidebar/components/Toggle.js +++ b/app/components/Sidebar/components/Toggle.tsx @@ -1,16 +1,15 @@ -// @flow import * as React from "react"; import styled from "styled-components"; import breakpoint from "styled-components-breakpoint"; import Arrow from "components/Arrow"; type Props = { - direction: "left" | "right", - style?: Object, - onClick?: () => any, + direction: "left" | "right"; + style?: any; + onClick?: () => any; }; -const Toggle = React.forwardRef( +const Toggle = React.forwardRef( ({ direction = "left", onClick, style }: Props, ref) => { return ( diff --git a/app/components/Sidebar/components/Version.js b/app/components/Sidebar/components/Version.tsx similarity index 99% rename from app/components/Sidebar/components/Version.js rename to app/components/Sidebar/components/Version.tsx index f7af29f425..e90475415c 100644 --- a/app/components/Sidebar/components/Version.js +++ b/app/components/Sidebar/components/Version.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import styled from "styled-components"; import Badge from "components/Badge"; diff --git a/app/components/Sidebar/index.js b/app/components/Sidebar/index.ts similarity index 85% rename from app/components/Sidebar/index.js rename to app/components/Sidebar/index.ts index 5b992fe751..3c3ce20015 100644 --- a/app/components/Sidebar/index.js +++ b/app/components/Sidebar/index.ts @@ -1,3 +1,2 @@ -// @flow import Sidebar from "./Main"; export default Sidebar; diff --git a/app/components/SkipNavContent.js b/app/components/SkipNavContent.tsx similarity index 93% rename from app/components/SkipNavContent.js rename to app/components/SkipNavContent.tsx index dfb86b0e7c..9ca268ab69 100644 --- a/app/components/SkipNavContent.js +++ b/app/components/SkipNavContent.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; export const id = "skip-nav"; diff --git a/app/components/SkipNavLink.js b/app/components/SkipNavLink.tsx similarity index 98% rename from app/components/SkipNavLink.js rename to app/components/SkipNavLink.tsx index 6cdb1a2344..9f7bc06cb8 100644 --- a/app/components/SkipNavLink.js +++ b/app/components/SkipNavLink.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import styled from "styled-components"; import { id } from "components/SkipNavContent"; diff --git a/app/components/SlackIcon.js b/app/components/SlackIcon.tsx similarity index 98% rename from app/components/SlackIcon.js rename to app/components/SlackIcon.tsx index 47f6729ab2..bb520dcf1d 100644 --- a/app/components/SlackIcon.js +++ b/app/components/SlackIcon.tsx @@ -1,8 +1,7 @@ -// @flow import * as React from "react"; type Props = { - color?: string, + color?: string; }; export default function SlackIcon({ color = "#4E5C6E" }: Props) { diff --git a/app/components/SocketProvider.js b/app/components/SocketProvider.tsx similarity index 97% rename from app/components/SocketProvider.js rename to app/components/SocketProvider.tsx index 810ac4b357..f8cf7735ba 100644 --- a/app/components/SocketProvider.js +++ b/app/components/SocketProvider.tsx @@ -1,4 +1,3 @@ -// @flow import { find } from "lodash"; import { observable } from "mobx"; import { inject, observer } from "mobx-react"; @@ -18,21 +17,22 @@ import { getVisibilityListener, getPageVisible } from "utils/pageVisibility"; export const SocketContext: any = React.createContext(); type Props = { - children: React.Node, - documents: DocumentsStore, - collections: CollectionsStore, - groups: GroupsStore, - memberships: MembershipsStore, - presence: DocumentPresenceStore, - policies: PoliciesStore, - views: ViewsStore, - auth: AuthStore, - ui: UiStore, + children: React.ReactNode; + documents: DocumentsStore; + collections: CollectionsStore; + groups: GroupsStore; + memberships: MembershipsStore; + presence: DocumentPresenceStore; + policies: PoliciesStore; + views: ViewsStore; + auth: AuthStore; + ui: UiStore; }; @observer class SocketProvider extends React.Component { - @observable socket: Socket; + @observable + socket: Socket; componentDidMount() { this.createConnection(); diff --git a/app/components/Star.js b/app/components/Star.tsx similarity index 90% rename from app/components/Star.js rename to app/components/Star.tsx index 8e16f0fb1a..baa1a07281 100644 --- a/app/components/Star.js +++ b/app/components/Star.tsx @@ -1,4 +1,3 @@ -// @flow import { StarredIcon, UnstarredIcon } from "outline-icons"; import * as React from "react"; import { useTranslation } from "react-i18next"; @@ -6,15 +5,17 @@ import styled from "styled-components"; import Document from "models/Document"; import NudeButton from "./NudeButton"; -type Props = {| - document: Document, - size?: number, -|}; +import type { SyntheticEvent } from "react"; + +type Props = { + document: Document; + size?: number; +}; function Star({ size, document, ...rest }: Props) { const { t } = useTranslation(); const handleClick = React.useCallback( - (ev: SyntheticEvent<>) => { + (ev: SyntheticEvent) => { ev.preventDefault(); ev.stopPropagation(); diff --git a/app/components/Subheading.js b/app/components/Subheading.tsx similarity index 94% rename from app/components/Subheading.js rename to app/components/Subheading.tsx index a55d128a4b..8e959cf71c 100644 --- a/app/components/Subheading.js +++ b/app/components/Subheading.tsx @@ -1,11 +1,10 @@ -// @flow import * as React from "react"; import styled from "styled-components"; -type Props = {| - children: React.Node, - sticky?: boolean, -|}; +type Props = { + children: React.ReactNode; + sticky?: boolean; +}; const H3 = styled.h3` border-bottom: 1px solid ${(props) => props.theme.divider}; diff --git a/app/components/Switch.js b/app/components/Switch.tsx similarity index 89% rename from app/components/Switch.js rename to app/components/Switch.tsx index 172c54e905..58cd20f967 100644 --- a/app/components/Switch.js +++ b/app/components/Switch.tsx @@ -1,17 +1,18 @@ -// @flow import * as React from "react"; import styled from "styled-components"; import { LabelText } from "components/Input"; -type Props = {| - width?: number, - height?: number, - label?: string, - checked?: boolean, - disabled?: boolean, - onChange: (event: SyntheticInputEvent) => mixed, - id?: string, -|}; +import type { ChangeEvent } from "react"; + +type Props = { + width?: number; + height?: number; + label?: string; + checked?: boolean; + disabled?: boolean; + onChange: (event: ChangeEvent) => unknown; + id?: string; +}; function Switch({ width = 38, height = 20, label, disabled, ...props }: Props) { const component = ( diff --git a/app/components/Tab.js b/app/components/Tab.tsx similarity index 93% rename from app/components/Tab.js rename to app/components/Tab.tsx index 5d77174452..f69c6878b7 100644 --- a/app/components/Tab.js +++ b/app/components/Tab.tsx @@ -1,11 +1,10 @@ -// @flow import * as React from "react"; import { NavLink } from "react-router-dom"; import styled, { withTheme } from "styled-components"; -import { type Theme } from "types"; +import type { Theme } from "types"; type Props = { - theme: Theme, + theme: Theme; }; const TabLink = styled(NavLink)` diff --git a/app/components/Table.js b/app/components/Table.tsx similarity index 92% rename from app/components/Table.js rename to app/components/Table.tsx index f47cdfce07..84fd7dba5f 100644 --- a/app/components/Table.js +++ b/app/components/Table.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import { CollapsedIcon } from "outline-icons"; import * as React from "react"; @@ -10,21 +9,24 @@ import Empty from "components/Empty"; import Flex from "components/Flex"; import Mask from "components/Mask"; -export type Props = {| - data: any[], - offset?: number, - isLoading: boolean, - empty?: React.Node, - currentPage?: number, - page: number, - pageSize?: number, - totalPages?: number, - defaultSort?: string, - topRef?: React.Ref, - onChangePage: (index: number) => void, - onChangeSort: (sort: ?string, direction: "ASC" | "DESC") => void, - columns: any, -|}; +export type Props = { + data: any[]; + offset?: number; + isLoading: boolean; + empty?: React.ReactNode; + currentPage?: number; + page: number; + pageSize?: number; + totalPages?: number; + defaultSort?: string; + topRef?: React.Ref; + onChangePage: (index: number) => void; + onChangeSort: ( + sort: string | undefined | null, + direction: "ASC" | "DESC" + ) => void; + columns: any; +}; function Table({ data, @@ -161,8 +163,8 @@ export const Placeholder = ({ columns, rows = 3, }: { - columns: number, - rows?: number, + columns: number; + rows?: number; }) => { return ( diff --git a/app/components/Tabs.js b/app/components/Tabs.tsx similarity index 99% rename from app/components/Tabs.js rename to app/components/Tabs.tsx index 1c6c5b4823..0b04988fc8 100644 --- a/app/components/Tabs.js +++ b/app/components/Tabs.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import styled from "styled-components"; diff --git a/app/components/TeamLogo.js b/app/components/TeamLogo.ts similarity index 97% rename from app/components/TeamLogo.js rename to app/components/TeamLogo.ts index 30a4c26ce1..e22c7ec0f5 100644 --- a/app/components/TeamLogo.js +++ b/app/components/TeamLogo.ts @@ -1,4 +1,3 @@ -// @flow import styled from "styled-components"; const TeamLogo = styled.img` diff --git a/app/components/Theme.js b/app/components/Theme.tsx similarity index 94% rename from app/components/Theme.js rename to app/components/Theme.tsx index bdcf628809..c06bd1fb00 100644 --- a/app/components/Theme.js +++ b/app/components/Theme.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import * as React from "react"; import { ThemeProvider } from "styled-components"; @@ -9,9 +8,9 @@ import useStores from "hooks/useStores"; const empty = {}; -type Props = {| - children: React.Node, -|}; +type Props = { + children: React.ReactNode; +}; function Theme({ children }: Props) { const { ui } = useStores(); diff --git a/app/components/Time.js b/app/components/Time.tsx similarity index 85% rename from app/components/Time.js rename to app/components/Time.tsx index 96a2e5fafa..76dad265e4 100644 --- a/app/components/Time.js +++ b/app/components/Time.tsx @@ -1,4 +1,3 @@ -// @flow import { formatDistanceToNow } from "date-fns"; import * as React from "react"; @@ -7,11 +6,11 @@ const LocaleTime = React.lazy(() => ); type Props = { - dateTime: string, - children?: React.Node, - tooltipDelay?: number, - addSuffix?: boolean, - shorten?: boolean, + dateTime: string; + children?: React.ReactNode; + tooltipDelay?: number; + addSuffix?: boolean; + shorten?: boolean; }; function Time(props: Props) { diff --git a/app/components/Toast.js b/app/components/Toast.tsx similarity index 97% rename from app/components/Toast.js rename to app/components/Toast.tsx index 21fe38cba2..318c860126 100644 --- a/app/components/Toast.js +++ b/app/components/Toast.tsx @@ -1,4 +1,3 @@ -// @flow import { CheckboxIcon, InfoIcon, WarningIcon } from "outline-icons"; import { darken } from "polished"; import * as React from "react"; @@ -7,9 +6,9 @@ import { fadeAndScaleIn, pulse } from "shared/styles/animations"; import type { Toast as TToast } from "types"; type Props = { - onRequestClose: () => void, - closeAfterMs?: number, - toast: TToast, + onRequestClose: () => void; + closeAfterMs?: number; + toast: TToast; }; function Toast({ closeAfterMs = 3000, onRequestClose, toast }: Props) { diff --git a/app/components/Toasts.js b/app/components/Toasts.tsx similarity index 98% rename from app/components/Toasts.js rename to app/components/Toasts.tsx index df2502fdce..e6f24544b5 100644 --- a/app/components/Toasts.js +++ b/app/components/Toasts.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import * as React from "react"; import styled from "styled-components"; diff --git a/app/components/Tooltip.js b/app/components/Tooltip.tsx similarity index 87% rename from app/components/Tooltip.js rename to app/components/Tooltip.tsx index d9395fdeea..950656cac1 100644 --- a/app/components/Tooltip.js +++ b/app/components/Tooltip.tsx @@ -1,16 +1,15 @@ -// @flow import Tippy from "@tippy.js/react"; import * as React from "react"; import styled from "styled-components"; -type Props = {| - tooltip: React.Node, - shortcut?: React.Node, - placement?: "top" | "bottom" | "left" | "right", - children: React.Node, - delay?: number, - className?: string, -|}; +type Props = { + tooltip: React.ReactNode; + shortcut?: React.ReactNode; + placement?: "top" | "bottom" | "left" | "right"; + children: React.ReactNode; + delay?: number; + className?: string; +}; class Tooltip extends React.Component { render() { diff --git a/app/components/ZapierIcon.js b/app/components/ZapierIcon.tsx similarity index 98% rename from app/components/ZapierIcon.js rename to app/components/ZapierIcon.tsx index 5923418e77..fe48fde356 100644 --- a/app/components/ZapierIcon.js +++ b/app/components/ZapierIcon.tsx @@ -1,8 +1,7 @@ -// @flow import * as React from "react"; type Props = { - color?: string, + color?: string; }; export default function ZapierIcon({ color = "#4E5C6E" }: Props) { diff --git a/app/embeds/Abstract.js b/app/embeds/Abstract.tsx similarity index 86% rename from app/embeds/Abstract.js rename to app/embeds/Abstract.tsx index f49a7c049f..bddca8ea6c 100644 --- a/app/embeds/Abstract.js +++ b/app/embeds/Abstract.tsx @@ -1,13 +1,12 @@ -// @flow import * as React from "react"; import Frame from "./components/Frame"; -type Props = {| - attrs: {| - href: string, - matches: string[], - |}, -|}; +type Props = { + attrs: { + href: string; + matches: string[]; + }; +}; export default class Abstract extends React.Component { static ENABLED = [ diff --git a/app/embeds/Airtable.js b/app/embeds/Airtable.tsx similarity index 85% rename from app/embeds/Airtable.js rename to app/embeds/Airtable.tsx index 69f9b49f9c..60ed39897b 100644 --- a/app/embeds/Airtable.js +++ b/app/embeds/Airtable.tsx @@ -1,15 +1,14 @@ -// @flow import * as React from "react"; import Frame from "./components/Frame"; const URL_REGEX = new RegExp("https://airtable.com/(?:embed/)?(shr.*)$"); -type Props = {| - attrs: {| - href: string, - matches: string[], - |}, -|}; +type Props = { + attrs: { + href: string; + matches: string[]; + }; +}; export default class Airtable extends React.Component { static ENABLED = [URL_REGEX]; diff --git a/app/embeds/Cawemo.js b/app/embeds/Cawemo.tsx similarity index 85% rename from app/embeds/Cawemo.js rename to app/embeds/Cawemo.tsx index 1039be85cd..46a488cf4f 100644 --- a/app/embeds/Cawemo.js +++ b/app/embeds/Cawemo.tsx @@ -1,15 +1,14 @@ -// @flow import * as React from "react"; import Frame from "./components/Frame"; const URL_REGEX = new RegExp("https?://cawemo.com/(?:share|embed)/(.*)$"); -type Props = {| - attrs: {| - href: string, - matches: string[], - |}, -|}; +type Props = { + attrs: { + href: string; + matches: string[]; + }; +}; export default class Cawemo extends React.Component { static ENABLED = [URL_REGEX]; diff --git a/app/embeds/ClickUp.js b/app/embeds/ClickUp.tsx similarity index 82% rename from app/embeds/ClickUp.js rename to app/embeds/ClickUp.tsx index f6683ee980..6e62e9879d 100644 --- a/app/embeds/ClickUp.js +++ b/app/embeds/ClickUp.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import Frame from "./components/Frame"; @@ -6,12 +5,12 @@ const URL_REGEX = new RegExp( "^https?://share.clickup.com/[a-z]/[a-z]/(.*)/(.*)$" ); -type Props = {| - attrs: {| - href: string, - matches: string[], - |}, -|}; +type Props = { + attrs: { + href: string; + matches: string[]; + }; +}; export default class ClickUp extends React.Component { static ENABLED = [URL_REGEX]; diff --git a/app/embeds/Codepen.js b/app/embeds/Codepen.tsx similarity index 82% rename from app/embeds/Codepen.js rename to app/embeds/Codepen.tsx index 69c446131c..3e09544d03 100644 --- a/app/embeds/Codepen.js +++ b/app/embeds/Codepen.tsx @@ -1,15 +1,14 @@ -// @flow import * as React from "react"; import Frame from "./components/Frame"; const URL_REGEX = new RegExp("^https://codepen.io/(.*?)/(pen|embed)/(.*)$"); -type Props = {| - attrs: {| - href: string, - matches: string[], - |}, -|}; +type Props = { + attrs: { + href: string; + matches: string[]; + }; +}; export default class Codepen extends React.Component { static ENABLED = [URL_REGEX]; diff --git a/app/embeds/Descript.js b/app/embeds/Descript.tsx similarity index 84% rename from app/embeds/Descript.js rename to app/embeds/Descript.tsx index c351930d5f..22d68d8390 100644 --- a/app/embeds/Descript.js +++ b/app/embeds/Descript.tsx @@ -1,13 +1,12 @@ -// @flow import * as React from "react"; import Frame from "./components/Frame"; -type Props = {| - attrs: {| - href: string, - matches: string[], - |}, -|}; +type Props = { + attrs: { + href: string; + matches: string[]; + }; +}; export default class Descript extends React.Component { static ENABLED = [new RegExp("https?://share.descript.com/view/(\\w+)$")]; diff --git a/app/embeds/Figma.js b/app/embeds/Figma.tsx similarity index 84% rename from app/embeds/Figma.js rename to app/embeds/Figma.tsx index 234c522d83..9bc744a1bb 100644 --- a/app/embeds/Figma.js +++ b/app/embeds/Figma.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import Frame from "./components/Frame"; @@ -6,12 +5,12 @@ const URL_REGEX = new RegExp( "https://([w.-]+.)?figma.com/(file|proto)/([0-9a-zA-Z]{22,128})(?:/.*)?$" ); -type Props = {| - attrs: {| - href: string, - matches: string[], - |}, -|}; +type Props = { + attrs: { + href: string; + matches: string[]; + }; +}; export default class Figma extends React.Component { static ENABLED = [URL_REGEX]; diff --git a/app/embeds/Framer.js b/app/embeds/Framer.tsx similarity index 81% rename from app/embeds/Framer.js rename to app/embeds/Framer.tsx index fdb0526710..3d52337685 100644 --- a/app/embeds/Framer.js +++ b/app/embeds/Framer.tsx @@ -1,15 +1,14 @@ -// @flow import * as React from "react"; import Frame from "./components/Frame"; const URL_REGEX = new RegExp("^https://framer.cloud/(.*)$"); -type Props = {| - attrs: {| - href: string, - matches: string[], - |}, -|}; +type Props = { + attrs: { + href: string; + matches: string[]; + }; +}; export default class Framer extends React.Component { static ENABLED = [URL_REGEX]; diff --git a/app/embeds/Gist.js b/app/embeds/Gist.tsx similarity index 93% rename from app/embeds/Gist.js rename to app/embeds/Gist.tsx index c777051e37..cba59a56f3 100644 --- a/app/embeds/Gist.js +++ b/app/embeds/Gist.tsx @@ -1,17 +1,16 @@ -// @flow import * as React from "react"; const URL_REGEX = new RegExp( "^https://gist.github.com/([a-z\\d](?:[a-z\\d]|-(?=[a-z\\d])){0,38})/(.*)$" ); -type Props = {| - isSelected: boolean, - attrs: {| - href: string, - matches: string[], - |}, -|}; +type Props = { + isSelected: boolean; + attrs: { + href: string; + matches: string[]; + }; +}; class Gist extends React.Component { static ENABLED = [URL_REGEX]; diff --git a/app/embeds/GoogleDocs.js b/app/embeds/GoogleDocs.tsx similarity index 88% rename from app/embeds/GoogleDocs.js rename to app/embeds/GoogleDocs.tsx index fd5a426332..b88bafdd7b 100644 --- a/app/embeds/GoogleDocs.js +++ b/app/embeds/GoogleDocs.tsx @@ -1,16 +1,15 @@ -// @flow import * as React from "react"; import Image from "components/Image"; import Frame from "./components/Frame"; const URL_REGEX = new RegExp("^https?://docs.google.com/document/(.*)$"); -type Props = {| - attrs: {| - href: string, - matches: string[], - |}, -|}; +type Props = { + attrs: { + href: string; + matches: string[]; + }; +}; export default class GoogleDocs extends React.Component { static ENABLED = [URL_REGEX]; diff --git a/app/embeds/GoogleDrawings.js b/app/embeds/GoogleDrawings.tsx similarity index 89% rename from app/embeds/GoogleDrawings.js rename to app/embeds/GoogleDrawings.tsx index 6be5db510e..a61c35b49d 100644 --- a/app/embeds/GoogleDrawings.js +++ b/app/embeds/GoogleDrawings.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import Image from "components/Image"; import Frame from "./components/Frame"; @@ -7,12 +6,12 @@ const URL_REGEX = new RegExp( "^https://docs.google.com/drawings/d/(.*)/(edit|preview)(.*)$" ); -type Props = {| - attrs: {| - href: string, - matches: string[], - |}, -|}; +type Props = { + attrs: { + href: string; + matches: string[]; + }; +}; export default class GoogleDrawings extends React.Component { static ENABLED = [URL_REGEX]; diff --git a/app/embeds/GoogleDrive.js b/app/embeds/GoogleDrive.tsx similarity index 89% rename from app/embeds/GoogleDrive.js rename to app/embeds/GoogleDrive.tsx index 28db91b29b..babaed3133 100644 --- a/app/embeds/GoogleDrive.js +++ b/app/embeds/GoogleDrive.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import Image from "components/Image"; import Frame from "./components/Frame"; @@ -7,12 +6,12 @@ const URL_REGEX = new RegExp( "^https?://drive.google.com/file/d/(.*)/(preview|view).?usp=sharing$" ); -type Props = {| - attrs: {| - href: string, - matches: string[], - |}, -|}; +type Props = { + attrs: { + href: string; + matches: string[]; + }; +}; export default class GoogleDrive extends React.Component { static ENABLED = [URL_REGEX]; diff --git a/app/embeds/GoogleSheets.js b/app/embeds/GoogleSheets.tsx similarity index 89% rename from app/embeds/GoogleSheets.js rename to app/embeds/GoogleSheets.tsx index 70a3d53e6d..83ad16b4dd 100644 --- a/app/embeds/GoogleSheets.js +++ b/app/embeds/GoogleSheets.tsx @@ -1,16 +1,15 @@ -// @flow import * as React from "react"; import Image from "components/Image"; import Frame from "./components/Frame"; const URL_REGEX = new RegExp("^https?://docs.google.com/spreadsheets/d/(.*)$"); -type Props = {| - attrs: {| - href: string, - matches: string[], - |}, -|}; +type Props = { + attrs: { + href: string; + matches: string[]; + }; +}; export default class GoogleSheets extends React.Component { static ENABLED = [URL_REGEX]; diff --git a/app/embeds/GoogleSlides.js b/app/embeds/GoogleSlides.tsx similarity index 89% rename from app/embeds/GoogleSlides.js rename to app/embeds/GoogleSlides.tsx index cc961a4f6f..2f9e0669f8 100644 --- a/app/embeds/GoogleSlides.js +++ b/app/embeds/GoogleSlides.tsx @@ -1,16 +1,15 @@ -// @flow import * as React from "react"; import Image from "components/Image"; import Frame from "./components/Frame"; const URL_REGEX = new RegExp("^https?://docs.google.com/presentation/d/(.*)$"); -type Props = {| - attrs: {| - href: string, - matches: string[], - |}, -|}; +type Props = { + attrs: { + href: string; + matches: string[]; + }; +}; export default class GoogleSlides extends React.Component { static ENABLED = [URL_REGEX]; diff --git a/app/embeds/InVision.js b/app/embeds/InVision.tsx similarity index 90% rename from app/embeds/InVision.js rename to app/embeds/InVision.tsx index cbc698c243..d11469ba8e 100644 --- a/app/embeds/InVision.js +++ b/app/embeds/InVision.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import ImageZoom from "react-medium-image-zoom"; import Frame from "./components/Frame"; @@ -11,13 +10,13 @@ const IMAGE_REGEX = new RegExp( "^https://(opal.invisionapp.com/static-signed/live-embed/.*)$" ); -type Props = {| - isSelected: boolean, - attrs: {| - href: string, - matches: string[], - |}, -|}; +type Props = { + isSelected: boolean; + attrs: { + href: string; + matches: string[]; + }; +}; export default class InVision extends React.Component { static ENABLED = [IFRAME_REGEX, IMAGE_REGEX]; diff --git a/app/embeds/Loom.js b/app/embeds/Loom.tsx similarity index 82% rename from app/embeds/Loom.js rename to app/embeds/Loom.tsx index f182a8fc24..c7414e6255 100644 --- a/app/embeds/Loom.js +++ b/app/embeds/Loom.tsx @@ -1,15 +1,14 @@ -// @flow import * as React from "react"; import Frame from "./components/Frame"; const URL_REGEX = /^https:\/\/(www\.)?(use)?loom.com\/(embed|share)\/(.*)$/; -type Props = {| - attrs: {| - href: string, - matches: string[], - |}, -|}; +type Props = { + attrs: { + href: string; + matches: string[]; + }; +}; export default class Loom extends React.Component { static ENABLED = [URL_REGEX]; diff --git a/app/embeds/Lucidchart.js b/app/embeds/Lucidchart.tsx similarity index 90% rename from app/embeds/Lucidchart.js rename to app/embeds/Lucidchart.tsx index f43df3b58d..1e3637f913 100644 --- a/app/embeds/Lucidchart.js +++ b/app/embeds/Lucidchart.tsx @@ -1,12 +1,12 @@ -// @flow import * as React from "react"; import Frame from "./components/Frame"; -type Props = {| - attrs: {| - href: string, - matches: Object, - |}, -|}; + +type Props = { + attrs: { + href: string; + matches: any; + }; +}; export default class Lucidchart extends React.Component { static ENABLED = [ diff --git a/app/embeds/Marvel.js b/app/embeds/Marvel.tsx similarity index 82% rename from app/embeds/Marvel.js rename to app/embeds/Marvel.tsx index 8175f3c012..f08502d22f 100644 --- a/app/embeds/Marvel.js +++ b/app/embeds/Marvel.tsx @@ -1,15 +1,14 @@ -// @flow import * as React from "react"; import Frame from "./components/Frame"; const URL_REGEX = new RegExp("^https://marvelapp.com/([A-Za-z0-9-]{6})/?$"); -type Props = {| - attrs: {| - href: string, - matches: string[], - |}, -|}; +type Props = { + attrs: { + href: string; + matches: string[]; + }; +}; export default class Marvel extends React.Component { static ENABLED = [URL_REGEX]; diff --git a/app/embeds/Mindmeister.js b/app/embeds/Mindmeister.tsx similarity index 88% rename from app/embeds/Mindmeister.js rename to app/embeds/Mindmeister.tsx index 3f2927e871..b951e6c634 100644 --- a/app/embeds/Mindmeister.js +++ b/app/embeds/Mindmeister.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import Frame from "./components/Frame"; @@ -6,12 +5,12 @@ const URL_REGEX = new RegExp( "^https://([w.-]+.)?(mindmeister.com|mm.tt)(/maps/public_map_shell)?/(\\d+)(\\?t=.*)?(/.*)?$" ); -type Props = {| - attrs: {| - href: string, - matches: string[], - |}, -|}; +type Props = { + attrs: { + href: string; + matches: string[]; + }; +}; export default class Mindmeister extends React.Component { static ENABLED = [URL_REGEX]; diff --git a/app/embeds/Miro.js b/app/embeds/Miro.tsx similarity index 87% rename from app/embeds/Miro.js rename to app/embeds/Miro.tsx index cdc8d91bee..f15f62b21b 100644 --- a/app/embeds/Miro.js +++ b/app/embeds/Miro.tsx @@ -1,15 +1,14 @@ -// @flow import * as React from "react"; import Frame from "./components/Frame"; const URL_REGEX = /^https:\/\/(realtimeboard|miro).com\/app\/board\/(.*)$/; -type Props = {| - attrs: {| - href: string, - matches: string[], - |}, -|}; +type Props = { + attrs: { + href: string; + matches: string[]; + }; +}; export default class RealtimeBoard extends React.Component { static ENABLED = [URL_REGEX]; diff --git a/app/embeds/ModeAnalytics.js b/app/embeds/ModeAnalytics.tsx similarity index 86% rename from app/embeds/ModeAnalytics.js rename to app/embeds/ModeAnalytics.tsx index 89851e2271..80cec945c3 100644 --- a/app/embeds/ModeAnalytics.js +++ b/app/embeds/ModeAnalytics.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import Frame from "./components/Frame"; @@ -6,12 +5,12 @@ const URL_REGEX = new RegExp( "^https://([w.-]+.)?modeanalytics.com/(.*)/reports/(.*)$" ); -type Props = {| - attrs: {| - href: string, - matches: string[], - |}, -|}; +type Props = { + attrs: { + href: string; + matches: string[]; + }; +}; export default class ModeAnalytics extends React.Component { static ENABLED = [URL_REGEX]; diff --git a/app/embeds/Prezi.js b/app/embeds/Prezi.tsx similarity index 82% rename from app/embeds/Prezi.js rename to app/embeds/Prezi.tsx index 4a79f40c34..5ca1bc07ee 100644 --- a/app/embeds/Prezi.js +++ b/app/embeds/Prezi.tsx @@ -1,15 +1,14 @@ -// @flow import * as React from "react"; import Frame from "./components/Frame"; const URL_REGEX = new RegExp("^https://prezi.com/view/(.*)$"); -type Props = {| - attrs: {| - href: string, - matches: string[], - |}, -|}; +type Props = { + attrs: { + href: string; + matches: string[]; + }; +}; export default class Prezi extends React.Component { static ENABLED = [URL_REGEX]; diff --git a/app/embeds/Spotify.js b/app/embeds/Spotify.tsx similarity index 91% rename from app/embeds/Spotify.js rename to app/embeds/Spotify.tsx index bb0fc49e38..68c3765da9 100644 --- a/app/embeds/Spotify.js +++ b/app/embeds/Spotify.tsx @@ -1,15 +1,15 @@ -// @flow import * as React from "react"; import Frame from "./components/Frame"; const URL_REGEX = new RegExp("https?://open.spotify.com/(.*)$"); -type Props = {| - attrs: {| - href: string, - matches: string[], - |}, -|}; +type Props = { + attrs: { + href: string; + matches: string[]; + }; +}; + export default class Spotify extends React.Component { static ENABLED = [URL_REGEX]; diff --git a/app/embeds/Trello.js b/app/embeds/Trello.tsx similarity index 90% rename from app/embeds/Trello.js rename to app/embeds/Trello.tsx index d9a5edeee7..b771193d35 100644 --- a/app/embeds/Trello.js +++ b/app/embeds/Trello.tsx @@ -1,15 +1,14 @@ -// @flow import * as React from "react"; import Frame from "./components/Frame"; const URL_REGEX = /^https:\/\/trello.com\/(c|b)\/([^/]*)(.*)?$/; -type Props = {| - attrs: {| - href: string, - matches: string[], - |}, -|}; +type Props = { + attrs: { + href: string; + matches: string[]; + }; +}; export default class Trello extends React.Component { static ENABLED = [URL_REGEX]; diff --git a/app/embeds/Typeform.js b/app/embeds/Typeform.tsx similarity index 83% rename from app/embeds/Typeform.js rename to app/embeds/Typeform.tsx index 2fcccef277..d9d777e5e5 100644 --- a/app/embeds/Typeform.js +++ b/app/embeds/Typeform.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import Frame from "./components/Frame"; @@ -6,12 +5,12 @@ const URL_REGEX = new RegExp( "^https://([A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?).typeform.com/to/(.*)$" ); -type Props = {| - attrs: {| - href: string, - matches: string[], - |}, -|}; +type Props = { + attrs: { + href: string; + matches: string[]; + }; +}; export default class Typeform extends React.Component { static ENABLED = [URL_REGEX]; diff --git a/app/embeds/Vimeo.js b/app/embeds/Vimeo.tsx similarity index 67% rename from app/embeds/Vimeo.js rename to app/embeds/Vimeo.tsx index f421f8cad1..0e8d69f308 100644 --- a/app/embeds/Vimeo.js +++ b/app/embeds/Vimeo.tsx @@ -1,15 +1,15 @@ -// @flow import * as React from "react"; import Frame from "./components/Frame"; -const URL_REGEX = /(http|https)?:\/\/(www\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^/]*)\/videos\/|)(\d+)(?:|\/\?)/; +const URL_REGEX = + /(http|https)?:\/\/(www\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^/]*)\/videos\/|)(\d+)(?:|\/\?)/; -type Props = {| - attrs: {| - href: string, - matches: string[], - |}, -|}; +type Props = { + attrs: { + href: string; + matches: string[]; + }; +}; export default class Vimeo extends React.Component { static ENABLED = [URL_REGEX]; diff --git a/app/embeds/YouTube.js b/app/embeds/YouTube.tsx similarity index 65% rename from app/embeds/YouTube.js rename to app/embeds/YouTube.tsx index a0687aa1e3..8a5e429079 100644 --- a/app/embeds/YouTube.js +++ b/app/embeds/YouTube.tsx @@ -1,16 +1,16 @@ -// @flow import * as React from "react"; import Frame from "./components/Frame"; -const URL_REGEX = /(?:https?:\/\/)?(?:www\.)?youtu\.?be(?:\.com)?\/?.*(?:watch|embed)?(?:.*v=|v\/|\/)([a-zA-Z0-9_-]{11})$/i; +const URL_REGEX = + /(?:https?:\/\/)?(?:www\.)?youtu\.?be(?:\.com)?\/?.*(?:watch|embed)?(?:.*v=|v\/|\/)([a-zA-Z0-9_-]{11})$/i; -type Props = {| - isSelected: boolean, - attrs: {| - href: string, - matches: string[], - |}, -|}; +type Props = { + isSelected: boolean; + attrs: { + href: string; + matches: string[]; + }; +}; export default class YouTube extends React.Component { static ENABLED = [URL_REGEX]; diff --git a/app/embeds/components/Frame.js b/app/embeds/components/Frame.tsx similarity index 90% rename from app/embeds/components/Frame.js rename to app/embeds/components/Frame.tsx index 2cd7962499..cabad6fcc8 100644 --- a/app/embeds/components/Frame.js +++ b/app/embeds/components/Frame.tsx @@ -1,4 +1,3 @@ -// @flow import { observable } from "mobx"; import { observer } from "mobx-react"; import { OpenIcon } from "outline-icons"; @@ -16,24 +15,25 @@ const StyledIframe = styled(Iframe)` `; type Props = { - src?: string, - border?: boolean, - title?: string, - icon?: React.Node, - canonicalUrl?: string, - isSelected?: boolean, - width?: string, - height?: string, + src?: string; + border?: boolean; + title?: string; + icon?: React.ReactNode; + canonicalUrl?: string; + isSelected?: boolean; + width?: string; + height?: string; }; type PropsWithRef = Props & { - forwardedRef: React.Ref, + forwardedRef: React.Ref; }; @observer class Frame extends React.Component { mounted: boolean; - @observable isLoaded: boolean = false; + @observable + isLoaded: boolean = false; componentDidMount() { this.mounted = true; @@ -140,6 +140,6 @@ const Bar = styled(Flex)` user-select: none; `; -export default React.forwardRef((props, ref) => ( +export default React.forwardRef((props, ref) => ( )); diff --git a/app/embeds/index.js b/app/embeds/index.tsx similarity index 99% rename from app/embeds/index.js rename to app/embeds/index.tsx index ecb7fdd63a..521bd98fc2 100644 --- a/app/embeds/index.js +++ b/app/embeds/index.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import styled from "styled-components"; import Image from "components/Image"; diff --git a/app/env.js b/app/env.ts similarity index 83% rename from app/env.js rename to app/env.ts index c48604031a..645a27b70a 100644 --- a/app/env.js +++ b/app/env.ts @@ -1,3 +1,2 @@ -// @flow const env = window.env; export default env; diff --git a/app/hooks/useCurrentTeam.js b/app/hooks/useCurrentTeam.ts similarity index 95% rename from app/hooks/useCurrentTeam.js rename to app/hooks/useCurrentTeam.ts index e03b0ade94..db5c386e72 100644 --- a/app/hooks/useCurrentTeam.js +++ b/app/hooks/useCurrentTeam.ts @@ -1,4 +1,3 @@ -// @flow import invariant from "invariant"; import useStores from "./useStores"; diff --git a/app/hooks/useCurrentUser.js b/app/hooks/useCurrentUser.ts similarity index 95% rename from app/hooks/useCurrentUser.js rename to app/hooks/useCurrentUser.ts index 3d375e3b8e..53fb54c8a9 100644 --- a/app/hooks/useCurrentUser.js +++ b/app/hooks/useCurrentUser.ts @@ -1,4 +1,3 @@ -// @flow import invariant from "invariant"; import useStores from "./useStores"; diff --git a/app/hooks/useDebouncedCallback.js b/app/hooks/useDebouncedCallback.ts similarity index 94% rename from app/hooks/useDebouncedCallback.js rename to app/hooks/useDebouncedCallback.ts index 9ba68d3276..2ed900f812 100644 --- a/app/hooks/useDebouncedCallback.js +++ b/app/hooks/useDebouncedCallback.ts @@ -1,8 +1,7 @@ -// @flow import * as React from "react"; export default function useDebouncedCallback( - callback: (any) => mixed, + callback: (a: any) => unknown, wait: number ) { // track args & timeout handle between calls diff --git a/app/hooks/useImportDocument.js b/app/hooks/useImportDocument.ts similarity index 95% rename from app/hooks/useImportDocument.js rename to app/hooks/useImportDocument.ts index de68824b2a..6c24e187d2 100644 --- a/app/hooks/useImportDocument.js +++ b/app/hooks/useImportDocument.ts @@ -1,4 +1,3 @@ -// @flow import invariant from "invariant"; import * as React from "react"; import { useTranslation } from "react-i18next"; @@ -10,7 +9,10 @@ let importingLock = false; export default function useImportDocument( collectionId: string, documentId?: string -): {| handleFiles: (files: File[]) => Promise, isImporting: boolean |} { +): { + handleFiles: (files: File[]) => Promise; + isImporting: boolean; +} { const { documents, ui } = useStores(); const [isImporting, setImporting] = React.useState(false); const { t } = useTranslation(); diff --git a/app/hooks/useMediaQuery.js b/app/hooks/useMediaQuery.ts similarity index 98% rename from app/hooks/useMediaQuery.js rename to app/hooks/useMediaQuery.ts index 1280f7d3e7..acd2d46900 100644 --- a/app/hooks/useMediaQuery.js +++ b/app/hooks/useMediaQuery.ts @@ -1,4 +1,3 @@ -// @flow import { useState, useEffect } from "react"; export default function useMediaQuery(query: string): boolean { diff --git a/app/hooks/useMobile.js b/app/hooks/useMobile.ts similarity index 96% rename from app/hooks/useMobile.js rename to app/hooks/useMobile.ts index c143439c04..62874f1429 100644 --- a/app/hooks/useMobile.js +++ b/app/hooks/useMobile.ts @@ -1,4 +1,3 @@ -// @flow import { useTheme } from "styled-components"; import useMediaQuery from "hooks/useMediaQuery"; diff --git a/app/hooks/usePrevious.js b/app/hooks/usePrevious.ts similarity index 95% rename from app/hooks/usePrevious.js rename to app/hooks/usePrevious.ts index 501ef32ef7..8a5847e131 100644 --- a/app/hooks/usePrevious.js +++ b/app/hooks/usePrevious.ts @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; export default function usePrevious(value: any) { diff --git a/app/hooks/useQuery.js b/app/hooks/useQuery.ts similarity index 93% rename from app/hooks/useQuery.js rename to app/hooks/useQuery.ts index cdc2478e42..accc29f7cc 100644 --- a/app/hooks/useQuery.js +++ b/app/hooks/useQuery.ts @@ -1,4 +1,3 @@ -// @flow import { useLocation } from "react-router-dom"; export default function useQuery() { diff --git a/app/hooks/useStores.js b/app/hooks/useStores.ts similarity index 96% rename from app/hooks/useStores.js rename to app/hooks/useStores.ts index f7873aca62..f77b70b390 100644 --- a/app/hooks/useStores.js +++ b/app/hooks/useStores.ts @@ -1,4 +1,3 @@ -// @flow import { MobXProviderContext } from "mobx-react"; import * as React from "react"; import RootStore from "stores"; diff --git a/app/hooks/useUnmount.js b/app/hooks/useUnmount.ts similarity index 96% rename from app/hooks/useUnmount.js rename to app/hooks/useUnmount.ts index 18d556c039..9ea6ecf23d 100644 --- a/app/hooks/useUnmount.js +++ b/app/hooks/useUnmount.ts @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; const useUnmount = (callback: Function) => { diff --git a/app/hooks/useUserLocale.js b/app/hooks/useUserLocale.ts similarity index 95% rename from app/hooks/useUserLocale.js rename to app/hooks/useUserLocale.ts index bd7f4894f7..50836cdf2b 100644 --- a/app/hooks/useUserLocale.js +++ b/app/hooks/useUserLocale.ts @@ -1,4 +1,3 @@ -// @flow import useStores from "./useStores"; export default function useUserLocale() { diff --git a/app/hooks/useWindowScrollPosition.js b/app/hooks/useWindowScrollPosition.ts similarity index 95% rename from app/hooks/useWindowScrollPosition.js rename to app/hooks/useWindowScrollPosition.ts index 6e4c296197..a4665f3c98 100644 --- a/app/hooks/useWindowScrollPosition.js +++ b/app/hooks/useWindowScrollPosition.ts @@ -1,4 +1,3 @@ -// @flow // Based on https://github.com/rehooks/window-scroll-position which is no longer // maintained. import { throttle } from "lodash"; @@ -25,8 +24,11 @@ const defaultOptions = { }; export default function useWindowScrollPosition(options: { - throttle: number, -}): { x: number, y: number } { + throttle: number; +}): { + x: number; + y: number; +} { let opts = Object.assign({}, defaultOptions, options); let [position, setPosition] = useState(getPosition()); diff --git a/app/hooks/useWindowSize.js b/app/hooks/useWindowSize.ts similarity index 98% rename from app/hooks/useWindowSize.js rename to app/hooks/useWindowSize.ts index 8c2111b24f..828c2371b8 100644 --- a/app/hooks/useWindowSize.js +++ b/app/hooks/useWindowSize.ts @@ -1,4 +1,3 @@ -// @flow import { debounce } from "lodash"; import * as React from "react"; diff --git a/app/index.js b/app/index.tsx similarity index 99% rename from app/index.js rename to app/index.tsx index 48c15f6b1a..da6ee1037f 100644 --- a/app/index.js +++ b/app/index.tsx @@ -1,4 +1,3 @@ -// @flow import "focus-visible"; import { createBrowserHistory } from "history"; import { Provider } from "mobx-react"; diff --git a/app/menus/AccountMenu.js b/app/menus/AccountMenu.tsx similarity index 95% rename from app/menus/AccountMenu.js rename to app/menus/AccountMenu.tsx index 8a2034bb02..847f5d9231 100644 --- a/app/menus/AccountMenu.js +++ b/app/menus/AccountMenu.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import { SunIcon, MoonIcon } from "outline-icons"; import * as React from "react"; @@ -22,9 +21,9 @@ import Guide from "components/Guide"; import usePrevious from "hooks/usePrevious"; import useStores from "hooks/useStores"; -type Props = {| - children: (props: any) => React.Node, -|}; +type Props = { + children: (props: any) => React.ReactNode; +}; const AppearanceMenu = React.forwardRef((props, ref) => { const { ui } = useStores(); @@ -78,9 +77,8 @@ function AccountMenu(props: Props) { const { auth, ui } = useStores(); const previousTheme = usePrevious(ui.theme); const { t } = useTranslation(); - const [keyboardShortcutsOpen, setKeyboardShortcutsOpen] = React.useState( - false - ); + const [keyboardShortcutsOpen, setKeyboardShortcutsOpen] = + React.useState(false); React.useEffect(() => { if (ui.theme !== previousTheme) { diff --git a/app/menus/BreadcrumbMenu.js b/app/menus/BreadcrumbMenu.tsx similarity index 87% rename from app/menus/BreadcrumbMenu.js rename to app/menus/BreadcrumbMenu.tsx index 3ccb1b1523..63eac67b74 100644 --- a/app/menus/BreadcrumbMenu.js +++ b/app/menus/BreadcrumbMenu.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import { useTranslation } from "react-i18next"; import { useMenuState } from "reakit/Menu"; @@ -6,14 +5,14 @@ import ContextMenu from "components/ContextMenu"; import OverflowMenuButton from "components/ContextMenu/OverflowMenuButton"; import Template from "components/ContextMenu/Template"; -type MenuItem = {| - icon?: React.Node, - title: React.Node, - to?: string, -|}; +type MenuItem = { + icon?: React.ReactNode; + title: React.ReactNode; + to?: string; +}; type Props = { - items: MenuItem[], + items: MenuItem[]; }; export default function BreadcrumbMenu({ items }: Props) { diff --git a/app/menus/CollectionGroupMemberMenu.js b/app/menus/CollectionGroupMemberMenu.tsx similarity index 93% rename from app/menus/CollectionGroupMemberMenu.js rename to app/menus/CollectionGroupMemberMenu.tsx index d226e37f42..9fbd310133 100644 --- a/app/menus/CollectionGroupMemberMenu.js +++ b/app/menus/CollectionGroupMemberMenu.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import * as React from "react"; import { useTranslation } from "react-i18next"; @@ -7,10 +6,10 @@ import ContextMenu from "components/ContextMenu"; import OverflowMenuButton from "components/ContextMenu/OverflowMenuButton"; import Template from "components/ContextMenu/Template"; -type Props = {| - onMembers: () => void, - onRemove: () => void, -|}; +type Props = { + onMembers: () => void; + onRemove: () => void; +}; function CollectionGroupMemberMenu({ onMembers, onRemove }: Props) { const { t } = useTranslation(); diff --git a/app/menus/CollectionMenu.js b/app/menus/CollectionMenu.tsx similarity index 91% rename from app/menus/CollectionMenu.js rename to app/menus/CollectionMenu.tsx index 5c0a1fbef7..74d6734da3 100644 --- a/app/menus/CollectionMenu.js +++ b/app/menus/CollectionMenu.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import * as React from "react"; import { useTranslation } from "react-i18next"; @@ -18,14 +17,16 @@ import useStores from "hooks/useStores"; import getDataTransferFiles from "utils/getDataTransferFiles"; import { newDocumentUrl } from "utils/routeHelpers"; -type Props = {| - collection: Collection, - placement?: string, - modal?: boolean, - label?: (any) => React.Node, - onOpen?: () => void, - onClose?: () => void, -|}; +import type { SyntheticEvent } from "react"; + +type Props = { + collection: Collection; + placement?: string; + modal?: boolean; + label?: (a: any) => React.ReactNode; + onOpen?: () => void; + onClose?: () => void; +}; function CollectionMenu({ collection, @@ -41,11 +42,9 @@ function CollectionMenu({ const { t } = useTranslation(); const history = useHistory(); - const file = React.useRef(); - const [ - showCollectionPermissions, - setShowCollectionPermissions, - ] = React.useState(false); + const file = React.useRef(); + const [showCollectionPermissions, setShowCollectionPermissions] = + React.useState(false); const [showCollectionEdit, setShowCollectionEdit] = React.useState(false); const [showCollectionDelete, setShowCollectionDelete] = React.useState(false); const [showCollectionExport, setShowCollectionExport] = React.useState(false); @@ -58,19 +57,19 @@ function CollectionMenu({ }, [onOpen]); const handleNewDocument = React.useCallback( - (ev: SyntheticEvent<>) => { + (ev: SyntheticEvent) => { ev.preventDefault(); history.push(newDocumentUrl(collection.id)); }, [history, collection.id] ); - const stopPropagation = React.useCallback((ev: SyntheticEvent<>) => { + const stopPropagation = React.useCallback((ev: SyntheticEvent) => { ev.stopPropagation(); }, []); const handleImportDocument = React.useCallback( - (ev: SyntheticEvent<>) => { + (ev: SyntheticEvent) => { ev.preventDefault(); ev.stopPropagation(); @@ -83,7 +82,7 @@ function CollectionMenu({ ); const handleFilePicked = React.useCallback( - async (ev: SyntheticEvent<>) => { + async (ev: SyntheticEvent) => { const files = getDataTransferFiles(ev); // Because this is the onChange handler it's possible for the change to be diff --git a/app/menus/CollectionSortMenu.js b/app/menus/CollectionSortMenu.tsx similarity index 94% rename from app/menus/CollectionSortMenu.js rename to app/menus/CollectionSortMenu.tsx index c6e1347a3c..a803b4e6ce 100644 --- a/app/menus/CollectionSortMenu.js +++ b/app/menus/CollectionSortMenu.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import { AlphabeticalSortIcon, ManualSortIcon } from "outline-icons"; import * as React from "react"; @@ -9,11 +8,11 @@ import ContextMenu from "components/ContextMenu"; import Template from "components/ContextMenu/Template"; import NudeButton from "components/NudeButton"; -type Props = {| - collection: Collection, - onOpen?: () => void, - onClose?: () => void, -|}; +type Props = { + collection: Collection; + onOpen?: () => void; + onClose?: () => void; +}; function CollectionSortMenu({ collection, onOpen, onClose, ...rest }: Props) { const { t } = useTranslation(); diff --git a/app/menus/DocumentMenu.js b/app/menus/DocumentMenu.tsx similarity index 92% rename from app/menus/DocumentMenu.js rename to app/menus/DocumentMenu.tsx index 79b3d98731..56c2d360e1 100644 --- a/app/menus/DocumentMenu.js +++ b/app/menus/DocumentMenu.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import * as React from "react"; import { useTranslation } from "react-i18next"; @@ -26,18 +25,20 @@ import { newDocumentUrl, } from "utils/routeHelpers"; -type Props = {| - document: Document, - className: string, - isRevision?: boolean, - showPrint?: boolean, - modal?: boolean, - showToggleEmbeds?: boolean, - showPin?: boolean, - label?: (any) => React.Node, - onOpen?: () => void, - onClose?: () => void, -|}; +import type { SyntheticEvent } from "react"; + +type Props = { + document: Document; + className: string; + isRevision?: boolean; + showPrint?: boolean; + modal?: boolean; + showToggleEmbeds?: boolean; + showPin?: boolean; + label?: (a: any) => React.ReactNode; + onOpen?: () => void; + onClose?: () => void; +}; function DocumentMenu({ document, @@ -62,13 +63,11 @@ function DocumentMenu({ const { t } = useTranslation(); const [renderModals, setRenderModals] = React.useState(false); const [showDeleteModal, setShowDeleteModal] = React.useState(false); - const [ - showPermanentDeleteModal, - setShowPermanentDeleteModal, - ] = React.useState(false); + const [showPermanentDeleteModal, setShowPermanentDeleteModal] = + React.useState(false); const [showMoveModal, setShowMoveModal] = React.useState(false); const [showTemplateModal, setShowTemplateModal] = React.useState(false); - const file = React.useRef(); + const file = React.useRef(); const handleOpen = React.useCallback(() => { setRenderModals(true); @@ -78,7 +77,7 @@ function DocumentMenu({ }, [onOpen]); const handleDuplicate = React.useCallback( - async (ev: SyntheticEvent<>) => { + async (ev: SyntheticEvent) => { const duped = await document.duplicate(); // when duplicating, go straight to the duplicated document content @@ -89,7 +88,7 @@ function DocumentMenu({ ); const handleArchive = React.useCallback( - async (ev: SyntheticEvent<>) => { + async (ev: SyntheticEvent) => { await document.archive(); ui.showToast(t("Document archived"), { type: "success" }); }, @@ -97,7 +96,12 @@ function DocumentMenu({ ); const handleRestore = React.useCallback( - async (ev: SyntheticEvent<>, options?: { collectionId: string }) => { + async ( + ev: SyntheticEvent, + options?: { + collectionId: string; + } + ) => { await document.restore(options); ui.showToast(t("Document restored"), { type: "success" }); }, @@ -105,19 +109,19 @@ function DocumentMenu({ ); const handleUnpublish = React.useCallback( - async (ev: SyntheticEvent<>) => { + async (ev: SyntheticEvent) => { await document.unpublish(); ui.showToast(t("Document unpublished"), { type: "success" }); }, [ui, t, document] ); - const handlePrint = React.useCallback((ev: SyntheticEvent<>) => { + const handlePrint = React.useCallback((ev: SyntheticEvent) => { window.print(); }, []); const handleStar = React.useCallback( - (ev: SyntheticEvent<>) => { + (ev: SyntheticEvent) => { ev.preventDefault(); ev.stopPropagation(); document.star(); @@ -126,7 +130,7 @@ function DocumentMenu({ ); const handleUnstar = React.useCallback( - (ev: SyntheticEvent<>) => { + (ev: SyntheticEvent) => { ev.preventDefault(); ev.stopPropagation(); document.unstar(); @@ -138,12 +142,12 @@ function DocumentMenu({ const can = policies.abilities(document.id); const canViewHistory = can.read && !can.restore; - const stopPropagation = React.useCallback((ev: SyntheticEvent<>) => { + const stopPropagation = React.useCallback((ev: SyntheticEvent) => { ev.stopPropagation(); }, []); const handleImportDocument = React.useCallback( - (ev: SyntheticEvent<>) => { + (ev: SyntheticEvent) => { ev.preventDefault(); ev.stopPropagation(); @@ -156,7 +160,7 @@ function DocumentMenu({ ); const handleFilePicked = React.useCallback( - async (ev: SyntheticEvent<>) => { + async (ev: SyntheticEvent) => { const files = getDataTransferFiles(ev); // Because this is the onChange handler it's possible for the change to be diff --git a/app/menus/GroupMemberMenu.js b/app/menus/GroupMemberMenu.tsx similarity index 94% rename from app/menus/GroupMemberMenu.js rename to app/menus/GroupMemberMenu.tsx index 02187c82bf..bebf0f1f50 100644 --- a/app/menus/GroupMemberMenu.js +++ b/app/menus/GroupMemberMenu.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import * as React from "react"; import { useTranslation } from "react-i18next"; @@ -7,9 +6,9 @@ import ContextMenu from "components/ContextMenu"; import OverflowMenuButton from "components/ContextMenu/OverflowMenuButton"; import Template from "components/ContextMenu/Template"; -type Props = {| - onRemove: () => void, -|}; +type Props = { + onRemove: () => void; +}; function GroupMemberMenu({ onRemove }: Props) { const { t } = useTranslation(); diff --git a/app/menus/GroupMenu.js b/app/menus/GroupMenu.tsx similarity index 96% rename from app/menus/GroupMenu.js rename to app/menus/GroupMenu.tsx index f936b20ee9..9e6b164629 100644 --- a/app/menus/GroupMenu.js +++ b/app/menus/GroupMenu.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import * as React from "react"; import { useTranslation } from "react-i18next"; @@ -12,10 +11,10 @@ import Template from "components/ContextMenu/Template"; import Modal from "components/Modal"; import useStores from "hooks/useStores"; -type Props = {| - group: Group, - onMembers: () => void, -|}; +type Props = { + group: Group; + onMembers: () => void; +}; function GroupMenu({ group, onMembers }: Props) { const { t } = useTranslation(); diff --git a/app/menus/MemberMenu.js b/app/menus/MemberMenu.tsx similarity index 93% rename from app/menus/MemberMenu.js rename to app/menus/MemberMenu.tsx index cfc84652a1..ef380ded0b 100644 --- a/app/menus/MemberMenu.js +++ b/app/menus/MemberMenu.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import { useTranslation } from "react-i18next"; import { useMenuState } from "reakit/Menu"; @@ -6,9 +5,9 @@ import ContextMenu from "components/ContextMenu"; import OverflowMenuButton from "components/ContextMenu/OverflowMenuButton"; import Template from "components/ContextMenu/Template"; -type Props = {| - onRemove: () => void, -|}; +type Props = { + onRemove: () => void; +}; function MemberMenu({ onRemove }: Props) { const { t } = useTranslation(); diff --git a/app/menus/NewChildDocumentMenu.js b/app/menus/NewChildDocumentMenu.tsx similarity index 96% rename from app/menus/NewChildDocumentMenu.js rename to app/menus/NewChildDocumentMenu.tsx index 336db705af..542582cb11 100644 --- a/app/menus/NewChildDocumentMenu.js +++ b/app/menus/NewChildDocumentMenu.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import * as React from "react"; import { useTranslation, Trans } from "react-i18next"; @@ -10,8 +9,8 @@ import useStores from "hooks/useStores"; import { newDocumentUrl } from "utils/routeHelpers"; type Props = { - label?: (any) => React.Node, - document: Document, + label?: (a: any) => React.ReactNode; + document: Document; }; function NewChildDocumentMenu({ document, label }: Props) { diff --git a/app/menus/NewDocumentMenu.js b/app/menus/NewDocumentMenu.tsx similarity index 99% rename from app/menus/NewDocumentMenu.js rename to app/menus/NewDocumentMenu.tsx index 2f1080b217..9d257b10be 100644 --- a/app/menus/NewDocumentMenu.js +++ b/app/menus/NewDocumentMenu.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import { PlusIcon } from "outline-icons"; import * as React from "react"; diff --git a/app/menus/NewTemplateMenu.js b/app/menus/NewTemplateMenu.tsx similarity index 99% rename from app/menus/NewTemplateMenu.js rename to app/menus/NewTemplateMenu.tsx index 1943209004..aa2f0447c9 100644 --- a/app/menus/NewTemplateMenu.js +++ b/app/menus/NewTemplateMenu.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import { PlusIcon } from "outline-icons"; import * as React from "react"; diff --git a/app/menus/RevisionMenu.js b/app/menus/RevisionMenu.tsx similarity index 91% rename from app/menus/RevisionMenu.js rename to app/menus/RevisionMenu.tsx index bc587295da..109414112d 100644 --- a/app/menus/RevisionMenu.js +++ b/app/menus/RevisionMenu.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import * as React from "react"; import { useTranslation } from "react-i18next"; @@ -14,12 +13,14 @@ import CopyToClipboard from "components/CopyToClipboard"; import useStores from "hooks/useStores"; import { documentHistoryUrl } from "utils/routeHelpers"; -type Props = {| - document: Document, - revision: Revision, - iconColor?: string, - className?: string, -|}; +import type { SyntheticEvent } from "react"; + +type Props = { + document: Document; + revision: Revision; + iconColor?: string; + className?: string; +}; function RevisionMenu({ document, revision, className, iconColor }: Props) { const { ui } = useStores(); @@ -28,7 +29,7 @@ function RevisionMenu({ document, revision, className, iconColor }: Props) { const history = useHistory(); const handleRestore = React.useCallback( - async (ev: SyntheticEvent<>) => { + async (ev: SyntheticEvent) => { ev.preventDefault(); await document.restore({ revisionId: revision.id }); ui.showToast(t("Document restored"), { type: "success" }); diff --git a/app/menus/ShareMenu.js b/app/menus/ShareMenu.tsx similarity index 94% rename from app/menus/ShareMenu.js rename to app/menus/ShareMenu.tsx index d5773f4930..bf921dd0f1 100644 --- a/app/menus/ShareMenu.js +++ b/app/menus/ShareMenu.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import * as React from "react"; import { useTranslation } from "react-i18next"; @@ -11,8 +10,10 @@ import OverflowMenuButton from "components/ContextMenu/OverflowMenuButton"; import CopyToClipboard from "components/CopyToClipboard"; import useStores from "hooks/useStores"; +import type { SyntheticEvent } from "react"; + type Props = { - share: Share, + share: Share; }; function ShareMenu({ share }: Props) { @@ -23,7 +24,7 @@ function ShareMenu({ share }: Props) { const can = policies.abilities(share.id); const handleGoToDocument = React.useCallback( - (ev: SyntheticEvent<>) => { + (ev: SyntheticEvent) => { ev.preventDefault(); history.push(share.documentUrl); }, @@ -31,7 +32,7 @@ function ShareMenu({ share }: Props) { ); const handleRevoke = React.useCallback( - async (ev: SyntheticEvent<>) => { + async (ev: SyntheticEvent) => { ev.preventDefault(); try { diff --git a/app/menus/TemplatesMenu.js b/app/menus/TemplatesMenu.tsx similarity index 97% rename from app/menus/TemplatesMenu.js rename to app/menus/TemplatesMenu.tsx index c1f7d6477a..53926f5c1c 100644 --- a/app/menus/TemplatesMenu.js +++ b/app/menus/TemplatesMenu.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import { DocumentIcon } from "outline-icons"; import * as React from "react"; @@ -12,9 +11,9 @@ import MenuItem from "components/ContextMenu/MenuItem"; import Separator from "components/ContextMenu/Separator"; import useStores from "hooks/useStores"; -type Props = {| - document: Document, -|}; +type Props = { + document: Document; +}; function TemplatesMenu({ document }: Props) { const menu = useMenuState({ modal: true }); diff --git a/app/menus/UserMenu.js b/app/menus/UserMenu.tsx similarity index 93% rename from app/menus/UserMenu.js rename to app/menus/UserMenu.tsx index c9a0786d5b..a3271c703f 100644 --- a/app/menus/UserMenu.js +++ b/app/menus/UserMenu.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import * as React from "react"; import { useTranslation } from "react-i18next"; @@ -9,9 +8,11 @@ import OverflowMenuButton from "components/ContextMenu/OverflowMenuButton"; import Template from "components/ContextMenu/Template"; import useStores from "hooks/useStores"; -type Props = {| - user: User, -|}; +import type { SyntheticEvent } from "react"; + +type Props = { + user: User; +}; function UserMenu({ user }: Props) { const { users, policies } = useStores(); @@ -20,7 +21,7 @@ function UserMenu({ user }: Props) { const can = policies.abilities(user.id); const handlePromote = React.useCallback( - (ev: SyntheticEvent<>) => { + (ev: SyntheticEvent) => { ev.preventDefault(); if ( !window.confirm( @@ -38,7 +39,7 @@ function UserMenu({ user }: Props) { ); const handleMember = React.useCallback( - (ev: SyntheticEvent<>) => { + (ev: SyntheticEvent) => { ev.preventDefault(); if ( !window.confirm( @@ -55,7 +56,7 @@ function UserMenu({ user }: Props) { ); const handleViewer = React.useCallback( - (ev: SyntheticEvent<>) => { + (ev: SyntheticEvent) => { ev.preventDefault(); if ( !window.confirm( @@ -75,7 +76,7 @@ function UserMenu({ user }: Props) { ); const handleSuspend = React.useCallback( - (ev: SyntheticEvent<>) => { + (ev: SyntheticEvent) => { ev.preventDefault(); if ( !window.confirm( @@ -92,7 +93,7 @@ function UserMenu({ user }: Props) { ); const handleRevoke = React.useCallback( - (ev: SyntheticEvent<>) => { + (ev: SyntheticEvent) => { ev.preventDefault(); users.delete(user, { confirmation: true }); }, @@ -100,7 +101,7 @@ function UserMenu({ user }: Props) { ); const handleActivate = React.useCallback( - (ev: SyntheticEvent<>) => { + (ev: SyntheticEvent) => { ev.preventDefault(); users.activate(user); }, diff --git a/app/models/ApiKey.js b/app/models/ApiKey.ts similarity index 94% rename from app/models/ApiKey.js rename to app/models/ApiKey.ts index bd920c08ad..06916b87c9 100644 --- a/app/models/ApiKey.js +++ b/app/models/ApiKey.ts @@ -1,4 +1,3 @@ -// @flow import BaseModel from "./BaseModel"; class ApiKey extends BaseModel { diff --git a/app/models/BaseModel.js b/app/models/BaseModel.ts similarity index 82% rename from app/models/BaseModel.js rename to app/models/BaseModel.ts index 7ff62515ce..4a85e02af4 100644 --- a/app/models/BaseModel.js +++ b/app/models/BaseModel.ts @@ -1,17 +1,18 @@ -// @flow import { set, observable } from "mobx"; export default class BaseModel { - @observable id: string; - @observable isSaving: boolean; - store: *; + @observable + id: string; + @observable + isSaving: boolean; + store: any; - constructor(fields: Object, store: *) { + constructor(fields: any, store: any) { set(this, fields); this.store = store; } - save = async (params: ?Object) => { + save = async (params?: any | null) => { this.isSaving = true; try { @@ -44,7 +45,7 @@ export default class BaseModel { } }; - toJS = (): Object => { + toJS = (): any => { return { ...this }; }; } diff --git a/app/models/Collection.js b/app/models/Collection.ts similarity index 93% rename from app/models/Collection.js rename to app/models/Collection.ts index c9b73b698a..be4655e4c7 100644 --- a/app/models/Collection.js +++ b/app/models/Collection.ts @@ -1,4 +1,3 @@ -// @flow import { pick, trim } from "lodash"; import { action, computed, observable } from "mobx"; import BaseModel from "models/BaseModel"; @@ -7,8 +6,10 @@ import type { NavigationNode } from "types"; import { client } from "utils/ApiClient"; export default class Collection extends BaseModel { - @observable isSaving: boolean; - @observable isLoadingUsers: boolean; + @observable + isSaving: boolean; + @observable + isLoadingUsers: boolean; id: string; name: string; @@ -21,8 +22,11 @@ export default class Collection extends BaseModel { documents: NavigationNode[]; createdAt: string; updatedAt: string; - deletedAt: ?string; - sort: { field: string, direction: "asc" | "desc" }; + deletedAt: string | undefined | null; + sort: { + field: string; + direction: "asc" | "desc"; + }; url: string; urlId: string; diff --git a/app/models/CollectionGroupMembership.js b/app/models/CollectionGroupMembership.ts similarity index 97% rename from app/models/CollectionGroupMembership.js rename to app/models/CollectionGroupMembership.ts index 692620eeb2..5111425fef 100644 --- a/app/models/CollectionGroupMembership.js +++ b/app/models/CollectionGroupMembership.ts @@ -1,4 +1,3 @@ -// @flow import { computed } from "mobx"; import BaseModel from "./BaseModel"; diff --git a/app/models/Document.js b/app/models/Document.ts similarity index 89% rename from app/models/Document.js rename to app/models/Document.ts index 601df02fdb..29c0e13215 100644 --- a/app/models/Document.js +++ b/app/models/Document.ts @@ -1,4 +1,3 @@ -// @flow import { addDays, differenceInDays } from "date-fns"; import invariant from "invariant"; import { action, computed, observable, set } from "mobx"; @@ -10,17 +9,21 @@ import User from "models/User"; import View from "./View"; type SaveOptions = { - publish?: boolean, - done?: boolean, - autosave?: boolean, - lastRevision?: number, + publish?: boolean; + done?: boolean; + autosave?: boolean; + lastRevision?: number; }; export default class Document extends BaseModel { - @observable isSaving: boolean = false; - @observable embedsDisabled: boolean = false; - @observable injectTemplate: boolean = false; - @observable lastViewedAt: ?string; + @observable + isSaving: boolean = false; + @observable + embedsDisabled: boolean = false; + @observable + injectTemplate: boolean = false; + @observable + lastViewedAt: string | undefined | null; store: DocumentsStore; collaboratorIds: string[]; @@ -36,16 +39,16 @@ export default class Document extends BaseModel { title: string; emoji: string; template: boolean; - templateId: ?string; - parentDocumentId: ?string; - publishedAt: ?string; + templateId: string | undefined | null; + parentDocumentId: string | undefined | null; + publishedAt: string | undefined | null; archivedAt: string; - deletedAt: ?string; + deletedAt: string | undefined | null; url: string; urlId: string; revision: number; - constructor(fields: Object, store: DocumentsStore) { + constructor(fields: any, store: DocumentsStore) { super(fields, store); if (this.isNewDocument && this.isFromTemplate) { @@ -132,7 +135,7 @@ export default class Document extends BaseModel { } @computed - get permanentlyDeletedAt(): ?string { + get permanentlyDeletedAt(): string | undefined | null { if (!this.deletedAt) { return undefined; } @@ -151,7 +154,7 @@ export default class Document extends BaseModel { } @computed - get placeholder(): ?string { + get placeholder(): string | undefined | null { return this.isTemplate ? "Start your template…" : "Start with a title…"; } @@ -161,7 +164,7 @@ export default class Document extends BaseModel { }; @action - updateFromJson = (data: Object) => { + updateFromJson = (data: any) => { set(this, data); }; @@ -169,7 +172,7 @@ export default class Document extends BaseModel { return this.store.archive(this); }; - restore = (options: { revisionId?: string, collectionId?: string }) => { + restore = (options: { revisionId?: string; collectionId?: string }) => { return this.store.restore(this, options); }; @@ -290,7 +293,7 @@ export default class Document extends BaseModel { } }; - move = (collectionId: string, parentDocumentId: ?string) => { + move = (collectionId: string, parentDocumentId?: string | null) => { return this.store.move(this.id, collectionId, parentDocumentId); }; diff --git a/app/models/Event.js b/app/models/Event.ts similarity index 68% rename from app/models/Event.js rename to app/models/Event.ts index d9e69b0d04..b6695f5a48 100644 --- a/app/models/Event.js +++ b/app/models/Event.ts @@ -1,24 +1,23 @@ -// @flow import BaseModel from "./BaseModel"; import User from "./User"; class Event extends BaseModel { id: string; name: string; - modelId: ?string; + modelId: string | undefined | null; actorId: string; - actorIpAddress: ?string; + actorIpAddress: string | undefined | null; documentId: string; - collectionId: ?string; + collectionId: string | undefined | null; userId: string; createdAt: string; actor: User; data: { - name: string, - email: string, - title: string, - published: boolean, - templateId: string, + name: string; + email: string; + title: string; + published: boolean; + templateId: string; }; get model() { diff --git a/app/models/Group.js b/app/models/Group.ts similarity index 96% rename from app/models/Group.js rename to app/models/Group.ts index cad3348e9b..492dbbd4e8 100644 --- a/app/models/Group.js +++ b/app/models/Group.ts @@ -1,4 +1,3 @@ -// @flow import BaseModel from "./BaseModel"; class Group extends BaseModel { diff --git a/app/models/GroupMembership.js b/app/models/GroupMembership.ts similarity index 94% rename from app/models/GroupMembership.js rename to app/models/GroupMembership.ts index c5d8a58ca8..f10d8cab33 100644 --- a/app/models/GroupMembership.js +++ b/app/models/GroupMembership.ts @@ -1,4 +1,3 @@ -// @flow import BaseModel from "./BaseModel"; class GroupMembership extends BaseModel { diff --git a/app/models/Integration.js b/app/models/Integration.ts similarity index 85% rename from app/models/Integration.js rename to app/models/Integration.ts index c7e52f7dda..c2217f31c1 100644 --- a/app/models/Integration.js +++ b/app/models/Integration.ts @@ -1,13 +1,12 @@ -// @flow import { extendObservable, action } from "mobx"; import BaseModel from "models/BaseModel"; import { client } from "utils/ApiClient"; type Settings = { - url: string, - channel: string, - channelId: string, + url: string; + channel: string; + channelId: string; }; type Events = "documents.create" | "collections.create"; @@ -20,7 +19,7 @@ class Integration extends BaseModel { settings: Settings; @action - update = async (data: Object) => { + update = async (data: any) => { await client.post("/integrations.update", { id: this.id, ...data }); extendObservable(this, data); return true; diff --git a/app/models/Membership.js b/app/models/Membership.ts similarity index 97% rename from app/models/Membership.js rename to app/models/Membership.ts index ddd29b424e..1df32ce6cd 100644 --- a/app/models/Membership.js +++ b/app/models/Membership.ts @@ -1,4 +1,3 @@ -// @flow import { computed } from "mobx"; import BaseModel from "./BaseModel"; diff --git a/app/models/NotificationSetting.js b/app/models/NotificationSetting.ts similarity index 94% rename from app/models/NotificationSetting.js rename to app/models/NotificationSetting.ts index d356967566..cf4b82e530 100644 --- a/app/models/NotificationSetting.js +++ b/app/models/NotificationSetting.ts @@ -1,4 +1,3 @@ -// @flow import BaseModel from "./BaseModel"; class NotificationSetting extends BaseModel { diff --git a/app/models/Policy.js b/app/models/Policy.ts similarity index 77% rename from app/models/Policy.js rename to app/models/Policy.ts index 11775309a3..4e208dc18c 100644 --- a/app/models/Policy.js +++ b/app/models/Policy.ts @@ -1,10 +1,9 @@ -// @flow import BaseModel from "./BaseModel"; class Policy extends BaseModel { id: string; abilities: { - [key: string]: boolean, + [key: string]: boolean; }; } diff --git a/app/models/Revision.js b/app/models/Revision.ts similarity index 96% rename from app/models/Revision.js rename to app/models/Revision.ts index 18282d05fd..e45dcd0767 100644 --- a/app/models/Revision.js +++ b/app/models/Revision.ts @@ -1,4 +1,3 @@ -// @flow import BaseModel from "./BaseModel"; import User from "./User"; diff --git a/app/models/Share.js b/app/models/Share.ts similarity index 88% rename from app/models/Share.js rename to app/models/Share.ts index b1902fc7a9..6388c45c45 100644 --- a/app/models/Share.js +++ b/app/models/Share.ts @@ -1,4 +1,3 @@ -// @flow import BaseModel from "./BaseModel"; import User from "./User"; @@ -9,7 +8,7 @@ class Share extends BaseModel { documentId: string; documentTitle: string; documentUrl: string; - lastAccessedAt: ?string; + lastAccessedAt: string | undefined | null; includeChildDocuments: boolean; createdBy: User; createdAt: string; diff --git a/app/models/Team.js b/app/models/Team.ts similarity index 81% rename from app/models/Team.js rename to app/models/Team.ts index fbe18bf93d..d10233e56a 100644 --- a/app/models/Team.js +++ b/app/models/Team.ts @@ -1,4 +1,3 @@ -// @flow import { computed } from "mobx"; import BaseModel from "./BaseModel"; @@ -9,8 +8,8 @@ class Team extends BaseModel { sharing: boolean; documentEmbeds: boolean; guestSignin: boolean; - subdomain: ?string; - domain: ?string; + subdomain: string | undefined | null; + domain: string | undefined | null; url: string; @computed diff --git a/app/models/User.js b/app/models/User.ts similarity index 98% rename from app/models/User.js rename to app/models/User.ts index d870969b95..1e724fd5b4 100644 --- a/app/models/User.js +++ b/app/models/User.ts @@ -1,4 +1,3 @@ -// @flow import { computed } from "mobx"; import type { Rank } from "shared/types"; import BaseModel from "./BaseModel"; diff --git a/app/models/View.js b/app/models/View.ts similarity index 97% rename from app/models/View.js rename to app/models/View.ts index aa717dafc0..7c4603de93 100644 --- a/app/models/View.js +++ b/app/models/View.ts @@ -1,4 +1,3 @@ -// @flow import { action } from "mobx"; import BaseModel from "./BaseModel"; import User from "./User"; diff --git a/app/routes/authenticated.js b/app/routes/authenticated.tsx similarity index 96% rename from app/routes/authenticated.js rename to app/routes/authenticated.tsx index 9f7b60f4a2..d8f1aacf43 100644 --- a/app/routes/authenticated.js +++ b/app/routes/authenticated.tsx @@ -1,6 +1,6 @@ -// @flow import * as React from "react"; -import { Switch, Redirect, type Match } from "react-router-dom"; +import { Switch, Redirect } from "react-router-dom"; +import type { Match } from "react-router-dom"; import Archive from "scenes/Archive"; import Collection from "scenes/Collection"; import DocumentNew from "scenes/DocumentNew"; diff --git a/app/routes/index.js b/app/routes/index.tsx similarity index 99% rename from app/routes/index.js rename to app/routes/index.tsx index f3d93a352e..8895c23023 100644 --- a/app/routes/index.js +++ b/app/routes/index.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import { Switch } from "react-router-dom"; import DelayedMount from "components/DelayedMount"; diff --git a/app/routes/settings.js b/app/routes/settings.tsx similarity index 99% rename from app/routes/settings.js rename to app/routes/settings.tsx index c52b961166..9239c99d0b 100644 --- a/app/routes/settings.js +++ b/app/routes/settings.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import { Switch, Redirect } from "react-router-dom"; import Details from "scenes/Settings/Details"; diff --git a/app/scenes/APITokenNew.js b/app/scenes/APITokenNew.tsx similarity index 96% rename from app/scenes/APITokenNew.js rename to app/scenes/APITokenNew.tsx index e84282e58e..321e17510e 100644 --- a/app/scenes/APITokenNew.js +++ b/app/scenes/APITokenNew.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import { useTranslation, Trans } from "react-i18next"; import Button from "components/Button"; @@ -7,9 +6,9 @@ import HelpText from "components/HelpText"; import Input from "components/Input"; import useStores from "hooks/useStores"; -type Props = {| - onSubmit: () => void, -|}; +type Props = { + onSubmit: () => void; +}; function APITokenNew({ onSubmit }: Props) { const [name, setName] = React.useState(""); diff --git a/app/scenes/Archive.js b/app/scenes/Archive.tsx similarity index 99% rename from app/scenes/Archive.js rename to app/scenes/Archive.tsx index d7c1f5504c..0dc3ac878d 100644 --- a/app/scenes/Archive.js +++ b/app/scenes/Archive.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import { ArchiveIcon } from "outline-icons"; import * as React from "react"; diff --git a/app/scenes/Collection.js b/app/scenes/Collection.tsx similarity index 99% rename from app/scenes/Collection.js rename to app/scenes/Collection.tsx index e35be10c27..cabd4035ab 100644 --- a/app/scenes/Collection.js +++ b/app/scenes/Collection.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import { NewDocumentIcon, PlusIcon, PinIcon, MoreIcon } from "outline-icons"; import * as React from "react"; @@ -57,7 +56,7 @@ function CollectionScene() { const [permissionsModalOpen, setPermissionsModalOpen] = React.useState(false); const id = params.id || ""; - const collection: ?Collection = + const collection: Collection | undefined | null = collections.getByUrl(id) || collections.get(id); const can = policies.abilities(collection?.id || ""); const canUser = policies.abilities(team.id); diff --git a/app/scenes/CollectionDelete.js b/app/scenes/CollectionDelete.tsx similarity index 80% rename from app/scenes/CollectionDelete.js rename to app/scenes/CollectionDelete.tsx index 13e93ea33a..c79b0e2aa6 100644 --- a/app/scenes/CollectionDelete.js +++ b/app/scenes/CollectionDelete.tsx @@ -1,8 +1,8 @@ -// @flow import { observable } from "mobx"; import { inject, observer } from "mobx-react"; import * as React from "react"; -import { withRouter, type RouterHistory } from "react-router-dom"; +import { withRouter } from "react-router-dom"; +import type { RouterHistory } from "react-router-dom"; import CollectionsStore from "stores/CollectionsStore"; import UiStore from "stores/UiStore"; import Collection from "models/Collection"; @@ -11,19 +11,22 @@ import Flex from "components/Flex"; import HelpText from "components/HelpText"; import { homeUrl } from "utils/routeHelpers"; +import type { SyntheticEvent } from "react"; + type Props = { - history: RouterHistory, - collection: Collection, - collections: CollectionsStore, - ui: UiStore, - onSubmit: () => void, + history: RouterHistory; + collection: Collection; + collections: CollectionsStore; + ui: UiStore; + onSubmit: () => void; }; @observer class CollectionDelete extends React.Component { - @observable isDeleting: boolean; + @observable + isDeleting: boolean; - handleSubmit = async (ev: SyntheticEvent<>) => { + handleSubmit = async (ev: SyntheticEvent) => { ev.preventDefault(); this.isDeleting = true; diff --git a/app/scenes/CollectionEdit.js b/app/scenes/CollectionEdit.tsx similarity index 80% rename from app/scenes/CollectionEdit.js rename to app/scenes/CollectionEdit.tsx index 0d4e3a2cb6..d451ee4e3d 100644 --- a/app/scenes/CollectionEdit.js +++ b/app/scenes/CollectionEdit.tsx @@ -1,8 +1,8 @@ -// @flow import { observable } from "mobx"; import { inject, observer } from "mobx-react"; import * as React from "react"; -import { withTranslation, Trans, type TFunction } from "react-i18next"; +import { withTranslation, Trans } from "react-i18next"; +import type { TFunction } from "react-i18next"; import AuthStore from "stores/AuthStore"; import UiStore from "stores/UiStore"; import Collection from "models/Collection"; @@ -14,25 +14,35 @@ import Input from "components/Input"; import InputSelect from "components/InputSelect"; import Switch from "components/Switch"; +import type { SyntheticEvent, ChangeEvent } from "react"; + type Props = { - collection: Collection, - ui: UiStore, - auth: AuthStore, - onSubmit: () => void, - t: TFunction, + collection: Collection; + ui: UiStore; + auth: AuthStore; + onSubmit: () => void; + t: TFunction; }; @observer class CollectionEdit extends React.Component { - @observable name: string = this.props.collection.name; - @observable sharing: boolean = this.props.collection.sharing; - @observable icon: string = this.props.collection.icon; - @observable color: string = this.props.collection.color || "#4E5C6E"; - @observable sort: { field: string, direction: "asc" | "desc" } = this.props - .collection.sort; - @observable isSaving: boolean; + @observable + name: string = this.props.collection.name; + @observable + sharing: boolean = this.props.collection.sharing; + @observable + icon: string = this.props.collection.icon; + @observable + color: string = this.props.collection.color || "#4E5C6E"; + @observable + sort: { + field: string; + direction: "asc" | "desc"; + } = this.props.collection.sort; + @observable + isSaving: boolean; - handleSubmit = async (ev: SyntheticEvent<*>) => { + handleSubmit = async (ev: SyntheticEvent) => { ev.preventDefault(); this.isSaving = true; const { t } = this.props; @@ -56,7 +66,7 @@ class CollectionEdit extends React.Component { } }; - handleSortChange = (ev: SyntheticInputEvent) => { + handleSortChange = (ev: ChangeEvent) => { const [field, direction] = ev.target.value.split("."); if (direction === "asc" || direction === "desc") { @@ -64,7 +74,7 @@ class CollectionEdit extends React.Component { } }; - handleNameChange = (ev: SyntheticInputEvent<*>) => { + handleNameChange = (ev: ChangeEvent) => { this.name = ev.target.value; }; @@ -73,7 +83,7 @@ class CollectionEdit extends React.Component { this.icon = icon; }; - handleSharingChange = (ev: SyntheticInputEvent<*>) => { + handleSharingChange = (ev: ChangeEvent) => { this.sharing = ev.target.checked; }; diff --git a/app/scenes/CollectionExport.js b/app/scenes/CollectionExport.tsx similarity index 85% rename from app/scenes/CollectionExport.js rename to app/scenes/CollectionExport.tsx index e2b14abff1..5c6c264a2f 100644 --- a/app/scenes/CollectionExport.js +++ b/app/scenes/CollectionExport.tsx @@ -1,4 +1,3 @@ -// @flow import { observable } from "mobx"; import { inject, observer } from "mobx-react"; import * as React from "react"; @@ -9,18 +8,21 @@ import Button from "components/Button"; import Flex from "components/Flex"; import HelpText from "components/HelpText"; +import type { SyntheticEvent } from "react"; + type Props = { - collection: Collection, - auth: AuthStore, - ui: UiStore, - onSubmit: () => void, + collection: Collection; + auth: AuthStore; + ui: UiStore; + onSubmit: () => void; }; @observer class CollectionExport extends React.Component { - @observable isLoading: boolean = false; + @observable + isLoading: boolean = false; - handleSubmit = async (ev: SyntheticEvent<>) => { + handleSubmit = async (ev: SyntheticEvent) => { ev.preventDefault(); this.isLoading = true; diff --git a/app/scenes/CollectionNew.js b/app/scenes/CollectionNew.tsx similarity index 83% rename from app/scenes/CollectionNew.js rename to app/scenes/CollectionNew.tsx index ae058bd848..49b92e91e1 100644 --- a/app/scenes/CollectionNew.js +++ b/app/scenes/CollectionNew.tsx @@ -1,10 +1,11 @@ -// @flow import { intersection } from "lodash"; import { observable } from "mobx"; import { inject, observer } from "mobx-react"; import * as React from "react"; -import { withTranslation, type TFunction, Trans } from "react-i18next"; -import { withRouter, type RouterHistory } from "react-router-dom"; +import { withTranslation, Trans } from "react-i18next"; +import type { TFunction } from "react-i18next"; +import { withRouter } from "react-router-dom"; +import type { RouterHistory } from "react-router-dom"; import AuthStore from "stores/AuthStore"; import CollectionsStore from "stores/CollectionsStore"; import UiStore from "stores/UiStore"; @@ -17,26 +18,34 @@ import Input from "components/Input"; import InputSelectPermission from "components/InputSelectPermission"; import Switch from "components/Switch"; +import type { SyntheticEvent, ChangeEvent } from "react"; + type Props = { - history: RouterHistory, - auth: AuthStore, - ui: UiStore, - collections: CollectionsStore, - onSubmit: () => void, - t: TFunction, + history: RouterHistory; + auth: AuthStore; + ui: UiStore; + collections: CollectionsStore; + onSubmit: () => void; + t: TFunction; }; @observer class CollectionNew extends React.Component { - @observable name: string = ""; - @observable icon: string = ""; - @observable color: string = "#4E5C6E"; - @observable sharing: boolean = true; - @observable permission: string = "read_write"; - @observable isSaving: boolean; + @observable + name: string = ""; + @observable + icon: string = ""; + @observable + color: string = "#4E5C6E"; + @observable + sharing: boolean = true; + @observable + permission: string = "read_write"; + @observable + isSaving: boolean; hasOpenedIconPicker: boolean = false; - handleSubmit = async (ev: SyntheticEvent<>) => { + handleSubmit = async (ev: SyntheticEvent) => { ev.preventDefault(); this.isSaving = true; const collection = new Collection( @@ -61,7 +70,7 @@ class CollectionNew extends React.Component { } }; - handleNameChange = (ev: SyntheticInputEvent<>) => { + handleNameChange = (ev: ChangeEvent) => { this.name = ev.target.value; // If the user hasn't picked an icon yet, go ahead and suggest one based on @@ -88,11 +97,11 @@ class CollectionNew extends React.Component { this.hasOpenedIconPicker = true; }; - handlePermissionChange = (ev: SyntheticInputEvent) => { + handlePermissionChange = (ev: ChangeEvent) => { this.permission = ev.target.value; }; - handleSharingChange = (ev: SyntheticInputEvent) => { + handleSharingChange = (ev: ChangeEvent) => { this.sharing = ev.target.checked; }; diff --git a/app/scenes/CollectionPermissions/AddGroupsToCollection.js b/app/scenes/CollectionPermissions/AddGroupsToCollection.tsx similarity index 89% rename from app/scenes/CollectionPermissions/AddGroupsToCollection.js rename to app/scenes/CollectionPermissions/AddGroupsToCollection.tsx index 0ed8056be8..3d9606ea21 100644 --- a/app/scenes/CollectionPermissions/AddGroupsToCollection.js +++ b/app/scenes/CollectionPermissions/AddGroupsToCollection.tsx @@ -1,9 +1,9 @@ -// @flow import { debounce } from "lodash"; import { observable } from "mobx"; import { inject, observer } from "mobx-react"; import * as React from "react"; -import { withTranslation, type TFunction } from "react-i18next"; +import { withTranslation } from "react-i18next"; +import type { TFunction } from "react-i18next"; import styled from "styled-components"; import AuthStore from "stores/AuthStore"; import CollectionGroupMembershipsStore from "stores/CollectionGroupMembershipsStore"; @@ -22,20 +22,24 @@ import Input from "components/Input"; import Modal from "components/Modal"; import PaginatedList from "components/PaginatedList"; +import type { ChangeEvent } from "react"; + type Props = { - ui: UiStore, - auth: AuthStore, - collection: Collection, - collectionGroupMemberships: CollectionGroupMembershipsStore, - groups: GroupsStore, - onSubmit: () => void, - t: TFunction, + ui: UiStore; + auth: AuthStore; + collection: Collection; + collectionGroupMemberships: CollectionGroupMembershipsStore; + groups: GroupsStore; + onSubmit: () => void; + t: TFunction; }; @observer class AddGroupsToCollection extends React.Component { - @observable newGroupModalOpen: boolean = false; - @observable query: string = ""; + @observable + newGroupModalOpen: boolean = false; + @observable + query: string = ""; handleNewGroupModalOpen = () => { this.newGroupModalOpen = true; @@ -45,7 +49,7 @@ class AddGroupsToCollection extends React.Component { this.newGroupModalOpen = false; }; - handleFilter = (ev: SyntheticInputEvent<>) => { + handleFilter = (ev: ChangeEvent) => { this.query = ev.target.value; this.debouncedFetch(); }; diff --git a/app/scenes/CollectionPermissions/AddPeopleToCollection.js b/app/scenes/CollectionPermissions/AddPeopleToCollection.tsx similarity index 89% rename from app/scenes/CollectionPermissions/AddPeopleToCollection.js rename to app/scenes/CollectionPermissions/AddPeopleToCollection.tsx index d92d93b71a..aad6ce153b 100644 --- a/app/scenes/CollectionPermissions/AddPeopleToCollection.js +++ b/app/scenes/CollectionPermissions/AddPeopleToCollection.tsx @@ -1,9 +1,9 @@ -// @flow import { debounce } from "lodash"; import { observable } from "mobx"; import { inject, observer } from "mobx-react"; import * as React from "react"; -import { withTranslation, type TFunction } from "react-i18next"; +import { withTranslation } from "react-i18next"; +import type { TFunction } from "react-i18next"; import AuthStore from "stores/AuthStore"; import MembershipsStore from "stores/MembershipsStore"; import UiStore from "stores/UiStore"; @@ -20,20 +20,24 @@ import Modal from "components/Modal"; import PaginatedList from "components/PaginatedList"; import MemberListItem from "./components/MemberListItem"; +import type { ChangeEvent } from "react"; + type Props = { - ui: UiStore, - auth: AuthStore, - collection: Collection, - memberships: MembershipsStore, - users: UsersStore, - onSubmit: () => void, - t: TFunction, + ui: UiStore; + auth: AuthStore; + collection: Collection; + memberships: MembershipsStore; + users: UsersStore; + onSubmit: () => void; + t: TFunction; }; @observer class AddPeopleToCollection extends React.Component { - @observable inviteModalOpen: boolean = false; - @observable query: string = ""; + @observable + inviteModalOpen: boolean = false; + @observable + query: string = ""; handleInviteModalOpen = () => { this.inviteModalOpen = true; @@ -43,7 +47,7 @@ class AddPeopleToCollection extends React.Component { this.inviteModalOpen = false; }; - handleFilter = (ev: SyntheticInputEvent<>) => { + handleFilter = (ev: ChangeEvent) => { this.query = ev.target.value; this.debouncedFetch(); }; diff --git a/app/scenes/CollectionPermissions/components/CollectionGroupMemberListItem.js b/app/scenes/CollectionPermissions/components/CollectionGroupMemberListItem.tsx similarity index 90% rename from app/scenes/CollectionPermissions/components/CollectionGroupMemberListItem.js rename to app/scenes/CollectionPermissions/components/CollectionGroupMemberListItem.tsx index bc988b9d1b..c24e0f5f3f 100644 --- a/app/scenes/CollectionPermissions/components/CollectionGroupMemberListItem.js +++ b/app/scenes/CollectionPermissions/components/CollectionGroupMemberListItem.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import { useTranslation } from "react-i18next"; import styled from "styled-components"; @@ -8,12 +7,12 @@ import GroupListItem from "components/GroupListItem"; import InputSelect from "components/InputSelect"; import CollectionGroupMemberMenu from "menus/CollectionGroupMemberMenu"; -type Props = {| - group: Group, - collectionGroupMembership: ?CollectionGroupMembership, - onUpdate: (permission: string) => any, - onRemove: () => any, -|}; +type Props = { + group: Group; + collectionGroupMembership: CollectionGroupMembership | undefined | null; + onUpdate: (permission: string) => any; + onRemove: () => any; +}; const CollectionGroupMemberListItem = ({ group, diff --git a/app/scenes/CollectionPermissions/components/MemberListItem.js b/app/scenes/CollectionPermissions/components/MemberListItem.tsx similarity index 93% rename from app/scenes/CollectionPermissions/components/MemberListItem.js rename to app/scenes/CollectionPermissions/components/MemberListItem.tsx index e3e2f49f2a..e24c4fd22c 100644 --- a/app/scenes/CollectionPermissions/components/MemberListItem.js +++ b/app/scenes/CollectionPermissions/components/MemberListItem.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import { Trans, useTranslation } from "react-i18next"; import styled from "styled-components"; @@ -14,12 +13,12 @@ import Time from "components/Time"; import MemberMenu from "menus/MemberMenu"; type Props = { - user: User, - membership?: ?Membership, - canEdit: boolean, - onAdd?: () => any, - onRemove?: () => any, - onUpdate?: (permission: string) => any, + user: User; + membership?: Membership | null; + canEdit: boolean; + onAdd?: () => any; + onRemove?: () => any; + onUpdate?: (permission: string) => any; }; const MemberListItem = ({ diff --git a/app/scenes/CollectionPermissions/components/UserListItem.js b/app/scenes/CollectionPermissions/components/UserListItem.tsx similarity index 95% rename from app/scenes/CollectionPermissions/components/UserListItem.js rename to app/scenes/CollectionPermissions/components/UserListItem.tsx index 815e1061a8..a3d366baaa 100644 --- a/app/scenes/CollectionPermissions/components/UserListItem.js +++ b/app/scenes/CollectionPermissions/components/UserListItem.tsx @@ -1,4 +1,3 @@ -// @flow import { PlusIcon } from "outline-icons"; import * as React from "react"; import { Trans, useTranslation } from "react-i18next"; @@ -10,9 +9,9 @@ import ListItem from "components/List/Item"; import Time from "components/Time"; type Props = { - user: User, - canEdit: boolean, - onAdd: () => any, + user: User; + canEdit: boolean; + onAdd: () => any; }; const UserListItem = ({ user, onAdd, canEdit }: Props) => { diff --git a/app/scenes/CollectionPermissions/index.js b/app/scenes/CollectionPermissions/index.tsx similarity index 96% rename from app/scenes/CollectionPermissions/index.js rename to app/scenes/CollectionPermissions/index.tsx index cb84dfaca4..0c35df924d 100644 --- a/app/scenes/CollectionPermissions/index.js +++ b/app/scenes/CollectionPermissions/index.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import { PlusIcon } from "outline-icons"; import * as React from "react"; @@ -20,20 +19,15 @@ import MemberListItem from "./components/MemberListItem"; import useCurrentUser from "hooks/useCurrentUser"; import useStores from "hooks/useStores"; -type Props = {| - collection: Collection, -|}; +type Props = { + collection: Collection; +}; function CollectionPermissions({ collection }: Props) { const { t } = useTranslation(); const user = useCurrentUser(); - const { - ui, - memberships, - collectionGroupMemberships, - users, - groups, - } = useStores(); + const { ui, memberships, collectionGroupMemberships, users, groups } = + useStores(); const [addGroupModalOpen, setAddGroupModalOpen] = React.useState(false); const [addMemberModalOpen, setAddMemberModalOpen] = React.useState(false); @@ -139,9 +133,10 @@ function CollectionPermissions({ collection }: Props) { [collection, ui, t] ); - const fetchOptions = React.useMemo(() => ({ id: collection.id }), [ - collection.id, - ]); + const fetchOptions = React.useMemo( + () => ({ id: collection.id }), + [collection.id] + ); const collectionName = collection.name; const collectionGroups = groups.inCollection(collection.id); diff --git a/app/scenes/Document/KeyedDocument.js b/app/scenes/Document/KeyedDocument.tsx similarity index 93% rename from app/scenes/Document/KeyedDocument.js rename to app/scenes/Document/KeyedDocument.tsx index aefd1a7808..9a062fde4d 100644 --- a/app/scenes/Document/KeyedDocument.js +++ b/app/scenes/Document/KeyedDocument.tsx @@ -1,9 +1,8 @@ -// @flow import { inject } from "mobx-react"; import * as React from "react"; import DataLoader from "./components/DataLoader"; -class KeyedDocument extends React.Component<*> { +class KeyedDocument extends React.Component { componentWillUnmount() { this.props.ui.clearActiveDocument(); } diff --git a/app/scenes/Document/components/Container.js b/app/scenes/Document/components/Container.ts similarity index 94% rename from app/scenes/Document/components/Container.js rename to app/scenes/Document/components/Container.ts index dc603eb524..91c0c8e677 100644 --- a/app/scenes/Document/components/Container.js +++ b/app/scenes/Document/components/Container.ts @@ -1,4 +1,3 @@ -// @flow import styled from "styled-components"; import Flex from "components/Flex"; diff --git a/app/scenes/Document/components/Contents.js b/app/scenes/Document/components/Contents.tsx similarity index 97% rename from app/scenes/Document/components/Contents.js rename to app/scenes/Document/components/Contents.tsx index 001b3fabdd..aee7a1e9c4 100644 --- a/app/scenes/Document/components/Contents.js +++ b/app/scenes/Document/components/Contents.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import styled from "styled-components"; import breakpoint from "styled-components-breakpoint"; @@ -8,7 +7,11 @@ import useWindowScrollPosition from "hooks/useWindowScrollPosition"; const HEADING_OFFSET = 20; type Props = { - headings: { title: string, level: number, id: string }[], + headings: { + title: string; + level: number; + id: string; + }[]; }; export default function Contents({ headings }: Props) { diff --git a/app/scenes/Document/components/DataLoader.js b/app/scenes/Document/components/DataLoader.tsx similarity index 92% rename from app/scenes/Document/components/DataLoader.js rename to app/scenes/Document/components/DataLoader.tsx index df8fc3b5e7..715aafa1a7 100644 --- a/app/scenes/Document/components/DataLoader.js +++ b/app/scenes/Document/components/DataLoader.tsx @@ -1,4 +1,3 @@ -// @flow import { formatDistanceToNow } from "date-fns"; import invariant from "invariant"; import { deburr, sortBy } from "lodash"; @@ -22,30 +21,34 @@ import DocumentComponent from "./Document"; import HideSidebar from "./HideSidebar"; import Loading from "./Loading"; import SocketPresence from "./SocketPresence"; -import { type LocationWithState, type NavigationNode } from "types"; +import type { LocationWithState, NavigationNode } from "types"; import { NotFoundError, OfflineError } from "utils/errors"; import { matchDocumentEdit, updateDocumentUrl } from "utils/routeHelpers"; import { isInternalUrl } from "utils/urls"; -type Props = {| - match: Match, - location: LocationWithState, - shares: SharesStore, - documents: DocumentsStore, - policies: PoliciesStore, - revisions: RevisionsStore, - auth: AuthStore, - ui: UiStore, - history: RouterHistory, -|}; + +type Props = { + match: Match; + location: LocationWithState; + shares: SharesStore; + documents: DocumentsStore; + policies: PoliciesStore; + revisions: RevisionsStore; + auth: AuthStore; + ui: UiStore; + history: RouterHistory; +}; const sharedTreeCache = {}; @observer class DataLoader extends React.Component { - sharedTree: ?NavigationNode; - @observable document: ?Document; - @observable revision: ?Revision; - @observable error: ?Error; + sharedTree: NavigationNode | undefined | null; + @observable + document: Document | undefined | null; + @observable + revision: Revision | undefined | null; + @observable + error: Error | undefined | null; componentDidMount() { const { documents, match } = this.props; @@ -96,7 +99,9 @@ class DataLoader extends React.Component { try { const { document, - }: { document: Document } = await this.props.documents.fetch(slug); + }: { + document: Document; + } = await this.props.documents.fetch(slug); const time = formatDistanceToNow(Date.parse(document.updatedAt), { addSuffix: true, diff --git a/app/scenes/Document/components/Document.js b/app/scenes/Document/components/Document.tsx similarity index 93% rename from app/scenes/Document/components/Document.js rename to app/scenes/Document/components/Document.tsx index 726c4ee52d..298f75662c 100644 --- a/app/scenes/Document/components/Document.js +++ b/app/scenes/Document/components/Document.tsx @@ -1,4 +1,3 @@ -// @flow import { debounce } from "lodash"; import { observable } from "mobx"; import { observer, inject } from "mobx-react"; @@ -31,7 +30,7 @@ import KeyboardShortcutsButton from "./KeyboardShortcutsButton"; import MarkAsViewed from "./MarkAsViewed"; import PublicReferences from "./PublicReferences"; import References from "./References"; -import { type LocationWithState, type NavigationNode, type Theme } from "types"; +import type { LocationWithState, NavigationNode, Theme } from "types"; import { isCustomDomain } from "utils/domains"; import { emojiToUrl } from "utils/emoji"; import { meta } from "utils/keyboard"; @@ -54,31 +53,38 @@ Are you sure you want to discard them? `; type Props = { - match: Match, - history: RouterHistory, - location: LocationWithState, - sharedTree: ?NavigationNode, - abilities: Object, - document: Document, - revision: Revision, - readOnly: boolean, - onCreateLink: (title: string) => Promise, - onSearchLink: (term: string) => any, - theme: Theme, - auth: AuthStore, - ui: UiStore, + match: Match; + history: RouterHistory; + location: LocationWithState; + sharedTree: NavigationNode | undefined | null; + abilities: any; + document: Document; + revision: Revision; + readOnly: boolean; + onCreateLink: (title: string) => Promise; + onSearchLink: (term: string) => any; + theme: Theme; + auth: AuthStore; + ui: UiStore; }; @observer class DocumentScene extends React.Component { @observable editor = React.createRef(); - @observable isUploading: boolean = false; - @observable isSaving: boolean = false; - @observable isPublishing: boolean = false; - @observable isDirty: boolean = false; - @observable isEmpty: boolean = true; - @observable lastRevision: number = this.props.document.revision; - @observable title: string = this.props.document.title; + @observable + isUploading: boolean = false; + @observable + isSaving: boolean = false; + @observable + isPublishing: boolean = false; + @observable + isDirty: boolean = false; + @observable + isEmpty: boolean = true; + @observable + lastRevision: number = this.props.document.revision; + @observable + title: string = this.props.document.title; getEditorText: () => string = () => this.props.document.text; componentDidUpdate(prevProps) { @@ -189,9 +195,9 @@ class DocumentScene extends React.Component { onSave = async ( options: { - done?: boolean, - publish?: boolean, - autosave?: boolean, + done?: boolean; + publish?: boolean; + autosave?: boolean; } = {} ) => { const { document } = this.props; @@ -294,15 +300,8 @@ class DocumentScene extends React.Component { }; render() { - const { - document, - revision, - readOnly, - abilities, - auth, - ui, - match, - } = this.props; + const { document, revision, readOnly, abilities, auth, ui, match } = + this.props; const team = auth.team; const { shareId } = match.params; const isShare = !!shareId; diff --git a/app/scenes/Document/components/Editor.js b/app/scenes/Document/components/Editor.tsx similarity index 90% rename from app/scenes/Document/components/Editor.js rename to app/scenes/Document/components/Editor.tsx index 48a44dedb0..8736d4c247 100644 --- a/app/scenes/Document/components/Editor.js +++ b/app/scenes/Document/components/Editor.tsx @@ -1,4 +1,3 @@ -// @flow import { observable } from "mobx"; import { observer } from "mobx-react"; import * as React from "react"; @@ -11,28 +10,33 @@ import parseTitle from "shared/utils/parseTitle"; import Document from "models/Document"; import ClickablePadding from "components/ClickablePadding"; import DocumentMetaWithViews from "components/DocumentMetaWithViews"; -import Editor, { type Props as EditorProps } from "components/Editor"; +import Editor from "components/Editor"; +import type { Props as EditorProps } from "components/Editor"; import Flex from "components/Flex"; import HoverPreview from "components/HoverPreview"; import Star, { AnimatedStar } from "components/Star"; import { isModKey } from "utils/keyboard"; import { documentHistoryUrl } from "utils/routeHelpers"; -type Props = {| - ...EditorProps, - onChangeTitle: (event: SyntheticInputEvent<>) => void, - title: string, - document: Document, - isDraft: boolean, - shareId: ?string, - onSave: ({ done?: boolean, autosave?: boolean, publish?: boolean }) => any, - innerRef: { current: any }, - children: React.Node, -|}; +import type { ChangeEvent, KeyboardEvent } from "react"; + +type Props = { + onChangeTitle: (event: ChangeEvent) => void; + title: string; + document: Document; + isDraft: boolean; + shareId: string | undefined | null; + onSave: (a: { done?: boolean; autosave?: boolean; publish?: boolean }) => any; + innerRef: { + current: any; + }; + children: React.ReactNode; +} & EditorProps; @observer class DocumentEditor extends React.Component { - @observable activeLinkEvent: ?MouseEvent; + @observable + activeLinkEvent: MouseEvent | undefined | null; @observable ref = React.createRef(); focusAtStart = () => { @@ -55,7 +59,7 @@ class DocumentEditor extends React.Component { } }; - handleTitleKeyDown = (event: SyntheticKeyboardEvent<>) => { + handleTitleKeyDown = (event: KeyboardEvent) => { if (event.key === "Enter") { event.preventDefault(); if (isModKey(event)) { diff --git a/app/scenes/Document/components/Header.js b/app/scenes/Document/components/Header.tsx similarity index 94% rename from app/scenes/Document/components/Header.js rename to app/scenes/Document/components/Header.tsx index 5b36a6b1ce..19c2b9fa95 100644 --- a/app/scenes/Document/components/Header.js +++ b/app/scenes/Document/components/Header.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import { TableOfContentsIcon, @@ -25,28 +24,28 @@ import useStores from "hooks/useStores"; import DocumentMenu from "menus/DocumentMenu"; import NewChildDocumentMenu from "menus/NewChildDocumentMenu"; import TemplatesMenu from "menus/TemplatesMenu"; -import { type NavigationNode } from "types"; +import type { NavigationNode } from "types"; import { metaDisplay } from "utils/keyboard"; import { newDocumentUrl, editDocumentUrl } from "utils/routeHelpers"; -type Props = {| - document: Document, - sharedTree: ?NavigationNode, - shareId: ?string, - isDraft: boolean, - isEditing: boolean, - isRevision: boolean, - isSaving: boolean, - isPublishing: boolean, - publishingIsDisabled: boolean, - savingIsDisabled: boolean, - onDiscard: () => void, - onSave: ({ - done?: boolean, - publish?: boolean, - autosave?: boolean, - }) => void, -|}; +type Props = { + document: Document; + sharedTree: NavigationNode | undefined | null; + shareId: string | undefined | null; + isDraft: boolean; + isEditing: boolean; + isRevision: boolean; + isSaving: boolean; + isPublishing: boolean; + publishingIsDisabled: boolean; + savingIsDisabled: boolean; + onDiscard: () => void; + onSave: (a: { + done?: boolean; + publish?: boolean; + autosave?: boolean; + }) => void; +}; function DocumentHeader({ document, diff --git a/app/scenes/Document/components/HideSidebar.js b/app/scenes/Document/components/HideSidebar.ts similarity index 88% rename from app/scenes/Document/components/HideSidebar.js rename to app/scenes/Document/components/HideSidebar.ts index 05869b6b21..b5d9677f2b 100644 --- a/app/scenes/Document/components/HideSidebar.js +++ b/app/scenes/Document/components/HideSidebar.ts @@ -1,10 +1,9 @@ -// @flow import * as React from "react"; import UiStore from "stores/UiStore"; type Props = { - ui: UiStore, - children?: React.Node, + ui: UiStore; + children?: React.ReactNode; }; class HideSidebar extends React.Component { diff --git a/app/scenes/Document/components/KeyboardShortcutsButton.js b/app/scenes/Document/components/KeyboardShortcutsButton.tsx similarity index 93% rename from app/scenes/Document/components/KeyboardShortcutsButton.js rename to app/scenes/Document/components/KeyboardShortcutsButton.tsx index 266f2dd7cf..7d2d5d87f8 100644 --- a/app/scenes/Document/components/KeyboardShortcutsButton.js +++ b/app/scenes/Document/components/KeyboardShortcutsButton.tsx @@ -1,4 +1,3 @@ -// @flow import { KeyboardIcon } from "outline-icons"; import * as React from "react"; import { useTranslation } from "react-i18next"; @@ -11,9 +10,8 @@ import Tooltip from "components/Tooltip"; function KeyboardShortcutsButton() { const { t } = useTranslation(); - const [keyboardShortcutsOpen, setKeyboardShortcutsOpen] = React.useState( - false - ); + const [keyboardShortcutsOpen, setKeyboardShortcutsOpen] = + React.useState(false); const handleCloseKeyboardShortcuts = React.useCallback(() => { setKeyboardShortcutsOpen(false); diff --git a/app/scenes/Document/components/Loading.js b/app/scenes/Document/components/Loading.tsx similarity index 91% rename from app/scenes/Document/components/Loading.js rename to app/scenes/Document/components/Loading.tsx index ed75aed028..674417ec8d 100644 --- a/app/scenes/Document/components/Loading.js +++ b/app/scenes/Document/components/Loading.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import { useTranslation } from "react-i18next"; import CenteredContent from "components/CenteredContent"; @@ -7,9 +6,9 @@ import PageTitle from "components/PageTitle"; import Container from "./Container"; import type { LocationWithState } from "types"; -type Props = {| - location: LocationWithState, -|}; +type Props = { + location: LocationWithState; +}; export default function Loading({ location }: Props) { const { t } = useTranslation(); diff --git a/app/scenes/Document/components/MarkAsViewed.js b/app/scenes/Document/components/MarkAsViewed.ts similarity index 88% rename from app/scenes/Document/components/MarkAsViewed.js rename to app/scenes/Document/components/MarkAsViewed.ts index ce1893be1f..cce3c13938 100644 --- a/app/scenes/Document/components/MarkAsViewed.js +++ b/app/scenes/Document/components/MarkAsViewed.ts @@ -1,13 +1,12 @@ -// @flow import * as React from "react"; import Document from "models/Document"; const MARK_AS_VIEWED_AFTER = 3 * 1000; -type Props = {| - document: Document, - children?: React.Node, -|}; +type Props = { + document: Document; + children?: React.ReactNode; +}; class MarkAsViewed extends React.Component { viewTimeout: TimeoutID; diff --git a/app/scenes/Document/components/PublicBreadcrumb.js b/app/scenes/Document/components/PublicBreadcrumb.tsx similarity index 88% rename from app/scenes/Document/components/PublicBreadcrumb.js rename to app/scenes/Document/components/PublicBreadcrumb.tsx index fd9435e209..c250567d8d 100644 --- a/app/scenes/Document/components/PublicBreadcrumb.js +++ b/app/scenes/Document/components/PublicBreadcrumb.tsx @@ -1,14 +1,13 @@ -// @flow import * as React from "react"; import Breadcrumb from "components/Breadcrumb"; import type { NavigationNode } from "types"; -type Props = {| - documentId: string, - shareId: string, - sharedTree: ?NavigationNode, - children?: React.Node, -|}; +type Props = { + documentId: string; + shareId: string; + sharedTree: NavigationNode | undefined | null; + children?: React.ReactNode; +}; function pathToDocument(sharedTree, documentId) { let path = []; diff --git a/app/scenes/Document/components/PublicReferences.js b/app/scenes/Document/components/PublicReferences.tsx similarity index 89% rename from app/scenes/Document/components/PublicReferences.js rename to app/scenes/Document/components/PublicReferences.tsx index 466f46d1ac..7ab777b4f8 100644 --- a/app/scenes/Document/components/PublicReferences.js +++ b/app/scenes/Document/components/PublicReferences.tsx @@ -1,16 +1,15 @@ -// @flow import { observer } from "mobx-react"; import * as React from "react"; import { useTranslation } from "react-i18next"; import Subheading from "components/Subheading"; import ReferenceListItem from "./ReferenceListItem"; -import { type NavigationNode } from "types"; +import type { NavigationNode } from "types"; -type Props = {| - shareId: string, - documentId: string, - sharedTree: NavigationNode, -|}; +type Props = { + shareId: string; + documentId: string; + sharedTree: NavigationNode; +}; function PublicReferences(props: Props) { const { t } = useTranslation(); diff --git a/app/scenes/Document/components/ReferenceListItem.js b/app/scenes/Document/components/ReferenceListItem.tsx similarity index 94% rename from app/scenes/Document/components/ReferenceListItem.js rename to app/scenes/Document/components/ReferenceListItem.tsx index c305fe6f6c..2b77b16140 100644 --- a/app/scenes/Document/components/ReferenceListItem.js +++ b/app/scenes/Document/components/ReferenceListItem.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import { DocumentIcon } from "outline-icons"; import * as React from "react"; @@ -8,12 +7,12 @@ import Document from "models/Document"; import DocumentMeta from "components/DocumentMeta"; import type { NavigationNode } from "types"; -type Props = {| - shareId?: string, - document: Document | NavigationNode, - anchor?: string, - showCollection?: boolean, -|}; +type Props = { + shareId?: string; + document: Document | NavigationNode; + anchor?: string; + showCollection?: boolean; +}; const DocumentLink = styled(Link)` display: block; diff --git a/app/scenes/Document/components/References.js b/app/scenes/Document/components/References.tsx similarity index 92% rename from app/scenes/Document/components/References.js rename to app/scenes/Document/components/References.tsx index 7851cafa02..1a600b79f4 100644 --- a/app/scenes/Document/components/References.js +++ b/app/scenes/Document/components/References.tsx @@ -1,7 +1,7 @@ -// @flow import { observer, inject } from "mobx-react"; import * as React from "react"; -import { withRouter, type Location } from "react-router-dom"; +import { withRouter } from "react-router-dom"; +import type { Location } from "react-router-dom"; import CollectionsStore from "stores/CollectionsStore"; import DocumentsStore from "stores/DocumentsStore"; import Document from "models/Document"; @@ -11,10 +11,10 @@ import Tabs from "components/Tabs"; import ReferenceListItem from "./ReferenceListItem"; type Props = { - document: Document, - documents: DocumentsStore, - collections: CollectionsStore, - location: Location, + document: Document; + documents: DocumentsStore; + collections: CollectionsStore; + location: Location; }; @observer diff --git a/app/scenes/Document/components/ShareButton.js b/app/scenes/Document/components/ShareButton.tsx similarity index 97% rename from app/scenes/Document/components/ShareButton.js rename to app/scenes/Document/components/ShareButton.tsx index 2862d385f6..7e4b518f4c 100644 --- a/app/scenes/Document/components/ShareButton.js +++ b/app/scenes/Document/components/ShareButton.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import { GlobeIcon } from "outline-icons"; import * as React from "react"; @@ -11,9 +10,9 @@ import Tooltip from "components/Tooltip"; import SharePopover from "./SharePopover"; import useStores from "hooks/useStores"; -type Props = {| - document: Document, -|}; +type Props = { + document: Document; +}; function ShareButton({ document }: Props) { const { t } = useTranslation(); diff --git a/app/scenes/Document/components/SharePopover.js b/app/scenes/Document/components/SharePopover.tsx similarity index 96% rename from app/scenes/Document/components/SharePopover.js rename to app/scenes/Document/components/SharePopover.tsx index f0500522f7..c8ac51eeb6 100644 --- a/app/scenes/Document/components/SharePopover.js +++ b/app/scenes/Document/components/SharePopover.tsx @@ -1,4 +1,3 @@ -// @flow import { formatDistanceToNow } from "date-fns"; import invariant from "invariant"; import { observer } from "mobx-react"; @@ -17,18 +16,18 @@ import Notice from "components/Notice"; import Switch from "components/Switch"; import useStores from "hooks/useStores"; -type Props = {| - document: Document, - share: Share, - sharedParent: ?Share, - onSubmit: () => void, -|}; +type Props = { + document: Document; + share: Share; + sharedParent: Share | undefined | null; + onSubmit: () => void; +}; function SharePopover({ document, share, sharedParent, onSubmit }: Props) { const { t } = useTranslation(); const { policies, shares, ui } = useStores(); const [isCopied, setIsCopied] = React.useState(false); - const timeout = React.useRef(); + const timeout = React.useRef(); const can = policies.abilities(share ? share.id : ""); const canPublish = can.update && !document.isTemplate; const isPubliclyShared = (share && share.published) || sharedParent; diff --git a/app/scenes/Document/components/SocketPresence.js b/app/scenes/Document/components/SocketPresence.ts similarity index 95% rename from app/scenes/Document/components/SocketPresence.js rename to app/scenes/Document/components/SocketPresence.ts index d919e26beb..3ac3cc5890 100644 --- a/app/scenes/Document/components/SocketPresence.js +++ b/app/scenes/Document/components/SocketPresence.ts @@ -1,12 +1,11 @@ -// @flow import * as React from "react"; import { USER_PRESENCE_INTERVAL } from "shared/constants"; import { SocketContext } from "components/SocketProvider"; type Props = { - children?: React.Node, - documentId: string, - isEditing: boolean, + children?: React.ReactNode; + documentId: string; + isEditing: boolean; }; export default class SocketPresence extends React.Component { diff --git a/app/scenes/Document/index.js b/app/scenes/Document/index.ts similarity index 89% rename from app/scenes/Document/index.js rename to app/scenes/Document/index.ts index 7af896b2e0..a8e76e6c05 100644 --- a/app/scenes/Document/index.js +++ b/app/scenes/Document/index.ts @@ -1,3 +1,2 @@ -// @flow import DataLoader from "./components/DataLoader"; export default DataLoader; diff --git a/app/scenes/DocumentDelete.js b/app/scenes/DocumentDelete.tsx similarity index 95% rename from app/scenes/DocumentDelete.js rename to app/scenes/DocumentDelete.tsx index 1b1ba0328b..723d02d270 100644 --- a/app/scenes/DocumentDelete.js +++ b/app/scenes/DocumentDelete.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import * as React from "react"; import { useTranslation, Trans } from "react-i18next"; @@ -10,9 +9,11 @@ import HelpText from "components/HelpText"; import useStores from "hooks/useStores"; import { collectionUrl, documentUrl } from "utils/routeHelpers"; +import type { SyntheticEvent } from "react"; + type Props = { - document: Document, - onSubmit: () => void, + document: Document; + onSubmit: () => void; }; function DocumentDelete({ document, onSubmit }: Props) { @@ -26,7 +27,7 @@ function DocumentDelete({ document, onSubmit }: Props) { const collection = collections.get(document.collectionId); const handleSubmit = React.useCallback( - async (ev: SyntheticEvent<>) => { + async (ev: SyntheticEvent) => { ev.preventDefault(); setDeleting(true); @@ -59,7 +60,7 @@ function DocumentDelete({ document, onSubmit }: Props) { ); const handleArchive = React.useCallback( - async (ev: SyntheticEvent<>) => { + async (ev: SyntheticEvent) => { ev.preventDefault(); setArchiving(true); diff --git a/app/scenes/DocumentMove.js b/app/scenes/DocumentMove.tsx similarity index 92% rename from app/scenes/DocumentMove.js rename to app/scenes/DocumentMove.tsx index a6dd5ec9bb..ce26a394e4 100644 --- a/app/scenes/DocumentMove.js +++ b/app/scenes/DocumentMove.tsx @@ -1,4 +1,3 @@ -// @flow import { Search } from "js-search"; import { last } from "lodash"; import { observable, computed } from "mobx"; @@ -7,7 +6,8 @@ import * as React from "react"; import AutoSizer from "react-virtualized-auto-sizer"; import { FixedSizeList as List } from "react-window"; import styled from "styled-components"; -import CollectionsStore, { type DocumentPath } from "stores/CollectionsStore"; +import CollectionsStore from "stores/CollectionsStore"; +import type { DocumentPath } from "stores/CollectionsStore"; import DocumentsStore from "stores/DocumentsStore"; import UiStore from "stores/UiStore"; import Document from "models/Document"; @@ -16,18 +16,22 @@ import { Outline } from "components/Input"; import Labeled from "components/Labeled"; import PathToDocument from "components/PathToDocument"; -type Props = {| - document: Document, - documents: DocumentsStore, - collections: CollectionsStore, - ui: UiStore, - onRequestClose: () => void, -|}; +import type { ChangeEvent } from "react"; + +type Props = { + document: Document; + documents: DocumentsStore; + collections: CollectionsStore; + ui: UiStore; + onRequestClose: () => void; +}; @observer class DocumentMove extends React.Component { - @observable searchTerm: ?string; - @observable isSaving: boolean; + @observable + searchTerm: string | undefined | null; + @observable + isSaving: boolean; @computed get searchIndex() { @@ -89,7 +93,7 @@ class DocumentMove extends React.Component { this.props.onRequestClose(); }; - handleFilter = (ev: SyntheticInputEvent<*>) => { + handleFilter = (ev: ChangeEvent) => { this.searchTerm = ev.target.value; }; diff --git a/app/scenes/DocumentNew.js b/app/scenes/DocumentNew.tsx similarity index 99% rename from app/scenes/DocumentNew.js rename to app/scenes/DocumentNew.tsx index bceca9e16b..278d75bd00 100644 --- a/app/scenes/DocumentNew.js +++ b/app/scenes/DocumentNew.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import queryString from "query-string"; import * as React from "react"; diff --git a/app/scenes/DocumentPermanentDelete.js b/app/scenes/DocumentPermanentDelete.tsx similarity index 92% rename from app/scenes/DocumentPermanentDelete.js rename to app/scenes/DocumentPermanentDelete.tsx index 47944f6b30..4cfe3b96b6 100644 --- a/app/scenes/DocumentPermanentDelete.js +++ b/app/scenes/DocumentPermanentDelete.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import * as React from "react"; import { useTranslation, Trans } from "react-i18next"; @@ -9,10 +8,12 @@ import Flex from "components/Flex"; import HelpText from "components/HelpText"; import useStores from "hooks/useStores"; -type Props = {| - document: Document, - onSubmit: () => void, -|}; +import type { SyntheticEvent } from "react"; + +type Props = { + document: Document; + onSubmit: () => void; +}; function DocumentPermanentDelete({ document, onSubmit }: Props) { const [isDeleting, setIsDeleting] = React.useState(false); @@ -22,7 +23,7 @@ function DocumentPermanentDelete({ document, onSubmit }: Props) { const history = useHistory(); const handleSubmit = React.useCallback( - async (ev: SyntheticEvent<>) => { + async (ev: SyntheticEvent) => { ev.preventDefault(); try { setIsDeleting(true); diff --git a/app/scenes/DocumentTemplatize.js b/app/scenes/DocumentTemplatize.tsx similarity index 83% rename from app/scenes/DocumentTemplatize.js rename to app/scenes/DocumentTemplatize.tsx index 8a6f44f208..72aebe03e6 100644 --- a/app/scenes/DocumentTemplatize.js +++ b/app/scenes/DocumentTemplatize.tsx @@ -1,8 +1,8 @@ -// @flow import { observable } from "mobx"; import { inject, observer } from "mobx-react"; import * as React from "react"; -import { withRouter, type RouterHistory } from "react-router-dom"; +import { withRouter } from "react-router-dom"; +import type { RouterHistory } from "react-router-dom"; import UiStore from "stores/UiStore"; import Document from "models/Document"; import Button from "components/Button"; @@ -10,18 +10,21 @@ import Flex from "components/Flex"; import HelpText from "components/HelpText"; import { documentUrl } from "utils/routeHelpers"; +import type { SyntheticEvent } from "react"; + type Props = { - ui: UiStore, - document: Document, - history: RouterHistory, - onSubmit: () => void, + ui: UiStore; + document: Document; + history: RouterHistory; + onSubmit: () => void; }; @observer class DocumentTemplatize extends React.Component { - @observable isSaving: boolean; + @observable + isSaving: boolean; - handleSubmit = async (ev: SyntheticEvent<>) => { + handleSubmit = async (ev: SyntheticEvent) => { ev.preventDefault(); this.isSaving = true; diff --git a/app/scenes/Drafts.js b/app/scenes/Drafts.tsx similarity index 87% rename from app/scenes/Drafts.js rename to app/scenes/Drafts.tsx index c6af84a524..c834e9a696 100644 --- a/app/scenes/Drafts.js +++ b/app/scenes/Drafts.tsx @@ -1,11 +1,11 @@ -// @flow import { observable } from "mobx"; import { inject, observer } from "mobx-react"; import { EditIcon } from "outline-icons"; import queryString from "query-string"; import * as React from "react"; -import { withTranslation, type TFunction } from "react-i18next"; -import { type RouterHistory } from "react-router-dom"; +import { withTranslation } from "react-i18next"; +import type { TFunction } from "react-i18next"; +import type { RouterHistory } from "react-router-dom"; import styled from "styled-components"; import DocumentsStore from "stores/DocumentsStore"; import CollectionFilter from "scenes/Search/components/CollectionFilter"; @@ -19,20 +19,19 @@ import PaginatedDocumentList from "components/PaginatedDocumentList"; import Scene from "components/Scene"; import Subheading from "components/Subheading"; import NewDocumentMenu from "menus/NewDocumentMenu"; -import { type LocationWithState } from "types"; +import type { LocationWithState } from "types"; -type Props = {| - documents: DocumentsStore, - history: RouterHistory, - location: LocationWithState, - t: TFunction, -|}; +type Props = { + documents: DocumentsStore; + history: RouterHistory; + location: LocationWithState; + t: TFunction; +}; @observer class Drafts extends React.Component { - @observable params: URLSearchParams = new URLSearchParams( - this.props.location.search - ); + @observable + params: URLSearchParams = new URLSearchParams(this.props.location.search); componentDidUpdate(prevProps: Props) { if (prevProps.location.search !== this.props.location.search) { @@ -45,8 +44,8 @@ class Drafts extends React.Component { }; handleFilterChange = (search: { - dateFilter?: ?string, - collectionId?: ?string, + dateFilter?: string | null; + collectionId?: string | null; }) => { this.props.history.replace({ pathname: this.props.location.pathname, diff --git a/app/scenes/Error404.js b/app/scenes/Error404.tsx similarity index 98% rename from app/scenes/Error404.js rename to app/scenes/Error404.tsx index 37a5a1bef7..d38805063b 100644 --- a/app/scenes/Error404.js +++ b/app/scenes/Error404.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import { useTranslation, Trans } from "react-i18next"; import { Link } from "react-router-dom"; diff --git a/app/scenes/ErrorOffline.js b/app/scenes/ErrorOffline.tsx similarity index 98% rename from app/scenes/ErrorOffline.js rename to app/scenes/ErrorOffline.tsx index b65913b955..d37df12e63 100644 --- a/app/scenes/ErrorOffline.js +++ b/app/scenes/ErrorOffline.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import { useTranslation } from "react-i18next"; import CenteredContent from "components/CenteredContent"; diff --git a/app/scenes/ErrorSuspended.js b/app/scenes/ErrorSuspended.tsx similarity index 99% rename from app/scenes/ErrorSuspended.js rename to app/scenes/ErrorSuspended.tsx index 5ae8ee6b41..f9556bc4ac 100644 --- a/app/scenes/ErrorSuspended.js +++ b/app/scenes/ErrorSuspended.tsx @@ -1,4 +1,3 @@ -// @flow import { inject, observer } from "mobx-react"; import * as React from "react"; import { useTranslation, Trans } from "react-i18next"; diff --git a/app/scenes/GroupDelete.js b/app/scenes/GroupDelete.tsx similarity index 81% rename from app/scenes/GroupDelete.js rename to app/scenes/GroupDelete.tsx index 7ae579de38..8fd3c91d6f 100644 --- a/app/scenes/GroupDelete.js +++ b/app/scenes/GroupDelete.tsx @@ -1,8 +1,8 @@ -// @flow import { observable } from "mobx"; import { inject, observer } from "mobx-react"; import * as React from "react"; -import { withRouter, type RouterHistory } from "react-router-dom"; +import { withRouter } from "react-router-dom"; +import type { RouterHistory } from "react-router-dom"; import { groupSettings } from "shared/utils/routeHelpers"; import UiStore from "stores/UiStore"; import Group from "models/Group"; @@ -10,18 +10,21 @@ import Button from "components/Button"; import Flex from "components/Flex"; import HelpText from "components/HelpText"; +import type { SyntheticEvent } from "react"; + type Props = { - history: RouterHistory, - group: Group, - ui: UiStore, - onSubmit: () => void, + history: RouterHistory; + group: Group; + ui: UiStore; + onSubmit: () => void; }; @observer class GroupDelete extends React.Component { - @observable isDeleting: boolean; + @observable + isDeleting: boolean; - handleSubmit = async (ev: SyntheticEvent<>) => { + handleSubmit = async (ev: SyntheticEvent) => { ev.preventDefault(); this.isDeleting = true; diff --git a/app/scenes/GroupEdit.js b/app/scenes/GroupEdit.tsx similarity index 77% rename from app/scenes/GroupEdit.js rename to app/scenes/GroupEdit.tsx index 5a28a41748..1cc88a05d9 100644 --- a/app/scenes/GroupEdit.js +++ b/app/scenes/GroupEdit.tsx @@ -1,8 +1,8 @@ -// @flow import { observable } from "mobx"; import { inject, observer } from "mobx-react"; import * as React from "react"; -import { withRouter, type RouterHistory } from "react-router-dom"; +import { withRouter } from "react-router-dom"; +import type { RouterHistory } from "react-router-dom"; import UiStore from "stores/UiStore"; import Group from "models/Group"; import Button from "components/Button"; @@ -10,19 +10,23 @@ import Flex from "components/Flex"; import HelpText from "components/HelpText"; import Input from "components/Input"; +import type { SyntheticEvent, ChangeEvent } from "react"; + type Props = { - history: RouterHistory, - ui: UiStore, - group: Group, - onSubmit: () => void, + history: RouterHistory; + ui: UiStore; + group: Group; + onSubmit: () => void; }; @observer class GroupEdit extends React.Component { - @observable name: string = this.props.group.name; - @observable isSaving: boolean; + @observable + name: string = this.props.group.name; + @observable + isSaving: boolean; - handleSubmit = async (ev: SyntheticEvent<>) => { + handleSubmit = async (ev: SyntheticEvent) => { ev.preventDefault(); this.isSaving = true; @@ -36,7 +40,7 @@ class GroupEdit extends React.Component { } }; - handleNameChange = (ev: SyntheticInputEvent<*>) => { + handleNameChange = (ev: ChangeEvent) => { this.name = ev.target.value; }; diff --git a/app/scenes/GroupMembers/AddPeopleToGroup.js b/app/scenes/GroupMembers/AddPeopleToGroup.tsx similarity index 89% rename from app/scenes/GroupMembers/AddPeopleToGroup.js rename to app/scenes/GroupMembers/AddPeopleToGroup.tsx index 6156d4d2b2..69ebe1f7cb 100644 --- a/app/scenes/GroupMembers/AddPeopleToGroup.js +++ b/app/scenes/GroupMembers/AddPeopleToGroup.tsx @@ -1,9 +1,9 @@ -// @flow import { debounce } from "lodash"; import { observable } from "mobx"; import { inject, observer } from "mobx-react"; import * as React from "react"; -import { withTranslation, type TFunction } from "react-i18next"; +import { withTranslation } from "react-i18next"; +import type { TFunction } from "react-i18next"; import AuthStore from "stores/AuthStore"; import GroupMembershipsStore from "stores/GroupMembershipsStore"; import UiStore from "stores/UiStore"; @@ -20,20 +20,24 @@ import Modal from "components/Modal"; import PaginatedList from "components/PaginatedList"; import GroupMemberListItem from "./components/GroupMemberListItem"; +import type { ChangeEvent } from "react"; + type Props = { - ui: UiStore, - auth: AuthStore, - group: Group, - groupMemberships: GroupMembershipsStore, - users: UsersStore, - onSubmit: () => void, - t: TFunction, + ui: UiStore; + auth: AuthStore; + group: Group; + groupMemberships: GroupMembershipsStore; + users: UsersStore; + onSubmit: () => void; + t: TFunction; }; @observer class AddPeopleToGroup extends React.Component { - @observable inviteModalOpen: boolean = false; - @observable query: string = ""; + @observable + inviteModalOpen: boolean = false; + @observable + query: string = ""; handleInviteModalOpen = () => { this.inviteModalOpen = true; @@ -43,7 +47,7 @@ class AddPeopleToGroup extends React.Component { this.inviteModalOpen = false; }; - handleFilter = (ev: SyntheticInputEvent<>) => { + handleFilter = (ev: ChangeEvent) => { this.query = ev.target.value; this.debouncedFetch(); }; diff --git a/app/scenes/GroupMembers/GroupMembers.js b/app/scenes/GroupMembers/GroupMembers.tsx similarity index 92% rename from app/scenes/GroupMembers/GroupMembers.js rename to app/scenes/GroupMembers/GroupMembers.tsx index 3938ef9f2c..1e5b59b2d3 100644 --- a/app/scenes/GroupMembers/GroupMembers.js +++ b/app/scenes/GroupMembers/GroupMembers.tsx @@ -1,9 +1,9 @@ -// @flow import { observable } from "mobx"; import { inject, observer } from "mobx-react"; import { PlusIcon } from "outline-icons"; import * as React from "react"; -import { withTranslation, type TFunction } from "react-i18next"; +import { withTranslation } from "react-i18next"; +import type { TFunction } from "react-i18next"; import AuthStore from "stores/AuthStore"; import GroupMembershipsStore from "stores/GroupMembershipsStore"; import PoliciesStore from "stores/PoliciesStore"; @@ -22,18 +22,19 @@ import AddPeopleToGroup from "./AddPeopleToGroup"; import GroupMemberListItem from "./components/GroupMemberListItem"; type Props = { - ui: UiStore, - auth: AuthStore, - group: Group, - users: UsersStore, - policies: PoliciesStore, - groupMemberships: GroupMembershipsStore, - t: TFunction, + ui: UiStore; + auth: AuthStore; + group: Group; + users: UsersStore; + policies: PoliciesStore; + groupMemberships: GroupMembershipsStore; + t: TFunction; }; @observer class GroupMembers extends React.Component { - @observable addModalOpen: boolean = false; + @observable + addModalOpen: boolean = false; handleAddModalOpen = () => { this.addModalOpen = true; diff --git a/app/scenes/GroupMembers/components/GroupMemberListItem.js b/app/scenes/GroupMembers/components/GroupMemberListItem.tsx similarity index 91% rename from app/scenes/GroupMembers/components/GroupMemberListItem.js rename to app/scenes/GroupMembers/components/GroupMemberListItem.tsx index e48121d70a..798ce5cb74 100644 --- a/app/scenes/GroupMembers/components/GroupMemberListItem.js +++ b/app/scenes/GroupMembers/components/GroupMemberListItem.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import User from "models/User"; import Avatar from "components/Avatar"; @@ -9,11 +8,11 @@ import ListItem from "components/List/Item"; import Time from "components/Time"; import GroupMemberMenu from "menus/GroupMemberMenu"; -type Props = {| - user: User, - onAdd?: () => Promise, - onRemove?: () => Promise, -|}; +type Props = { + user: User; + onAdd?: () => Promise; + onRemove?: () => Promise; +}; const GroupMemberListItem = ({ user, onRemove, onAdd }: Props) => { return ( diff --git a/app/scenes/GroupMembers/components/UserListItem.js b/app/scenes/GroupMembers/components/UserListItem.tsx similarity index 94% rename from app/scenes/GroupMembers/components/UserListItem.js rename to app/scenes/GroupMembers/components/UserListItem.tsx index af63ab4cdd..e46d705897 100644 --- a/app/scenes/GroupMembers/components/UserListItem.js +++ b/app/scenes/GroupMembers/components/UserListItem.tsx @@ -1,4 +1,3 @@ -// @flow import { PlusIcon } from "outline-icons"; import * as React from "react"; import User from "models/User"; @@ -9,9 +8,9 @@ import ListItem from "components/List/Item"; import Time from "components/Time"; type Props = { - user: User, - canEdit: boolean, - onAdd: () => void, + user: User; + canEdit: boolean; + onAdd: () => void; }; const UserListItem = ({ user, onAdd, canEdit }: Props) => { diff --git a/app/scenes/GroupMembers/index.js b/app/scenes/GroupMembers/index.ts similarity index 88% rename from app/scenes/GroupMembers/index.js rename to app/scenes/GroupMembers/index.ts index 53829cf83a..e203dc6ff1 100644 --- a/app/scenes/GroupMembers/index.js +++ b/app/scenes/GroupMembers/index.ts @@ -1,3 +1,2 @@ -// @flow import GroupMembers from "./GroupMembers"; export default GroupMembers; diff --git a/app/scenes/GroupNew.js b/app/scenes/GroupNew.tsx similarity index 82% rename from app/scenes/GroupNew.js rename to app/scenes/GroupNew.tsx index f6131a989a..230ecee905 100644 --- a/app/scenes/GroupNew.js +++ b/app/scenes/GroupNew.tsx @@ -1,8 +1,8 @@ -// @flow import { observable } from "mobx"; import { inject, observer } from "mobx-react"; import * as React from "react"; -import { withRouter, type RouterHistory } from "react-router-dom"; +import { withRouter } from "react-router-dom"; +import type { RouterHistory } from "react-router-dom"; import GroupsStore from "stores/GroupsStore"; import UiStore from "stores/UiStore"; import Group from "models/Group"; @@ -13,20 +13,25 @@ import HelpText from "components/HelpText"; import Input from "components/Input"; import Modal from "components/Modal"; +import type { SyntheticEvent, ChangeEvent } from "react"; + type Props = { - history: RouterHistory, - ui: UiStore, - groups: GroupsStore, - onSubmit: () => void, + history: RouterHistory; + ui: UiStore; + groups: GroupsStore; + onSubmit: () => void; }; @observer class GroupNew extends React.Component { - @observable name: string = ""; - @observable isSaving: boolean; - @observable group: Group; + @observable + name: string = ""; + @observable + isSaving: boolean; + @observable + group: Group; - handleSubmit = async (ev: SyntheticEvent<>) => { + handleSubmit = async (ev: SyntheticEvent) => { ev.preventDefault(); this.isSaving = true; const group = new Group( @@ -45,7 +50,7 @@ class GroupNew extends React.Component { } }; - handleNameChange = (ev: SyntheticInputEvent<*>) => { + handleNameChange = (ev: ChangeEvent) => { this.name = ev.target.value; }; diff --git a/app/scenes/Home.js b/app/scenes/Home.tsx similarity index 99% rename from app/scenes/Home.js rename to app/scenes/Home.tsx index ff18fae483..0ed0253d41 100644 --- a/app/scenes/Home.js +++ b/app/scenes/Home.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import { HomeIcon } from "outline-icons"; import * as React from "react"; diff --git a/app/scenes/Invite.js b/app/scenes/Invite.tsx similarity index 91% rename from app/scenes/Invite.js rename to app/scenes/Invite.tsx index 92191cacbb..0cc22a3336 100644 --- a/app/scenes/Invite.js +++ b/app/scenes/Invite.tsx @@ -1,9 +1,9 @@ -// @flow import { observable, action } from "mobx"; import { inject, observer } from "mobx-react"; import { LinkIcon, CloseIcon } from "outline-icons"; import * as React from "react"; -import { Link, withRouter, type RouterHistory } from "react-router-dom"; +import { Link, withRouter } from "react-router-dom"; +import type { RouterHistory } from "react-router-dom"; import styled from "styled-components"; import AuthStore from "stores/AuthStore"; import PoliciesStore from "stores/PoliciesStore"; @@ -17,26 +17,30 @@ import Input from "components/Input"; import NudeButton from "components/NudeButton"; import Tooltip from "components/Tooltip"; +import type { SyntheticEvent } from "react"; + const MAX_INVITES = 20; type Props = { - auth: AuthStore, - users: UsersStore, - history: RouterHistory, - policies: PoliciesStore, - ui: UiStore, - onSubmit: () => void, + auth: AuthStore; + users: UsersStore; + history: RouterHistory; + policies: PoliciesStore; + ui: UiStore; + onSubmit: () => void; }; type InviteRequest = { - email: string, - name: string, + email: string; + name: string; }; @observer class Invite extends React.Component { - @observable isSaving: boolean; - @observable linkCopied: boolean = false; + @observable + isSaving: boolean; + @observable + linkCopied: boolean = false; @observable invites: InviteRequest[] = [ { email: "", name: "" }, @@ -44,7 +48,7 @@ class Invite extends React.Component { { email: "", name: "" }, ]; - handleSubmit = async (ev: SyntheticEvent<>) => { + handleSubmit = async (ev: SyntheticEvent) => { ev.preventDefault(); this.isSaving = true; @@ -82,7 +86,7 @@ class Invite extends React.Component { }; @action - handleRemove = (ev: SyntheticEvent<>, index: number) => { + handleRemove = (ev: SyntheticEvent, index: number) => { ev.preventDefault(); this.invites.splice(index, 1); }; diff --git a/app/scenes/KeyboardShortcuts.js b/app/scenes/KeyboardShortcuts.tsx similarity index 99% rename from app/scenes/KeyboardShortcuts.js rename to app/scenes/KeyboardShortcuts.tsx index 5fa1c58983..4b830bfc4e 100644 --- a/app/scenes/KeyboardShortcuts.js +++ b/app/scenes/KeyboardShortcuts.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import { useTranslation } from "react-i18next"; import styled from "styled-components"; diff --git a/app/scenes/Login/Notices.js b/app/scenes/Login/Notices.tsx similarity index 99% rename from app/scenes/Login/Notices.js rename to app/scenes/Login/Notices.tsx index 24ad3cd561..7fe44ed24a 100644 --- a/app/scenes/Login/Notices.js +++ b/app/scenes/Login/Notices.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import NoticeAlert from "components/NoticeAlert"; import useQuery from "hooks/useQuery"; diff --git a/app/scenes/Login/Provider.js b/app/scenes/Login/Provider.tsx similarity index 90% rename from app/scenes/Login/Provider.js rename to app/scenes/Login/Provider.tsx index 27eb6e5f5d..a16a6a6c94 100644 --- a/app/scenes/Login/Provider.js +++ b/app/scenes/Login/Provider.tsx @@ -1,4 +1,3 @@ -// @flow import { EmailIcon } from "outline-icons"; import * as React from "react"; import styled from "styled-components"; @@ -7,18 +6,20 @@ import ButtonLarge from "components/ButtonLarge"; import InputLarge from "components/InputLarge"; import { client } from "utils/ApiClient"; +import type { SyntheticEvent, ChangeEvent } from "react"; + type Props = { - id: string, - name: string, - authUrl: string, - isCreate: boolean, - onEmailSuccess: (email: string) => void, + id: string; + name: string; + authUrl: string; + isCreate: boolean; + onEmailSuccess: (email: string) => void; }; type State = { - showEmailSignin: boolean, - isSubmitting: boolean, - email: string, + showEmailSignin: boolean; + isSubmitting: boolean; + email: string; }; class Provider extends React.Component { @@ -28,7 +29,7 @@ class Provider extends React.Component { email: "", }; - handleChangeEmail = (event: SyntheticInputEvent) => { + handleChangeEmail = (event: ChangeEvent) => { this.setState({ email: event.target.value }); }; diff --git a/app/scenes/Login/index.js b/app/scenes/Login/index.tsx similarity index 97% rename from app/scenes/Login/index.js rename to app/scenes/Login/index.tsx index f150e51af8..99b7df42ca 100644 --- a/app/scenes/Login/index.js +++ b/app/scenes/Login/index.tsx @@ -1,9 +1,9 @@ -// @flow import { find } from "lodash"; import { observer } from "mobx-react"; import { BackIcon, EmailIcon } from "outline-icons"; import * as React from "react"; -import { Redirect, Link, type Location } from "react-router-dom"; +import { Redirect, Link } from "react-router-dom"; +import type { Location } from "react-router-dom"; import styled from "styled-components"; import { setCookie } from "tiny-cookie"; import ButtonLarge from "components/ButtonLarge"; @@ -20,9 +20,9 @@ import env from "env"; import useQuery from "hooks/useQuery"; import useStores from "hooks/useStores"; -type Props = {| - location: Location, -|}; +type Props = { + location: Location; +}; function Login({ location }: Props) { const query = useQuery(); diff --git a/app/scenes/Logout.js b/app/scenes/Logout.tsx similarity index 96% rename from app/scenes/Logout.js rename to app/scenes/Logout.tsx index 36e94659db..4b99fcd0c2 100644 --- a/app/scenes/Logout.js +++ b/app/scenes/Logout.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import { Redirect } from "react-router-dom"; import useStores from "../hooks/useStores"; diff --git a/app/scenes/Search/Search.js b/app/scenes/Search/Search.tsx similarity index 92% rename from app/scenes/Search/Search.js rename to app/scenes/Search/Search.tsx index e1709319c2..0aefe49868 100644 --- a/app/scenes/Search/Search.js +++ b/app/scenes/Search/Search.tsx @@ -1,4 +1,3 @@ -// @flow import ArrowKeyNavigation from "boundless-arrow-key-navigation"; import { debounce, isEqual } from "lodash"; import { observable, action } from "mobx"; @@ -6,7 +5,8 @@ import { observer, inject } from "mobx-react"; import { PlusIcon } from "outline-icons"; import queryString from "query-string"; import * as React from "react"; -import { withTranslation, Trans, type TFunction } from "react-i18next"; +import { withTranslation, Trans } from "react-i18next"; +import type { TFunction } from "react-i18next"; import keydown from "react-keydown"; import { withRouter, Link } from "react-router-dom"; import type { RouterHistory, Match } from "react-router-dom"; @@ -35,36 +35,43 @@ import SearchField from "./components/SearchField"; import StatusFilter from "./components/StatusFilter"; import UserFilter from "./components/UserFilter"; import NewDocumentMenu from "menus/NewDocumentMenu"; -import { type LocationWithState } from "types"; +import type { LocationWithState } from "types"; import { metaDisplay } from "utils/keyboard"; import { newDocumentUrl, searchUrl } from "utils/routeHelpers"; import { decodeURIComponentSafe } from "utils/urls"; +import type { KeyboardEvent } from "react"; + type Props = { - history: RouterHistory, - match: Match, - location: LocationWithState, - documents: DocumentsStore, - auth: AuthStore, - users: UsersStore, - policies: PoliciesStore, - notFound: ?boolean, - t: TFunction, + history: RouterHistory; + match: Match; + location: LocationWithState; + documents: DocumentsStore; + auth: AuthStore; + users: UsersStore; + policies: PoliciesStore; + notFound: boolean | undefined | null; + t: TFunction; }; @observer class Search extends React.Component { - firstDocument: ?React.Component; + firstDocument: React.Component | undefined | null; lastQuery: string = ""; - lastParams: Object; + lastParams: any; @observable query: string = decodeURIComponentSafe(this.props.match.params.term || ""); - @observable params: URLSearchParams = new URLSearchParams(); - @observable offset: number = 0; - @observable allowLoadMore: boolean = true; - @observable isLoading: boolean = false; - @observable pinToTop: boolean = !!this.props.match.params.term; + @observable + params: URLSearchParams = new URLSearchParams(); + @observable + offset: number = 0; + @observable + allowLoadMore: boolean = true; + @observable + isLoading: boolean = false; + @observable + pinToTop: boolean = !!this.props.match.params.term; componentDidMount() { this.handleTermChange(); @@ -88,7 +95,7 @@ class Search extends React.Component { this.props.history.goBack(); } - handleKeyDown = (ev: SyntheticKeyboardEvent<>) => { + handleKeyDown = (ev: KeyboardEvent) => { if (ev.key === "Enter") { this.fetchResults(); return; @@ -133,10 +140,10 @@ class Search extends React.Component { }; handleFilterChange = (search: { - collectionId?: ?string, - userId?: ?string, - dateFilter?: ?string, - includeArchived?: ?string, + collectionId?: string | null; + userId?: string | null; + dateFilter?: string | null; + includeArchived?: string | null; }) => { this.props.history.replace({ pathname: this.props.location.pathname, diff --git a/app/scenes/Search/components/CollectionFilter.js b/app/scenes/Search/components/CollectionFilter.tsx similarity index 90% rename from app/scenes/Search/components/CollectionFilter.js rename to app/scenes/Search/components/CollectionFilter.tsx index f755f3896f..e0487f3c0f 100644 --- a/app/scenes/Search/components/CollectionFilter.js +++ b/app/scenes/Search/components/CollectionFilter.tsx @@ -1,14 +1,13 @@ -// @flow import { observer } from "mobx-react"; import * as React from "react"; import { useTranslation } from "react-i18next"; import FilterOptions from "components/FilterOptions"; import useStores from "hooks/useStores"; -type Props = {| - collectionId: ?string, - onSelect: (key: ?string) => void, -|}; +type Props = { + collectionId: string | undefined | null; + onSelect: (key?: string | null) => void; +}; function CollectionFilter(props: Props) { const { t } = useTranslation(); diff --git a/app/scenes/Search/components/DateFilter.js b/app/scenes/Search/components/DateFilter.tsx similarity index 87% rename from app/scenes/Search/components/DateFilter.js rename to app/scenes/Search/components/DateFilter.tsx index fa16624828..a5bca77fe1 100644 --- a/app/scenes/Search/components/DateFilter.js +++ b/app/scenes/Search/components/DateFilter.tsx @@ -1,12 +1,11 @@ -// @flow import * as React from "react"; import { useTranslation } from "react-i18next"; import FilterOptions from "components/FilterOptions"; -type Props = {| - dateFilter: ?string, - onSelect: (key: ?string) => void, -|}; +type Props = { + dateFilter: string | undefined | null; + onSelect: (key?: string | null) => void; +}; const DateFilter = ({ dateFilter, onSelect }: Props) => { const { t } = useTranslation(); diff --git a/app/scenes/Search/components/SearchField.js b/app/scenes/Search/components/SearchField.tsx similarity index 88% rename from app/scenes/Search/components/SearchField.js rename to app/scenes/Search/components/SearchField.tsx index c4425f35f4..2b8bc9b8b7 100644 --- a/app/scenes/Search/components/SearchField.js +++ b/app/scenes/Search/components/SearchField.tsx @@ -1,19 +1,20 @@ -// @flow import { SearchIcon } from "outline-icons"; import * as React from "react"; import styled, { withTheme } from "styled-components"; import Flex from "components/Flex"; -import { type Theme } from "types"; +import type { Theme } from "types"; + +import type { SyntheticEvent } from "react"; type Props = { - onChange: (string) => void, - defaultValue?: string, - placeholder?: string, - theme: Theme, + onChange: (a: string) => void; + defaultValue?: string; + placeholder?: string; + theme: Theme; }; class SearchField extends React.Component { - input: ?HTMLInputElement; + input: HTMLInputElement | undefined | null; componentDidMount() { if (this.props && this.input) { @@ -27,7 +28,7 @@ class SearchField extends React.Component { this.props.onChange(ev.currentTarget.value ? ev.currentTarget.value : ""); }; - focusInput = (ev: SyntheticEvent<>) => { + focusInput = (ev: SyntheticEvent) => { if (this.input) this.input.focus(); }; diff --git a/app/scenes/Search/components/StatusFilter.js b/app/scenes/Search/components/StatusFilter.tsx similarity index 89% rename from app/scenes/Search/components/StatusFilter.js rename to app/scenes/Search/components/StatusFilter.tsx index f1b92e7485..1f8f7dec3b 100644 --- a/app/scenes/Search/components/StatusFilter.js +++ b/app/scenes/Search/components/StatusFilter.tsx @@ -1,12 +1,11 @@ -// @flow import * as React from "react"; import { useTranslation } from "react-i18next"; import FilterOptions from "components/FilterOptions"; -type Props = {| - includeArchived?: boolean, - onSelect: (key: ?string) => void, -|}; +type Props = { + includeArchived?: boolean; + onSelect: (key?: string | null) => void; +}; const StatusFilter = ({ includeArchived, onSelect }: Props) => { const { t } = useTranslation(); diff --git a/app/scenes/Search/components/UserFilter.js b/app/scenes/Search/components/UserFilter.tsx similarity index 90% rename from app/scenes/Search/components/UserFilter.js rename to app/scenes/Search/components/UserFilter.tsx index 9fab2c0c00..5fe048c657 100644 --- a/app/scenes/Search/components/UserFilter.js +++ b/app/scenes/Search/components/UserFilter.tsx @@ -1,14 +1,13 @@ -// @flow import { observer } from "mobx-react"; import * as React from "react"; import { useTranslation } from "react-i18next"; import FilterOptions from "components/FilterOptions"; import useStores from "hooks/useStores"; -type Props = {| - userId: ?string, - onSelect: (key: ?string) => void, -|}; +type Props = { + userId: string | undefined | null; + onSelect: (key?: string | null) => void; +}; function UserFilter(props: Props) { const { onSelect, userId } = props; diff --git a/app/scenes/Search/index.js b/app/scenes/Search/index.ts similarity index 85% rename from app/scenes/Search/index.js rename to app/scenes/Search/index.ts index 1fa6535a9e..4d5515e8c5 100644 --- a/app/scenes/Search/index.js +++ b/app/scenes/Search/index.ts @@ -1,3 +1,2 @@ -// @flow import Search from "./Search"; export default Search; diff --git a/app/scenes/Settings/Details.js b/app/scenes/Settings/Details.tsx similarity index 90% rename from app/scenes/Settings/Details.js rename to app/scenes/Settings/Details.tsx index 6d21df9495..9ae1d9a74e 100644 --- a/app/scenes/Settings/Details.js +++ b/app/scenes/Settings/Details.tsx @@ -1,4 +1,3 @@ -// @flow import { observable } from "mobx"; import { observer, inject } from "mobx-react"; import { TeamIcon } from "outline-icons"; @@ -15,19 +14,24 @@ import Scene from "components/Scene"; import ImageUpload from "./components/ImageUpload"; import env from "env"; +import type { SyntheticEvent, ChangeEvent } from "react"; + type Props = { - auth: AuthStore, - ui: UiStore, + auth: AuthStore; + ui: UiStore; }; @observer class Details extends React.Component { timeout: TimeoutID; - form: ?HTMLFormElement; + form: HTMLFormElement | undefined | null; - @observable name: string; - @observable subdomain: ?string; - @observable avatarUrl: ?string; + @observable + name: string; + @observable + subdomain: string | undefined | null; + @observable + avatarUrl: string | undefined | null; componentDidMount() { const { team } = this.props.auth; @@ -41,7 +45,7 @@ class Details extends React.Component { clearTimeout(this.timeout); } - handleSubmit = async (event: ?SyntheticEvent<>) => { + handleSubmit = async (event?: SyntheticEvent | null) => { if (event) { event.preventDefault(); } @@ -58,11 +62,11 @@ class Details extends React.Component { } }; - handleNameChange = (ev: SyntheticInputEvent<*>) => { + handleNameChange = (ev: ChangeEvent) => { this.name = ev.target.value; }; - handleSubdomainChange = (ev: SyntheticInputEvent<*>) => { + handleSubdomainChange = (ev: ChangeEvent) => { this.subdomain = ev.target.value.toLowerCase(); }; @@ -71,7 +75,7 @@ class Details extends React.Component { this.handleSubmit(); }; - handleAvatarError = (error: ?string) => { + handleAvatarError = (error?: string | null) => { this.props.ui.showToast(error || "Unable to upload new logo"); }; diff --git a/app/scenes/Settings/Groups.js b/app/scenes/Settings/Groups.tsx similarity index 99% rename from app/scenes/Settings/Groups.js rename to app/scenes/Settings/Groups.tsx index 1a3fc2b71c..4c6850d161 100644 --- a/app/scenes/Settings/Groups.js +++ b/app/scenes/Settings/Groups.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import { PlusIcon, GroupIcon } from "outline-icons"; import * as React from "react"; diff --git a/app/scenes/Settings/ImportExport.js b/app/scenes/Settings/ImportExport.tsx similarity index 98% rename from app/scenes/Settings/ImportExport.js rename to app/scenes/Settings/ImportExport.tsx index f8188dde8e..a04007919d 100644 --- a/app/scenes/Settings/ImportExport.js +++ b/app/scenes/Settings/ImportExport.tsx @@ -1,4 +1,3 @@ -// @flow import invariant from "invariant"; import { observer } from "mobx-react"; import { CollectionIcon, DocumentIcon } from "outline-icons"; @@ -17,6 +16,8 @@ import useStores from "hooks/useStores"; import getDataTransferFiles from "utils/getDataTransferFiles"; import { uploadFile } from "utils/uploadFile"; +import type { SyntheticEvent } from "react"; + function ImportExport() { const { t } = useTranslation(); const user = useCurrentUser(); @@ -83,7 +84,7 @@ function ImportExport() { ); const handleExport = React.useCallback( - async (ev: SyntheticEvent<>) => { + async (ev: SyntheticEvent) => { ev.preventDefault(); setLoading(true); diff --git a/app/scenes/Settings/Notifications.js b/app/scenes/Settings/Notifications.tsx similarity index 95% rename from app/scenes/Settings/Notifications.js rename to app/scenes/Settings/Notifications.tsx index d9d490af6c..0b823cf1ad 100644 --- a/app/scenes/Settings/Notifications.js +++ b/app/scenes/Settings/Notifications.tsx @@ -1,4 +1,3 @@ -// @flow import { debounce } from "lodash"; import { observer, inject } from "mobx-react"; import { EmailIcon } from "outline-icons"; @@ -16,10 +15,12 @@ import Subheading from "components/Subheading"; import NotificationListItem from "./components/NotificationListItem"; +import type { ChangeEvent } from "react"; + type Props = { - ui: UiStore, - auth: AuthStore, - notificationSettings: NotificationSettingsStore, + ui: UiStore; + auth: AuthStore; + notificationSettings: NotificationSettingsStore; }; const options = [ @@ -60,7 +61,7 @@ class Notifications extends React.Component { this.props.notificationSettings.fetchPage(); } - handleChange = async (ev: SyntheticInputEvent<>) => { + handleChange = async (ev: ChangeEvent) => { const { notificationSettings } = this.props; const setting = notificationSettings.getByEvent(ev.target.name); diff --git a/app/scenes/Settings/People.js b/app/scenes/Settings/People.tsx similarity index 99% rename from app/scenes/Settings/People.js rename to app/scenes/Settings/People.tsx index 7b670ef037..a436bf57de 100644 --- a/app/scenes/Settings/People.js +++ b/app/scenes/Settings/People.tsx @@ -1,4 +1,3 @@ -// @flow import { sortBy } from "lodash"; import { observer } from "mobx-react"; import { PlusIcon, UserIcon } from "outline-icons"; diff --git a/app/scenes/Settings/Profile.js b/app/scenes/Settings/Profile.tsx similarity index 89% rename from app/scenes/Settings/Profile.js rename to app/scenes/Settings/Profile.tsx index 4efedaaea2..897f03878b 100644 --- a/app/scenes/Settings/Profile.js +++ b/app/scenes/Settings/Profile.tsx @@ -1,9 +1,9 @@ -// @flow import { observable } from "mobx"; import { observer, inject } from "mobx-react"; import { ProfileIcon } from "outline-icons"; import * as React from "react"; -import { Trans, withTranslation, type TFunction } from "react-i18next"; +import { Trans, withTranslation } from "react-i18next"; +import type { TFunction } from "react-i18next"; import styled from "styled-components"; import { languageOptions } from "shared/i18n"; import AuthStore from "stores/AuthStore"; @@ -18,21 +18,27 @@ import InputSelect from "components/InputSelect"; import Scene from "components/Scene"; import ImageUpload from "./components/ImageUpload"; +import type { SyntheticEvent, ChangeEvent } from "react"; + type Props = { - auth: AuthStore, - ui: UiStore, - t: TFunction, + auth: AuthStore; + ui: UiStore; + t: TFunction; }; @observer class Profile extends React.Component { timeout: TimeoutID; - form: ?HTMLFormElement; + form: HTMLFormElement | undefined | null; - @observable name: string; - @observable avatarUrl: ?string; - @observable showDeleteModal: boolean = false; - @observable language: string; + @observable + name: string; + @observable + avatarUrl: string | undefined | null; + @observable + showDeleteModal: boolean = false; + @observable + language: string; componentDidMount() { if (this.props.auth.user) { @@ -45,7 +51,7 @@ class Profile extends React.Component { clearTimeout(this.timeout); } - handleSubmit = async (ev: SyntheticEvent<>) => { + handleSubmit = async (ev: SyntheticEvent) => { const { t } = this.props; ev.preventDefault(); @@ -58,7 +64,7 @@ class Profile extends React.Component { this.props.ui.showToast(t("Profile saved"), { type: "success" }); }; - handleNameChange = (ev: SyntheticInputEvent<*>) => { + handleNameChange = (ev: ChangeEvent) => { this.name = ev.target.value; }; @@ -72,7 +78,7 @@ class Profile extends React.Component { this.props.ui.showToast(t("Profile picture updated"), { type: "success" }); }; - handleAvatarError = (error: ?string) => { + handleAvatarError = (error?: string | null) => { const { t } = this.props; this.props.ui.showToast( error || t("Unable to upload new profile picture"), @@ -80,7 +86,7 @@ class Profile extends React.Component { ); }; - handleLanguageChange = (ev: SyntheticInputEvent<*>) => { + handleLanguageChange = (ev: ChangeEvent) => { this.language = ev.target.value; }; diff --git a/app/scenes/Settings/Security.js b/app/scenes/Settings/Security.tsx similarity index 89% rename from app/scenes/Settings/Security.js rename to app/scenes/Settings/Security.tsx index 5f19bfceae..174c6a342b 100644 --- a/app/scenes/Settings/Security.js +++ b/app/scenes/Settings/Security.tsx @@ -1,4 +1,3 @@ -// @flow import { debounce } from "lodash"; import { observable } from "mobx"; import { observer, inject } from "mobx-react"; @@ -11,18 +10,23 @@ import Heading from "components/Heading"; import HelpText from "components/HelpText"; import Scene from "components/Scene"; +import type { ChangeEvent } from "react"; + type Props = { - auth: AuthStore, - ui: UiStore, + auth: AuthStore; + ui: UiStore; }; @observer class Security extends React.Component { - form: ?HTMLFormElement; + form: HTMLFormElement | undefined | null; - @observable sharing: boolean; - @observable documentEmbeds: boolean; - @observable guestSignin: boolean; + @observable + sharing: boolean; + @observable + documentEmbeds: boolean; + @observable + guestSignin: boolean; componentDidMount() { const { auth } = this.props; @@ -33,7 +37,7 @@ class Security extends React.Component { } } - handleChange = async (ev: SyntheticInputEvent<*>) => { + handleChange = async (ev: ChangeEvent) => { switch (ev.target.name) { case "sharing": this.sharing = ev.target.checked; diff --git a/app/scenes/Settings/Shares.js b/app/scenes/Settings/Shares.tsx similarity index 99% rename from app/scenes/Settings/Shares.js rename to app/scenes/Settings/Shares.tsx index 68f90e9e74..7f5ee42b98 100644 --- a/app/scenes/Settings/Shares.js +++ b/app/scenes/Settings/Shares.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import { LinkIcon } from "outline-icons"; import * as React from "react"; diff --git a/app/scenes/Settings/Slack.js b/app/scenes/Settings/Slack.tsx similarity index 99% rename from app/scenes/Settings/Slack.js rename to app/scenes/Settings/Slack.tsx index 8d2e5a4a35..9c29e9d44e 100644 --- a/app/scenes/Settings/Slack.js +++ b/app/scenes/Settings/Slack.tsx @@ -1,4 +1,3 @@ -// @flow import { find } from "lodash"; import { observer } from "mobx-react"; import * as React from "react"; diff --git a/app/scenes/Settings/Tokens.js b/app/scenes/Settings/Tokens.tsx similarity index 99% rename from app/scenes/Settings/Tokens.js rename to app/scenes/Settings/Tokens.tsx index 1c6f83a26c..7d2e658a96 100644 --- a/app/scenes/Settings/Tokens.js +++ b/app/scenes/Settings/Tokens.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import { CodeIcon } from "outline-icons"; import * as React from "react"; diff --git a/app/scenes/Settings/Zapier.js b/app/scenes/Settings/Zapier.tsx similarity index 98% rename from app/scenes/Settings/Zapier.js rename to app/scenes/Settings/Zapier.tsx index 6899375ca8..c496b6ad52 100644 --- a/app/scenes/Settings/Zapier.js +++ b/app/scenes/Settings/Zapier.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import Button from "components/Button"; import Heading from "components/Heading"; diff --git a/app/scenes/Settings/components/ImageUpload.js b/app/scenes/Settings/components/ImageUpload.tsx similarity index 91% rename from app/scenes/Settings/components/ImageUpload.js rename to app/scenes/Settings/components/ImageUpload.tsx index c4d3997194..de51af0d34 100644 --- a/app/scenes/Settings/components/ImageUpload.js +++ b/app/scenes/Settings/components/ImageUpload.tsx @@ -1,4 +1,3 @@ -// @flow import { observable } from "mobx"; import { observer, inject } from "mobx-react"; import * as React from "react"; @@ -13,23 +12,29 @@ import Modal from "components/Modal"; import { compressImage } from "utils/compressImage"; import { uploadFile, dataUrlToBlob } from "utils/uploadFile"; +import type { DragEvent } from "react"; + const EMPTY_OBJECT = {}; type Props = { - children?: React.Node, - onSuccess: (string) => void | Promise, - onError: (string) => void, - submitText: string, - borderRadius: number, - ui: UiStore, + children?: React.ReactNode; + onSuccess: (a: string) => void | Promise; + onError: (a: string) => void; + submitText: string; + borderRadius: number; + ui: UiStore; }; @observer class ImageUpload extends React.Component { - @observable isUploading: boolean = false; - @observable isCropping: boolean = false; - @observable zoom: number = 1; - @observable file: File; + @observable + isUploading: boolean = false; + @observable + isCropping: boolean = false; + @observable + zoom: number = 1; + @observable + file: File; avatarEditorRef: AvatarEditor; static defaultProps = { @@ -76,7 +81,7 @@ class ImageUpload extends React.Component { this.isCropping = false; }; - handleZoom = (event: SyntheticDragEvent<*>) => { + handleZoom = (event: DragEvent) => { let target = event.target; if (target instanceof HTMLInputElement) { this.zoom = parseFloat(target.value); diff --git a/app/scenes/Settings/components/NotificationListItem.js b/app/scenes/Settings/components/NotificationListItem.tsx similarity index 70% rename from app/scenes/Settings/components/NotificationListItem.js rename to app/scenes/Settings/components/NotificationListItem.tsx index 970ecdc3cf..febd49d439 100644 --- a/app/scenes/Settings/components/NotificationListItem.js +++ b/app/scenes/Settings/components/NotificationListItem.tsx @@ -1,15 +1,16 @@ -// @flow import * as React from "react"; import NotificationSetting from "models/NotificationSetting"; import Checkbox from "components/Checkbox"; +import type { ChangeEvent } from "react"; + type Props = { - setting?: NotificationSetting, - title: string, - event: string, - description: string, - disabled: boolean, - onChange: (ev: SyntheticInputEvent<>) => void | Promise, + setting?: NotificationSetting; + title: string; + event: string; + description: string; + disabled: boolean; + onChange: (ev: ChangeEvent) => void | Promise; }; const NotificationListItem = ({ diff --git a/app/scenes/Settings/components/PeopleTable.js b/app/scenes/Settings/components/PeopleTable.tsx similarity index 93% rename from app/scenes/Settings/components/PeopleTable.js rename to app/scenes/Settings/components/PeopleTable.tsx index 942302d020..ca11d0c95f 100644 --- a/app/scenes/Settings/components/PeopleTable.js +++ b/app/scenes/Settings/components/PeopleTable.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import * as React from "react"; import { useTranslation } from "react-i18next"; @@ -7,7 +6,7 @@ import User from "models/User"; import Avatar from "components/Avatar"; import Badge from "components/Badge"; import Flex from "components/Flex"; -import { type Props as TableProps } from "components/Table"; +import type { Props as TableProps } from "components/Table"; import Time from "components/Time"; import useCurrentUser from "hooks/useCurrentUser"; import UserMenu from "menus/UserMenu"; @@ -16,11 +15,10 @@ const Table = React.lazy(() => import(/* webpackChunkName: "table" */ "components/Table") ); -type Props = {| - ...$Diff, - data: User[], - canManage: boolean, -|}; +type Props = { + data: User[]; + canManage: boolean; +} & Omit; function PeopleTable({ canManage, ...rest }: Props) { const { t } = useTranslation(); diff --git a/app/scenes/Settings/components/ShareListItem.js b/app/scenes/Settings/components/ShareListItem.tsx similarity index 95% rename from app/scenes/Settings/components/ShareListItem.js rename to app/scenes/Settings/components/ShareListItem.tsx index d948b5179a..8c30618285 100644 --- a/app/scenes/Settings/components/ShareListItem.js +++ b/app/scenes/Settings/components/ShareListItem.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import { useTranslation } from "react-i18next"; import Share from "models/Share"; @@ -6,9 +5,9 @@ import ListItem from "components/List/Item"; import Time from "components/Time"; import ShareMenu from "menus/ShareMenu"; -type Props = {| - share: Share, -|}; +type Props = { + share: Share; +}; const ShareListItem = ({ share }: Props) => { const { t } = useTranslation(); diff --git a/app/scenes/Settings/components/SlackButton.js b/app/scenes/Settings/components/SlackButton.tsx similarity index 86% rename from app/scenes/Settings/components/SlackButton.js rename to app/scenes/Settings/components/SlackButton.tsx index 7eeefe8828..3c4e3d7a77 100644 --- a/app/scenes/Settings/components/SlackButton.js +++ b/app/scenes/Settings/components/SlackButton.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from "react"; import { useTranslation } from "react-i18next"; import { slackAuth } from "shared/utils/routeHelpers"; @@ -6,12 +5,12 @@ import Button from "components/Button"; import SlackIcon from "components/SlackIcon"; import env from "env"; -type Props = {| - scopes?: string[], - redirectUri: string, - state?: string, - label?: string, -|}; +type Props = { + scopes?: string[]; + redirectUri: string; + state?: string; + label?: string; +}; function SlackButton({ state = "", scopes, redirectUri, label }: Props) { const { t } = useTranslation(); diff --git a/app/scenes/Settings/components/TokenListItem.js b/app/scenes/Settings/components/TokenListItem.tsx similarity index 84% rename from app/scenes/Settings/components/TokenListItem.js rename to app/scenes/Settings/components/TokenListItem.tsx index 3fd91cb245..21aa31f7ba 100644 --- a/app/scenes/Settings/components/TokenListItem.js +++ b/app/scenes/Settings/components/TokenListItem.tsx @@ -1,13 +1,12 @@ -// @flow import * as React from "react"; import ApiKey from "models/ApiKey"; import Button from "components/Button"; import ListItem from "components/List/Item"; -type Props = {| - token: ApiKey, - onDelete: (tokenId: string) => Promise, -|}; +type Props = { + token: ApiKey; + onDelete: (tokenId: string) => Promise; +}; const TokenListItem = ({ token, onDelete }: Props) => { return ( diff --git a/app/scenes/Settings/components/UserListItem.js b/app/scenes/Settings/components/UserListItem.tsx similarity index 95% rename from app/scenes/Settings/components/UserListItem.js rename to app/scenes/Settings/components/UserListItem.tsx index 18c0c84ca1..2f13ef3424 100644 --- a/app/scenes/Settings/components/UserListItem.js +++ b/app/scenes/Settings/components/UserListItem.tsx @@ -1,4 +1,3 @@ -// @flow import { observable } from "mobx"; import { observer } from "mobx-react"; import * as React from "react"; @@ -12,13 +11,14 @@ import Time from "components/Time"; import UserMenu from "menus/UserMenu"; type Props = { - user: User, - showMenu: boolean, + user: User; + showMenu: boolean; }; @observer class UserListItem extends React.Component { - @observable profileOpen: boolean = false; + @observable + profileOpen: boolean = false; handleOpenProfile = () => { this.profileOpen = true; diff --git a/app/scenes/Settings/components/UserStatusFilter.js b/app/scenes/Settings/components/UserStatusFilter.tsx similarity index 91% rename from app/scenes/Settings/components/UserStatusFilter.js rename to app/scenes/Settings/components/UserStatusFilter.tsx index c61f5bdd0a..48bcc4623e 100644 --- a/app/scenes/Settings/components/UserStatusFilter.js +++ b/app/scenes/Settings/components/UserStatusFilter.tsx @@ -1,12 +1,11 @@ -// @flow import * as React from "react"; import { useTranslation } from "react-i18next"; import FilterOptions from "components/FilterOptions"; -type Props = {| - activeKey: string, - onSelect: (key: ?string) => void, -|}; +type Props = { + activeKey: string; + onSelect: (key?: string | null) => void; +}; const UserStatusFilter = ({ activeKey, onSelect }: Props) => { const { t } = useTranslation(); diff --git a/app/scenes/Starred.js b/app/scenes/Starred.tsx similarity index 96% rename from app/scenes/Starred.js rename to app/scenes/Starred.tsx index c875340a0d..421bcc1bbd 100644 --- a/app/scenes/Starred.js +++ b/app/scenes/Starred.tsx @@ -1,9 +1,8 @@ -// @flow import { observer } from "mobx-react"; import { StarredIcon } from "outline-icons"; import * as React from "react"; import { useTranslation } from "react-i18next"; -import { type Match } from "react-router-dom"; +import type { Match } from "react-router-dom"; import { Action } from "components/Actions"; import Empty from "components/Empty"; import Heading from "components/Heading"; @@ -16,7 +15,7 @@ import useStores from "hooks/useStores"; import NewDocumentMenu from "menus/NewDocumentMenu"; type Props = { - match: Match, + match: Match; }; function Starred(props: Props) { diff --git a/app/scenes/Templates.js b/app/scenes/Templates.tsx similarity index 96% rename from app/scenes/Templates.js rename to app/scenes/Templates.tsx index 1c9378801f..40176e414c 100644 --- a/app/scenes/Templates.js +++ b/app/scenes/Templates.tsx @@ -1,9 +1,8 @@ -// @flow import { observer } from "mobx-react"; import { TemplateIcon } from "outline-icons"; import * as React from "react"; import { useTranslation } from "react-i18next"; -import { type Match } from "react-router-dom"; +import type { Match } from "react-router-dom"; import { Action } from "components/Actions"; import Empty from "components/Empty"; import Heading from "components/Heading"; @@ -16,7 +15,7 @@ import useStores from "hooks/useStores"; import NewTemplateMenu from "menus/NewTemplateMenu"; type Props = { - match: Match, + match: Match; }; function Templates(props: Props) { diff --git a/app/scenes/Trash.js b/app/scenes/Trash.tsx similarity index 99% rename from app/scenes/Trash.js rename to app/scenes/Trash.tsx index 37dda1e6d0..ddfa51eb9d 100644 --- a/app/scenes/Trash.js +++ b/app/scenes/Trash.tsx @@ -1,4 +1,3 @@ -// @flow import { observer } from "mobx-react"; import { TrashIcon } from "outline-icons"; import * as React from "react"; diff --git a/app/scenes/UserDelete.js b/app/scenes/UserDelete.tsx similarity index 89% rename from app/scenes/UserDelete.js rename to app/scenes/UserDelete.tsx index 3aa5448614..b68864868c 100644 --- a/app/scenes/UserDelete.js +++ b/app/scenes/UserDelete.tsx @@ -1,4 +1,3 @@ -// @flow import { observable } from "mobx"; import { inject, observer } from "mobx-react"; import * as React from "react"; @@ -9,17 +8,20 @@ import Flex from "components/Flex"; import HelpText from "components/HelpText"; import Modal from "components/Modal"; +import type { SyntheticEvent } from "react"; + type Props = { - auth: AuthStore, - ui: UiStore, - onRequestClose: () => void, + auth: AuthStore; + ui: UiStore; + onRequestClose: () => void; }; @observer class UserDelete extends React.Component { - @observable isDeleting: boolean; + @observable + isDeleting: boolean; - handleSubmit = async (ev: SyntheticEvent<>) => { + handleSubmit = async (ev: SyntheticEvent) => { ev.preventDefault(); this.isDeleting = true; diff --git a/app/scenes/UserProfile.js b/app/scenes/UserProfile.tsx similarity index 93% rename from app/scenes/UserProfile.js rename to app/scenes/UserProfile.tsx index b78c7eeed3..43228bdf53 100644 --- a/app/scenes/UserProfile.js +++ b/app/scenes/UserProfile.tsx @@ -1,10 +1,10 @@ -// @flow import { formatDistanceToNow } from "date-fns"; import { observer } from "mobx-react"; import { EditIcon } from "outline-icons"; import * as React from "react"; import { useTranslation } from "react-i18next"; -import { withRouter, type RouterHistory } from "react-router-dom"; +import { withRouter } from "react-router-dom"; +import type { RouterHistory } from "react-router-dom"; import styled from "styled-components"; import { settings } from "shared/utils/routeHelpers"; import User from "models/User"; @@ -19,11 +19,11 @@ import Subheading from "components/Subheading"; import useCurrentUser from "hooks/useCurrentUser"; import useStores from "hooks/useStores"; -type Props = {| - user: User, - history: RouterHistory, - onRequestClose: () => void, -|}; +type Props = { + user: User; + history: RouterHistory; + onRequestClose: () => void; +}; function UserProfile(props: Props) { const { t } = useTranslation(); diff --git a/app/stores/ApiKeysStore.js b/app/stores/ApiKeysStore.ts similarity index 96% rename from app/stores/ApiKeysStore.js rename to app/stores/ApiKeysStore.ts index 82bec16bee..a856ab9cc3 100644 --- a/app/stores/ApiKeysStore.js +++ b/app/stores/ApiKeysStore.ts @@ -1,4 +1,3 @@ -// @flow import ApiKey from "models/ApiKey"; import BaseStore from "./BaseStore"; import RootStore from "./RootStore"; diff --git a/app/stores/AuthStore.js b/app/stores/AuthStore.ts similarity index 88% rename from app/stores/AuthStore.js rename to app/stores/AuthStore.ts index 2a7791717e..699864a4c5 100644 --- a/app/stores/AuthStore.js +++ b/app/stores/AuthStore.ts @@ -1,4 +1,3 @@ -// @flow import * as Sentry from "@sentry/react"; import invariant from "invariant"; import { observable, action, computed, autorun, runInAction } from "mobx"; @@ -14,27 +13,35 @@ import { getCookieDomain } from "utils/domains"; const AUTH_STORE = "AUTH_STORE"; const NO_REDIRECT_PATHS = ["/", "/create", "/home"]; -type Provider = {| - id: string, - name: string, - authUrl: string, -|}; +type Provider = { + id: string; + name: string; + authUrl: string; +}; -type Config = {| - name?: string, - hostname?: string, - providers: Provider[], -|}; +type Config = { + name?: string; + hostname?: string; + providers: Provider[]; +}; export default class AuthStore { - @observable user: ?User; - @observable team: ?Team; - @observable token: ?string; - @observable lastSignedIn: ?string; - @observable isSaving: boolean = false; - @observable isSuspended: boolean = false; - @observable suspendedContactEmail: ?string; - @observable config: ?Config; + @observable + user: User | undefined | null; + @observable + team: Team | undefined | null; + @observable + token: string | undefined | null; + @observable + lastSignedIn: string | undefined | null; + @observable + isSaving: boolean = false; + @observable + isSuspended: boolean = false; + @observable + suspendedContactEmail: string | undefined | null; + @observable + config: Config | undefined | null; rootStore: RootStore; constructor(rootStore: RootStore) { @@ -78,7 +85,7 @@ export default class AuthStore { } @action - rehydrate(data: { user: User, team: Team }) { + rehydrate(data: { user: User; team: Team }) { this.user = new User(data.user); this.team = new Team(data.team); this.token = getCookie("accessToken"); @@ -165,7 +172,10 @@ export default class AuthStore { }; @action - updateUser = async (params: { name?: string, avatarUrl: ?string }) => { + updateUser = async (params: { + name?: string; + avatarUrl: string | undefined | null; + }) => { this.isSaving = true; try { @@ -183,9 +193,9 @@ export default class AuthStore { @action updateTeam = async (params: { - name?: string, - avatarUrl?: ?string, - sharing?: boolean, + name?: string; + avatarUrl?: string | null; + sharing?: boolean; }) => { this.isSaving = true; diff --git a/app/stores/BaseStore.js b/app/stores/BaseStore.ts similarity index 83% rename from app/stores/BaseStore.js rename to app/stores/BaseStore.ts index a5e072cfa6..b09c490b9f 100644 --- a/app/stores/BaseStore.js +++ b/app/stores/BaseStore.ts @@ -1,4 +1,3 @@ -// @flow import invariant from "invariant"; import { orderBy } from "lodash"; import { observable, set, action, computed, runInAction } from "mobx"; @@ -17,18 +16,29 @@ export const DEFAULT_PAGINATION_LIMIT = 25; export const PAGINATION_SYMBOL = Symbol.for("pagination"); -export default class BaseStore { - @observable data: Map = new Map(); - @observable isFetching: boolean = false; - @observable isSaving: boolean = false; - @observable isLoaded: boolean = false; +export default class BaseStore { + @observable + data: Map = new Map(); + @observable + isFetching: boolean = false; + @observable + isSaving: boolean = false; + @observable + isLoaded: boolean = false; - model: Class; + model: { + new (...args: any): T; + }; modelName: string; rootStore: RootStore; actions: Action[] = ["list", "info", "create", "update", "delete", "count"]; - constructor(rootStore: RootStore, model: Class) { + constructor( + rootStore: RootStore, + model: { + new (...args: any): T; + } + ) { this.rootStore = rootStore; this.model = model; this.modelName = modelNameFromClassName(model.name); @@ -46,11 +56,11 @@ export default class BaseStore { }; @action - add = (item: Object): T => { + add = (item: any): T => { const Model = this.model; if (!(item instanceof Model)) { - const existing: ?T = this.data.get(item.id); + const existing: T | undefined | null = this.data.get(item.id); if (existing) { set(existing, item); return existing; @@ -68,17 +78,17 @@ export default class BaseStore { this.data.delete(id); } - save(params: Object) { + save(params: any) { if (params.id) return this.update(params); return this.create(params); } - get(id: string): ?T { + get(id: string): T | undefined | null { return this.data.get(id); } @action - async create(params: Object) { + async create(params: any) { if (!this.actions.includes("create")) { throw new Error(`Cannot create ${this.modelName}`); } @@ -97,7 +107,7 @@ export default class BaseStore { } @action - async update(params: Object): * { + async update(params: any): any { if (!this.actions.includes("update")) { throw new Error(`Cannot update ${this.modelName}`); } @@ -116,7 +126,7 @@ export default class BaseStore { } @action - async delete(item: T, options: Object = {}) { + async delete(item: T, options: any = {}) { if (!this.actions.includes("delete")) { throw new Error(`Cannot delete ${this.modelName}`); } @@ -134,7 +144,7 @@ export default class BaseStore { } @action - async fetch(id: string, options: Object = {}): Promise<*> { + async fetch(id: string, options: any = {}): Promise { if (!this.actions.includes("info")) { throw new Error(`Cannot fetch ${this.modelName}`); } @@ -162,7 +172,7 @@ export default class BaseStore { } @action - fetchPage = async (params: ?PaginationParams): Promise<*> => { + fetchPage = async (params?: PaginationParams | null): Promise => { if (!this.actions.includes("list")) { throw new Error(`Cannot list ${this.modelName}`); } diff --git a/app/stores/CollectionGroupMembershipsStore.js b/app/stores/CollectionGroupMembershipsStore.ts similarity index 90% rename from app/stores/CollectionGroupMembershipsStore.js rename to app/stores/CollectionGroupMembershipsStore.ts index a8996db0ca..bebdebe8b5 100644 --- a/app/stores/CollectionGroupMembershipsStore.js +++ b/app/stores/CollectionGroupMembershipsStore.ts @@ -1,4 +1,3 @@ -// @flow import invariant from "invariant"; import { action, runInAction } from "mobx"; import CollectionGroupMembership from "models/CollectionGroupMembership"; @@ -15,7 +14,7 @@ export default class CollectionGroupMembershipsStore extends BaseStore => { + fetchPage = async (params?: PaginationParams | null): Promise => { this.isFetching = true; try { @@ -40,9 +39,9 @@ export default class CollectionGroupMembershipsStore extends BaseStore { @@ -25,7 +24,7 @@ export default class CollectionsStore extends BaseStore { } @computed - get active(): ?Collection { + get active(): Collection | undefined | null { return this.rootStore.ui.activeCollectionId ? this.data.get(this.rootStore.ui.activeCollectionId) : undefined; @@ -108,7 +107,7 @@ export default class CollectionsStore extends BaseStore { } }; - async update(params: Object): Promise { + async update(params: any): Promise { const result = await super.update(params); // If we're changing sharing permissions on the collection then we need to @@ -127,7 +126,7 @@ export default class CollectionsStore extends BaseStore { } @action - async fetch(id: string, options: Object = {}): Promise<*> { + async fetch(id: string, options: any = {}): Promise { const item = this.get(id) || this.getByUrl(id); if (item && !options.force) return item; @@ -150,16 +149,16 @@ export default class CollectionsStore extends BaseStore { } } - getPathForDocument(documentId: string): ?DocumentPath { + getPathForDocument(documentId: string): DocumentPath | undefined | null { return this.pathsToDocuments.find((path) => path.id === documentId); } - titleForDocument(documentUrl: string): ?string { + titleForDocument(documentUrl: string): string | undefined | null { const path = this.pathsToDocuments.find((path) => path.url === documentUrl); if (path) return path.title; } - getByUrl(url: string): ?Collection { + getByUrl(url: string): Collection | undefined | null { return find(this.orderedData, (col: Collection) => url.endsWith(col.urlId)); } diff --git a/app/stores/DocumentPresenceStore.js b/app/stores/DocumentPresenceStore.ts similarity index 89% rename from app/stores/DocumentPresenceStore.js rename to app/stores/DocumentPresenceStore.ts index d0513eb312..f4be9f4971 100644 --- a/app/stores/DocumentPresenceStore.js +++ b/app/stores/DocumentPresenceStore.ts @@ -1,11 +1,17 @@ -// @flow import { observable, action } from "mobx"; import { USER_PRESENCE_INTERVAL } from "shared/constants"; -type DocumentPresence = Map; +type DocumentPresence = Map< + string, + { + isEditing: boolean; + userId: string; + } +>; export default class PresenceStore { - @observable data: Map = new Map(); + @observable + data: Map = new Map(); timeouts: Map = new Map(); // called to setup when we get the initial state from document.presence @@ -58,7 +64,7 @@ export default class PresenceStore { } } - get(documentId: string): ?DocumentPresence { + get(documentId: string): DocumentPresence | undefined | null { return this.data.get(documentId); } diff --git a/app/stores/DocumentsStore.js b/app/stores/DocumentsStore.ts similarity index 86% rename from app/stores/DocumentsStore.js rename to app/stores/DocumentsStore.ts index a0aed5af10..4c801b2510 100644 --- a/app/stores/DocumentsStore.js +++ b/app/stores/DocumentsStore.ts @@ -1,4 +1,3 @@ -// @flow import path from "path"; import invariant from "invariant"; import { find, orderBy, filter, compact, omitBy } from "lodash"; @@ -19,14 +18,18 @@ import type { import { client } from "utils/ApiClient"; type ImportOptions = { - publish?: boolean, + publish?: boolean; }; export default class DocumentsStore extends BaseStore { - @observable searchCache: Map = new Map(); - @observable starredIds: Map = new Map(); - @observable backlinks: Map = new Map(); - @observable movingDocumentId: ?string; + @observable + searchCache: Map = new Map(); + @observable + starredIds: Map = new Map(); + @observable + backlinks: Map = new Map(); + @observable + movingDocumentId: string | undefined | null; importFileTypes: string[] = [ ".md", @@ -195,10 +198,9 @@ export default class DocumentsStore extends BaseStore { drafts = ( options: { - ...PaginationParams, - dateFilter?: "day" | "week" | "month" | "year", - collectionId?: string, - } = {} + dateFilter?: "day" | "week" | "month" | "year"; + collectionId?: string; + } & PaginationParams = {} ): Document[] => { let drafts = filter( orderBy(this.all, "updatedAt", "desc"), @@ -222,14 +224,16 @@ export default class DocumentsStore extends BaseStore { }; @computed - get active(): ?Document { + get active(): Document | undefined | null { return this.rootStore.ui.activeDocumentId ? this.data.get(this.rootStore.ui.activeDocumentId) : undefined; } @action - fetchBacklinks = async (documentId: string): Promise => { + fetchBacklinks = async ( + documentId: string + ): Promise => { const res = await client.post(`/documents.list`, { backlinkDocumentId: documentId, }); @@ -255,7 +259,9 @@ export default class DocumentsStore extends BaseStore { } @action - fetchChildDocuments = async (documentId: string): Promise => { + fetchChildDocuments = async ( + documentId: string + ): Promise => { const res = await client.post(`/documents.list`, { parentDocumentId: documentId, }); @@ -270,8 +276,8 @@ export default class DocumentsStore extends BaseStore { @action fetchNamedPage = async ( request: string = "list", - options: ?Object - ): Promise => { + options?: any | null + ): Promise => { this.isFetching = true; try { @@ -289,27 +295,31 @@ export default class DocumentsStore extends BaseStore { }; @action - fetchArchived = async (options: ?PaginationParams): Promise<*> => { + fetchArchived = async (options?: PaginationParams | null): Promise => { return this.fetchNamedPage("archived", options); }; @action - fetchDeleted = async (options: ?PaginationParams): Promise<*> => { + fetchDeleted = async (options?: PaginationParams | null): Promise => { return this.fetchNamedPage("deleted", options); }; @action - fetchRecentlyUpdated = async (options: ?PaginationParams): Promise<*> => { + fetchRecentlyUpdated = async ( + options?: PaginationParams | null + ): Promise => { return this.fetchNamedPage("list", options); }; @action - fetchTemplates = async (options: ?PaginationParams): Promise<*> => { + fetchTemplates = async (options?: PaginationParams | null): Promise => { return this.fetchNamedPage("list", { ...options, template: true }); }; @action - fetchAlphabetical = async (options: ?PaginationParams): Promise<*> => { + fetchAlphabetical = async ( + options?: PaginationParams | null + ): Promise => { return this.fetchNamedPage("list", { sort: "title", direction: "ASC", @@ -319,8 +329,8 @@ export default class DocumentsStore extends BaseStore { @action fetchLeastRecentlyUpdated = async ( - options: ?PaginationParams - ): Promise<*> => { + options?: PaginationParams | null + ): Promise => { return this.fetchNamedPage("list", { sort: "updatedAt", direction: "ASC", @@ -329,7 +339,9 @@ export default class DocumentsStore extends BaseStore { }; @action - fetchRecentlyPublished = async (options: ?PaginationParams): Promise<*> => { + fetchRecentlyPublished = async ( + options?: PaginationParams | null + ): Promise => { return this.fetchNamedPage("list", { sort: "publishedAt", direction: "DESC", @@ -338,27 +350,29 @@ export default class DocumentsStore extends BaseStore { }; @action - fetchRecentlyViewed = async (options: ?PaginationParams): Promise<*> => { + fetchRecentlyViewed = async ( + options?: PaginationParams | null + ): Promise => { return this.fetchNamedPage("viewed", options); }; @action - fetchStarred = (options: ?PaginationParams): Promise<*> => { + fetchStarred = (options?: PaginationParams | null): Promise => { return this.fetchNamedPage("starred", options); }; @action - fetchDrafts = (options: ?PaginationParams): Promise<*> => { + fetchDrafts = (options?: PaginationParams | null): Promise => { return this.fetchNamedPage("drafts", options); }; @action - fetchPinned = (options: ?PaginationParams): Promise<*> => { + fetchPinned = (options?: PaginationParams | null): Promise => { return this.fetchNamedPage("pinned", options); }; @action - fetchOwned = (options: ?PaginationParams): Promise<*> => { + fetchOwned = (options?: PaginationParams | null): Promise => { return this.fetchNamedPage("list", options); }; @@ -379,13 +393,13 @@ export default class DocumentsStore extends BaseStore { search = async ( query: string, options: { - offset?: number, - limit?: number, - dateFilter?: "day" | "week" | "month" | "year", - includeArchived?: boolean, - includeDrafts?: boolean, - collectionId?: string, - userId?: string, + offset?: number; + limit?: number; + dateFilter?: "day" | "week" | "month" | "year"; + includeArchived?: boolean; + includeDrafts?: boolean; + collectionId?: string; + userId?: string; } ): Promise => { const compactedOptions = omitBy(options, (o) => !o); @@ -431,8 +445,8 @@ export default class DocumentsStore extends BaseStore { }; @action - templatize = async (id: string): Promise => { - const doc: ?Document = this.data.get(id); + templatize = async (id: string): Promise => { + const doc: Document | undefined | null = this.data.get(id); invariant(doc, "Document should exist"); if (doc.template) { @@ -452,11 +466,15 @@ export default class DocumentsStore extends BaseStore { fetch = async ( id: string, options: FetchOptions = {} - ): Promise<{ document: ?Document, sharedTree?: NavigationNode }> => { + ): Promise<{ + document: Document | undefined | null; + sharedTree?: NavigationNode; + }> => { if (!options.prefetch) this.isFetching = true; try { - const doc: ?Document = this.data.get(id) || this.getByUrl(id); + const doc: Document | undefined | null = + this.data.get(id) || this.getByUrl(id); const policy = doc ? this.rootStore.policies.get(doc.id) : undefined; if (doc && policy && !options.force) { return { document: doc }; @@ -485,8 +503,8 @@ export default class DocumentsStore extends BaseStore { move = async ( documentId: string, collectionId: string, - parentDocumentId: ?string, - index: ?number + parentDocumentId?: string | null, + index?: number | null ) => { this.movingDocumentId = documentId; @@ -508,7 +526,7 @@ export default class DocumentsStore extends BaseStore { }; @action - duplicate = async (document: Document): * => { + duplicate = async (document: Document): any => { const append = " (duplicate)"; const res = await client.post("/documents.create", { @@ -582,7 +600,7 @@ export default class DocumentsStore extends BaseStore { _add = this.add; @action - add = (item: Object) => { + add = (item: any) => { const document = this._add(item); if (item.starred !== undefined) { @@ -601,10 +619,10 @@ export default class DocumentsStore extends BaseStore { @action async update(params: { - id: string, - title: string, - text: string, - lastRevision: number, + id: string; + title: string; + text: string; + lastRevision: number; }) { const document = await super.update(params); @@ -616,7 +634,12 @@ export default class DocumentsStore extends BaseStore { } @action - async delete(document: Document, options?: {| permanent: boolean |}) { + async delete( + document: Document, + options?: { + permanent: boolean; + } + ) { await super.delete(document, options); // check to see if we have any shares related to this document already @@ -648,7 +671,10 @@ export default class DocumentsStore extends BaseStore { @action restore = async ( document: Document, - options: { revisionId?: string, collectionId?: string } = {} + options: { + revisionId?: string; + collectionId?: string; + } = {} ) => { const res = await client.post("/documents.restore", { id: document.id, @@ -709,7 +735,7 @@ export default class DocumentsStore extends BaseStore { } }; - getByUrl = (url: string = ""): ?Document => { + getByUrl = (url: string = ""): Document | undefined | null => { return find(this.orderedData, (doc) => url.endsWith(doc.urlId)); }; diff --git a/app/stores/GroupMembershipsStore.js b/app/stores/GroupMembershipsStore.ts similarity index 91% rename from app/stores/GroupMembershipsStore.js rename to app/stores/GroupMembershipsStore.ts index d9e62acf92..6d0766de16 100644 --- a/app/stores/GroupMembershipsStore.js +++ b/app/stores/GroupMembershipsStore.ts @@ -1,4 +1,3 @@ -// @flow import invariant from "invariant"; import { filter } from "lodash"; import { action, runInAction } from "mobx"; @@ -16,7 +15,7 @@ export default class GroupMembershipsStore extends BaseStore { } @action - fetchPage = async (params: ?PaginationParams): Promise<*> => { + fetchPage = async (params?: PaginationParams | null): Promise => { this.isFetching = true; try { @@ -36,7 +35,7 @@ export default class GroupMembershipsStore extends BaseStore { }; @action - async create({ groupId, userId }: { groupId: string, userId: string }) { + async create({ groupId, userId }: { groupId: string; userId: string }) { const res = await client.post("/groups.add_user", { id: groupId, userId, @@ -49,7 +48,7 @@ export default class GroupMembershipsStore extends BaseStore { } @action - async delete({ groupId, userId }: { groupId: string, userId: string }) { + async delete({ groupId, userId }: { groupId: string; userId: string }) { const res = await client.post("/groups.remove_user", { id: groupId, userId, diff --git a/app/stores/GroupsStore.js b/app/stores/GroupsStore.ts similarity index 96% rename from app/stores/GroupsStore.js rename to app/stores/GroupsStore.ts index 98dedec814..3924f1e5d6 100644 --- a/app/stores/GroupsStore.js +++ b/app/stores/GroupsStore.ts @@ -1,4 +1,3 @@ -// @flow import invariant from "invariant"; import { filter } from "lodash"; import { action, runInAction, computed } from "mobx"; @@ -20,7 +19,7 @@ export default class GroupsStore extends BaseStore { } @action - fetchPage = async (params: ?PaginationParams): Promise<*> => { + fetchPage = async (params?: PaginationParams | null): Promise => { this.isFetching = true; try { diff --git a/app/stores/IntegrationsStore.js b/app/stores/IntegrationsStore.ts similarity index 98% rename from app/stores/IntegrationsStore.js rename to app/stores/IntegrationsStore.ts index 04ab8292d9..8854463f0d 100644 --- a/app/stores/IntegrationsStore.js +++ b/app/stores/IntegrationsStore.ts @@ -1,4 +1,3 @@ -// @flow import { filter } from "lodash"; import { computed } from "mobx"; diff --git a/app/stores/MembershipsStore.js b/app/stores/MembershipsStore.ts similarity index 90% rename from app/stores/MembershipsStore.js rename to app/stores/MembershipsStore.ts index 1f6536808c..b85d99586c 100644 --- a/app/stores/MembershipsStore.js +++ b/app/stores/MembershipsStore.ts @@ -1,4 +1,3 @@ -// @flow import invariant from "invariant"; import { action, runInAction } from "mobx"; import Membership from "models/Membership"; @@ -15,7 +14,7 @@ export default class MembershipsStore extends BaseStore { } @action - fetchPage = async (params: ?PaginationParams): Promise<*> => { + fetchPage = async (params?: PaginationParams | null): Promise => { this.isFetching = true; try { @@ -40,9 +39,9 @@ export default class MembershipsStore extends BaseStore { userId, permission, }: { - collectionId: string, - userId: string, - permission: string, + collectionId: string; + userId: string; + permission: string; }) { const res = await client.post("/collections.add_user", { id: collectionId, @@ -60,8 +59,8 @@ export default class MembershipsStore extends BaseStore { collectionId, userId, }: { - collectionId: string, - userId: string, + collectionId: string; + userId: string; }) { await client.post("/collections.remove_user", { id: collectionId, diff --git a/app/stores/NotificationSettingsStore.js b/app/stores/NotificationSettingsStore.ts similarity index 98% rename from app/stores/NotificationSettingsStore.js rename to app/stores/NotificationSettingsStore.ts index cf4968a504..ea57fd782a 100644 --- a/app/stores/NotificationSettingsStore.js +++ b/app/stores/NotificationSettingsStore.ts @@ -1,4 +1,3 @@ -// @flow import { find } from "lodash"; import NotificationSetting from "models/NotificationSetting"; import BaseStore from "./BaseStore"; diff --git a/app/stores/PoliciesStore.js b/app/stores/PoliciesStore.ts similarity index 97% rename from app/stores/PoliciesStore.js rename to app/stores/PoliciesStore.ts index 56bc7b132b..cff9db6ade 100644 --- a/app/stores/PoliciesStore.js +++ b/app/stores/PoliciesStore.ts @@ -1,4 +1,3 @@ -// @flow import Policy from "models/Policy"; import BaseStore from "./BaseStore"; import RootStore from "./RootStore"; diff --git a/app/stores/RevisionsStore.js b/app/stores/RevisionsStore.ts similarity index 92% rename from app/stores/RevisionsStore.js rename to app/stores/RevisionsStore.ts index 348083cd2f..f098cf66b7 100644 --- a/app/stores/RevisionsStore.js +++ b/app/stores/RevisionsStore.ts @@ -1,4 +1,3 @@ -// @flow import invariant from "invariant"; import { filter } from "lodash"; import { action, runInAction } from "mobx"; @@ -44,7 +43,10 @@ export default class RevisionsStore extends BaseStore { } @action - fetch = async (id: string, options?: FetchOptions): Promise => { + fetch = async ( + id: string, + options?: FetchOptions + ): Promise => { this.isFetching = true; invariant(id, "Id is required"); @@ -69,7 +71,7 @@ export default class RevisionsStore extends BaseStore { }; @action - fetchPage = async (options: ?PaginationParams): Promise<*> => { + fetchPage = async (options?: PaginationParams | null): Promise => { this.isFetching = true; try { diff --git a/app/stores/RootStore.js b/app/stores/RootStore.ts similarity index 99% rename from app/stores/RootStore.js rename to app/stores/RootStore.ts index 11a4e06b60..86eef7fc76 100644 --- a/app/stores/RootStore.js +++ b/app/stores/RootStore.ts @@ -1,4 +1,3 @@ -// @flow import ApiKeysStore from "./ApiKeysStore"; import AuthStore from "./AuthStore"; import CollectionGroupMembershipsStore from "./CollectionGroupMembershipsStore"; diff --git a/app/stores/SharesStore.js b/app/stores/SharesStore.ts similarity index 89% rename from app/stores/SharesStore.js rename to app/stores/SharesStore.ts index 39c91e7dc2..1e6f043f0d 100644 --- a/app/stores/SharesStore.js +++ b/app/stores/SharesStore.ts @@ -1,4 +1,3 @@ -// @flow import invariant from "invariant"; import { sortBy, filter, find, isUndefined } from "lodash"; import { action, computed } from "mobx"; @@ -31,7 +30,7 @@ export default class SharesStore extends BaseStore { }; @action - async create(params: Object) { + async create(params: any) { let item = this.getByDocumentId(params.documentId); if (item) return item; @@ -39,7 +38,7 @@ export default class SharesStore extends BaseStore { } @action - async fetch(documentId: string, options?: Object = {}): Promise<*> { + async fetch(documentId: string, options: any = {}): Promise { let item = this.getByDocumentId(documentId); if (item && !options.force) return item; @@ -61,7 +60,7 @@ export default class SharesStore extends BaseStore { } } - getByDocumentParents = (documentId: string): ?Share => { + getByDocumentParents = (documentId: string): Share | undefined | null => { const document = this.rootStore.documents.get(documentId); if (!document) return; @@ -81,7 +80,7 @@ export default class SharesStore extends BaseStore { } }; - getByDocumentId = (documentId: string): ?Share => { + getByDocumentId = (documentId: string): Share | undefined | null => { return find(this.orderedData, (share) => share.documentId === documentId); }; } diff --git a/app/stores/UiStore.js b/app/stores/UiStore.ts similarity index 86% rename from app/stores/UiStore.js rename to app/stores/UiStore.ts index a4638e30e2..80a864d916 100644 --- a/app/stores/UiStore.js +++ b/app/stores/UiStore.ts @@ -1,4 +1,3 @@ -// @flow import { orderBy } from "lodash"; import { observable, action, autorun, computed } from "mobx"; import { v4 as uuidv4 } from "uuid"; @@ -11,23 +10,36 @@ const UI_STORE = "UI_STORE"; class UiStore { // has the user seen the prompt to change the UI language and actioned it - @observable languagePromptDismissed: boolean; + @observable + languagePromptDismissed: boolean; // theme represents the users UI preference (defaults to system) - @observable theme: "light" | "dark" | "system"; + @observable + theme: "light" | "dark" | "system"; // systemTheme represents the system UI theme (Settings -> General in macOS) - @observable systemTheme: "light" | "dark"; - @observable activeDocumentId: ?string; - @observable activeCollectionId: ?string; - @observable progressBarVisible: boolean = false; - @observable isEditing: boolean = false; - @observable tocVisible: boolean = false; - @observable mobileSidebarVisible: boolean = false; - @observable sidebarWidth: number; - @observable sidebarCollapsed: boolean = false; - @observable sidebarIsResizing: boolean = false; - @observable toasts: Map = new Map(); + @observable + systemTheme: "light" | "dark"; + @observable + activeDocumentId: string | undefined | null; + @observable + activeCollectionId: string | undefined | null; + @observable + progressBarVisible: boolean = false; + @observable + isEditing: boolean = false; + @observable + tocVisible: boolean = false; + @observable + mobileSidebarVisible: boolean = false; + @observable + sidebarWidth: number; + @observable + sidebarCollapsed: boolean = false; + @observable + sidebarIsResizing: boolean = false; + @observable + toasts: Map = new Map(); lastToastId: string; constructor() { @@ -177,12 +189,12 @@ class UiStore { showToast = ( message: string, options: { - type: "warning" | "error" | "info" | "success", - timeout?: number, + type: "warning" | "error" | "info" | "success"; + timeout?: number; action?: { - text: string, - onClick: () => void, - }, + text: string; + onClick: () => void; + }; } = { type: "info", } diff --git a/app/stores/UsersStore.js b/app/stores/UsersStore.ts similarity index 94% rename from app/stores/UsersStore.js rename to app/stores/UsersStore.ts index 24197f3dd7..a52af8a5bc 100644 --- a/app/stores/UsersStore.js +++ b/app/stores/UsersStore.ts @@ -1,4 +1,3 @@ -// @flow import invariant from "invariant"; import { filter, orderBy } from "lodash"; import { observable, computed, action, runInAction } from "mobx"; @@ -9,13 +8,14 @@ import RootStore from "./RootStore"; import { client } from "utils/ApiClient"; export default class UsersStore extends BaseStore { - @observable counts: { - active: number, - admins: number, - all: number, - invited: number, - suspended: number, - viewers: number, + @observable + counts: { + active: number; + admins: number; + all: number; + invited: number; + suspended: number; + viewers: number; } = {}; constructor(rootStore: RootStore) { @@ -110,7 +110,12 @@ export default class UsersStore extends BaseStore { }; @action - invite = async (invites: { email: string, name: string }[]) => { + invite = async ( + invites: { + email: string; + name: string; + }[] + ) => { const res = await client.post(`/users.invite`, { invites }); invariant(res && res.data, "Data should be available"); runInAction(`invite`, () => { @@ -122,7 +127,7 @@ export default class UsersStore extends BaseStore { }; @action - fetchCounts = async (teamId: string): Promise<*> => { + fetchCounts = async (teamId: string): Promise => { const res = await client.post(`/users.count`, { teamId }); invariant(res && res.data, "Data should be available"); @@ -131,7 +136,7 @@ export default class UsersStore extends BaseStore { }; @action - async delete(user: User, options: Object = {}) { + async delete(user: User, options: any = {}) { super.delete(user, options); if (!user.isSuspended && user.lastActiveAt) { this.counts.active -= 1; diff --git a/app/stores/ViewsStore.js b/app/stores/ViewsStore.ts similarity index 99% rename from app/stores/ViewsStore.js rename to app/stores/ViewsStore.ts index efbe33d196..2fcb36dd00 100644 --- a/app/stores/ViewsStore.js +++ b/app/stores/ViewsStore.ts @@ -1,4 +1,3 @@ -// @flow import { reduce, filter, find, orderBy } from "lodash"; import View from "models/View"; import BaseStore from "./BaseStore"; diff --git a/app/stores/index.js b/app/stores/index.ts similarity index 91% rename from app/stores/index.js rename to app/stores/index.ts index bd27266da2..dc68230eaa 100644 --- a/app/stores/index.js +++ b/app/stores/index.ts @@ -1,4 +1,3 @@ -// @flow import RootStore from "stores/RootStore"; const stores = new RootStore(); diff --git a/app/test/setup.js b/app/test/setup.ts similarity index 73% rename from app/test/setup.js rename to app/test/setup.ts index 5e49a92f38..aa4b20ad49 100644 --- a/app/test/setup.js +++ b/app/test/setup.ts @@ -1,6 +1,5 @@ -// @flow /* eslint-disable */ -import localStorage from '../../__mocks__/localStorage'; +import localStorage from "../../__mocks__/localStorage"; import Enzyme from "enzyme"; import Adapter from "enzyme-adapter-react-16"; diff --git a/app/test/support.js b/app/test/support.ts similarity index 88% rename from app/test/support.js rename to app/test/support.ts index 3a8df26116..ca16b3f02f 100644 --- a/app/test/support.js +++ b/app/test/support.ts @@ -1,2 +1 @@ -// @flow export const runAllPromises = () => new Promise(setImmediate); diff --git a/app/types/index.js b/app/types/index.js deleted file mode 100644 index db040656d8..0000000000 --- a/app/types/index.js +++ /dev/null @@ -1,60 +0,0 @@ -// @flow -import { type Location } from "react-router-dom"; -import theme from "shared/styles/theme"; -import Document from "models/Document"; - -export type Theme = typeof theme; - -export type LocationWithState = Location & { - state: { - [key: string]: string, - }, -}; - -export type Toast = {| - id: string, - createdAt: string, - message: string, - type: "warning" | "error" | "info" | "success", - timeout?: number, - reoccurring?: number, - action?: { - text: string, - onClick: () => void, - }, -|}; - -export type FetchOptions = { - prefetch?: boolean, - revisionId?: string, - shareId?: string, - force?: boolean, -}; - -export type NavigationNode = {| - id: string, - title: string, - url: string, - children: NavigationNode[], -|}; - -// Pagination response in an API call -export type Pagination = { - limit: number, - nextPath: string, - offset: number, -}; - -// Pagination request params -export type PaginationParams = {| - limit?: number, - offset?: number, - sort?: string, - direction?: "ASC" | "DESC", -|}; - -export type SearchResult = { - ranking: number, - context: string, - document: Document, -}; diff --git a/app/types/index.ts b/app/types/index.ts new file mode 100644 index 0000000000..45b8b26beb --- /dev/null +++ b/app/types/index.ts @@ -0,0 +1,59 @@ +import type { Location } from "react-router-dom"; +import theme from "shared/styles/theme"; +import Document from "models/Document"; + +export type Theme = typeof theme; + +export type LocationWithState = Location & { + state: { + [key: string]: string; + }; +}; + +export type Toast = { + id: string; + createdAt: string; + message: string; + type: "warning" | "error" | "info" | "success"; + timeout?: number; + reoccurring?: number; + action?: { + text: string; + onClick: () => void; + }; +}; + +export type FetchOptions = { + prefetch?: boolean; + revisionId?: string; + shareId?: string; + force?: boolean; +}; + +export type NavigationNode = { + id: string; + title: string; + url: string; + children: NavigationNode[]; +}; + +// Pagination response in an API call +export type Pagination = { + limit: number; + nextPath: string; + offset: number; +}; + +// Pagination request params +export type PaginationParams = { + limit?: number; + offset?: number; + sort?: string; + direction?: "ASC" | "DESC"; +}; + +export type SearchResult = { + ranking: number; + context: string; + document: Document; +}; diff --git a/app/utils/ApiClient.js b/app/utils/ApiClient.ts similarity index 95% rename from app/utils/ApiClient.js rename to app/utils/ApiClient.ts index d717cd52d9..6898b03d61 100644 --- a/app/utils/ApiClient.js +++ b/app/utils/ApiClient.ts @@ -1,4 +1,3 @@ -// @flow import invariant from "invariant"; import { map, trim } from "lodash"; import { getCookie } from "tiny-cookie"; @@ -16,7 +15,7 @@ import { } from "./errors"; type Options = { - baseUrl?: string, + baseUrl?: string; }; // authorization cookie set by a Cloudflare Access proxy @@ -36,8 +35,8 @@ class ApiClient { fetch = async ( path: string, method: string, - data: ?Object | FormData | void, - options: Object = {} + data: any | FormData | void, + options: any = {} ) => { let body; let modifiedPath; @@ -172,11 +171,11 @@ class ApiClient { throw new RequestError(error.message); }; - get = (path: string, data: ?Object, options?: Object) => { + get = (path: string, data?: any | null, options?: any) => { return this.fetch(path, "GET", data, options); }; - post = (path: string, data: ?Object, options?: Object) => { + post = (path: string, data?: any | null, options?: any) => { return this.fetch(path, "POST", data, options); }; diff --git a/app/utils/compressImage.js b/app/utils/compressImage.ts similarity index 81% rename from app/utils/compressImage.js rename to app/utils/compressImage.ts index d378cc004e..d08b857e53 100644 --- a/app/utils/compressImage.js +++ b/app/utils/compressImage.ts @@ -1,7 +1,9 @@ -// @flow import Compressor from "compressorjs"; -type Options = { maxWidth?: number, maxHeight?: number }; +type Options = { + maxWidth?: number; + maxHeight?: number; +}; export const compressImage = async ( file: File | Blob, diff --git a/app/utils/domains.js b/app/utils/domains.ts similarity index 97% rename from app/utils/domains.js rename to app/utils/domains.ts index f7796d725c..d8fa0f667d 100644 --- a/app/utils/domains.js +++ b/app/utils/domains.ts @@ -1,4 +1,3 @@ -// @flow import { parseDomain, stripSubdomain } from "shared/utils/domains"; import env from "env"; diff --git a/app/utils/download.js b/app/utils/download.ts similarity index 99% rename from app/utils/download.js rename to app/utils/download.ts index 89a4dcdc80..9fdf601bf8 100644 --- a/app/utils/download.js +++ b/app/utils/download.ts @@ -1,5 +1,3 @@ -// @flow - // download.js v3.0, by dandavis; 2008-2014. [CCBY2] see http://danml.com/download.html for tests/usage // v1 landed a FF+Chrome compat way of downloading strings to local un-named files, upgraded to use a hidden frame and optional mime // v2 added named files via a[download], msSaveBlob, IE (10+) support, and window.URL support for larger+faster saves than dataURLs diff --git a/app/utils/emoji.js b/app/utils/emoji.ts similarity index 95% rename from app/utils/emoji.js rename to app/utils/emoji.ts index 14fd5d5006..03d0685806 100644 --- a/app/utils/emoji.js +++ b/app/utils/emoji.ts @@ -1,5 +1,3 @@ -// @flow - export function emojiToUrl(text: string) { return `data:image/svg+xml;data:image/svg+xml,${text}`; } diff --git a/app/utils/errors.js b/app/utils/errors.ts similarity index 98% rename from app/utils/errors.js rename to app/utils/errors.ts index db71a7c3eb..50eda03bea 100644 --- a/app/utils/errors.js +++ b/app/utils/errors.ts @@ -1,4 +1,3 @@ -// @flow import ExtendableError from "es6-error"; export class AuthorizationError extends ExtendableError {} diff --git a/app/utils/getDataTransferFiles.js b/app/utils/getDataTransferFiles.ts similarity index 92% rename from app/utils/getDataTransferFiles.js rename to app/utils/getDataTransferFiles.ts index 9822e0dd97..818d670dca 100644 --- a/app/utils/getDataTransferFiles.js +++ b/app/utils/getDataTransferFiles.ts @@ -1,5 +1,5 @@ -// @flow -export default function getDataTransferFiles(event: SyntheticEvent<>): File[] { +import type { SyntheticEvent } from "react"; +export default function getDataTransferFiles(event: SyntheticEvent): File[] { let dataTransferItemsList = []; // $FlowFixMe diff --git a/app/utils/keyboard.js b/app/utils/keyboard.ts similarity index 62% rename from app/utils/keyboard.js rename to app/utils/keyboard.ts index 09e8f1c0c0..70b492a54d 100644 --- a/app/utils/keyboard.js +++ b/app/utils/keyboard.ts @@ -1,12 +1,10 @@ -// @flow +import type { KeyboardEvent } from "react"; const isMac = window.navigator.platform === "MacIntel"; export const metaDisplay = isMac ? "⌘" : "Ctrl"; export const meta = isMac ? "cmd" : "ctrl"; -export function isModKey( - event: KeyboardEvent | MouseEvent | SyntheticKeyboardEvent<> -) { +export function isModKey(event: KeyboardEvent | MouseEvent | KeyboardEvent) { return isMac ? event.metaKey : event.ctrlKey; } diff --git a/app/utils/language.js b/app/utils/language.ts similarity index 93% rename from app/utils/language.js rename to app/utils/language.ts index 722f359b04..46e02f52a5 100644 --- a/app/utils/language.js +++ b/app/utils/language.ts @@ -1,5 +1,3 @@ -// @flow - export function detectLanguage() { const [ln, r] = navigator.language.split("-"); const region = (r || ln).toUpperCase(); diff --git a/app/utils/pageVisibility.js b/app/utils/pageVisibility.ts similarity index 98% rename from app/utils/pageVisibility.js rename to app/utils/pageVisibility.ts index 512b3eb38c..acfa37321b 100644 --- a/app/utils/pageVisibility.js +++ b/app/utils/pageVisibility.ts @@ -1,4 +1,3 @@ -// @flow let hidden = "hidden"; let visibilityChange = "visibilitychange"; diff --git a/app/utils/routeHelpers.js b/app/utils/routeHelpers.ts similarity index 90% rename from app/utils/routeHelpers.js rename to app/utils/routeHelpers.ts index f31557d3aa..b4841c933c 100644 --- a/app/utils/routeHelpers.js +++ b/app/utils/routeHelpers.ts @@ -1,4 +1,3 @@ -// @flow import queryString from "query-string"; import Collection from "models/Collection"; import Document from "models/Document"; @@ -15,7 +14,7 @@ export function newCollectionUrl(): string { return "/collection/new"; } -export function collectionUrl(url: string, section: ?string): string { +export function collectionUrl(url: string, section?: string | null): string { if (section) return `${url}/${section}`; return url; } @@ -61,9 +60,9 @@ export function updateDocumentUrl(oldUrl: string, document: Document): string { export function newDocumentUrl( collectionId: string, params?: { - parentDocumentId?: string, - templateId?: string, - template?: boolean, + parentDocumentId?: string; + templateId?: string; + template?: boolean; } ): string { return `/collection/${collectionId}/new?${queryString.stringify(params)}`; @@ -72,8 +71,8 @@ export function newDocumentUrl( export function searchUrl( query?: string, params?: { - collectionId?: string, - ref?: string, + collectionId?: string; + ref?: string; } ): string { let search = queryString.stringify(params); diff --git a/app/utils/sentry.js b/app/utils/sentry.ts similarity index 92% rename from app/utils/sentry.js rename to app/utils/sentry.ts index 3acabd5ca2..5a72ff62b4 100644 --- a/app/utils/sentry.js +++ b/app/utils/sentry.ts @@ -1,7 +1,6 @@ -// @flow import * as Sentry from "@sentry/react"; import { Integrations } from "@sentry/tracing"; -import { type RouterHistory } from "react-router-dom"; +import type { RouterHistory } from "react-router-dom"; import env from "env"; export function initSentry(history: RouterHistory) { diff --git a/app/utils/uploadFile.js b/app/utils/uploadFile.ts similarity index 92% rename from app/utils/uploadFile.js rename to app/utils/uploadFile.ts index 8cd7384e24..55abc91baa 100644 --- a/app/utils/uploadFile.js +++ b/app/utils/uploadFile.ts @@ -1,16 +1,15 @@ -// @flow import invariant from "invariant"; import { client } from "./ApiClient"; type Options = { - name?: string, - documentId?: string, - public?: boolean, + name?: string; + documentId?: string; + public?: boolean; }; export const uploadFile = async ( file: File | Blob, - options?: Options = { name: "" } + options: Options = { name: "" } ) => { const name = file instanceof File ? file.name : options.name; const response = await client.post("/attachments.create", { diff --git a/app/utils/urls.test.js b/app/utils/urls.test.ts similarity index 97% rename from app/utils/urls.test.js rename to app/utils/urls.test.ts index 8a6741aa41..443546e71c 100644 --- a/app/utils/urls.test.js +++ b/app/utils/urls.test.ts @@ -1,4 +1,3 @@ -// @flow import { decodeURIComponentSafe } from "./urls"; describe("decodeURIComponentSafe", () => { diff --git a/app/utils/urls.js b/app/utils/urls.ts similarity index 98% rename from app/utils/urls.js rename to app/utils/urls.ts index 6f38a6e721..d729ba4303 100644 --- a/app/utils/urls.js +++ b/app/utils/urls.ts @@ -1,4 +1,3 @@ -// @flow import { parseDomain } from "../../shared/utils/domains"; import env from "env";