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
"type inference", "property deep inside"
tested at 5.3.3, 4.9.3, 4.6.3
5.3.3
4.9.3
4.6.3
https://www.typescriptlang.org/play?#code/C4TwDgpgBAglC8AoKUA+UDeUwCcD2YAXJlKJMQEQCGFA3FAG5UA2ArhMVgBYCWxATFAC+w4cjQlcBTqXAcoFAEZ1GLdjK4RmzPMQCMokUNqJEAYzwA7AM7AoVBFAAUVYjACUCAHyZx1gO48wGZczlQAdFJg4WQQnhjiKGZU1tDUFISJKFA4EMCsOJb2kfjRTGwQ4bz0APQ1UAAqclAAkpYAZhC5lmbQ-ng4ANbhWcmpCsqZ2dm5+YXOnvA+EVHh5exVWjq19U2QrR1dED3Qlnh2-UMjKEKIxqYWNnaKjk6Kbos+CUlWtpKlongUEUJj8gWCoScq1i8VGKTSNCm0xyeQKRVW60q1SgdUazTanW6vSgl2GcPGSgyWRQszRC282FKazUWK2eB2eP2BKOJxJAzJNzuQA
type A = | { prop: { type: "a"; value: { hi: 2 } } } | { prop: { type: "b"; value: { hello: 1 } } }; const a = (a: A) => { switch (a.prop.type) { case "a": return a.prop.value.hi; // Type Inference work. case "b": return () => a.prop.value.hello; // Type Inference not work. } }; const b = (b: A) => { const { prop } = b; switch (prop.type) { case "a": return prop.value.hi; // Type Inference work. case "b": return () => prop.value.hello; // Type Inference work. } }
When a property deep inside an object is entered in a conditional statement, type inference is not made.
type error not occur.
No response
The text was updated successfully, but these errors were encountered:
#18758
Sorry, something went wrong.
This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes.
No branches or pull requests
π Search Terms
"type inference", "property deep inside"
π Version & Regression Information
tested at
5.3.3
,4.9.3
,4.6.3
β― Playground Link
https://www.typescriptlang.org/play?#code/C4TwDgpgBAglC8AoKUA+UDeUwCcD2YAXJlKJMQEQCGFA3FAG5UA2ArhMVgBYCWxATFAC+w4cjQlcBTqXAcoFAEZ1GLdjK4RmzPMQCMokUNqJEAYzwA7AM7AoVBFAAUVYjACUCAHyZx1gO48wGZczlQAdFJg4WQQnhjiKGZU1tDUFISJKFA4EMCsOJb2kfjRTGwQ4bz0APQ1UAAqclAAkpYAZhC5lmbQ-ng4ANbhWcmpCsqZ2dm5+YXOnvA+EVHh5exVWjq19U2QrR1dED3Qlnh2-UMjKEKIxqYWNnaKjk6Kbos+CUlWtpKlongUEUJj8gWCoScq1i8VGKTSNCm0xyeQKRVW60q1SgdUazTanW6vSgl2GcPGSgyWRQszRC282FKazUWK2eB2eP2BKOJxJAzJNzuQA
π» Code
π Actual behavior
When a property deep inside an object is entered in a conditional statement, type inference is not made.
π Expected behavior
type error not occur.
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: