-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
Bug Report
π Search Terms
Property Definition Check
Property Undefined Check
π Version & Regression Information
- This is the behavior in every version I tried.
β― Playground Link
Playground link with relevant code
π» Code
export type Point2D = { x: number, y: number };
export type Point3D = Point2D & { z: number };
export type Point = Point2D | Point3D;
export function draw(p: Point) {
// This check should not be an error!
if (p.z != undefined) { console.log("Point3D"); }
else { console.log("Point2D"); }
}
let p1: Point = { x: 1, y: 2, z: 3 };
draw(p1);
// We can quickly address your report if:
// - The code sample is short. Nearly all TypeScript bugs can be demonstrated in 20-30 lines of code!
// - It doesn't use external libraries. These are often issues with the type definitions rather than TypeScript bugs.
// - The incorrectness of the behavior is readily apparent from reading the sample.
// Reports are slower to investigate if:
// - We have to pare too much extraneous code.
// - We have to clone a large repo and validate that the problem isn't elsewhere.
// - The sample is confusing or doesn't clearly demonstrate what's wrong.π Actual behavior
Property 'z' does not exist on type 'Point'.
Property 'z' does not exist on type 'Point2D'.(2339)
π Expected behavior
Checking if the property is defined should not be an error.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created