Skip to content

fix(web_core): return any from an untyped DataModel.get call - #4054

Open
Anoshor wants to merge 9 commits into
a2ui-project:mainfrom
Anoshor:fix/datamodel-get-overload
Open

Anoshor wants to merge 9 commits into
a2ui-project:mainfrom
Anoshor:fix/datamodel-get-overload

Conversation

@Anoshor

@Anoshor Anoshor commented Nov 8, 2026

Copy link
Copy Markdown

Description

DataModel.get<T = any>(path): T lets TypeScript infer T from where the call sits. Inside an overloaded callee such as expect(...) with an accessibility matcher augmentation (expect(actual: A11yCheckResult): A11yCheckJasmineMatcher), T is inferred from that first overload's parameter, the overload matches, and the test fails to compile:

error TS2339: Property 'toBeFalse' does not exist on type 'A11yCheckJasmineMatcher'.

This adds a non-generic get(path: string): any overload ahead of get<T>(path: string): T, as proposed in the issue. An untyped call now returns any; overload resolution's first pass compares by subtype, and any is not a subtype of A11yCheckResult, so the generic expect<T> overload is chosen. model.get<string>(path) still returns string. The implementation signature and body are unchanged.

Verification:

  • New test in data-model.test.ts declares a local overloaded check() and calls check(model.get('/flag')).isFalse(). Its assertion is the build: with the change reverted, tsc fails with TS2339: Property 'isFalse' does not exist on type '{ isOther(): boolean; }'.
  • yarn test in typescript/core/web_core: 1535 passed, 0 failed.

Fixes #3784

Pre-launch Checklist

One time:

For this PR:

  • I have updated the relevant CHANGELOG.md file.
  • I updated/added relevant documentation.
  • My code changes (if any) have tests.
  • If my branch is on a fork, I have verified that scripts/e2e_test.sh passes.

`get<T = any>(path): T` lets TypeScript infer `T` from the call site, so
`expect(model.get(path))` with an overloaded `expect` (such as an
accessibility matcher augmentation) infers `T` from the first overload and
picks it, failing with TS2339 on the Jasmine matcher.

Add a non-generic `get(path): any` overload ahead of `get<T>(path): T`.
An untyped call resolves to `any`, which overload resolution does not treat
as a subtype of the other overload parameter, and `get<string>(path)` still
returns `string`.

Fixes a2ui-project#3784

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

Copy link
Copy Markdown
Contributor

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 updates DataModel.get(path) in typescript/core/web_core/src/state/data-model.ts by adding overloads so that calling it without a type argument explicitly returns any instead of inferring the type from the context. This prevents overloaded callees from incorrectly inferring the result type. A corresponding test case has been added to data-model.test.ts, and the CHANGELOG.md has been updated. There are no review comments, so I have no feedback to provide.

@github-actions github-actions Bot added the status: needs-triage auto-managed: https://github.com/a2ui-project/a2ui/blob/main/scripts/triage.mjs label Nov 8, 2026
# Conflicts:
#	typescript/core/web_core/CHANGELOG.md
@Anoshor

Anoshor commented Nov 12, 2026

Copy link
Copy Markdown
Author

Hi @jacobsimionato, this adds the non-generic get(path): any overload you proposed in #3784, with a compile-time test that fails without it. It's up to date with main and mergeable. Could you take a look when you have time?

@polina-c

polina-c commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

From triage bot, analysis:

For humans

TL;DR
Case: this external PR is a small bug fix for an issue filed by a team member.
Suggestion: review it and assign jacobsimionato.

Summary:
The PR adds a non-generic get(path): any overload to DataModel.get in @a2ui/web_core, so that an untyped call such as expect(model.get(path)) no longer infers its type from an overloaded callee. It fixes #3784.

Targeted issues:
#3784

Why flagged for triage:
This external PR has no assignee.

Suggestion:
Review the PR and assign jacobsimionato, who filed #3784 and proposed this exact fix in it. The author asked them for a review on 2026-11-12, with no answer yet. It is a small bug fix: two overload lines above get in data-model.ts, and a test that fails to compile without them. gspencergoog, who wrote all 3 commits to data-model.ts, is the other choice. The PR merges cleanly with main, and its CI runs wait for maintainer approval. #3784 has no priority label yet.

  1. Add labels: component: core sdk, type: bug
  2. Assign: jacobsimionato

To adjust the analysis and apply its suggestion, run in your a2ui checkout:

