I'm looking to create a typed array where each element is made up of different data types, eliminating the need for manual casting. Currently, I have an array called 'cases' that contains arrays with a string as the first element and a boolean as the second.
const cases = [
[ 'http://gmail.com', false ],
[ '/some_page', true ],
[ 'some_page', false ]
]
describe("'isInternalLink' utility", () => {
test.each(cases)(
"given %p as argument, returns %p", (link, result) => {
expect(
isInternalLink(<string>link)
).toEqual(
<boolean> result
)
}
)
})
Instead of having an array of 'string | boolean' type, I want to specify separate data types for the first and second elements in each array within 'cases'.
If you have any suggestions on how to achieve this efficiently, please let me know!