我在运行时加载JSON配置文件,并使用接口定义其预期 struct :
interface EngineConfig {
pathplanner?: PathPlannerConfig;
debug?: DebugConfig;
...
}
interface PathPlannerConfig {
nbMaxIter?: number;
nbIterPerChunk?: number;
heuristic?: string;
}
interface DebugConfig {
logLevel?: number;
}
...
这使得访问各种属性变得很方便,因为我可以使用自动补全等功能.
问题:is there a way to use this declaration to check the correctness of the file I load? ie that I do not have unexpected properties?