[microsoft/TypeScript] Parenthesis breaks narrowing. (Issue #61784)
DRANK

JeanMeche created an issue (microsoft/TypeScript#61784) ### 🔎 Search Terms * narrowing * parenthesis * union * if condition * switch ### 🕗 Version & Regression Information Tested in 5.8, probably not a regression. ### ⏯ Playground Link https://www.typescriptlang.org/play/?#code/C4TwDgpgBAKhDOwoF5YOAQSgHzYgQgNwBQAlgHbAQBOAZgIYDG0ciWA3sVN1KJAFxQA5PSEkeUcvQC2EQYmoUA5iQC+xMpRoNmeYPiicJfOcIBGYrjwBu9ADYBXU+QfSzNNRtoPyjYKQB7cigAfWBGMwBGAApgAAtSeEF2XnRBViRVAEpDK24AenzYAGUoJQhyGnoqABMoMxAoDHIlBzt6aiF4WHBoAGE4iEYAa3q7AJG8qEYgxFDgSJQoaJWV+MSsgDoqRCytkz3xHlJaZbDF5EuoACJ6a5yjCR5VtYT4ffQ9zalZQ6hCqAAaQA8lN1FMAcUZNB6N16GYAtYIAAaKAAd1I8QCDiQ8WgYA6FTx8ESqMxXSgwMBUxm5DmYQATEt1vBtuhtr0jtwTmdgEzLqhbvdck9ni8WR9dlsfhBDmCNBCilDZCUoIlKYCoDTZrj0DBesy3mzEBzIFy1adYnqDQLhKIHlMJLT4AE7BBNuMlLEjTtgN9oVlzepVFAgA ### 💻 Code ```ts type Test = TestA | TestB; interface TestA { type: 'a'; name: string; } interface TestB { type: 'b'; value: number; } function _tcb1(this: { test: Test }) { // TS generated by Angular's Type Check block const _t1 = (((((this).test)).type)); if (_t1 === "a") { (((((this).test)).name)); // KO } } ``` ### 🙁 Actual behavior TS doesn't narrow correctly ### 🙂 Expected behavior TS should narrow correctly despite the execessive parenthesis. ### Additional information about the issue This is similar to a priori issue with `typeof` expressions #60784 -- Reply to this email directly or view it on GitHub: https://github.com/microsoft/TypeScript/issues/61784 You are receiving this because you are subscribed to this thread. Message ID: <microsoft/TypeScript/issues/61784@github.com>

github.com
Related Topics: TypeScript
1 comments