mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-30 09:17:56 +00:00
d16dc9a739
* refactor(config/global): improve type restrictions for `GlobalConfig.OPTIONS` Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io> * fixup! refactor(config/global): improve type restrictions for `GlobalConfig.OPTIONS` --------- Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>
25 lines
1.1 KiB
TypeScript
25 lines
1.1 KiB
TypeScript
import { GlobalConfig } from './global.ts';
|
|
import type { InternalGlobalConfigOptions, RepoGlobalConfig } from './types.ts';
|
|
|
|
describe('config/global', () => {
|
|
it('OPTIONS contains every key of RepoGlobalConfig', () => {
|
|
// If this fails to compile, a field was added to (or removed from) `RepoGlobalConfig` without updating `GlobalConfig.OPTIONS` to match
|
|
// Unlike the forward direction (every entry in OPTIONS is a valid key of RepoGlobalConfig), which is enforced by the `satisfies` clause on OPTIONS itself, this direction can't be caught by the compiler any other way: adding an optional field to an interface doesn't require every array of its keys to be updated
|
|
//
|
|
// In more rare cases, it's been missed from InternalGlobalConfigOptions
|
|
expectTypeOf<(typeof GlobalConfig.OPTIONS)[number]>().toEqualTypeOf<
|
|
keyof RepoGlobalConfig | keyof InternalGlobalConfigOptions
|
|
>();
|
|
});
|
|
|
|
it('all values in OPTIONS are sorted', () => {
|
|
const defined = GlobalConfig.OPTIONS;
|
|
|
|
const sorted = [...defined].sort();
|
|
|
|
expect(defined, 'OPTIONS should be sorted alphabetically').toStrictEqual(
|
|
sorted,
|
|
);
|
|
});
|
|
});
|