Fallback to project type message on unknown types (#1470)
This commit adds a fallback to getProjectTypeMessage function to return a generic project type whenever it encounters an unknown project type, ensuring there are no errors when the new project types are added.
This commit is contained in:
parent
2d14e5682d
commit
b453e2cf1a
@ -47,6 +47,14 @@ const projectTypeMessages = defineMessages({
|
||||
id: 'project-type.shader.plural',
|
||||
defaultMessage: 'Shaders',
|
||||
},
|
||||
project: {
|
||||
id: 'project-type.project.singular',
|
||||
defaultMessage: 'Project',
|
||||
},
|
||||
projects: {
|
||||
id: 'project-type.project.plural',
|
||||
defaultMessage: 'Projects',
|
||||
},
|
||||
})
|
||||
|
||||
type ExtractSingulars<K extends string> = K extends `${infer T}s` ? T : never
|
||||
@ -54,5 +62,8 @@ type ExtractSingulars<K extends string> = K extends `${infer T}s` ? T : never
|
||||
type ProjectType = ExtractSingulars<keyof typeof projectTypeMessages>
|
||||
|
||||
export function getProjectTypeMessage(type: ProjectType, plural = false) {
|
||||
return projectTypeMessages[`${type}${plural ? 's' : ''}`]
|
||||
return (
|
||||
projectTypeMessages[`${type}${plural ? 's' : ''}`] ??
|
||||
projectTypeMessages[`project${plural ? 's' : ''}`]
|
||||
)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user