Skip to content

Support ?? in observable bindings#33

Merged
rajsite merged 8 commits intoarchives/fast-element-1from
users/makinc/template-null-coalesce
Feb 3, 2026
Merged

Support ?? in observable bindings#33
rajsite merged 8 commits intoarchives/fast-element-1from
users/makinc/template-null-coalesce

Conversation

@m-akinc
Copy link

@m-akinc m-akinc commented Feb 2, 2026

Pull Request

Motivation

We are enabling a new eslint rule (@typescript-eslint/strict-boolean-expressions) in Nimble that disallows using non-booleans in boolean expressions. We have some template bindings like x.foo || 'default_val' which are flagged by this rule and would ideally be rewritten as x.foo ?? 'default_val'. However, without proper support for ?? in binding expressions, we would have to rewrite them as x.foo !== undefined ? x.foo : 'default_value', which is excessively verbose.

📖 Description

See ni/nimble#2127

The observable binding logic uses a regex pattern to determine which kinds of expressions in a binding should cause the binding to be marked as volatile. The regex did not include ??, presumably because the FAST libraries targeted es2015, in which a binding like (x) => x.trigger ?? x.value would be transpiled to something like (x) => { var _a; return (_a = x.trigger) !== null && _a !== void 0 ? _a : x.value; }. However, a client library like Nimble, which targets a later version of the language that directly supports ?? requires FAST to include ?? in its regex.

As part of this change, I've:

  • updated the regex to include ??
  • changed the target of the FAST libraries to es2022 (for consistency with our client libraries)
  • fixed an unrelated issue with aggregate bindings never being marked as volatile
  • added test cases

@m-akinc m-akinc requested a review from rajsite February 2, 2026 23:54
Copy link
Member

@rajsite rajsite left a comment

Choose a reason for hiding this comment

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

Waiting for successful build 👍

@m-akinc m-akinc requested a review from rajsite February 3, 2026 18:54
@m-akinc m-akinc enabled auto-merge (squash) February 3, 2026 19:06
Copy link
Member

@rajsite rajsite left a comment

Choose a reason for hiding this comment

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

Looks like most of the test suite was accidentally disabled. If enabling the tests causes additional changes to be needed would like to take a look, please reset. If enabling the tests allows them to pass without further changes then feel free to merge

@m-akinc m-akinc disabled auto-merge February 3, 2026 23:52
@rajsite rajsite merged commit ad97e08 into archives/fast-element-1 Feb 3, 2026
3 checks passed
@rajsite rajsite deleted the users/makinc/template-null-coalesce branch February 3, 2026 23:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants