Open
Description
It would be nice to be able to inform users when they encounter specific errors related to a property.
In this example use case, we would like to inform the user that a property on a discriminated union can only be set when the discriminator matches the type.
interface Base {
discriminator: boolean;
foo: string | never;
}
interface UnionTypeA extends Base {
discriminator: true;
foo: string;
}
interface UnionTypeB extends Base {
discriminator: false;
/**
*
* {@errorCode 2322 | This property can only be set when discriminator is equal to `true`}
*
*/
foo: never;
}
type DiscriminatedUnion = UnionTypeA | UnionTypeB;
const bar: DiscriminatedUnion = {
discriminator: false,
foo: ""
}
The current error is shown as:
I based the syntax around what I have seen as prior art in the @link
tag.
Apologies if this has been suggested or discussed before, I could not find anything from an initial search of issues.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
Labels
No labels