I am currently working on implementing the documentation provided here.
This is the code snippet I have:
enum InputFieldName {
ReactionsCheckbox = 'reactionsEnabled',
SettingsCheckbox = 'settingsEnabled',
}
type PropEventSource<Type> = `${string & keyof Type}Checkbox`;
const inputMap: Record<InputFieldName, PropEventSource<InputFieldName>> = {
[InputFieldName.ReactionsCheckbox]: 'reactionsEnabledCheckbox',
[InputFieldName.SettingsCheckbox]: 'settingsEnabledCheckbox',
}
const fieldName = inputMap[InputFieldName.ReactionsCheckbox]
console.log('fieldName', fieldName);
Although I am able to see ‘reactionsEnabledCheckbox’ in the console correctly, I am encountering a TypeScript error:
Type of computed property's value is '"settingsEnabledCheckbox"',
which is not assignable to type '"charAtCheckbox" | "charCodeAtCheckbox"
| "concatCheckbox" | "indexOfCheckbox" | "lastIndexOfCheckbox"
| "localeCompareCheckbox" | "matchCheckbox" | "replaceCheckbox" | ... 33 more ... | "valueOfCheckbox
Can anyone provide guidance on how to resolve this issue?
Furthermore, it seems like prettier is not recognizing the following line as valid code:
type PropEventSource<Type> = `${string & keyof Type}Checkbox`;