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