I'm attempting to reproduce this structure for react navigation route parameters:
export type RootStackParamList = {
"Welcome": undefined;
"Onboarding User": { category: string };
}
Instead of a string as the key, I want to use a variable like shown below
interface path { [key: string]: string }
export const PATHS: path = {
welcome: 'Welcome',
onboardingUser: "Onboarding User",
};
export type RootStackParamList = {
[PATHS.welcome]: undefined;
[PATHS.onboardingUser]: { category: string };
}
The error message says
TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type.
How do I create an interface with a constant variable?