We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
TypeScript Version: 3.1.1
Search Terms: unions
Code
export enum ButtonStatus { ENABLED = 'enabled', DISABLED = 'disabled', LOADING = 'loading', } export interface RegularButtonProps { readonly status: ButtonStatus; } export interface LoadingButtonProps { readonly status: ButtonStatus.LOADING; readonly loadingText: string; } export type ButtonProps = RegularButtonProps | LoadingButtonProps; const buttonProps: ButtonProps = { status: ButtonStatus.LOADING, loadingText: 42, };
Expected behavior:
Error saying loadingText should be of type string.
loadingText
string
Actual behavior:
No error. Hovering over loadingText does tell me that loadingText is a string, so the compiler knows but doesn't raise it?
Playground Link:
https://www.typescriptlang.org/play/#src=export%20enum%20ButtonStatus%20%7B%0A%20%20ENABLED%20%3D%20'enabled'%2C%0A%20%20DISABLED%20%3D%20'disabled'%2C%0A%20%20LOADING%20%3D%20'loading'%2C%0A%7D%0A%0Aexport%20interface%20RegularButtonProps%20%7B%0A%20%20readonly%20status%3A%20ButtonStatus%3B%0A%7D%0A%0Aexport%20interface%20LoadingButtonProps%20%7B%0A%20%20readonly%20status%3A%20ButtonStatus.LOADING%3B%0A%20%20readonly%20loadingText%3A%20string%3B%0A%7D%0A%0Aexport%20type%20ButtonProps%20%3D%20RegularButtonProps%20%7C%20LoadingButtonProps%3B%0A%0Aconst%20buttonProps%3A%20ButtonProps%20%3D%20%7B%0A%20%20status%3A%20ButtonStatus.LOADING%2C%0A%20%20loadingText%3A%2042%2C%0A%7D%3B%0A
Related Issues:
Mmmaybe this one? #26450
The text was updated successfully, but these errors were encountered:
Ah, sorry, didn't see @DanielRosenwasser's PR: #27087
Sorry, something went wrong.
No branches or pull requests
TypeScript Version: 3.1.1
Search Terms: unions
Code
Expected behavior:
Error saying
loadingText
should be of typestring
.Actual behavior:
No error. Hovering over
loadingText
does tell me thatloadingText
is a string, so the compiler knows but doesn't raise it?Playground Link:
https://www.typescriptlang.org/play/#src=export%20enum%20ButtonStatus%20%7B%0A%20%20ENABLED%20%3D%20'enabled'%2C%0A%20%20DISABLED%20%3D%20'disabled'%2C%0A%20%20LOADING%20%3D%20'loading'%2C%0A%7D%0A%0Aexport%20interface%20RegularButtonProps%20%7B%0A%20%20readonly%20status%3A%20ButtonStatus%3B%0A%7D%0A%0Aexport%20interface%20LoadingButtonProps%20%7B%0A%20%20readonly%20status%3A%20ButtonStatus.LOADING%3B%0A%20%20readonly%20loadingText%3A%20string%3B%0A%7D%0A%0Aexport%20type%20ButtonProps%20%3D%20RegularButtonProps%20%7C%20LoadingButtonProps%3B%0A%0Aconst%20buttonProps%3A%20ButtonProps%20%3D%20%7B%0A%20%20status%3A%20ButtonStatus.LOADING%2C%0A%20%20loadingText%3A%2042%2C%0A%7D%3B%0A
Related Issues:
Mmmaybe this one? #26450
The text was updated successfully, but these errors were encountered: