Skip to content
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

@switch does not have type awareness in case statements #52315

Closed
jpike88 opened this issue Oct 23, 2023 · 3 comments
Closed

@switch does not have type awareness in case statements #52315

jpike88 opened this issue Oct 23, 2023 · 3 comments
Assignees
Labels
bug core: control flow Issues related to the built-in control flow (@if, @for, @switch) state: has PR

Comments

@jpike88
Copy link

jpike88 commented Oct 23, 2023

Which @angular/* package(s) are the source of the bug?

compiler-cli

Is this a regression?

No

Description

Am using package versions of 17.0.0-rc.0, with extension version v17.0.0-next.2.

When either using ng build or in vscode itself, there is no error thrown for the below code, isDebug is type boolean yet the case statements conflict with that type.
Screenshot 2023-10-23 at 08 56 57

Interestingly on mouseover, it does look like an attempt to perform type coercion happens, resulting predictably in a never type
Screenshot 2023-10-23 at 08 58 41

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

No response

Anything else?

No response

@jpike88
Copy link
Author

jpike88 commented Oct 23, 2023

closed because duplicate issue #52107

@jpike88 jpike88 closed this as completed Oct 23, 2023
@jpike88
Copy link
Author

jpike88 commented Oct 23, 2023

actually its not a dupe, that other issue is about exhaustive type checking, my one is about more basic type awareness

@jpike88 jpike88 reopened this Oct 23, 2023
@crisbeto crisbeto self-assigned this Oct 23, 2023
crisbeto added a commit to crisbeto/angular that referenced this issue Oct 23, 2023
…ncompatible type comparisons

In angular#52110 the compiler was changed to produce `if` statements when type checking `@switch` in order to avoid a bug in the TypeScript compiler. In order to avoid duplicate diagnostics, the main `@switch` expression was ignored in each of the `@case` comparisons. This appears to have caused a regression where comparing incompatible types wasn't being reported anymore.

These changes resolve the issue by wrapping the expression in parentheses which allows the compiler to report comparison diagnostics while ignoring diagnostics in the expression itself.

Fixes angular#52315.
@crisbeto crisbeto added state: has PR bug core: control flow Issues related to the built-in control flow (@if, @for, @switch) labels Oct 23, 2023
crisbeto added a commit to crisbeto/angular that referenced this issue Oct 23, 2023
…ncompatible type comparisons

In angular#52110 the compiler was changed to produce `if` statements when type checking `@switch` in order to avoid a bug in the TypeScript compiler. In order to avoid duplicate diagnostics, the main `@switch` expression was ignored in each of the `@case` comparisons. This appears to have caused a regression where comparing incompatible types wasn't being reported anymore.

These changes resolve the issue by wrapping the expression in parentheses which allows the compiler to report comparison diagnostics while ignoring diagnostics in the expression itself.

Fixes angular#52315.
dylhunn pushed a commit that referenced this issue Oct 23, 2023
…ncompatible type comparisons (#52322)

In #52110 the compiler was changed to produce `if` statements when type checking `@switch` in order to avoid a bug in the TypeScript compiler. In order to avoid duplicate diagnostics, the main `@switch` expression was ignored in each of the `@case` comparisons. This appears to have caused a regression where comparing incompatible types wasn't being reported anymore.

These changes resolve the issue by wrapping the expression in parentheses which allows the compiler to report comparison diagnostics while ignoring diagnostics in the expression itself.

Fixes #52315.

PR Close #52322
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Nov 23, 2023
tbondwilkinson pushed a commit to tbondwilkinson/angular that referenced this issue Dec 6, 2023
…ncompatible type comparisons (angular#52322)

In angular#52110 the compiler was changed to produce `if` statements when type checking `@switch` in order to avoid a bug in the TypeScript compiler. In order to avoid duplicate diagnostics, the main `@switch` expression was ignored in each of the `@case` comparisons. This appears to have caused a regression where comparing incompatible types wasn't being reported anymore.

These changes resolve the issue by wrapping the expression in parentheses which allows the compiler to report comparison diagnostics while ignoring diagnostics in the expression itself.

Fixes angular#52315.

PR Close angular#52322
ChellappanRajan pushed a commit to ChellappanRajan/angular that referenced this issue Jan 23, 2024
…ncompatible type comparisons (angular#52322)

In angular#52110 the compiler was changed to produce `if` statements when type checking `@switch` in order to avoid a bug in the TypeScript compiler. In order to avoid duplicate diagnostics, the main `@switch` expression was ignored in each of the `@case` comparisons. This appears to have caused a regression where comparing incompatible types wasn't being reported anymore.

These changes resolve the issue by wrapping the expression in parentheses which allows the compiler to report comparison diagnostics while ignoring diagnostics in the expression itself.

Fixes angular#52315.

PR Close angular#52322
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug core: control flow Issues related to the built-in control flow (@if, @for, @switch) state: has PR
Projects
None yet
2 participants