fix: define user's config as DeepPartial
This commit is contained in:
@@ -1,8 +1,17 @@
|
||||
import defaultConfig from "../../data/config.default.json";
|
||||
import _userConfig from "../../data/config.json";
|
||||
|
||||
const userConfig = _userConfig as typeof defaultConfig;
|
||||
const config = { ...defaultConfig, ...userConfig };
|
||||
type DeepPartial<T> = T extends object
|
||||
? {
|
||||
[P in keyof T]?: DeepPartial<T[P]>;
|
||||
}
|
||||
: T;
|
||||
|
||||
type Config = typeof defaultConfig;
|
||||
type UserConfig = DeepPartial<typeof defaultConfig>;
|
||||
|
||||
const userConfig = _userConfig as UserConfig;
|
||||
const config = { ...defaultConfig, ...userConfig } as Config;
|
||||
|
||||
if (userConfig.colors)
|
||||
config.colors = { ...defaultConfig.colors, ...userConfig.colors };
|
||||
|
||||
Reference in New Issue
Block a user