tools/internal/triage/triage_ui.sh https://github.com/a2ui-project/a2ui/pull/4054
For software
<a2ui>
root = TriageAnalysis(
  tldr="""Case: this external PR is a small bug fix for an issue filed by a team member.
Suggestion: review it and assign `jacobsimionato`.""",
  summary="""The PR adds a non-generic `get(path): any` overload to `DataModel.get` in `@a2ui/web_core`, so that an untyped call such as `expect(model.get(path))` no longer infers its type from an overloaded callee. It fixes #3784.""",
  reason="""This external PR has no assignee.""",
  suggestion="""Review the PR and assign `jacobsimionato`, who filed #3784 and proposed this exact fix in it. The author [asked them](https://github.com/a2ui-project/a2ui/pull/4054#issuecomment-6833006115) for a review on 2026-11-12, with no answer yet. It is a small bug fix: two overload lines above [`get`](https://github.com/a2ui-project/a2ui/blob/496df0e76e2ad9aba4cc2a12abe066f43d4f171d/typescript/core/web_core/src/state/data-model.ts#L325) in `data-model.ts`, and a test that fails to compile without them. `gspencergoog`, who wrote [all 3 commits](https://github.com/a2ui-project/a2ui/commits/main/typescript/core/web_core/src/state/data-model.ts) to `data-model.ts`, is the other choice. The PR merges cleanly with `main`, and its CI runs wait for maintainer approval. #3784 has no priority label yet.""",
  added_labels=["component: core sdk", "type: bug"],
  new_assignees=["jacobsimionato"],
  targeted_issues=[3784]
)
</a2ui>

This analysis is auto-created to help humans to triage this item. Please, do not treat it as a team decision.

🤖 Agent-generated

@polina-c

Copy link
Copy Markdown
Collaborator

Thanks for the fix and the compile-time test. Assigning this PR to jacobsimionato, who proposed this overload in #3784, to decide on it.

@polina-c polina-c added component: core sdk Affects the core SDK layer in any language lang: typescript Typescript agent SDK issues status: assigned-for-triage issue/pr is assigned to a domain expert for further triage type: bug Something isn't working and removed status: needs-triage auto-managed: https://github.com/a2ui-project/a2ui/blob/main/scripts/triage.mjs labels Nov 20, 2026
# Conflicts:
#	typescript/core/web_core/CHANGELOG.md
# Conflicts:
#	typescript/core/web_core/CHANGELOG.md
Comment thread typescript/core/web_core/CHANGELOG.md Outdated
@@ -1,5 +1,6 @@
## Unreleased

- `DataModel.get(path)` called without a type argument returns `any` instead of inferring its result type from the context, so a call such as `expect(model.get(path))` no longer picks an overload of `expect` (for example an accessibility matcher's) from that inference. `get<T>(path)` still returns `T`. [#3784](https://github.com/a2ui-project/a2ui/issues/3784)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

There's no blank line between this new entry and the ## 0.16.1 heading below it, which will cause the Presubmit Lint formatting check (prettier --check) to fail in CI. While adding that blank line, please also include a link to this PR (#4054) alongside the issue link per our changelog convention.

Additional details

Resolving the CHANGELOG.md merge conflict in 9c3cf2c9b3 dropped the blank line before ## 0.16.1. .github/workflows/presubmit-lint.yml runs ./scripts/fix_format.sh --check (prettier@3.8.4 --config .prettierrc --check .), which fails on this file as written. Also, per the changelog convention, entries should end with a link to their pull request ([#4054](https://github.com/a2ui-project/a2ui/pull/4054)).

Suggested change
- `DataModel.get(path)` called without a type argument returns `any` instead of inferring its result type from the context, so a call such as `expect(model.get(path))` no longer picks an overload of `expect` (for example an accessibility matcher's) from that inference. `get<T>(path)` still returns `T`. [#3784](https://github.com/a2ui-project/a2ui/issues/3784)
- `DataModel.get(path)` called without a type argument returns `any` instead of inferring its result type from the context, so a call such as `expect(model.get(path))` no longer picks an overload of `expect` (for example an accessibility matcher's) from that inference. `get<T>(path)` still returns `T`. [#3784](https://github.com/a2ui-project/a2ui/issues/3784), [#4054](https://github.com/a2ui-project/a2ui/pull/4054)

🤖 Agent-generated

# Conflicts:
#	typescript/core/web_core/CHANGELOG.md
…entry and keep the blank line before the heading
@Anoshor

Anoshor commented Nov 27, 2026

Copy link
Copy Markdown
Author

Thanks. Fixed in f05f7b9: the blank line before the next heading is back, and the entry now links this PR as well as #3784. prettier --check passes on the changelog, and web_core passes 1668 tests on current main.

# Conflicts:
#	typescript/core/web_core/CHANGELOG.md
@Anoshor

Anoshor commented Dec 3, 2026

Copy link
Copy Markdown
Author

Hi @jacobsimionato, thanks for the approval. I've merged main in again, so this is mergeable, and web_core passes 1709 tests on it. Could you merge it when you have a moment?

This branch has not been deployed

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

Labels

component: core sdk Affects the core SDK layer in any language lang: typescript Typescript agent SDK issues status: assigned-for-triage issue/pr is assigned to a domain expert for further triage type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[web_core] DataModel.get<T = any> causes contextual type inference collisions with custom matchers

3 participants