Skip to content

Conversation

@btw17
Copy link
Member

@btw17 btw17 commented Feb 10, 2026

When implementing a custom node, StringValue is incompatible with ResolvedValue despite being supported for nodes like TextNode. The ResolvedMap type requires that all provided keys be non-optional, so I've updated it to support optional keys.

Description

Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.

List which issues are fixed by this PR. For larger changes, raising an issue first helps reduce redundant work.

Pre-launch Checklist

If you need help, consider asking for advice on the discussion board.

When implementing a custom node, [StringValue](https://github.com/google/A2UI/blob/main/renderers/web_core/src/v0_8/types/primitives.ts#L17) is incompatible with [ResolvedValue](https://github.com/google/A2UI/blob/main/renderers/web_core/src/v0_8/types/types.ts#L305) despite being supported for nodes like `TextNode`. The `ResolvedMap` type requires that all provided keys be non-optional, so I've updated it to support optional keys.
@github-project-automation github-project-automation bot moved this to Todo in A2UI Feb 10, 2026
@btw17 btw17 marked this pull request as draft February 10, 2026 16:30
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request aims to fix a type incompatibility with ResolvedMap for primitive-like objects such as StringValue by making the index signature property optional. However, this change does not solve the underlying TypeScript issue. I've provided a critical comment with a suggested fix to correctly address the type assignability problem.


/** A generic map where each value has been recursively resolved. */
export type ResolvedMap = { [key: string]: ResolvedValue };
export type ResolvedMap = { [key: string]?: ResolvedValue };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This change does not fix the underlying type issue. An object with optional properties (e.g., prop?: T) is not assignable to {[key: string]?: T} because the type of the optional property is T | undefined, which is not assignable to T. In this case, ResolvedValue does not include undefined.

To correctly fix the type assignability for objects with optional properties, the value type of the index signature must include undefined.

While this is a significant change to the type definition, it appears safe with respect to the current implementation of resolvePropertyValue, which does not produce undefined values. This change is necessary to correctly type the relationship between primitive objects with optional fields and ResolvedMap.

Suggested change
export type ResolvedMap = { [key: string]?: ResolvedValue };
export type ResolvedMap = { [key: string]: ResolvedValue | undefined };

@btw17 btw17 closed this Feb 10, 2026
@github-project-automation github-project-automation bot moved this from Todo to Done in A2UI Feb 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant