-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
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
cannot instantiate a tagged union whose discriminant property is union type #12052
Comments
Related weirdness: const axis: IAxis = { type: "categorical"; };
axis.type = "linear";
// errors here saying axis.type === "categorical" Apparently it sees axis as type ICategoricalAxis even though I explicitly typedef-ed it as IAxis? |
For your example to type check with no errors we would have to consider types of the form In your example, if all that ever differs between |
Creation was not possible and we can achieve the same thing with "crit" in props. See also microsoft/TypeScript#12052
Ref #8289 |
Hey typescript, I'm getting an error when instantiating a tagged union whose discriminant property is inlined into the literal, vs. set via assignment right afterwards. Is there something I'm missing here?
TypeScript Version: 2.0.3 (or whatever's on http://www.typescriptlang.org/play/)
Code
Expected behavior: Both should work
Actual behavior: The "bad" axis declaration fails with the error described
Thanks!
The text was updated successfully, but these errors were encountered: