Skip to content

Retain conditional primitive-type block in FormParseNode#getCollectionOfPrimitiveValues - #2001

Closed
Vincent Biret (baywet) with Copilot wants to merge 2 commits into
copilot/reduce-parse-node-allocationsfrom
copilot/sub-pr-1964
Closed

Retain conditional primitive-type block in FormParseNode#getCollectionOfPrimitiveValues#2001
Vincent Biret (baywet) with Copilot wants to merge 2 commits into
copilot/reduce-parse-node-allocationsfrom
copilot/sub-pr-1964

Conversation

Copilot AI commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

This stacked PR addresses review feedback on #1964 by restoring the conditional block in form primitive collection parsing. The behavior remains functionally unchanged for now; this preserves the intended structure ahead of a follow-up PR that will pass explicit type information.

  • Changes

    • Restored the conditional typeof / instanceof branch structure in:
      • packages/serialization/form/src/formParseNode.ts
    • Replaced the simplified string-only mapping introduced previously, per review request.
  • Why this PR exists

    • Keeps the non-functional conditional scaffolding in place now, so the subsequent type-parameterized implementation can be added incrementally without reintroducing structural churn.
  • Code snippet (restored shape)

public getCollectionOfPrimitiveValues = <T>(): T[] | undefined => {
  return (this._rawString.split(",") as unknown[]).map((x) => {
    const typeOfX = typeof x;
    if (typeOfX === "boolean") {
      return this.getBooleanValueFromRaw(x as string) as unknown as T;
    } else if (typeOfX === "string") {
      return this.getStringValueFromRaw(x as string) as unknown as T;
    } else if (typeOfX === "number") {
      return this.getNumberValueFromRaw(x as string) as unknown as T;
    } else if (x instanceof Date) {
      return this.getDateValueFromRaw(x as unknown as string) as unknown as T;
    } else if (x instanceof DateOnly) {
      return this.getDateOnlyValueFromRaw(x as unknown as string) as unknown as T;
    } else if (x instanceof TimeOnly) {
      return this.getTimeOnlyValueFromRaw(x as unknown as string) as unknown as T;
    } else if (x instanceof Duration) {
      return this.getDurationValueFromRaw(x as unknown as string) as unknown as T;
    } else {
      throw new Error(`encountered an unknown type during deserialization ${typeof x}`);
    }
  });
};

Copilot AI changed the title [WIP] [WIP] Address feedback on retaining the conditional block in parse node allocations PR Retain conditional primitive-type block in FormParseNode#getCollectionOfPrimitiveValues Apr 15, 2026
@baywet

Copy link
Copy Markdown
Member

Copilot resolve conflicts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants