Improve type defs for styled-components

This commit is contained in:
Junyoung Choi 2020-02-12 01:14:01 +09:00 committed by Junyoung Choi
parent f059e65037
commit ee40a133d1
6 changed files with 6 additions and 16 deletions

View File

@ -45,13 +45,6 @@ const AttachmentList = ({ storage }: AttachmentListProps) => {
event.preventDefault()
popup(event, [
// {
// type: MenuTypes.Normal,
// label: 'Copy Image Reference',
// onClick: () => {
// // TODO Clipboard
// }
// },
{
type: MenuTypes.Normal,
label: 'Download',

View File

@ -2,7 +2,7 @@ import { createGlobalStyle } from 'styled-components'
import { backgroundColor, textColor } from '../lib/styled/styleFunctions'
import { BaseTheme } from '../lib/styled/BaseTheme'
export default createGlobalStyle<BaseTheme>`
export default createGlobalStyle<{ theme: BaseTheme }>`
body {
margin: 0;
${backgroundColor}

View File

@ -60,7 +60,7 @@ export default () => {
useGlobalKeyDownHandler(keydownHandler)
const backgroundClickHandler = useMemo(() => {
return (event: MouseEvent) => {
return (event: React.MouseEvent<HTMLDivElement>) => {
event.preventDefault()
closeHandler()
}

View File

@ -1,6 +1,6 @@
import React, { useMemo, useCallback } from 'react'
import { tutorialsTree, TutorialsNavigatorTreeItem } from '../../lib/tutorials'
import SideNavigatorItem from '../SideNavigator/SideNavigatorItem'
import SideNavigatorItem from '../molecules/SideNavigatorItem'
import { useRouter, useCurrentTutorialPathname } from '../../lib/router'
import { useGeneralStatus } from '../../lib/generalStatus'
import { useContextMenu, MenuTypes } from '../../lib/contextMenu'

View File

@ -1,7 +1,7 @@
import React from 'react'
import styled from '../../lib/styled'
const StyledButtonIcon = styled.button<{ active: boolean }>`
const StyledButtonIcon = styled.button`
color: currentColor;
background-color: transparent;
border: none;

View File

@ -1,12 +1,9 @@
declare module 'styled-components' {
export type StyledComponent<T1, T2, T3, T4> = any
export function createGlobalStyle<T>(
export function createGlobalStyle<P>(
strings: TemplateStringsArray,
...keys: Array<
| number
| undefined
| string
| ((props: { theme: T }) => string | number | undefined)
number | undefined | string | ((props: P) => string | number | undefined)
>
): any
export type ThemedBaseStyledInterface<T> = {