-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Description
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.
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:
Related Issues:
Mmmaybe this one? #26450
Metadata
Metadata
Assignees
Labels
No labels
