Reactjs TypeScript React,导出样式化组件函数

Reactjs TypeScript React,导出样式化组件函数,reactjs,typescript,styled-components,Reactjs,Typescript,Styled Components,我正在导出一个函数,用作React上的样式化组件的混合 styles.ts export const fontSize = (size: number) => ` font-size: ${(size / 16) * 100}%; font-size: ${size / 16}rem; ` button.tsx import React, { FC } from 'react' import styled from 'styled-components' import { fo

我正在导出一个函数,用作React上的样式化组件的混合

styles.ts

export const fontSize = (size: number) => `
  font-size: ${(size / 16) * 100}%;
  font-size: ${size / 16}rem;
`
button.tsx

import React, { FC } from 'react'
import styled from 'styled-components'

import { fontSize } from './styles'

type ButtonProps = {
  onClick(): void
}

const StyledButton = styled.button`
  background-color: #4f2e0e;
  font-size: ${fontSize(18)};
  cursor: pointer;
`

const Button: FC<ButtonProps> = (props) => (
  <StyledButton>{props.children}</StyledButton>
)

export default Button
我已尝试将
allowExpressions:true
添加到
.eslintjs
中,但不起作用:

'@typescript-eslint/explicit-function-return-type': ['warn', { allowExpressions: true}]

尝试添加函数的返回类型
fontSize
。示例:
export const fontSize=(size:number):string=>…
@CarmeloCatalfamo哇,很简单,谢谢。我需要了解TypeScript的类型声明
'@typescript-eslint/explicit-function-return-type': ['warn', { allowExpressions: true}]