def METHOD_NAME(value: str, allow_quoted: bool) -> str:
    """Normalize a namespace, e.g. variable name, or object key, to values supported by TS.
    Args:
        value: A string to normalize.
        allow_quoted: Whether to allow quoting the value.
    Returns:
        A normalized value
    """
    if not allow_quoted and not value[0].isalpha() and value[0] not in {"_", "$"}:
        raise ValueError(f"invalid typescript namespace {value}")
    if allow_quoted:
        return value if allowed_key_re.fullmatch(value) else f'"{value}"'
    return invalid_namespace_re.sub("", value)