I cannot use to array method for testing library.
My test code is like below.
const ListTitle = fakeData.forEach((el) => {
el.filter((element: string | object) => (typeof element === "string" ? element : element?.props?.children)); **** filter method has a error ts.2339
});
Attached, I want to exclude only text in fakeData array.
fakeData is like below the code.
interface FakeDataProps {
id:number
titleChild:JSX.Element
}
const fakeData: FakeDataProps[] = [
{
id: 1,
titleChild: (
<>
party goes on <span style=> The end</span>
</>
),
},
{
id: 2,
titleChild: (
<>
party goes on <span style=>The end</span> Your time
is ...{" "}
</>
),
},
{
id: 3,
titleChild: (
<>
party goes on <span style=>The end</span>
</>
)
}
];
I expected
[ "party goes on The end", "party goes on The end Your time is ...", "party goes on The end", ]
But, In my test code, There are error occured that has "Property 'filter' does not exist on type 'FakeDataProps'.ts(2339)"
What shall I do?
Aucun commentaire:
Enregistrer un commentaire