Commit 16e37788 authored by Alejandro Celaya's avatar Alejandro Celaya Committed by Alejandro Celaya

Remove runtime check for case that can be checked via types

parent 45aca203
......@@ -31,15 +31,11 @@ type ConfigDefinitionMap = Record<string, ConfigDefinition>;
*/
type Context = 'sidebar' | 'notebook' | 'profile' | 'annotator' | 'all';
function throwInvalidContext(context: string): never {
throw new Error(`Invalid application context used: "${context}"`);
}
/**
* Returns the configuration keys that are relevant to a particular context.
*/
function configurationKeys(context: Context): string[] {
const contexts = {
const contexts: Record<Exclude<Context, 'all'>, string[]> = {
annotator: [
'clientUrl',
'contentInfoBanner',
......@@ -82,7 +78,7 @@ function configurationKeys(context: Context): string[] {
return Object.values(contexts).flat();
}
return contexts[context] ?? throwInvalidContext(context);
return contexts[context];
}
const getHostPageSetting: ValueGetter = (settings, name) =>
......
......@@ -282,10 +282,4 @@ describe('annotator/config/index', () => {
});
});
});
it(`throws an error if an invalid context was passed`, () => {
assert.throws(() => {
getConfig('fake', 'WINDOW');
}, 'Invalid application context used: "fake"');
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment