【发布时间】:2023-04-05 03:12:01
【问题描述】:
考虑以下测试代码:
import { isHtmlLinkDescriptor } from '@remix-run/react/links'
import invariant from 'tiny-invariant'
import { links } from '~/root'
it('should return a rel=stylesheet', () => {
const response = links()
invariant(isHtmlLinkDescriptor(response[0]))
expect(response[0].rel).toBe('stylesheet')
})
和实施:
import { LinksFunction } from 'remix'
import tailwindProdUrl from '~/styles/tailwind.css'
export const links: LinksFunction = () => {
const href =
process.env.NODE_ENV !== 'production' ? './tailwind.css' : tailwindProdUrl
return [{ rel: 'stylesheet', href }]
}
其中LinksFunction 定义为here 和here。
为什么 ESLint 抱怨“any 值的分配不安全”。和“any 类型值的不安全调用。”在下面一行?
const response = links()
【问题讨论】:
标签: javascript typescript eslint