Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Type mismatch for FormControl<boolean> initialized with boolean value. #18

Closed
rcollette opened this issue Mar 8, 2019 · 2 comments
Closed
Labels
type: bug/fix Something isn't working

Comments

@rcollette
Copy link

https://stackblitz.com/edit/angular-zqy45b

import { Component, Input } from '@angular/core';
import { FormControl, FormGroup } from '@ng-stack/forms';

interface IEntitlementsForm {
  perpetualLicense: boolean;
}

@Component({
  selector: 'hello',
  template: `<h1>Hello {{name}}!</h1>`,
  styles: [`h1 { font-family: Lato; }`]
})
export class HelloComponent  {
  @Input() name: string;
  public perpetualLicense = new FormControl<boolean>(false);
  public formGroup=new FormGroup<IEntitlementsForm>({
    perpetualLicense:this.perpetualLicense
  });
}

Error

Argument of type '{ perpetualLicense: FormControl<boolean, ValidatorsModel>; }' is not assignable to parameter of type '{ perpetualLicense?: FormControl<false, ValidatorsModel> | FormControl<true, ValidatorsModel>; }'.
  Types of property 'perpetualLicense' are incompatible.
    Type 'FormControl<boolean, ValidatorsModel>' is not assignable to type 'FormControl<false, ValidatorsModel> | FormControl<true, ValidatorsModel>'.
      Type 'FormControl<boolean, ValidatorsModel>' is not assignable to type 'FormControl<false, ValidatorsModel>'.
        Type 'boolean' is not assignable to type 'false'.
@KostyaTretyak KostyaTretyak added the type: bug/fix Something isn't working label Mar 8, 2019
@KostyaTretyak
Copy link
Owner

Thank you for reported the issue. Seems that is "design limitation" see Unexpected splitting of "boolean" type in conditional types

KostyaTretyak added a commit that referenced this issue Mar 8, 2019
Unexpected splitting of "boolean" type in conditional types. See microsoft/TypeScript#30280

Close #18
@KostyaTretyak
Copy link
Owner

Fixed via fbec6d84

Checkout

npm i @ng-stack/forms

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug/fix Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants