TanStack / form

🤖 Powerful and type-safe form state management for the web. TS/JS, React Form, Solid Form, Lit Form and Vue Form.

Home Page:https://tanstack.com/form

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Angular form does not allow standard html attributes for boolean and number inputs

jyjor opened this issue · comments

Describe the bug

Boolean and number attributes in Angular do not follow typical HTML conventions. Here are some examples:
<div myInput> - In Angular, myInput is '', but in standard HTML it is the boolean value true.
<div myInput="true"> - In Angular, myInput is the string 'true', but in standard HTML it is the boolean value true.

Angular has transform functions to address these discrepancies and it looks like the number and boolean inputs are missing these. This is a simple problem with a simple fix, and I would love put up a PR to fix it.

Side note - I spoke with Corbin at ng-conf during a lunch break, was very impressed with him from our short conversation, and he inspired me to take a look. He also said he won't respond with " ☹️ " and close the issue, even though it's small.

Your minimal, reproducible example

https://stackblitz.com/edit/stackblitz-starters-pszun1?file=src%2Fmain.ts

Steps to reproduce

  1. Open the linked example
  2. Note the error on line 19 of main.ts

NG2: Type '""' is not assignable to type 'boolean | undefined'.

  1. Change the line to asyncAlways="true" to get the same error
  2. Change the line to [asyncAlways]="true" and it will be fixed.
  3. In addition to asyncAlways, this also applies toasyncDebounceMs and preserveValue attributes.

Expected behavior

asyncAlways and asyncAlways="true" should be equivalent to [asyncAlways]="true" and asyncAlways="false" should be equivalent to [asyncAlways]="false".

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • OS: Linux
  • Browser: Chrome
  • Version 0.17.0

TanStack Form adapter

None

TanStack Form version

0.17.0

TypeScript version

5.4.2

Additional context

In the "TanStack Form adapter" drop down above, there is no option for "angular-form", but that is the version with the error.

If you're up for it, I'd accept a PR adding the transforms 😊 Let's just make sure it doesn't break the TS type inferencing