Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FormControlState should be able to take unknown as generic type #277

Open
Yohandah opened this issue Apr 22, 2022 · 0 comments
Open

FormControlState should be able to take unknown as generic type #277

Yohandah opened this issue Apr 22, 2022 · 0 comments
Labels

Comments

@Yohandah
Copy link

Describe the bug
FormControlState<unknown>; throws TS2344: Type 'unknown' does not satisfy the constraint 'FormControlValueTypes'.   Type 'unknown' is not assignable to type 'Boxed<any>'. while any is working. I have a eslint rule that disallow the use of any and I can't see why unknown can't work.

I am in need of this because I have a reusable component that takes a FormControlState as an Input and then use it in the template, it could be a number, a string, ... but I don't care I don't need to know

@Input() formControlState!: FormControlState<unknown>;

<mat-form-field class="field" appearance="outline" floatLabel="always">
  <mat-label>{{ label }}</mat-label>
  <input
    matInput
    required
    placeholder="Sélectionner une date ..."
    autocomplete="off"
    [ngrxFormControlState]="formStateControl"
    [ngrxValueConverter]="dateValueConverter"
    [matDatepicker]="picker"
  />
  <mat-hint>JJ/MM/AAAA</mat-hint>
  <mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
  <mat-datepicker #picker></mat-datepicker>

  <mat-error *ngIf="formStateControl.errors">
    <ng-container *ngIf="formStateControl.errors?.required"> Champ obligatoire.</ng-container>
  </mat-error>
</mat-form-field>
@Yohandah Yohandah added the bug label Apr 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant