Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[FR] Public API to Detect FieldValue.increment()

未关闭
#2,957 2 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

@ehsannas 已经在做这个了。

开始于 2025年8月12日。

评估

这个 Issue 还没有评估数据。

描述

api: firestore type: feature request

The Firebase Admin Node SDK currently does not provide a public API to detect if a value is a FieldValue.increment() object. This forces developers to rely on internal implementation details like checking for constructor.name === 'NumericIncrementTransform', which is fragile and may break with SDK updates.

Current Workaround

// Current approach relies on internal implementation
function hasFieldValueIncrement(value: unknown): boolean {
  return (
    typeof value === 'object' &&
    value.constructor &&
    value.constructor.name === 'NumericIncrementTransform'
  );
}

Problem

  1. Fragility: The NumericIncrementTransform class name is an internal implementation detail
  2. No Stability Guarantee: This approach may break in future SDK versions
  3. Lack of Documentation: No official way to detect increment operations

Requested Enhancement

Please provide a public API method to detect FieldValue.increment() objects, similar to how other Firebase features provide type guards.

Suggested API
import { FieldValue } from 'firebase-admin/firestore';

// Option 1: Static method on FieldValue
FieldValue.isIncrement(value: unknown): value is FieldValue

// Option 2: Dedicated type guard function
import { isIncrement } from 'firebase-admin/firestore';
isIncrement(value: unknown): value is FieldValue

Use Case

This is needed for:

  • Data validation pipelines that need to identify increment operations
  • Custom diffing systems that handle FieldValue operations differently
  • Development tools that analyze Firestore update patterns
  • Testing utilities that need to verify increment operations
主要语言
TypeScript
星标
1.7k
派生
419
平均合并
4 天 20 小时
30 天内合并 PR
16

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

firebase/firebase-admin-node 的其他 Issue

查看 firebase/firebase-admin-node 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。