我可以检查 cypress 中是否存在文本cy.contains('hello'),但现在我从页面中删除 hello,我想检查 hello 不存在,我该怎么做cy.notContains('hello')?
我收到此错误:
Element implicitly has an 'any' type because expression of type 'any' can't be used to index type '{ foo: string; bar: string; }'.ts(7053)
Run Code Online (Sandbox Code Playgroud)
在此代码中:
const CATEGORY_COLORS = {
foo: '#6f79F6',
bar: '#4fA0E9',
};
const CATEGORY_LABELS = {
foo: 'FOO',
bar: 'BAR',
};
const ItemRenderer = ({ item }: ItemRendererPropsType): React.ReactElement => {
return (
<div>
<Tag color={CATEGORY_COLORS[item.category]}>
{CATEGORY_LABELS[item.category]}
</Tag>
</div>
);
};
Run Code Online (Sandbox Code Playgroud)
CATEGORY_COLORS[item.category]当我将鼠标悬停在 TypeScript或上时会出现错误CATEGORY_LABELS[item.category]。我该如何解决?