I have a long array:
const allRoles = {
'product_manager': [
{
id: 'productManager_1',
image: '/icon.png',
title: 'CEO of the product',
description: 'Some description'.</>,
},
'backend_engineer': [{...}]
...
}
Component code:
// roleTitle = "Product Manager"
export function OverviewModal(roleTitle: string) {
const convertedRole: keyof typeof allRoles = roleTitle.toLowerCase().replace(/ /g,'_');
const roleCardInfo = allRoles[convertedRole];
// Tried the above but got an error:
// Type 'string' is not assignable to type '"product_manager" | "backend_engineer"...'.ts(2322)
In this case, this doesn't seem to apply: Typescript Type 'string' is not assignable to type
Instead of a class, I just have an object of arrays. I'm not sure what type it would be in this scenario.