Skip to content

feat(forms): add better type support for AbstractControl#status - #16841

Closed
Toxicable wants to merge 1 commit into
angular:masterfrom
Toxicable:status-changes-types
Closed

feat(forms): add better type support for AbstractControl#status#16841
Toxicable wants to merge 1 commit into
angular:masterfrom
Toxicable:status-changes-types

Conversation

@Toxicable

@Toxicable Toxicable commented May 17, 2017

Copy link
Copy Markdown

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines:
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

What kind of change does this PR introduce? (check one with "x")

[x] Feature

What is the current behavior? (You can also link to an open issue here)
Abstract#status is currently typed to string where as it has four distinct cases of it's value

What is the new behavior?
Abstract#status now is of type 'VALID' | 'INVALID' | 'PENDING' | 'DISABLED' giving slightly better support for the developer

Does this PR introduce a breaking change? (check one with "x")

[x] Yes
[ ] No

Im not 100% certain if this is valid, but if someone is comparing Abstract#status to a string other than the ones it can possibly be then after this change TS will throw an error at compile time

cc @kara

@Toxicable Toxicable changed the title feat(forms): add better type support for AbstractControl#status [WIP] feat(forms): add better type support for AbstractControl#status May 17, 2017
@Toxicable
Toxicable force-pushed the status-changes-types branch from b7ebe08 to 4db2d0c Compare May 17, 2017 10:18
@Toxicable Toxicable changed the title [WIP] feat(forms): add better type support for AbstractControl#status feat(forms): add better type support for AbstractControl#status May 17, 2017
@Toxicable
Toxicable force-pushed the status-changes-types branch 2 times, most recently from 3358024 to 2a6dabd Compare May 17, 2017 11:35
@devoto13

devoto13 commented May 17, 2017

Copy link
Copy Markdown
Contributor

Yes, it will break if somebody compares to the 'randomString'. See playground.

While technically it's a breaking change, in fact it exposes bug in user's application.

@Toxicable

Copy link
Copy Markdown
Author

@devoto13 yeah that's the same thoughts that I had, just wasn't sure if that kind of scenario counts as a breaking change or not

@Toxicable
Toxicable force-pushed the status-changes-types branch 4 times, most recently from 90ee991 to b48fa05 Compare July 25, 2017 01:45
@Toxicable
Toxicable force-pushed the status-changes-types branch 3 times, most recently from cb4c808 to cc12408 Compare July 31, 2017 23:02
@Toxicable
Toxicable force-pushed the status-changes-types branch from cc12408 to 9f25637 Compare July 31, 2017 23:10
*/
get statusChanges(): Observable<any> { return this._statusChanges; }
get statusChanges(): Observable<'VALID'|'INVALID'|'PENDING'|'DISABLED'> {
return <EventEmitter<any>>this._statusChanges;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

TS throws here if we don't do this silly cast.
It appears there is some issue where we can't assign EventEmitter<T> to Observable<T>

@Toxicable

Copy link
Copy Markdown
Author

Reopened here #18442

@Toxicable Toxicable closed this Aug 1, 2017
@Toxicable
Toxicable deleted the status-changes-types branch August 1, 2017 00:55
@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Sep 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants