fix: narrow ParsedConfigValue to LocalEmulatorConfigValue with type guard

Co-Authored-By: mantra <mantra@stack-auth.com>
This commit is contained in:
Devin AI 2026-06-24 00:06:17 +00:00
parent f71cde84b8
commit 97b1a2f960

View File

@ -76,7 +76,14 @@ async function readConfigContent(filePath: string): Promise<string> {
async function readConfigValueFromFile(filePath: string): Promise<LocalEmulatorConfigValue> {
const content = await readConfigContent(filePath);
try {
return evalConfigFileContent(content, filePath);
const result = evalConfigFileContent(content, filePath);
if (typeof result === "string") {
if (result !== LOCAL_EMULATOR_SHOW_ONBOARDING_VALUE) {
throw new Error(`Unexpected string config value: ${JSON.stringify(result)}`);
}
return result;
}
return result;
} catch (e) {
const message = e instanceof Error ? e.message : String(e);
throw new StatusError(StatusError.BadRequest, `Error evaluating config in ${filePath}: ${message}`);